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

Possibility of parse errors in the ADK USB receive call #25

Open
psigen opened this issue Aug 14, 2016 · 0 comments
Open

Possibility of parse errors in the ADK USB receive call #25

psigen opened this issue Aug 14, 2016 · 0 comments

Comments

@psigen
Copy link
Member

psigen commented Aug 14, 2016

https://github.com/platypusllc/firmware/blob/master/firmware/firmware.ino#L283

Currently, we assume that adk.read() will always receive the entire contents of a single command. This is not guaranteed, it could receive half of a packet, and append the other half to the beginning of the next read operation.

If this fragmentation continues, it can corrupt a chain of packets indefinitely if they happen to alias against the USB receive buffer size.

We should treat USB input like any other serial input:

  • read into the buffer
  • manually checking for EOL characters
  • process any completed substring
  • memmove() the unused remaining buffer
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

1 participant