GPSlibrary

GPS.cpp

Committer:
Nerosho
Date:
2019-07-30
Revision:
1:432f77f0d864
Parent:
0:3d25bc7ff80e
Child:
2:e3c59956d8ce
Child:
4:0893111db5e7

File content as of revision 1:432f77f0d864:

#include "GPS.h"



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);
    //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')) {


                for(int n=0; n<i+1; n++) {
                    //pc.printf("%c",getGPS[n]);

                    GPSMessage[n] = getGPS[n];
                    return 1;

                }

                //pc.printf("%s",GPSMessage);


            }//if GAの終わり

            i=0;

            //break;

        }//if \nの終わり

        i++;

        //}//forの終わり

    }

    //}//whileの終わり
    return 0;
}