
If $iVerify And UBound($avData) _NMEAChecksum Yes = Func _NMEAChecksum ( $sData, $iVerify = Default ) Local $vChecksum = 0 If $iVerify = Default Then $iVerify = 0 Local $avData = StringRegExp ( $sData, "^\$(*)(?:\*(\wquot, 1) |2 - Verify mode specified for data containing no embedded checksum.

: Success - The sentence's checksum, or True, depending on the value of $iVerify.

|1 - Verify the sentence's validity by comparing the calculated and embedded checksums. : $sData - The NMEA sentence $iVerify - Numeric value that defines the function's behaviour as follows: |0 - Calculate checksum. Syntax.: _NMEAChecksum($sData ) Parameters. : Takes a NMEA sentence, and returns its validity, or calculates its checksum.
LINUX NMEA CHECKSUM CALCULATOR CODE
I have tested the code on the following NMEA sentences and it works perfectly The checksum is calculated and added to each sentence and is used to confirm that the data contained within each sentence has not been corrupted. WTF is a NMEA sentence? Well the short answer is its the standard protocol used by a GPS receiver to create a sentence from data streamed from a GPS Satellite. I would like to confirm that your help is very much appreciated. I will check it further to make sure that it works on all NMEA sentence types. Not knowing WTF an 'NMEA checksum' is, I obviously can't be sure, so over to you. Global $input = "GPGLL,5300.97914,N,00259.98174,E,125926,A" Global $result = NMEA _Checksum ( $input ) MsgBox ( 0, "NMEA Checksummmer", " input: " & $input & & "output: " & $result ) Func NMEA _Checksum ( $string ) Local $ret = 0 For $i = 1 To StringLen ( $string ) $ret = BitXOR ( $ret, Asc ( StringMid ( $string, $i, 1 ) ) ) Next Return Hex ( $ret, 2 ) EndFunc This worked for me (as in: gives the answer you specified) strChecksum=checksum.ToString(“X2”).Ĭan this calculator be coded in AutoIT and is their an example available? In VB.Net and C# you can use the ToString function for this, e.g.

What is left is to transform the checksum into two hexadecimal characters, and that is it. Int checksum = 0 for (inti = 0 i checksum ^= Convert.ToByte(sentence ) }ĭim checksum as Integer = 0 For Each Character As Char In stringToCalculateTheChecksumOver checksum = checksum Xor Convert.ToByte(Character) Next Var checksum = 0 for(var i = 0 i checksum = checksum ^ stringToCalculateTheChecksumOver.charCodeAt(i) } Then just XOR the first character with the next character, until the end of the string.īelow you find a code example in Java script, VB.Net and C#. In the examples below the name of this new string is stringToCalculateTheChecksumOver. To calculate the checksum you parse all characters between $ and * from the NMEA sentence into a new string.

The string that the checksum is calculated over is In this sentence the checksum is the character representation of the hexadecimal value 28. Calculating the checksum is the representation of two hexadecimal characters of an XOR of all characters in the sentence between – but not including – the $ and the * character.
