Skip to content

Commit

Permalink
Add more data in ESP420 for USB Port when connected
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Oct 20, 2024
1 parent 9f303ca commit b892b3f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions esp3d/src/core/commands/ESP420.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ void ESP3DCommands::ESP420(int cmd_params_pos, ESP3DMessage* msg) {
return;
}
}
if (esp3d_usb_serial_service.isConnected()) {
tmpstr = esp3d_usb_serial_service.getVIDString();
tmpstr += ":";
tmpstr += esp3d_usb_serial_service.getPIDString();
if (!dispatchIdValue(json, "Vid/Pid", tmpstr.c_str(), target, requestId,
false)) {
return;
}
}
#endif // defined(USB_SERIAL_FEATURE)

#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
Expand Down
26 changes: 26 additions & 0 deletions esp3d/src/modules/usb-serial/usb_serial_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,32 @@ void ESP3DUsbSerialService::connectDevice() {
}
}

const char *ESP3DUsbSerialService::getVIDString() {
if (_vcp_ptr && _is_connected) {
return esp_usb::getVIDString();
}
return "None";
}
const char *ESP3DUsbSerialService::getPIDString() {
if (_vcp_ptr && _is_connected) {
return esp_usb::getPIDString();
}
return "None";
}

uint16_t ESP3DUsbSerialService::getVID() {
if (_vcp_ptr && _is_connected) {
return esp_usb::getVID();
}
return 0;
}
uint16_t ESP3DUsbSerialService::getPID() {
if (_vcp_ptr && _is_connected) {
return esp_usb::getPID();
}
return 0;
}

// Setup Serial
bool ESP3DUsbSerialService::begin() {
_buffer_mutex = xSemaphoreCreateMutex();
Expand Down
5 changes: 5 additions & 0 deletions esp3d/src/modules/usb-serial/usb_serial_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class ESP3DUsbSerialService final {
void connectDevice();
void setConnected(bool connected);
void receiveCb(const uint8_t *data, size_t data_len, void *arg = nullptr);
bool isConnected() { return _is_connected; }
const char * getVIDString();
const char * getPIDString();
uint16_t getVID();
uint16_t getPID();

private:
uint32_t _baudRate;
Expand Down

0 comments on commit b892b3f

Please sign in to comment.