0
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ Oh thanks, its help full. :) The protocol specification does not include the information on how to generate the checksum. \$\endgroup\$ – R. Hirur Jan 30 '16 at 6:57
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – PeterJ Jan 30 '16 at 11:52
  • \$\begingroup\$ Check out the Wikipedia page for NEMA Standard \$\endgroup\$ – MaNyYaCk Jun 22 '18 at 9:36
4
\$\begingroup\$

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.