GPSlibrary
Revision 1:432f77f0d864, committed 2019-07-30
- Comitter:
- Nerosho
- Date:
- Tue Jul 30 11:08:55 2019 +0000
- Parent:
- 0:3d25bc7ff80e
- Child:
- 2:e3c59956d8ce
- Child:
- 4:0893111db5e7
- Commit message:
- ver2_2
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 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
--- a/GPS.h Tue Jul 16 12:07:09 2019 +0000 +++ b/GPS.h Tue Jul 30 11:08:55 2019 +0000 @@ -1,23 +1,27 @@ #include "mbed.h" -#ifndef GPS_Class -#define GPS_Class +#ifndef GPS_CLASS +#define GPS_CLASS + class GPS { private: - Serial gps; + Serial _gps; PinName _tx; //tx pin name which connected to mbed PinName _rx; //rx pin name which connected to mbed //char GPSMessage[128]; - + public: GPS(PinName tx, PinName rx); int getGPGGA(); + int GPSread; char GPSMessage[128]; - //char eGPSMessage[128]; + //char errorMessage[128]; + char getGPS[128]; + //int i=0; };