Serial port and GPS

Utils.nmeaChksum Method 

Computes nme checksum for the given NMEA string

[Visual Basic]
Public Shared Function nmeaChksum( _
   ByVal nmea As Byte() _
) As Byte
[C#]
public static byte nmeaChksum(
   byte[] nmea
);

Parameters

nmea
The NMEA message for the checksum

Return Value

The computed checksum

Remarks

The checksum for an NMEA string is computed as an XOR value for all bytes between (but not including) the dollar sign and the asterisk character, according to http://www.codepedia.com/1/Taking+Out+the+Garbage:+NMEA+Checksums This method computes the checksum from the first dollar character and the first asterisk after it or up to the end of the array, if asterisk has not been found. If the array has at least two bytes more after the asterisk, the the checksum is additionally put hexadecimally in there. Exammple, for the followig byte array

$PSRF103,00,01,00,01*xx\r\n
the method computes checksum 37 (hex 25) and puts it into the two bytes xx after the asterisk character. The resulting byte array will be then:
$PSRF103,00,01,00,01*25\r\n

See Also

Utils Class | serial Namespace