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