Bugs in parse method fixed
Revision 1:130bb8aa6cf2, committed 2019-07-29
- Comitter:
- jorgmassih
- Date:
- Mon Jul 29 05:46:40 2019 +0000
- Parent:
- 0:a23e3099bb0a
- Commit message:
- bug with Fix fixed!
Changed in this revision
| MBed_Adafruit_GPS.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MBed_Adafruit_GPS.cpp Sat Mar 22 05:00:47 2014 +0000
+++ b/MBed_Adafruit_GPS.cpp Mon Jul 29 05:46:40 2019 +0000
@@ -46,6 +46,68 @@
}
// look for a few common sentences
+ if (strstr(nmea, "$GPRMC")) {
+ // found RMC
+ char *p = nmea;
+
+ // get time
+ p = strchr(p, ',')+1;
+ float timef = atof(p);
+ uint32_t time = timef;
+ hour = time / 10000;
+ minute = (time % 10000) / 100;
+ seconds = (time % 100);
+
+ milliseconds = fmod((double) timef, 1.0) * 1000;
+
+ p = strchr(p, ',')+1;
+ // Serial.println(p);
+
+ if (p[0] == 'A')
+ fix = true;
+ else if (p[0] == 'V')
+ fix = false;
+ else
+ return false;
+
+ // parse out latitude
+ p = strchr(p, ',')+1;
+ latitude = atof(p);
+
+ p = strchr(p, ',')+1;
+ if (p[0] == 'N') lat = 'N';
+ else if (p[0] == 'S') lat = 'S';
+ else if (p[0] == ',') lat = 0;
+ else return false;
+
+ // parse out longitude
+ p = strchr(p, ',')+1;
+ longitude = atof(p);
+
+ p = strchr(p, ',')+1;
+ if (p[0] == 'W') lon = 'W';
+ else if (p[0] == 'E') lon = 'E';
+ else if (p[0] == ',') lon = 0;
+ else return false;
+
+ // speed
+ p = strchr(p, ',')+1;
+ speed = atof(p);
+
+ // angle
+ p = strchr(p, ',')+1;
+ angle = atof(p);
+
+ p = strchr(p, ',')+1;
+ uint32_t fulldate = atof(p);
+ day = fulldate / 10000;
+ month = (fulldate % 10000) / 100;
+ year = (fulldate % 100);
+
+ // we dont parse the remaining, yet!
+ return true;
+ }
+
if (strstr(nmea, "$GPGGA")) {
// found GGA
char *p = nmea;
@@ -95,67 +157,7 @@
geoidheight = atof(p);
return true;
}
- if (strstr(nmea, "$GPRMC")) {
- // found RMC
- char *p = nmea;
-
- // get time
- p = strchr(p, ',')+1;
- float timef = atof(p);
- uint32_t time = timef;
- hour = time / 10000;
- minute = (time % 10000) / 100;
- seconds = (time % 100);
-
- milliseconds = fmod((double) timef, 1.0) * 1000;
-
- p = strchr(p, ',')+1;
- // Serial.println(p);
- if (p[0] == 'A')
- fix = true;
- else if (p[0] == 'V')
- fix = false;
- else
- return false;
-
- // parse out latitude
- p = strchr(p, ',')+1;
- latitude = atof(p);
-
- p = strchr(p, ',')+1;
- if (p[0] == 'N') lat = 'N';
- else if (p[0] == 'S') lat = 'S';
- else if (p[0] == ',') lat = 0;
- else return false;
-
- // parse out longitude
- p = strchr(p, ',')+1;
- longitude = atof(p);
-
- p = strchr(p, ',')+1;
- if (p[0] == 'W') lon = 'W';
- else if (p[0] == 'E') lon = 'E';
- else if (p[0] == ',') lon = 0;
- else return false;
-
- // speed
- p = strchr(p, ',')+1;
- speed = atof(p);
-
- // angle
- p = strchr(p, ',')+1;
- angle = atof(p);
-
- p = strchr(p, ',')+1;
- uint32_t fulldate = atof(p);
- day = fulldate / 10000;
- month = (fulldate % 10000) / 100;
- year = (fulldate % 100);
-
- // we dont parse the remaining, yet!
- return true;
- }
-
+
return false;
}