adafruit / Adafruit_CircuitPython_GPS

GPS parsing module for CircuitPython. Meant to parse NMEA data from serial GPS modules.
MIT License
75 stars 60 forks source link

The CRC check doesn't catch all bad messages #55

Closed lesamouraipourpre closed 3 years ago

lesamouraipourpre commented 3 years ago

Because, the CRC value in the NMEA sentence is only 8-bit, it is fairly easy for a bad message to get past the CRC check. By observation, with my GPS on the window it takes on average ~3 hours before a bad message crashes the program.

This is usually triggered by _parse_int and _parse_float functions and can happen elsewhere.

lesamouraipourpre commented 3 years ago

I intend to fix this by making the _parse_int etc. methods always return either a valid value or None and never raise a ValueError.

I also intend to put checks into the _parse_gpgll etc functions which will fail quickly if the wrong number of comma separated parts has been received.

tannewt commented 3 years ago

Would it be possible to fail in the same way as CRC if parse int or float fail? That way you still get an error but you only have one type of error to handle.

lesamouraipourpre commented 3 years ago

I'm aiming to keep it so that the update() method behaviour stays the same, specifically Returns True if new data was processed, and False if nothing new was received. Returning False in the event of an unparseable sentence will match the behaviour of a CRC failure.

tannewt commented 3 years ago

Ok, that sounds perfect! Thank you!