From cb32e3abfe6300fb48348aa2aa1029ae556d79d0 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sat, 20 Sep 2025 10:59:43 -0700 Subject: [PATCH] Fix SerialPIO::available during wraparound Fixes #3142 --- cores/rp2040/SerialPIO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/rp2040/SerialPIO.cpp b/cores/rp2040/SerialPIO.cpp index 32af295ac..ddd9b0a7f 100644 --- a/cores/rp2040/SerialPIO.cpp +++ b/cores/rp2040/SerialPIO.cpp @@ -338,7 +338,7 @@ int SerialPIO::available() { if (!_running || !m || (_rx == NOPIN)) { return 0; } - return (_writer - _reader) % _fifoSize; + return (_fifoSize + _writer - _reader) % _fifoSize; } int SerialPIO::availableForWrite() {