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:
sellensr 2019-04-15 13:50:37 -04:00
parent 0f867b508a
commit 8bad5eacfb
1 changed files with 2 additions and 2 deletions

View File

@ -61,7 +61,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
sum += parseHex(*(ast+2));
// check checksum
for (char *p = nmea+2; p < ast; p++) {
for (char *p = strchr(nmea,'$')+1; p < ast; p++) {
sum ^= *p;
}
if (sum != 0) {
@ -414,7 +414,7 @@ char Adafruit_GPS::read(void) {
recvdflag = true;
}
currentline[lineidx++] = c;
if(c != '\n' && c != '\r') currentline[lineidx++] = c;
if (lineidx >= MAXLINELENGTH)
lineidx = MAXLINELENGTH-1;