1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-30 19:52:13 +01:00

Fixed bug in Serial.available() causing it to return incorrect values when the head wrapped around. Thanks to Don Cross.

This commit is contained in:
David A. Mellis 2007-01-12 21:27:18 +00:00
parent 5a39312e74
commit cfeb4a3bce

View File

@ -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()