Created
July 10, 2015 07:32
-
-
Save tomaskrcka/60f7c94b8c93c12516da to your computer and use it in GitHub Desktop.
NMEA message checksum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, getopt | |
def main(argv): | |
if len(argv) < 1: | |
print "Put a message - like GPVTG,,T,,M,0.191,N,0.354,K,D" | |
return | |
msg = argv[0] | |
checksum = 0 | |
for item in msg: | |
byteitem = ord(item) | |
checksum ^= byteitem | |
print "$%s*%s" % (msg, str(hex(checksum)[2:])) | |
if __name__ == "__main__": | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment