Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rjhelms opened this issue Jul 12, 2021 · 1 comment
Open

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

rjhelms opened this issue Jul 12, 2021 · 1 comment

Comments

@rjhelms
Copy link

rjhelms commented Jul 12, 2021

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:

if (rxbuffer.tail == BUFFER_SIZE)
rxbuffer.tail = 0;
else
rxbuffer.tail++;

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
Copy link

Hi!

This is my solution:

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

Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants