tidy lines and checksum
Parse start of checksum as character after first $. Don't include '\n' or '\r' in GPS lines read. Previous code was putting '\r' at the end of each line and '\n' at the start before the $, thus having to start the checksum calculation at the third character. This may break the spacing on some code that prints out the NMEA lines.
This commit is contained in:
parent
0f867b508a
commit
8bad5eacfb
|
|
@ -61,7 +61,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
sum += parseHex(*(ast+2));
|
sum += parseHex(*(ast+2));
|
||||||
|
|
||||||
// check checksum
|
// check checksum
|
||||||
for (char *p = nmea+2; p < ast; p++) {
|
for (char *p = strchr(nmea,'$')+1; p < ast; p++) {
|
||||||
sum ^= *p;
|
sum ^= *p;
|
||||||
}
|
}
|
||||||
if (sum != 0) {
|
if (sum != 0) {
|
||||||
|
|
@ -414,7 +414,7 @@ char Adafruit_GPS::read(void) {
|
||||||
recvdflag = true;
|
recvdflag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentline[lineidx++] = c;
|
if(c != '\n' && c != '\r') currentline[lineidx++] = c;
|
||||||
if (lineidx >= MAXLINELENGTH)
|
if (lineidx >= MAXLINELENGTH)
|
||||||
lineidx = MAXLINELENGTH-1;
|
lineidx = MAXLINELENGTH-1;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue