Here is one check sum solution for gps:
Code:
gpsdata var byte[82] ' Max length of a GPS sentence is 82 bytes.
DoCS:
i = 0 ' Initialize the position counter
WHILE gpsdata[i] != "*" ' Count everthing until the *
cs = cs ^gpsdata[i] ' XOR for checksum
i = i + 1 ' Increment position counter
WEND
' A quick and easy atoh function
' Make it a seperate label if we add more atoh conversions in the future
LOOKDOWN gpsdata[i+1],["0123456789ABCDEF"],tempbyte
gpscs = tempbyte * 16
LOOKDOWN gpsdata[i+2],["0123456789ABCDEF"],tempbyte
gpscs = gpscs + tempbyte
' Flag bad data "V" if checksum doesn't add up.
' Or if the sentence is less then 20 chars long
' Which means there is no active waypoint to go to.
' Should be "A" otherwise.
IF (cs != gpscs) OR (i < 20 )THEN
gpsvalid = 0
ELSE
gpsvalid = 1
ENDIF
RETURN
Bookmarks