From a047465a7330ffd8b95eff81f099bccabdae1f78 Mon Sep 17 00:00:00 2001 From: Rick Sellens Date: Fri, 7 Feb 2020 14:26:39 -0500 Subject: [PATCH] More rigor in parseTime() previous version ran ok with M0, but generated exceptions in ESP32 when decimals not found. --- src/NMEA_parse.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/NMEA_parse.cpp b/src/NMEA_parse.cpp index 97d603a..652becd 100644 --- a/src/NMEA_parse.cpp +++ b/src/NMEA_parse.cpp @@ -768,8 +768,11 @@ bool Adafruit_GPS::parseTime(char *p) { hour = time / 10000; minute = (time % 10000) / 100; seconds = (time % 100); - p = strchr(p, '.'); - milliseconds = atof(p) * 1000; + char *dec = strchr(p, '.'); + char *comstar = min(strchr(p, ','), strchr(p, '*')); + if(dec != NULL && comstar != NULL && dec < comstar) + milliseconds = atof(p) * 1000; + else milliseconds = 0; lastTime = sentTime; return true; }