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.
Revision:
2:72ac4d7044a7
Parent:
1:fade122a76a8
Child:
4:d911d7c4e09d
diff -r fade122a76a8 -r 72ac4d7044a7 GPS.cpp
--- a/GPS.cpp	Mon Apr 06 17:41:43 2015 +0000
+++ b/GPS.cpp	Sun Feb 14 05:55:38 2016 +0000
@@ -3,6 +3,9 @@
 
 GPS::GPS(PinName tx, PinName rx) : RawSerial(tx, rx)
 {
+    RxQueueSize=0;
+    RxQueueWriteIndex=0;
+    RxQueueReadIndex=0;
     RawSerial::baud(115200);
     attach(this, &GPS::RxIrqHandler);
 }
@@ -21,17 +24,52 @@
         {
             insertIndex = 0;
             RxMessageBuffer.data[(insertIndex++)%RX_BUFFER_SIZE] = in;
+            RxMessageBuffer.MessageIsNew = 1;
         }
         else if(in == END_CHAR)
         {
-            RxMessageBuffer.data[(insertIndex++)%RX_BUFFER_SIZE] = 0;
-            DecodeMessage(RxMessageBuffer,info);
+            RxMessageBuffer.data[(insertIndex++)%RX_BUFFER_SIZE] = 0;   
+            //identify GPS message
+            int GPSMessageType = IdentifyGPSMessage(RxMessageBuffer);
+            if(GPSMessageType > 0)
+            {
+                if(GPSMessageType == GPS_GPGGAR)
+                    memcpy(&GPSGGAMessage,&RxMessageBuffer,sizeof(message));
+                if(GPSMessageType == GPS_GPGSAR)
+                    memcpy(&GPSGSAMessage,&RxMessageBuffer,sizeof(message));
+                if(GPSMessageType == GPS_GPVTGR)
+                    memcpy(&GPSVTGMessage,&RxMessageBuffer,sizeof(message));
+                if(GPSMessageType == GPS_GPRMCR)
+                    memcpy(&GPSRMCMessage,&RxMessageBuffer,sizeof(message));
+            }   
         }
         else
             RxMessageBuffer.data[(insertIndex++)%RX_BUFFER_SIZE] = in;
     }
 }
-
+void GPS::PumpGpsMessages(void)
+{
+    if(GPSRMCMessage.MessageIsNew > 0)
+    {
+        GPSRMCMessage.MessageIsNew = 0;
+        DecodeMessage(GPSRMCMessage,info);
+    }
+    if(GPSGGAMessage.MessageIsNew > 0)
+    {
+        GPSGGAMessage.MessageIsNew = 0;
+        DecodeMessage(GPSGGAMessage,info);
+    }
+    if(GPSVTGMessage.MessageIsNew > 0)
+    {
+        GPSVTGMessage.MessageIsNew = 0;
+        DecodeMessage(GPSVTGMessage,info);
+    }
+    if(GPSGSAMessage.MessageIsNew > 0)
+    {
+        GPSGSAMessage.MessageIsNew = 0;
+        DecodeMessage(GPSGSAMessage,info);
+    }
+}
 
 ECEFPoint GPS::ReadPositionECEF(void)
 {