エレキジャックweb mbed入門用です。課題2 $マーク発見後、文字列GPGGAを含む行のみを表示します。sscanf()関数を使います。

Dependencies:   mbed

Revision:
0:1d5d3506a5ea
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jan 30 07:24:25 2011 +0000
@@ -0,0 +1,47 @@
+// GPS GT-720F Test02
+#include "mbed.h"
+#include "TextLCD0420.h"
+
+#define ON 1
+#define OFF 0
+
+TextLCD lcd(p24, p25, p26, p27, p28, p29, p30,20,4); // rs, rw, e, d0, d1, d2, d3
+Serial pc(USBTX, USBRX); // tx, rx 
+Serial gps(p9,p10);
+
+int main() {
+
+      int i;
+      char gps_data[256];
+      float dummy1,dummy2;
+      
+      gps.baud(9600);
+      lcd.cls();
+      lcd.locate(0,0);
+      lcd.printf("GPS GT720F Test\n");
+
+    while (1) {
+      i=0;
+      while(gps.getc()!='$'){
+      }
+      
+      while( (gps_data[i]=gps.getc()) != '\r'){
+        i++;
+        if(i==255){
+           pc.printf("*** Error! ***\n");
+           break;
+         }
+      }
+      gps_data[i]='0';
+     
+      if(sscanf(gps_data, "GPGGA,%f,%f",&dummy1,&dummy2) >= 1){
+        pc.printf("\x0D");
+        pc.printf("GPGGA data:\n");
+        pc.printf("%s\n\n",gps_data);
+      }
+      
+    }//while
+}//main
+
+
+