Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: plcnut on March 19, 2013, 11:00:38 AM
-
I have to calculate a checksum for some data that I will be transmitting. The communication manual says:
"Checksum
This represents an "OR exsclusive" of all preceding bytes (identification, length and data bytes)"
I was hoping to use the CHECKSUM command, but didn't find a function that will produce this result. Can I use MATH in a FOR/NEXT loop to cycle through each of the Bytes of data with an "^" to XOR each Byte with the next?
Any advice is appreciated.
-
Here is what I have come up with so far, but surely there is a better way.
-
Looks good! I would definitely look for a valid example from their manual to make sure it's correct.
It's really not a checkSUM, but a byte-wide odd-parity value for all 8 bit positions across all the bytes. ;D