Avamander / arduino-tvout

Arduino-TVout
333 stars 83 forks source link

Reading from pollserial returns invalid data every 65th byte #128

Open rjhelms opened 3 years ago

rjhelms commented 3 years ago

Pollserial is returning invalid data every 65th byte. It seems like the logic is not wrapping the tail around correctly when the end of the buffer is reached:

https://github.com/Avamander/arduino-tvout/blob/74e6853fbb45dc0ec7cd3cb22eced14673d739da/pollserial/pollserial.cpp#L119-L122

This should likely increment the tail and then wrap if needed, something like:

if (rxbuffer.tail == BUFFER_SIZE)
    rxbuffer.tail = 0;
else
    rxbuffer.tail++;
SanZamoyski commented 2 years ago

Hi!

This is my solution:

        if (rxbuffer.tail == BUFFER_SIZE-1)
            rxbuffer.tail = 0;
        else
            rxbuffer.tail++;
        return c;

Best regards!