Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Better packet validity checking #89

Merged
merged 1 commit into from
Apr 16, 2020
Merged

Conversation

PaulZC
Copy link
Collaborator

@PaulZC PaulZC commented Apr 16, 2020

This merge is a big one!
It addresses Issue #85 where the fault was manifesting as CRC failures when using Serial.
The underlying problem was actually caused by the slow arrival rate of serial bytes.
It was possible for a received packet to appear valid (with the expected class and ID) before the end of the message had actually been received. The CRC did of course fail as not all of the bytes had been received.
This would not have been seen on I2C / Qwiic because there the whole message appears in the module's buffer at the same instant and the complete message can be read all in one go.
The solution involves defining three states for the packet validity: VALID (the whole message has been received and the checksum is OK); NOT_VALID (the whole message has been received and the checksum has actually failed - which should be extremely rare!); NOT_DEFINED (we have not yet reached the end of the message and cannot yet check the checksum).
This has been checked using:

  • SoftwareSerial: RedBoard ATmega328P + NEO_M8T
  • I2C / Qwiic: RedBoard ATmega328P + NEO_M8T
  • Serial1: Artemis Thing Plus + NEO_M8T
  • I2C / Qwiic: Artemis Thing Plus + NEO_M8T
  • I2C / Qwiic: RedBoard ATmega328P + ZED_F9P

The standard examples have been tested successfully on all sets of hardware.
Confidence is high!
Enjoy!
Paul

@PaulZC PaulZC merged commit 86e78de into master Apr 16, 2020
@PaulZC PaulZC deleted the Serial_checksum_correction branch April 16, 2020 16:32
@jafrado
Copy link

jafrado commented Apr 16, 2020

@PaulZC - thank you very much! Just pulled the latest master at (86e78de) and it works great! Please consider this issue closed. Thank you for the outstanding engineering work here :-)

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

Successfully merging this pull request may close these issues.

2 participants