Skip to content

Commit b892b3f

Browse files
committed
Add more data in ESP420 for USB Port when connected
1 parent 9f303ca commit b892b3f

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

esp3d/src/core/commands/ESP420.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@ void ESP3DCommands::ESP420(int cmd_params_pos, ESP3DMessage* msg) {
240240
return;
241241
}
242242
}
243+
if (esp3d_usb_serial_service.isConnected()) {
244+
tmpstr = esp3d_usb_serial_service.getVIDString();
245+
tmpstr += ":";
246+
tmpstr += esp3d_usb_serial_service.getPIDString();
247+
if (!dispatchIdValue(json, "Vid/Pid", tmpstr.c_str(), target, requestId,
248+
false)) {
249+
return;
250+
}
251+
}
243252
#endif // defined(USB_SERIAL_FEATURE)
244253

245254
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL

esp3d/src/modules/usb-serial/usb_serial_service.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,32 @@ void ESP3DUsbSerialService::connectDevice() {
255255
}
256256
}
257257

258+
const char *ESP3DUsbSerialService::getVIDString() {
259+
if (_vcp_ptr && _is_connected) {
260+
return esp_usb::getVIDString();
261+
}
262+
return "None";
263+
}
264+
const char *ESP3DUsbSerialService::getPIDString() {
265+
if (_vcp_ptr && _is_connected) {
266+
return esp_usb::getPIDString();
267+
}
268+
return "None";
269+
}
270+
271+
uint16_t ESP3DUsbSerialService::getVID() {
272+
if (_vcp_ptr && _is_connected) {
273+
return esp_usb::getVID();
274+
}
275+
return 0;
276+
}
277+
uint16_t ESP3DUsbSerialService::getPID() {
278+
if (_vcp_ptr && _is_connected) {
279+
return esp_usb::getPID();
280+
}
281+
return 0;
282+
}
283+
258284
// Setup Serial
259285
bool ESP3DUsbSerialService::begin() {
260286
_buffer_mutex = xSemaphoreCreateMutex();

esp3d/src/modules/usb-serial/usb_serial_service.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class ESP3DUsbSerialService final {
5656
void connectDevice();
5757
void setConnected(bool connected);
5858
void receiveCb(const uint8_t *data, size_t data_len, void *arg = nullptr);
59+
bool isConnected() { return _is_connected; }
60+
const char * getVIDString();
61+
const char * getPIDString();
62+
uint16_t getVID();
63+
uint16_t getPID();
5964

6065
private:
6166
uint32_t _baudRate;

0 commit comments

Comments
 (0)