Fix issue with millisecond parsing.
By calling atof() on p, we're converting the entire time string (101520.123 for 10:15:20am and 123 milliseconds) to a float, then multiplying by 1000 to get ms. This results in a value that overflows and exhibits all sorts of strange behavior as seconds and minutes turn over. It's clearly not what was intended. From the if statement wrapping the conversion, it is clear that the author intended to make the atof() conversion on the dec pointer, instead. Making this change actually does fix the parsing so that Adafruit_GPS' milliseconds property correctly matches the value in the NMEA sentence. You guys do great work. Thanks for everything!
This commit is contained in:
parent
8d7ea109f1
commit
1666dae26b
|
|
@ -785,7 +785,7 @@ bool Adafruit_GPS::parseTime(char *p) {
|
|||
char *dec = strchr(p, '.');
|
||||
char *comstar = min(strchr(p, ','), strchr(p, '*'));
|
||||
if (dec != NULL && comstar != NULL && dec < comstar)
|
||||
milliseconds = atof(p) * 1000;
|
||||
milliseconds = atof(dec) * 1000;
|
||||
else
|
||||
milliseconds = 0;
|
||||
lastTime = sentTime;
|
||||
|
|
|
|||
Loading…
Reference in New Issue