How to calculate NMEA checksum.

Joined
Oct 15, 2018
Messages
4
Reaction score
0
NMEA sentence/string is :
$GPRMC,062745.044,A,1830.2470,N,07350.5297,E,1.07,44.40,101018,,,A*

How to calculate checksum of above string. I need formula for this checksum calculation.

Thanks in advance.
 
Writen macro for NMEA checksum Calculation.

Shared Working Macro code:

Private Function GetChecksum(ByRef sInString As String) As String
Dim lCurrent&, lLast&
On Error Resume Next
'-- We don't use the $ in the checksum
If Mid$(sInString, 1, 1) = "$" Then
sInString = Mid$(sInString, 2)
End If
'-- Get the ASC of the first Char
lLast& = Asc(Mid$(sInString, 1, 1))
'-- Use a loop to Xor through the string
For lCurrent& = 2 To Len(sInString)
lLast& = lLast& Xor Asc(Mid$(sInString, lCurrent&, 1))
Next
'-- Pass the data back as a string
GetChecksum = CStr(Hex(lLast&))
End Function

This code is working ... use as it is.

 

Members online

No members online now.
Back
Top