Skip to content

Commit 461c3e9

Browse files
committed
USBSerial: make bool() sleep to avoid cpu hog in while !Serial
1 parent a885c58 commit 461c3e9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cores/arduino/USB/PluggableUSBSerial.h

+2
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
259259
using Print::write; // pull in write(str) and write(buf, size) from Print
260260

261261
operator bool() {
262+
// call delay() to force rescheduing during while !Serial pattern
263+
delay(1);
262264
return connected();
263265
}
264266

0 commit comments

Comments
 (0)