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/GPRMCdecoder.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 | 3:20f8faf2ad18 | 4 | |
chris215 | 0:0c1aa5906cef | 5 | |
chris215 | 0:0c1aa5906cef | 6 | void DecodeGPRMC(char * tokenStr,GPSInfo& data){ |
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){ //utc fix time |
chris215 | 0:0c1aa5906cef | 16 | data.time.time[0] = *token; |
chris215 | 0:0c1aa5906cef | 17 | data.time.time[1] = *(token+1); |
chris215 | 0:0c1aa5906cef | 18 | data.time.time[2] = *(token+2); |
chris215 | 0:0c1aa5906cef | 19 | data.time.time[3] = *(token+3); |
chris215 | 0:0c1aa5906cef | 20 | data.time.time[4] = *(token+4); |
chris215 | 0:0c1aa5906cef | 21 | data.time.time[5] = *(token+5); |
chris215 | 0:0c1aa5906cef | 22 | data.time.time[6] = '\0'; //properly finish the string |
chris215 | 0:0c1aa5906cef | 23 | data.time.hour = (data.time.time[0]-0x30)*10 + (data.time.time[1]-0x30); |
chris215 | 0:0c1aa5906cef | 24 | data.time.min = (data.time.time[2]-0x30)*10 + (data.time.time[3]-0x30); |
chris215 | 0:0c1aa5906cef | 25 | data.time.sec = (data.time.time[4]-0x30)*10 + (data.time.time[5]-0x30); |
chris215 | 0:0c1aa5906cef | 26 | if(*(token+6) == '.')//check is sentence has ms precision, if so parse it |
chris215 | 0:0c1aa5906cef | 27 | data.time.msec = (*(token+7)-0x30)*100 +(*(token+8)-0x30)*10 + (*(token+9)-0x30); |
chris215 | 0:0c1aa5906cef | 28 | else |
chris215 | 0:0c1aa5906cef | 29 | data.time.msec = 0; |
chris215 | 0:0c1aa5906cef | 30 | |
chris215 | 0:0c1aa5906cef | 31 | } |
chris215 | 0:0c1aa5906cef | 32 | if(parameterCount == 2){ //GPS fix status |
chris215 | 0:0c1aa5906cef | 33 | data.GPSStatus = *token; |
chris215 | 0:0c1aa5906cef | 34 | } |
chris215 | 0:0c1aa5906cef | 35 | if(parameterCount == 9){ //fix date |
chris215 | 0:0c1aa5906cef | 36 | data.date.date[0] = *token; |
chris215 | 0:0c1aa5906cef | 37 | data.date.date[1] = *(token+1); |
chris215 | 0:0c1aa5906cef | 38 | data.date.date[2] = *(token+2); |
chris215 | 0:0c1aa5906cef | 39 | data.date.date[3] = *(token+3); |
chris215 | 0:0c1aa5906cef | 40 | data.date.date[4] = *(token+4); |
chris215 | 0:0c1aa5906cef | 41 | data.date.date[5] = *(token+5); |
chris215 | 0:0c1aa5906cef | 42 | data.date.date[6] = '\0'; //properly finish the string |
chris215 | 0:0c1aa5906cef | 43 | data.date.day = (data.date.date[0]-0x30)*10 + (data.date.date[1]-0x30); |
chris215 | 0:0c1aa5906cef | 44 | data.date.month = (data.date.date[2]-0x30)*10 + (data.date.date[3]-0x30);; |
chris215 | 0:0c1aa5906cef | 45 | data.date.year = (data.date.date[4]-0x30)*10 + (data.date.date[5]-0x30);; |
chris215 | 0:0c1aa5906cef | 46 | } |
chris215 | 0:0c1aa5906cef | 47 | |
chris215 | 0:0c1aa5906cef | 48 | parameterCount++; |
chris215 | 0:0c1aa5906cef | 49 | ptr = rest; // rest contains the left over part..assign it to ptr. |
chris215 | 3:20f8faf2ad18 | 50 | //token = strtok_r(ptr, ",",&rest); |
chris215 | 3:20f8faf2ad18 | 51 | token = strtok_single(NULL, ","); |
chris215 | 0:0c1aa5906cef | 52 | } |
chris215 | 0:0c1aa5906cef | 53 | } |