particle-iot / ElectronAssetTracker

Library for the Electron Asset Tracker!
Apache License 2.0
53 stars 84 forks source link

Adafruit_GPS::parse is not robust to certain strings #1

Open bkobkobko opened 8 years ago

bkobkobko commented 8 years ago

In the parse function, there is a test for the char 4 from the end to make sure it is a '' followed by a checksum test if it is a '', but the alternative, when there is not a '*' does not do an early return with false.

An input string that starts with "$GPGGA" or "$GPRMC" but does not have a '*' at the end will cause the code to attempt to parse an illegal string.

A better approach might be to have an early return with false if there is no '*' character four from the end.

The original Adafruit library also has this problem of course.

See this particle community discussion for more details:

https://community.particle.io/t/default-example-for-asset-tracker-gps-prints-erratic-nmea-sentences-to-serial/21356

jmccorm commented 8 years ago

The Adafruit_GPS library is significantly bugged, yet it seems to operate despite those bugs because it accidentally bypasses a checksum in certain situations. That allows just a minority of messages to make it through, but enough to make the library look like it is working. Some of the problems are in the parser, some of the problems are in the routine which reads from the GPS and assembles together a string.

We ended up with lots of good stuff in that thread. I wanted to thank you, bkokobko, for asking those questions which pushed me to gather more information which gave us a better understanding of the problem. Also thanks for bringing in Hypnopompia who poured his experience and expertise into this.

I'm hoping that you or he can take over from here. My employer greatly values my ability to dive in and debug something which I (and my coworkers) don't understand. But I'm not a programmer and I have to hand this over to those who are more capable than I to drive this forward.

I'm think I'm going to be really happy with a far more robust GPS library in my hot little hands. :)