You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Steve.
Just realized the check sum doesn't create two hex digits when the leading hex is supposed to be 0. That means some NMEA sentences get ignored due to bad checksum.
Also, be good to add a comment about why NMEA chars are always ascii so the ord(s) is always 0-127...that bounds the range of the check in hex to be < 255, i.e. two hex digits.
here's the change (just one line and comment add, but this shows the context. Used the newer style string formating
# the xor of the ord() won't have an int value of more than 127 (2 hex digits) because they are ascii chars
# (ord is 0-127 for ascii). Could range check the ord(s) result to make sure all chars are ascii, not other unicode?
checksumInt = reduce(operator.xor, (ord(s) for s in nmeaData), 0)
# change it to base 16
# return a string, but without the 0x
# better, use string formatting to make it hex without 0x
# always make sure it's 2 hex digits when there's leading 0. And use the newer string format style
checksumHex = '{:02X}'.format(checksumInt)
# was:
# checksumHex = '%x' % checksumInt
can add a test case for this after the existing test case:
# test with leading zero in checksum
checksum = NMEA_checksum_gen('GPGSA,A,1,,,,,,,,,,,,,25.5,25.5,25.5')
if checksum!="02":
print("ERROR: checksum gen test failed. checksum", checksum, "should be '02'")
sys.exit(1)
The leading zero checksum seems to be more frequent when the NMEA sentences are relatively empty.
I guess the ublox and pygpsclient ignored those sentences when the 1 digit checksum was passed? (guess).
not common, but should fix.
I noticed there were some missing GBGSV sentences in the console, and I believe this is the reason why.
Tested feeding to pygpsclient and it looks good.
-kevin
apparently I can't submit an issue without a file. this is just an empty file.
Hi Steve.
Just realized the check sum doesn't create two hex digits when the leading hex is supposed to be 0. That means some NMEA sentences get ignored due to bad checksum.
Also, be good to add a comment about why NMEA chars are always ascii so the ord(s) is always 0-127...that bounds the range of the check in hex to be < 255, i.e. two hex digits.
here's the change (just one line and comment add, but this shows the context. Used the newer style string formating
can add a test case for this after the existing test case:
The leading zero checksum seems to be more frequent when the NMEA sentences are relatively empty.
I guess the ublox and pygpsclient ignored those sentences when the 1 digit checksum was passed? (guess).
not common, but should fix.
I noticed there were some missing GBGSV sentences in the console, and I believe this is the reason why.
Tested feeding to pygpsclient and it looks good.
-kevin
apparently I can't submit an issue without a file. this is just an empty file.
nofile.txt
The text was updated successfully, but these errors were encountered: