sony a/v receiver checksum
cbucha
Posts: 9
I am trying to figure out the the checksum for a sony strda2000es A/V receiver. On the protocol Sheet it gives this example command for power on "02 02 A0 20 3D" where 02 is STX, 02 is BC, A0 is product code, 20 is the cmd, and 3D is the checksum but i can not figure out how they are comming up with the checksum byte of 3D. Becuase while this command works the off command of "02 02 A0 21 3D" does not Becaus i can't figure out the check sum byte.
this is the data format:
5. Data Format (Host Controller <-> Amplifier)
STX + BC + PDC + CMD + Data1 +
+ DataN + CS
The terminological definition is as follows.
STX 02 H : Start of text code
BC : Byte Count
(Number of bytes of until before CS from PDC.)
PDC : Product Code
CMD : Command (Opecode)
DataN : Data Block ( 0 < M + FAH )
CS : Check Sum
A value from which 8 bits of low ranks of the sum
from BC to CS are set to 0.
this is the data format:
5. Data Format (Host Controller <-> Amplifier)
STX + BC + PDC + CMD + Data1 +
+ DataN + CS
The terminological definition is as follows.
STX 02 H : Start of text code
BC : Byte Count
(Number of bytes of until before CS from PDC.)
PDC : Product Code
CMD : Command (Opecode)
DataN : Data Block ( 0 < M + FAH )
CS : Check Sum
A value from which 8 bits of low ranks of the sum
from BC to CS are set to 0.
0
Comments
in this example, i use the power off command:
02 02 A0 21 3D
If you look at how the checksum is calculated, you say this:
"CS : Check Sum
A value from which 8 bits of low ranks of the sum
from BC to CS are set to 0."
So, we sum all the hex values excluding the first 0x02 (STX) => 02+A0+21 = C3
We then do a binary not (BNOT in Netlinx) and we get "3C"
So the power off command should be: "$02,$02,$A0,$21,$3C"
Let me know if i got it right
Are you sure you posted correct examples at the top of this thread? I don’t think you did and that made things difficult to figure out until you posted another example. Back to that in a moment.
To calculate the checksum do what yuri said and then add 1. Doing a BNOT flips all the bits so if you add the sum to the BNOT version you will get $FF, not $00. I believe the protocol is asking for the two’s compliment of the sum (What plus the sum = 0?) and one way to do that is to do a BNOT of the sum and then add 1. (Only use the least significant 8 bits for an answer – If you do your calculations with a CHAR, the lopping off will take care of itself.)
I believe that statement is in error and the correct Power On string is:
“$02,$02,$A0,$21,$3D"
That should be correct for Power On, not Power Off.
I believe the correct Power Off string is:
“$02,$02,$A0,$20,$3E"
I believe the other Power Off command string is:
“$02,$04,$A0,$60,$00,$00,$FC"
Let us know how it turns out.
Edit: Grammar fix.
thanks.
Glad you got things working, cbucha.