Atsumi Toda / Mbed 2 deprecated mbed_GPS_TP

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Joeatsumi
Date:
Sun Sep 03 11:54:59 2017 +0000
Commit message:
TBT S-240???TP?GPS???

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7fe771d8b39a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Sep 03 11:54:59 2017 +0000
@@ -0,0 +1,55 @@
+//LPC1768での作動を確認。
+#include "mbed.h"
+DigitalOut led(LED1);
+LocalFileSystem local("local");
+
+//機体に搭載する際には、LPC1768ではなく、LPC1114を使うと思うので、
+//LocalFileSystem ではなく、sdfilesystemを使うといいかも。
+
+Serial gps(p9,p10);//9,10ピンをGPSの送受信に用いる。
+
+int main(){
+       
+    char rcv[256];
+    int count=0;
+    int log_count=0;
+    FILE*fp;
+    
+    gps.baud(9600); //gpsのボーレート設定
+    
+    
+    while(1){
+    if(gps.readable()){//GPSからの文字を受信したら
+        
+        rcv[count]=gps.getc();
+        
+        if(rcv[count]=='$'){//$という文字を受信したら、
+            rcv[0]='$';
+            count=1;
+        }else{
+            if(rcv[count-1]=='\r'&&rcv[count]=='\n'){
+                rcv[count+1]='\0';
+                
+                if(memcmp(rcv, "$GPRMC",6) == 0) {//$GPRMCという文字を10回取得すると記録する。
+                         
+                         if(log_count >= 10) {
+                          
+                          log_count=0;                 
+                            led=1;                                  
+                            fp=fopen("/local/nmea.log","a");
+                                if(fp != NULL){
+                                fprintf(fp,"%s",rcv);
+                                fclose(fp);                        
+                    }    // if(log_count >= 10) ends
+            }else{
+                led=0;
+                log_count++;
+                }//else ends
+                
+            }
+        count =0;
+       }else{
+        count++;
+        }
+    }
+  }}}
diff -r 000000000000 -r 7fe771d8b39a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Sep 03 11:54:59 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/fd96258d940d
\ No newline at end of file