14.08.2017, 06:13
You don't need a separate function for this, last 2 bytes of the message is the resulting checksum. You can do it like this:
Code:
message = '16XK40392361108171100067'
calccs = checksum(message:sub(1, -3)) -- calculated checksum from message data
recvcs = message:sub(-2, -1) -- received checksum
log(calccs, recvcs)