vorpalrobotics / VorpalHexapod

Arduino code for both the Vorpal Hexapod and Vorpal Hexapod Gamepad.
http://www.vorpalrobotics.com
139 stars 58 forks source link

Two packet buffers, Rx and Execution buffer #2

Open shakram02 opened 7 years ago

shakram02 commented 7 years ago

What about having 2 packet buffers, one for receiving data and another one to use it for the commands are are currently runny, That can make partially received packets more likely to be read correctly. Assume the following,

We are now receiving a packet that has correct header, correct length (this is a don't care) and some and some data but are missing some characters, and a checksum.

The command partition of the data isn't complete and has a missing part, But in the receiver state machine, it updates the packetData field while its receiving the data. And also uses that for executing the command, Now the checksum will fail and the receiveDataHandler will return 0, while it actually modified the command being executed in the packetData array and will going to execute it (that might cause unexplained behavior)