Skip to content

Commit

Permalink
USBSerial: make bool() sleep to avoid cpu hog in while !Serial
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Dec 3, 2020
1 parent bba78c4 commit e2b0634
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cores/arduino/USB/PluggableUSBSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
using Print::write; // pull in write(str) and write(buf, size) from Print

operator bool() {
// call delay() to force rescheduing during while !Serial pattern
delay(1);
return connected();
}

Expand Down

0 comments on commit e2b0634

Please sign in to comment.