Skip to content

Commit 18ead5f

Browse files
softhack007Djelibeybi
authored andcommitted
USB CDC: avoid hung devices when USB host is not connected
see espressif/arduino-esp32#9043 " The S3, C3, C6 and H2 that have HW CDC JTAG USB port may cause a delay when using HWCDC in Serial by activating CDC on Boot and selecting the USB Mode for Hardware CDC and JTAG. This happens when no USB application in USB Host side is started to receive the data sent by the ESP32xx. The USB CDC buffer gets full and the Arduino HW CDC layer will timeout, by default 100ms, until give up trying to send the CDC data. As a workaround, it is necessary to use HWCDC::setTxTimeoutMs(timeout_ms) and set it to zero. "
1 parent 3776ee0 commit 18ead5f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

wled00/wled.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ void WLED::setup()
451451
if (!Serial) delay(2500); // WLEDMM allow CDC USB serial to initialise
452452
#endif
453453
#if ARDUINO_USB_CDC_ON_BOOT || ARDUINO_USB_MODE
454+
#if ARDUINO_USB_CDC_ON_BOOT && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6))
455+
// WLEDMM avoid "hung devices" when USB_CDC is enabled; see https://github.com/espressif/arduino-esp32/issues/9043
456+
Serial.setTxTimeoutMs(0); // potential side-effect: incomplete debug output, with missing characters whenever TX buffer is full.
457+
#endif
454458
if (!Serial) delay(2500); // WLEDMM: always allow CDC USB serial to initialise
455459
if (Serial) Serial.println("wait 1"); // waiting a bit longer ensures that a debug messages are shown in serial monitor
456460
if (!Serial) delay(2500);

0 commit comments

Comments
 (0)