Merge pull request #87 from sellensr/master
Add 115200 bps and parse $GPGLL
This commit is contained in:
commit
90f059091d
|
|
@ -285,6 +285,89 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
// we dont parse the remaining, yet!
|
// we dont parse the remaining, yet!
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (strStartsWith(nmea, "$GPGLL")) {
|
||||||
|
// found GLL
|
||||||
|
char *p = nmea;
|
||||||
|
|
||||||
|
// parse out latitude
|
||||||
|
p = strchr(p, ',')+1;
|
||||||
|
if (',' != *p)
|
||||||
|
{
|
||||||
|
strncpy(degreebuff, p, 2);
|
||||||
|
p += 2;
|
||||||
|
degreebuff[2] = '\0';
|
||||||
|
long degree = atol(degreebuff) * 10000000;
|
||||||
|
strncpy(degreebuff, p, 2); // minutes
|
||||||
|
p += 3; // skip decimal point
|
||||||
|
strncpy(degreebuff + 2, p, 4);
|
||||||
|
degreebuff[6] = '\0';
|
||||||
|
long minutes = 50 * atol(degreebuff) / 3;
|
||||||
|
latitude_fixed = degree + minutes;
|
||||||
|
latitude = degree / 100000 + minutes * 0.000006F;
|
||||||
|
latitudeDegrees = (latitude-100*int(latitude/100))/60.0;
|
||||||
|
latitudeDegrees += int(latitude/100);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = strchr(p, ',')+1;
|
||||||
|
if (',' != *p)
|
||||||
|
{
|
||||||
|
if (p[0] == 'S') latitudeDegrees *= -1.0;
|
||||||
|
if (p[0] == 'N') lat = 'N';
|
||||||
|
else if (p[0] == 'S') lat = 'S';
|
||||||
|
else if (p[0] == ',') lat = 0;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse out longitude
|
||||||
|
p = strchr(p, ',')+1;
|
||||||
|
if (',' != *p)
|
||||||
|
{
|
||||||
|
strncpy(degreebuff, p, 3);
|
||||||
|
p += 3;
|
||||||
|
degreebuff[3] = '\0';
|
||||||
|
degree = atol(degreebuff) * 10000000;
|
||||||
|
strncpy(degreebuff, p, 2); // minutes
|
||||||
|
p += 3; // skip decimal point
|
||||||
|
strncpy(degreebuff + 2, p, 4);
|
||||||
|
degreebuff[6] = '\0';
|
||||||
|
minutes = 50 * atol(degreebuff) / 3;
|
||||||
|
longitude_fixed = degree + minutes;
|
||||||
|
longitude = degree / 100000 + minutes * 0.000006F;
|
||||||
|
longitudeDegrees = (longitude-100*int(longitude/100))/60.0;
|
||||||
|
longitudeDegrees += int(longitude/100);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = strchr(p, ',')+1;
|
||||||
|
if (',' != *p)
|
||||||
|
{
|
||||||
|
if (p[0] == 'W') longitudeDegrees *= -1.0;
|
||||||
|
if (p[0] == 'W') lon = 'W';
|
||||||
|
else if (p[0] == 'E') lon = 'E';
|
||||||
|
else if (p[0] == ',') lon = 0;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get time
|
||||||
|
p = strchr(p, ',')+1;
|
||||||
|
float timef = atof(p);
|
||||||
|
uint32_t time = timef;
|
||||||
|
hour = time / 10000;
|
||||||
|
minute = (time % 10000) / 100;
|
||||||
|
seconds = (time % 100);
|
||||||
|
|
||||||
|
milliseconds = fmod(timef, 1.0) * 1000;
|
||||||
|
|
||||||
|
p = strchr(p, ',')+1;
|
||||||
|
// Serial.println(p);
|
||||||
|
if (p[0] == 'A')
|
||||||
|
fix = true;
|
||||||
|
else if (p[0] == 'V')
|
||||||
|
fix = false;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,9 @@
|
||||||
#define PMTK_API_SET_FIX_CTL_5HZ "$PMTK300,200,0,0,0,0*2F" ///< 5 Hz
|
#define PMTK_API_SET_FIX_CTL_5HZ "$PMTK300,200,0,0,0,0*2F" ///< 5 Hz
|
||||||
// Can't fix position faster than 5 times a second!
|
// Can't fix position faster than 5 times a second!
|
||||||
|
|
||||||
#define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C" ///< 57600 bps
|
#define PMTK_SET_BAUD_115200 "$PMTK251,115200*1F" ///< 115200 bps
|
||||||
#define PMTK_SET_BAUD_9600 "$PMTK251,9600*17" ///< 9600 bps
|
#define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C" ///< 57600 bps
|
||||||
|
#define PMTK_SET_BAUD_9600 "$PMTK251,9600*17" ///< 9600 bps
|
||||||
|
|
||||||
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29" ///< turn on only the second sentence (GPRMC)
|
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29" ///< turn on only the second sentence (GPRMC)
|
||||||
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28" ///< turn on GPRMC and GGA
|
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28" ///< turn on GPRMC and GGA
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue