Hello together!
I have created a sub, which add a checksum to a NMEA-protocol. My question is: is there an easier way to calculate the checksum? I think, that my sub sometimes works and sometimes it doesn`t.
NMEA is the NMEA-protocol as string without the checksum,
Thanks for an answer
schimanski
I have created a sub, which add a checksum to a NMEA-protocol. My question is: is there an easier way to calculate the checksum? I think, that my sub sometimes works and sometimes it doesn`t.
NMEA is the NMEA-protocol as string without the checksum,
B4X:
Sub Globals
Dim buffer(0) as Byte
End Sub
Sub Checksum_NMEA
buffer()=bit_NMEA.stringToBytes(NMEA,1,StrLength(NMEA)-2)
laenge=ArrayLen(buffer())
summe=buffer(0)
for j=1 to laenge-1
summe=bit_NMEA.XOR(summe,buffer(j))
next
checksum=bit_NMEA.DecToHex(summe)
NMEA=NMEA & checksum & crlf
End Sub
Thanks for an answer
schimanski