mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-30 03:13:51 +00:00
cope with race on available() vs read() found while looking at #838
This commit is contained in:
parent
9f450cb1c5
commit
a9f8080ee7
@ -26,7 +26,11 @@ int32_t StreamAPI::readStream()
|
|||||||
return recentRx ? 5 : 250;
|
return recentRx ? 5 : 250;
|
||||||
} else {
|
} else {
|
||||||
while (stream->available()) { // Currently we never want to block
|
while (stream->available()) { // Currently we never want to block
|
||||||
uint8_t c = stream->read();
|
int cInt = stream->read();
|
||||||
|
if(cInt < 0)
|
||||||
|
break; // We ran out of characters (even though available said otherwise) - this can happen on rf52 adafruit arduino
|
||||||
|
|
||||||
|
uint8_t c = (uint8_t) cInt;
|
||||||
|
|
||||||
// Use the read pointer for a little state machine, first look for framing, then length bytes, then payload
|
// Use the read pointer for a little state machine, first look for framing, then length bytes, then payload
|
||||||
size_t ptr = rxPtr;
|
size_t ptr = rxPtr;
|
||||||
|
Loading…
Reference in New Issue
Block a user