Mbed library to handle GPS data reception and parsing
Dependents: GPS_U-blox_NEO-6M_Code
Features
- All positionning parameters are contained into a global data structure.
- Automatic nema string parsing and data structure update.
- GSA,GGA,VTG and RMC
- Convert latitude and longitude to decimal value.
- Converts latittude,longitude and altitude to ECEF coordinates.
Planed developement
- Test library for RTOS use.
- Complete the nema parsing decoders (couple of parameters are not parsed yet and not present in the data structure).
- Add conversion tool to get ENU coordinates.
Decoders/GPGGAdecoder.hpp@5:8a73e34b3978, 2016-02-16 (annotated)
- Committer:
- chris215
- Date:
- Tue Feb 16 02:57:35 2016 +0000
- Revision:
- 5:8a73e34b3978
- Parent:
- 3:20f8faf2ad18
Function renaming. Adding gps update calls.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris215 | 0:0c1aa5906cef | 1 | #include "mbed.h" |
chris215 | 0:0c1aa5906cef | 2 | #include "mbedGPSDefs.h" |
chris215 | 3:20f8faf2ad18 | 3 | #include "DecodersUtils.h" |
chris215 | 0:0c1aa5906cef | 4 | |
chris215 | 0:0c1aa5906cef | 5 | void DecodeGPGGA(char * tokenStr,GPSInfo& data) |
chris215 | 0:0c1aa5906cef | 6 | { |
chris215 | 0:0c1aa5906cef | 7 | int parameterCount = 0; |
chris215 | 0:0c1aa5906cef | 8 | char *rest; // to point to the rest of the string after token extraction. |
chris215 | 0:0c1aa5906cef | 9 | char *token; // to point to the actual token returned. |
chris215 | 0:0c1aa5906cef | 10 | char *ptr = tokenStr; // make q point to start of hello. |
chris215 | 3:20f8faf2ad18 | 11 | //token = strtok_r(ptr, ",",&rest); |
chris215 | 3:20f8faf2ad18 | 12 | token = strtok_single(ptr, ","); |
chris215 | 0:0c1aa5906cef | 13 | while (token != NULL) |
chris215 | 0:0c1aa5906cef | 14 | { |
chris215 | 0:0c1aa5906cef | 15 | if(parameterCount == 1) |
chris215 | 0:0c1aa5906cef | 16 | data.GPStime = atof(token); |
chris215 | 0:0c1aa5906cef | 17 | |
chris215 | 0:0c1aa5906cef | 18 | if(parameterCount == 2) |
chris215 | 0:0c1aa5906cef | 19 | data.latitude = atof(token); |
chris215 | 0:0c1aa5906cef | 20 | |
chris215 | 0:0c1aa5906cef | 21 | if(parameterCount == 3) |
chris215 | 0:0c1aa5906cef | 22 | data.latLoc = *token; |
chris215 | 0:0c1aa5906cef | 23 | |
chris215 | 0:0c1aa5906cef | 24 | if(parameterCount == 4) |
chris215 | 0:0c1aa5906cef | 25 | data.longitude = atof(token); |
chris215 | 0:0c1aa5906cef | 26 | |
chris215 | 0:0c1aa5906cef | 27 | if(parameterCount == 5) |
chris215 | 0:0c1aa5906cef | 28 | data.lonLoc = *token; |
chris215 | 0:0c1aa5906cef | 29 | |
chris215 | 0:0c1aa5906cef | 30 | if(parameterCount == 6) |
chris215 | 0:0c1aa5906cef | 31 | data.FixQal = atoi(token); |
chris215 | 0:0c1aa5906cef | 32 | |
chris215 | 0:0c1aa5906cef | 33 | if(parameterCount == 7) |
chris215 | 0:0c1aa5906cef | 34 | data.TrackedSatCnt = atoi(token); |
chris215 | 0:0c1aa5906cef | 35 | |
chris215 | 0:0c1aa5906cef | 36 | if(parameterCount == 8) |
chris215 | 0:0c1aa5906cef | 37 | data.HDOP = atof(token); |
chris215 | 0:0c1aa5906cef | 38 | |
chris215 | 0:0c1aa5906cef | 39 | if(parameterCount == 9) |
chris215 | 0:0c1aa5906cef | 40 | data.GPSAltitude = atof(token); |
chris215 | 0:0c1aa5906cef | 41 | |
chris215 | 0:0c1aa5906cef | 42 | if(parameterCount == 11) |
chris215 | 0:0c1aa5906cef | 43 | data.GEOIDHeight = atof(token); |
chris215 | 0:0c1aa5906cef | 44 | |
chris215 | 0:0c1aa5906cef | 45 | parameterCount++; |
chris215 | 0:0c1aa5906cef | 46 | ptr = rest; // rest contains the left over part..assign it to ptr. |
chris215 | 3:20f8faf2ad18 | 47 | //token = strtok_r(ptr, ",",&rest); |
chris215 | 3:20f8faf2ad18 | 48 | token = strtok_single(NULL, ","); |
chris215 | 0:0c1aa5906cef | 49 | } |
chris215 | 0:0c1aa5906cef | 50 | /*printf("Time:%lf\n",data.GPStime); |
chris215 | 0:0c1aa5906cef | 51 | printf("Latitude:%4.4lf\n",data.latitude); |
chris215 | 0:0c1aa5906cef | 52 | printf("Longitude:%4.4lf\n",data.longitude); |
chris215 | 0:0c1aa5906cef | 53 | printf("GPS FIX:%d\n",data.GPSFix); |
chris215 | 0:0c1aa5906cef | 54 | printf("GPS Altitude:%f\n",data.GPSAltitude); |
chris215 | 0:0c1aa5906cef | 55 | printf("GPS Geoide Heigth:%f\n",data.GEOIDHeight);*/ |
chris215 | 0:0c1aa5906cef | 56 | |
chris215 | 0:0c1aa5906cef | 57 | } |