GPSlibrary
Diff: GPS.cpp
- Revision:
- 4:0893111db5e7
- Parent:
- 1:432f77f0d864
--- a/GPS.cpp Tue Jul 30 11:08:55 2019 +0000 +++ b/GPS.cpp Sun Aug 18 08:17:48 2019 +0000 @@ -1,68 +1,40 @@ #include "GPS.h" - - +#include "mbed.h" -GPS::GPS(PinName tx, PinName rx):_gps(tx,rx) +GPS::GPS(PinName tx, PinName rx) { - _gps.baud(9600); _tx=tx; _rx=rx; + _gps(_tx,_rx); } //Serial pc(USBTX,USBRX); //char getGPS[128]; //int i=0; -int GPS::getGPGGA() +char GPS::getGPGGA() { - //Serial gps(_tx,_rx); - //gps.baud(9600); - //Serial pc(USBTX,USBRX); - //pc.baud(19200); - int i=0; - - //while(1) { - - - - if(_gps.readable()) { - //GPSread=1; - - //for (i=0; i<256; i++) { - getGPS[i]=_gps.getc(); - - if(getGPS[i]=='\n') { - - - if((getGPS[5]=='G')&&(getGPS[6]=='A')) { - + _gps.start(); + while(1) + { + getGPS[i]=_gps.read(); - for(int n=0; n<i+1; n++) { - //pc.printf("%c",getGPS[n]); - + if(getGPS[i]=='\n') + { + if((getGPS[5]=='G')&&(getGPS[6]=='A')) + { + for(int n=0; n<i+1; n++) + { GPSMessage[n] = getGPS[n]; - return 1; - } - - //pc.printf("%s",GPSMessage); - - + //pc.printf("%s",GPSMessage); + goto OUT; }//if GAの終わり - i=0; - - //break; - }//if \nの終わり - i++; - - //}//forの終わり - } - - //}//whileの終わり - return 0; + OUT: + return GPSMessage; } \ No newline at end of file