GPS With Thread

Dependencies:   MODSERIAL mbed-rtos mbed-src

Fork of GPS_U-blox_NEO-6M_Test_Code by Edoardo De Marchi

Files at this revision

API Documentation at this revision

Comitter:
saypulung
Date:
Sun Apr 26 11:51:49 2015 +0000
Parent:
1:acd907fbcbae
Commit message:
GPS UBlox With Thread RTOS

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
diff -r acd907fbcbae -r 13ef79e40e45 main.cpp
--- 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;
+}
 
 
 
diff -r acd907fbcbae -r 13ef79e40e45 main.h
--- a/main.h	Fri Aug 22 12:43:55 2014 +0000
+++ b/main.h	Sun Apr 26 11:51:49 2015 +0000
@@ -16,4 +16,5 @@
 
 
 void Init();
+void splitString(char str[],char *delimiter);
 void parse(char *cmd, int n);
diff -r acd907fbcbae -r 13ef79e40e45 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Sun Apr 26 11:51:49 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#899aee34da6a