From cfeb4a3bceef95268b4aad38eb245b18df15f24e Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 12 Jan 2007 21:27:18 +0000 Subject: [PATCH] Fixed bug in Serial.available() causing it to return incorrect values when the head wrapped around. Thanks to Don Cross. --- targets/arduino/wiring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/arduino/wiring.c b/targets/arduino/wiring.c index 7b9123665..52bac34d4 100755 --- a/targets/arduino/wiring.c +++ b/targets/arduino/wiring.c @@ -291,7 +291,7 @@ void serialWrite(unsigned char c) int serialAvailable() { - return (rx_buffer_head - rx_buffer_tail) % RX_BUFFER_SIZE; + return (RX_BUFFER_SIZE + rx_buffer_head - rx_buffer_tail) % RX_BUFFER_SIZE; } int serialRead()