Skip to content

Commit 3068761

Browse files
committed
Add safety timeout on 1200 bps touch
1 parent bdfc514 commit 3068761

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cores/arduino/USB/USBSerial.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
using namespace arduino;
2323

2424
static void waitForPortClose() {
25-
// wait for DTR be 0 (port closed)
26-
while (SerialUSB.connected()) {
25+
// wait for DTR be 0 (port closed) and timeout to be over
26+
long start = millis();
27+
static const int WAIT_TIMEOUT = 200;
28+
while (SerialUSB.connected() || (millis() - start) < WAIT_TIMEOUT) {
2729
// the delay is needed to handle other "concurrent" IRQ events
2830
delay(1);
2931
}

0 commit comments

Comments
 (0)