Unverified Commit 30704a7c authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Obey timeout value on SerialUART.read/.peek (#211)

Fixes a hang when reading from the Serial UART ports because before the
core would pause indefinitely for the next character.

Now, wait up to Serial.setTimeout() milliseconds and if it times out
return -1 to the app.

Fixes #210
parent 08b6748d
......@@ -115,7 +115,11 @@ int SerialUART::peek() {
if (_peek >= 0) {
return _peek;
}
_peek = uart_getc(_uart);
if (uart_is_readable_within_us(_uart, _timeout * 1000)) {
_peek = uart_getc(_uart);
} else {
_peek = -1; // Timeout
}
return _peek;
}
......@@ -129,7 +133,11 @@ int SerialUART::read() {
_peek = -1;
return ret;
}
return uart_getc(_uart);
if (uart_is_readable_within_us(_uart, _timeout * 1000)) {
return uart_getc(_uart);
} else {
return -1; // Timeout
}
}
int SerialUART::available() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment