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:
When available read a complete sentence from UART/I2C. Return False if not available. (No change)
Check the CRC. Return False if it fails. (No change)
If the sentence is NOT from a GNSS talker, assume it is valid and return True.
Call a _parse_XXX method for the sentence type, eg. _parse_rmc() for RMC.
If the data length is not an expected size, return False.
Within these methods, call _parse_data() with an appropriate sentence type and the data.
Match the data against the expected type and convert it. Return False if it fails.
Use the parsed data to interpret the message and update instance variables.
Return 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.
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.