diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp index 24141be28..fb40bf891 100644 --- a/src/SerialConsole.cpp +++ b/src/SerialConsole.cpp @@ -16,6 +16,11 @@ #ifdef SERIAL_HAS_ON_RECEIVE #undef SERIAL_HAS_ON_RECEIVE #endif +// Port is HWCDC only in hardware USB-Serial/JTAG mode. With ARDUINO_USB_MODE=0 it is TinyUSB +// USBCDC, the PHY is routed away from the USJ peripheral, and isPlugged() would never see a SOF. +#if defined(ARDUINO_USB_MODE) && ARDUINO_USB_MODE +#define IS_USB_HWCDC +#endif #include "HWCDC.h" #endif @@ -130,8 +135,10 @@ int32_t SerialConsole::runOnce() if (hasPendingOutput()) return delay < 25 ? delay : 25; // 0 continues a budget slice; else short-poll TX drain return Port.available() ? delay : INT32_MAX; -#elif defined(IS_USB_SERIAL) - return HWCDC::isPlugged() ? delay : (1000 * 20); +#elif defined(IS_USB_HWCDC) + // isPlugged() is a SOF watchdog that flaps false while USB is fine (#11864), and nothing wakes + // this thread on RX, so cap the idle sleep at the rate readStream() already idles at. + return HWCDC::isPlugged() ? delay : 250; #else return delay; #endif