-
Notifications
You must be signed in to change notification settings - Fork 60
Fail bad sentences that pass the CRC check #57
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
Conversation
…rt of their name. eg. _parse_gpgll -> _parse_gll
Refactor the date and time parsing into a method Add an instance variable self.mode_indicator Add an instance variable self.magnetic_variation Sentence Parsing: 1) Read the sentence from I2C/UART (No change) 2) Validate the CRC, else fail (No change) 3) Call _parse_[SENTENCE_TYPE](), if the sentence was from a GNSS, else return True 4) The data length is compared against it's expected length, else fail 5) These then call _parse_data(PSEUDO_SENTENCE_TYPE,DATA) 6) The data is converted into the expected parameter types, else fail PSEUDO_SENTENCE_TYPE is usually SENTENCE_TYPE, but can be modified for a SENTENCE_TYPE with variable data length. The update() method returns True if: The sentence passes CRC AND Not from A GNSS (No parsing happens) OR From a GNSS, with a handled sentence type which passes parsing OR From a GNSS, with an unhandled sentence type (No parsing happens) Else False
Here is how I think we'll want to fix the duplicate-code check: adafruit/cookiecutter-adafruit-circuitpython#111 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these further improvements. Please check the RAM impact too.
… to reduce memory usage.
…hen the pre-commit gets updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you!
Updating https://github.com/adafruit/Adafruit_CircuitPython_Fingerprint to 2.2.0 from 2.1.4: > Merge pull request adafruit/Adafruit_CircuitPython_Fingerprint#28 from admiralmaggie/master Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.8.0 from 3.7.1: > Merge pull request adafruit/Adafruit_CircuitPython_GPS#57 from lesamouraipourpre/bad-sentences Updating https://github.com/adafruit/Adafruit_CircuitPython_HT16K33 to 4.1.5 from 4.1.4: > Merge pull request adafruit/Adafruit_CircuitPython_HT16K33#86 from SAK917/master Updating https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731 to 3.0.1 from 3.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_IS31FL3731#39 from dglaude/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_MONSTERM4SK to 0.1.2 from 0.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_MONSTERM4SK#6 from FoamyGuy/pylintrc_update > Removed pylint process from github workflow Updating https://github.com/adafruit/Adafruit_CircuitPython_AirLift to 1.0.1 from 1.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_AirLift#2 from FoamyGuy/pylintrc > Set correct black and reuse versions > Removed pylint process from github workflow > Hardcoded black version Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.15.4 from 2.15.1: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#132 from jposada202020/tab_replacement > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#130 from kmatch98/master > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#126 from FoamyGuy/label_base_class Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.2.2 from 0.2.1: > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#9 from tannewt/audiobusio_examples > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#13 from FoamyGuy/pylintrc Updating https://github.com/adafruit/Adafruit_CircuitPython_Pixel_Framebuf to 1.1.2 from 1.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_Pixel_Framebuf#4 from FoamyGuy/main > Hardcoded black version
As the CRC is only 8 bit and bad sentences will get past it, this PR attempts to catch bad sentences by comparing them to an expected parameter type list after the CRC check. Fixes #55
The
_update()
method does the following:False
if not available. (No change)False
if it fails. (No change)True
._parse_rmc()
for RMC.False
._parse_data()
with an appropriate sentence type and the data.False
if it fails.True
The time/data parsing code has also been refactored into a method so that it is not repeated through the code.
Hardware tested with:
Pyportal Pynt to Adafruit Mini GPS over I2C
I've had it connected for over 18 hours with no errors raised.
This is Draft as it would be appreciated if others can test on different hardware.