# Generating Hexadecimal checksum for a NMEA (PMTK) message

I am trying to use quectel L80 GPS receiver for my project. I am trying to configure the L80 using the PMTK strings. But the problem is the string should also contain a hexadecimal check sum.

eg. $PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29 This is the example string given in the "protocol specification" document. In this string '29' is the check sum. My question is how do I generate the checksum? I know that for NMEA strings, the check sum is generated by 'XOR' operation of consecutive characters between '$' and '*' . while calculating the check sum do I also need to include 'comma'?

Thanks

• Oh thanks, its help full. :) The protocol specification does not include the information on how to generate the checksum. – R. Hirur Jan 30 '16 at 6:57
• @Roger I think on that page they're talking about the $and * delimiters, the commas are included in NMEA checksums and you can see on that page if you include commas it changes the value. – PeterJ Jan 30 '16 at 11:52 • Check out the Wikipedia page for NEMA Standard – MaNyYaCk Jun 22 '18 at 9:36 ## 1 Answer You just exclusive-or all the characters between the '$' and the '*' (including commas) and use the two-character hex representation of that byte (leading 0 if required to pad to two characters). Here's an example code fragment in Python:

st = "PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
i = 0
checksum = 0
while i < len(st):
checksum ^= ord(st[i])
i+= 1
print "%02X"%checksum


Result is 29

For "GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38", the result is 0A

• This. Double-check it for known cases. As the specification and sample agree when you include the commas you have your answer. – Brian Drummond Jan 30 '16 at 12:54