diff --git a/esp3d/src/core/commands/ESP420.cpp b/esp3d/src/core/commands/ESP420.cpp index 1a2d30f2..da4cb85a 100644 --- a/esp3d/src/core/commands/ESP420.cpp +++ b/esp3d/src/core/commands/ESP420.cpp @@ -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 diff --git a/esp3d/src/modules/usb-serial/usb_serial_service.cpp b/esp3d/src/modules/usb-serial/usb_serial_service.cpp index a4450bb4..25ccd2da 100644 --- a/esp3d/src/modules/usb-serial/usb_serial_service.cpp +++ b/esp3d/src/modules/usb-serial/usb_serial_service.cpp @@ -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(); diff --git a/esp3d/src/modules/usb-serial/usb_serial_service.h b/esp3d/src/modules/usb-serial/usb_serial_service.h index cf320aa8..cfdbd65b 100644 --- a/esp3d/src/modules/usb-serial/usb_serial_service.h +++ b/esp3d/src/modules/usb-serial/usb_serial_service.h @@ -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;