Update GPS With Thread---> Receiving data from GPS and parsing latitude and longitude to decimal. Using Ublox-Neo 6M.

Dependencies:   MODSERIAL mbed-rtos mbed-src

Fork of UbloxGPSWithThread by Say Pulung

Revision:
2:13ef79e40e45
Parent:
1:acd907fbcbae
Child:
3:dd2e91231e3c
--- a/main.cpp	Fri Aug 22 12:43:55 2014 +0000
+++ b/main.cpp	Sun Apr 26 11:51:49 2015 +0000
@@ -5,23 +5,20 @@
 */
 
 #include "main.h"
-
-
+#include "string.h"
+#include "rtos.h"
+char gpsData[10][500];
 void Init()
 {
     gps.baud(9600);
-    pc.baud(115200);
+    pc.baud(9600);
 
     pc.printf("Init OK\n");
 }
 
-
-
-int main() 
-{   
-    Init();
+void readGPSThread(void const *args)
+{
     char c;
-
     while(true) 
     {
         if(gps.readable())
@@ -33,8 +30,20 @@
                     c = gps.getc();
                     if( c == '\r' )
                     {
-                        //pc.printf("%s\n", cDataBuffer);
-                        parse(cDataBuffer, i);
+                        //int a = sizeof(cDataBuffer);
+                        //char data[500];
+                        //int ccS = sprintf(data,"%s",cDataBuffer);
+                        
+                        pc.printf("Message : %s\n", cDataBuffer);
+                        if(strncmp(cDataBuffer,"$GPRMC",6)==0)
+                        {
+                            
+                        }
+                        //int count = getDataCount(data,",");
+                        //pc.printf("Length  : %d\n",count);
+                        //fflush(stdin);
+                        //fflush(stdout);
+                        //parse(cDataBuffer, i);
                         i = sizeof(cDataBuffer);
                     }
                     else
@@ -47,6 +56,21 @@
     }
 }
 
+int main() 
+{   
+    Init();
+    DigitalOut l1(LED1);
+    Thread gpsReader(readGPSThread);
+    
+    while(1){
+        l1 = 1;
+        wait(0.5);
+        l1=0;
+        wait(0.5);
+    }
+    
+}
+
 
 void parse(char *cmd, int n)
 {
@@ -55,7 +79,7 @@
     int fq, nst, fix, date;                                     // fix quality, Number of satellites being tracked, 3D fix
     float latitude, longitude, timefix, speed, altitude;
     
-    
+    pc.printf("Parser cooyy\n");
     // Global Positioning System Fix Data
     if(strncmp(cmd,"$GPGGA", 6) == 0) 
     {
@@ -85,6 +109,20 @@
     }
 }
 
+void splitString(char str[],char *delimiter)
+{
+    int count=0;
+    char *tok = strtok(str,delimiter);
+    int idx=0;
+    while(0!=tok)
+    {
+        int cpy = sprintf(gpsData[idx],"%s",tok);
+        pc.printf("Data %d = %s\n",idx,gpsData[idx]);
+        tok = strtok(NULL,delimiter);
+        idx++;
+    }   
+    //return count;
+}