An eensy teensy bug with serial_peek():
I'm looking at the serial[1,2,3].c files in the teensy3 core library. I understand that RX and TX data handling is provided by a pair of ring buffers, where head points to the newest element, and tail points to the byte before the oldest element. However, the peek function is implemented as:
But it looks like it ought to be:
I'm looking at the serial[1,2,3].c files in the teensy3 core library. I understand that RX and TX data handling is provided by a pair of ring buffers, where head points to the newest element, and tail points to the byte before the oldest element. However, the peek function is implemented as:
Code:
int serial_peek(void)
{
...
if (head == tail) return -1;
return rx_buffer[tail];
}
But it looks like it ought to be:
Code:
int serial_peek(void)
{
...
if (head == tail) return -1;
if (++tail >= RX_BUFFER_SIZE) tail = 0;
return rx_buffer[tail];
}