I *think* this routine generates a Checksum that can be used with NMEA/GPS. While I am not using for that exactly, I think the routine works, but I'd be interested in getting another set of eyes on it...
The objective in Checksum is to take each character in a sentence to be transmitted - Between the "$" and the "*" in a NMEA sentence, and XOR each one in sequence, creating a 'rolling XOR' through the sentence... (I think).
Anyway, THIS routine does that, and it generates something that looks like a checksum, and my GPS takes it, BUT.. can anyone help make this better, confirm it works, etc?
waypoint:
' create checksum '************** Checksum
WPT_array[1]="G"
WPT_array[2]="P"
WPT_array[3]="W"
WPT_array[4]="P"
WPT_array[5]="L"
WPT_array[6]=","
WPT_array[7]=Dec_lat1.byte0
WPT_array[8]=Dec_lat1.byte1
WPT_array[9]="."
WPT_array[10]=Dec_lat2.byte0
WPT_array[11]=Dec_lat2.byte1
WPT_array[12]=","
WPT_array[13]=S_byte
WPT_array[14]=","
WPT_array[15]=Dec_long1.byte0
WPT_array[16]=Dec_long1.byte1
WPT_array[17]="."
WPT_array[18]=Dec_lat2.byte0
WPT_array[19]=Dec_lat2.byte1
WPT_array[20]="."
WPT_array[21]=E_byte
WPT_array[22]=","
WPT_array[23]=TracID
WPT_array[24]=","
' Implied * not computed
p=0
cksum = %00000000
for p = 1 to 24
cksum = cksum^(WPT_array[p])
Next P
serout2 AGPSout, 16572,["$GPWPL,",#Dec_lat1,".",#Dec_lat2,",",S_Byte," ,"]
serout2 AGPSout, 16572,[#Dec_long1,".",#Dec_long2,",",E_Byte,",",#TracID," ,*",HEX Cksum,10,13]
wp=%0
Return
Bookmarks