GPSlibrary
Revision 3:dc8f7484b379, committed 2019-08-18
- Comitter:
- takepiyo
- Date:
- Sun Aug 18 06:03:11 2019 +0000
- Parent:
- 2:e3c59956d8ce
- Commit message:
- while 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 Sun Aug 18 05:06:58 2019 +0000 +++ b/GPS.cpp Sun Aug 18 06:03:11 2019 +0000 @@ -1,11 +1,12 @@ #include "mbed.h" #include "GPS.h" -GPS::GPS(PinName tx, PinName rx):_gps(tx,rx) +GPS::GPS(PinName tx, PinName rx) { - _gps.baud(9600); _tx=tx; _rx=rx; + Serial _gps(_tx,_rx); + _gps.baud(9600); } //Serial pc(USBTX,USBRX); @@ -23,43 +24,30 @@ //while(1) { - - - if(_gps.readable()) { + 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')) { - - - for(int n=0; n<i+1; n++) { - //pc.printf("%c",getGPS[n]); - - GPSMessage[n] = getGPS[n]; - return 1; + for (i=0; i<256; i++) + { + getGPS[i]=_gps.getc(); - } - + if(getGPS[i]=='\n') + { + if((getGPS[5]==103)&&(getGPS[6]==97)) + { + for(int n=0; n<i+1; n++) + { + //pc.printf("%c",getGPS[n]); + GPSMessage[n] = getGPS[n]; + } //pc.printf("%s",GPSMessage); - - - }//if GAの終わり - - i=0; - - //break; - - }//if \nの終わり - - i++; - - //}//forの終わり - + }//if GAの終わり + i=0; + + }//if \nの終わり + i++; + }//forの終わり } //}//whileの終わり
--- a/GPS.h Sun Aug 18 05:06:58 2019 +0000 +++ b/GPS.h Sun Aug 18 06:03:11 2019 +0000 @@ -8,7 +8,7 @@ { 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];