GPSlibrary

Revision:
1:432f77f0d864
Parent:
0:3d25bc7ff80e
Child:
2:e3c59956d8ce
Child:
4:0893111db5e7
--- a/GPS.cpp	Tue Jul 16 12:07:09 2019 +0000
+++ b/GPS.cpp	Tue Jul 30 11:08:55 2019 +0000
@@ -1,54 +1,68 @@
 #include "GPS.h"
-#include "mbed.h"
+
 
 
-GPS::GPS(PinName tx, PinName rx):gps(tx,rx)
+GPS::GPS(PinName tx, PinName rx):_gps(tx,rx)
 {
+    _gps.baud(9600);
     _tx=tx;
     _rx=rx;
+}
+//Serial pc(USBTX,USBRX);
 
-}
+//char getGPS[128];
+//int i=0;
 
 int GPS::getGPGGA()
 {
     //Serial gps(_tx,_rx);
-    gps.baud(9600);
+    //gps.baud(9600);
     //Serial pc(USBTX,USBRX);
-    //pc.baud(9600);
+    //pc.baud(19200);
 
-    char recvGPS=0;
-    char getGPS[128];
-    //char GPSMessage[128];
     int i=0;
-    
+
+    //while(1) {
+
 
-    if(gps.readable()) {
+
+    if(_gps.readable()) {
+        //GPSread=1;
 
-        recvGPS=gps.getc();
-        getGPS[i]=recvGPS;
+        //for (i=0; i<256; i++) {
+        getGPS[i]=_gps.getc();
 
-        if(getGPS[i]==10) {
+        if(getGPS[i]=='\n') {
+
 
-            if((getGPS[5]==71)&&(getGPS[6]==65)) {
+            if((getGPS[5]=='G')&&(getGPS[6]=='A')) {
+
 
                 for(int n=0; n<i+1; n++) {
+                    //pc.printf("%c",getGPS[n]);
 
                     GPSMessage[n] = getGPS[n];
-                
-                    
+                    return 1;
+
                 }
-            return 1;
+
+                //pc.printf("%s",GPSMessage);
 
-            }
+
+            }//if GAの終わり
 
             i=0;
 
-        }
+            //break;
+
+        }//if \nの終わり
 
         i++;
+
+        //}//forの終わり
+
     }
 
-    //char eGPSMessage[]= "Could not get GPS data!";
+    //}//whileの終わり
     return 0;
-
 }
\ No newline at end of file