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
1 changed files with 1 additions and 1 deletions

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