Check Sum Question - for you math people
JohnMichnr
Posts: 279
Hey All - I have a Hitachi LCOS video wall cube that says it's check sum is a "twos complement" check sum. Looking Two's compliment up on Wikipedia I find that it is a inversion of the bit in a byte plus one. So I am thinking that I can calculate the checksum by doing this:
sum (addition of the Bytes in question)
CheckSum = !Sum + 1
Will that work ? or do I have to go into the bits in the byte and invert each one? before I add one.
Anybody got any suggestions?
sum (addition of the Bytes in question)
CheckSum = !Sum + 1
Will that work ? or do I have to go into the bits in the byte and invert each one? before I add one.
Anybody got any suggestions?
0
Comments
!Sum will make Sum = 1 if it's currently 0, otherwise it will make it 0. So, no matter what's it's value, you are going to wind up with 0 or 1. You need to do a bitwise operation.
So it is back to the bitwise not on each bit.
edit:
damnit... BNOT == ~ :P
I don't know how to do the little quote boxes
FORMAT of COMMANDS TO THE PROJECTOR
(A) When individually specifying a projector
STX + BC + CMD + PARA + CS + SN
STX - Start command (fixed to 02H) 1 Byte
BC - Byte count from CMD to the last byte of PARA 1 Byte
CMD - Command code 1 Byte
PARA* Parameter Variable
CS - Value when the sum of the lower 8 bits from BC to CS is 0. Two?s complement. 1 Byte
SN - Projector No.. FFH corresponds to all projectors. 1 Byte
Obviously the area I am looking at is the CS. And I think the BNOT (~) is the way to go about it. I'll be trying that this morning with some strings.
CS = 256 - count.
- Chip