gps

Dependencies:   SDFileSystem mbed

Fork of SDFileSystem_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
Nike3221
Date:
Mon Feb 29 11:23:34 2016 +0000
Parent:
0:bdbd3d6fc5d5
Commit message:
gps

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r bdbd3d6fc5d5 -r 6ea35a0ac85d main.cpp
--- a/main.cpp	Fri Dec 07 11:25:01 2012 +0000
+++ b/main.cpp	Mon Feb 29 11:23:34 2016 +0000
@@ -1,19 +1,76 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
- 
+
+Ticker timer; 
 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+Serial gps_line(p28, p27);       // tx, rx
+Serial pc(USBTX, USBRX);    // tx, rx
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+char gpsc2[200];
+int gpsc3;
+int a,b;
+int ido;
+int old_ido,old_kei;
+FILE *gpsc;
+
+void kakiko()
+{
+    
+    b=0;
+    mkdir("/sd/gps1", 0777);//*************************************************************************
+    myled1 = myled2 = myled3 = myled4 = 1;
+    FILE *gps_date = fopen("/sd/gps1/gps1.txt", "a");
+    
+    if(gps_date == NULL) {
+        error("Could not open file for write\n");
+        }
+    while(b!=50){
+      fputc(gps_line.getc(),gps_date);
+       b++; }
+    fclose(gps_date);//****************************************************************************************
+    
+    myled1 = myled2 = myled3 = myled4 = 0;
+    printf("Goodbye World!\n");
+}
  
 int main() {
-    printf("Hello World!\n");   
- 
-    mkdir("/sd/mydir", 0777);
+   
+    gps_line.baud(9600);
+    timer.attach(&kakiko,2.0);
+    int i=0;
+    printf("Hello World!\n");
     
-    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
-    if(fp == NULL) {
-        error("Could not open file for write\n");
-    }
-    fprintf(fp, "Hello fun SD Card World!");
-    fclose(fp); 
- 
-    printf("Goodbye World!\n");
+       for(a=30;a<200;a++)
+       {gpsc2[a]= gps_line.getc();
+        pc.printf("%c",gpsc2[a]);
+        
+        if(gpsc2[a-21]=='P')
+         {if(gpsc2[a-20]=='G')
+          {if(gpsc2[a-19]=='G')
+           {ido=gpsc2[a-4]*1000+gpsc2[a-3]*100+gpsc2[a-1]*10+gpsc2[a]*1;
+            pc.printf("cc%dcc",ido);
+            
+            mkdir("/sd/ido1", 0777);//*************************************************************************
+            myled1 = myled2 = myled3 = myled4 = 1;
+            FILE *idof = fopen("/sd/ido1/ido1.txt", "a");
+    
+            if(idof == NULL) {
+              error("Could not open file for write\n");
+             }
+    
+            fprintf(idof,"%d\n",ido);
+      
+            fclose(idof);//****************************************************************************************
+            myled1 = myled2 = myled3 = myled4 = 0;
+             }}} 
+        if(a>=50)
+         {a=25;}
+        old_ido=ido;
+        
+        
+       }//for
+       
 }