Skip to content

Instantly share code, notes, and snippets.

@tomaskrcka
Created July 10, 2015 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaskrcka/60f7c94b8c93c12516da to your computer and use it in GitHub Desktop.
Save tomaskrcka/60f7c94b8c93c12516da to your computer and use it in GitHub Desktop.
NMEA message checksum
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