XOR calculation for NMEA checksums (GPS protocol)

If you’ve ever seen the serial output of a GPS reader, you’ve seen a mystery string at the end like this:

That’s the checksum of the whole string. NMEA data structure for Global Positioning (GPS) readers has a checksum on the end of each sentence. The checksum is the XOR of all the bytes between the $ and the * in the sentence. For example, if the sentence is this:

$GPRMC,155123.000,A,4043.8432,N,07359.7653,W,0.15,83.25,200407,,*28

then you run a checksum on this:

GPRMC,155123.000,A,4043.8432,N,07359.7653,W,0.15,83.25,200407,,

Here’s a Processing method to calculate the checksum, given the string between the $ and the *:

Technorati Tags: ,


Continue Reading »