8000 Fix SerialUART::overflow reporting race condition (#1133) · uPesy/arduino-pico@ecaa2bd · GitHub
[go: up one dir, main page]

Skip to content

Commit ecaa2bd

Browse files
Fix SerialUART::overflow reporting race condition (earlephilhower#1133)
Fixes earlephilhower#1132
1 parent d619bf0 commit ecaa2bd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

cores/rp2040/SerialUART.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,22 @@ int SerialUART::read() {
289289
}
290290

291291
bool SerialUART::overflow() {
292-
CoreMutex m(&_mutex);
293-
if (!_running || !m) {
292+
if (!_running) {
294293
return false;
295294
}
296-
bool hold = _overflow;
295+
296+
if (_polling) {
297+
_handleIRQ(false);
298+
} else {
299+
_pumpFIFO();
300+
}
301+
302+
mutex_enter_blocking(&_fifoMutex);
303+
bool ovf = _overflow;
297304
_overflow = false;
298-
return hold;
305+
mutex_exit(&_fifoMutex);
306+
307+
return ovf;
299308
}
300309

301310
int SerialUART::available() {

0 commit comments

Comments
 (0)
0