GPSlibrary
Revision 4:0893111db5e7, committed 2019-08-18
- Comitter:
- takepiyo
- Date:
- Sun Aug 18 08:17:48 2019 +0000
- Parent:
- 1:432f77f0d864
- Commit message:
- i2c change
Changed in this revision
GPS.cpp | Show annotated file Show diff for this revision Revisions of this file |
GPS.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
--- a/GPS.h Tue Jul 30 11:08:55 2019 +0000 +++ b/GPS.h Sun Aug 18 08:17:48 2019 +0000 @@ -1,14 +1,14 @@ #include "mbed.h" -#ifndef GPS_CLASS -#define GPS_CLASS +#ifndef GPS_CLASS_H +#define GPS_CLASS_H class GPS { private: - Serial _gps; + I2C _gps; PinName _tx; //tx pin name which connected to mbed PinName _rx; //rx pin name which connected to mbed //char GPSMessage[128]; @@ -16,7 +16,7 @@ public: GPS(PinName tx, PinName rx); - int getGPGGA(); + char getGPGGA(); int GPSread; char GPSMessage[128]; //char errorMessage[128];