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

Title: Help with a Checksum
Post 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.
Title: Re: Help with a Checksum
Post by: plcnut on March 19, 2013, 11:58:44 AM
Here is what I have come up with so far, but surely there is a better way.
Title: Re: Help with a Checksum
Post by: franji1 on March 19, 2013, 02:44:15 PM
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