Allows for a GPS module to be connected to a serial port and exposes an easy to use API to get the GPS data.
Fork of MODGPS by
Diff: GPS.cpp
- Revision:
- 6:64771e31464e
- Parent:
- 5:7f130f85d5a4
- Child:
- 7:049436bc2225
--- a/GPS.cpp Wed Apr 20 09:15:07 2011 +0000 +++ b/GPS.cpp Thu Apr 21 14:06:17 2011 +0000 @@ -28,6 +28,12 @@ _lastByte = 0; + _gga = (char *)NULL; + + _rmc = (char *)NULL; + + _vtg = (char *)NULL; + switch(_uidx) { case 1: _base = LPC_UART1; break; case 2: _base = LPC_UART2; break; @@ -120,6 +126,8 @@ void GPS::ticktock(void) { + int i; + // Increment the time structure by 1/100th of a second. ++theTime; @@ -127,18 +135,45 @@ if (process_required) { char *s = buffer[active_buffer == 0 ? 1 : 0]; if (!strncmp(s, "$GPRMC", 6)) { + if (_rmc) { + for(i = 0; s[i] != '\n'; i++) { + _rmc[i] = s[i]; + } + _rmc[i++] = '\n'; _rmc[i] = '\0'; + } theTime.nmea_rmc(s); cb_rmc.call(); if (!_ppsInUse) theTime.fractionalReset(); } else if (!strncmp(s, "$GPGGA", 6)) { + if (_gga) { + for(int i = 0; s[i] != '\n'; i++) { + _gga[i] = s[i]; + } + _gga[i++] = '\n'; _gga[i] = '\0'; + } thePlace.nmea_gga(s); cb_gga.call(); } else if (!strncmp(s, "$GPVTG", 6)) { + if (_vtg) { + for(int i = 0; s[i] != '\n'; i++) { + _vtg[i] = s[i]; + } + _vtg[i++] = '\n'; _vtg[i] = '\0'; + } theVTG.nmea_vtg(s); cb_vtg.call(); } + else { + if (_ukn) { + for(int i = 0; s[i] != '\n'; i++) { + _ukn[i] = s[i]; + } + _ukn[i++] = '\n'; _ukn[i] = '\0'; + cb_ukn.call(); + } + } process_required = false; }