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)
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 thereceiveDataHandler
will return 0, while it actually modified the command being executed in thepacketData
array and will going to execute it (that might cause unexplained behavior)