tag:blogger.com,1999:blog-27141794.post5451304778206582087..comments2023-04-02T20:41:41.023-05:00Comments on Dosch-man's Blog: Calculating NMEA sentence checksums with Pythondoschmanhttp://www.blogger.com/profile/00219948412523833756noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-27141794.post-71879648161502955452022-11-11T07:41:25.392-06:002022-11-11T07:41:25.392-06:00Thanks for this - very useful also on micropython ...Thanks for this - very useful also on micropython with the Raspberry Pi Pico microcontroller. <br />I now have a working rouine, albeit with some mods to the string handling to remove "\r\n" which can be troublesome.<br />Baltimore Billhttps://www.blogger.com/profile/01773362643046882470noreply@blogger.comtag:blogger.com,1999:blog-27141794.post-27428997106009962312021-07-28T03:49:30.557-05:002021-07-28T03:49:30.557-05:00Thank you! It was very helpful for me!Thank you! It was very helpful for me!Алексейhttps://www.blogger.com/profile/14642761062246123582noreply@blogger.comtag:blogger.com,1999:blog-27141794.post-1767050705267669322016-12-08T10:53:12.477-06:002016-12-08T10:53:12.477-06:00Finally, something I can add to...
This code work...Finally, something I can add to...<br /><br />This code works except that cksum contains the checksum flag * and int(cksum, 16) fails.<br /><br />Change<br />cksum = sentence[len(sentence) - 3:]<br /><br />to<br />cksum = sentence[len(sentence) - 2:]<br /><br />because the NMEA checksum is always the last two characters on the line.<br /><br />SteveMannhttps://www.blogger.com/profile/12970435031364389076noreply@blogger.comtag:blogger.com,1999:blog-27141794.post-21833146446128420752015-07-22T18:51:11.560-05:002015-07-22T18:51:11.560-05:00The behavior of removing the new line had mixed re...The behavior of removing the new line had mixed results. Here's an alternative version to try.<br /><br /><br />def nmea_chksum(sentence):<br /> sentence = sentence.rstrip('\n')<br /> cksum = sentence[len(sentence) - 3:]<br /> chksumdata = re.sub("(\n|\r\n)","", sentence[sentence.find("$")+1:sentence.find("*")])<br /> csum = 0<br /> for c in chksumdata:<br /> csum ^= ord(c)<br /> if hex(csum) == hex(int(cksum, 16)):<br /> return True<br /> return False<br /><br /><br />nmea_chksum(sentene)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27141794.post-24522576222314831072015-07-20T17:45:46.299-05:002015-07-20T17:45:46.299-05:00Awesome, found several bad examples of this online...Awesome, found several bad examples of this online.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27141794.post-19030380509876060792014-07-02T23:24:23.844-05:002014-07-02T23:24:23.844-05:00Best description that I've found on the web of...Best description that I've found on the web of exactly how to handle the NMEA data and XOR each character in the NMEA sentences. THANK YOU!!Anonymousnoreply@blogger.com