Skip to content

Commit e2b0634

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

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: cores/arduino/USB/PluggableUSBSerial.h

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

255255
operator bool() {
256+
// call delay() to force rescheduing during while !Serial pattern
257+
delay(1);
256258
return connected();
257259
}
258260

0 commit comments

Comments
 (0)