Home AMX User Forum NetLinx Studio
Options

Another Sony Checksum Question

I guess I am checksum challenged...

I am working with the new CAV-CV12ES video switcher. I have not done much with checksums, but the protocol file from sony has a broken cell for the checksum example.

Can anyone help me out with some first steps. I cant even verify that my cabling is correct. Also I know that the baudrate is 9600 (in the manual), but it does not list parity or stop bits. Has anyone used this unit & have the answers?

I have searched threads for the "answer", but I can't seem to find the same explination twice...

Attached is the protocol file, any help would be great...

Thanks--Scott

Comments

  • Options
    ericmedleyericmedley Posts: 4,177
    From sifting through the gobble-dee-gook it appears that it might be a simple 2s comp Check Sum schema. I could be wrong, but here it goes.

    So, for example. here's a short sample command string.
    0x02	0x03	0xF4	0x82	0x00   $CS
    

    You skip the first char. Then add up the next chars,

    $03+$F4+$82+$00=$179

    You only use the last two bytes of the number, so drop the 'one' off.

    $79

    Now, two's comp is done this way. You simply take the binary bits and flip all of them.

    so, $79 = 0111 1001 binary
    after inverting all the bits you get 1000 0110 which equals $86

    Therefor, the check sum for this string is $86.

    You use the Bitwise command BNOT to flip the binary bits of a number.

    I'm culling this from the formulas in the spredsheet. I may be totally off base. There is also a way of calculating checksum called 1s compilment. I don't think this is what they're doing. Best thing is give it a try and see if it does something.

    Then do what I do and skip the whole check sum crap and make a data table with the commands already writte out with the check sum included. :D
  • Options
    TurnipTruckTurnipTruck Posts: 1,485
    For the home theater receivers, the cs is calculated as follows:

    sum all of the bytes excluding the STX,

    subtract one from the sum,

    Checksum=BNOT(Checksum) BAND $FF

    I am not sure if your device is the same way, but Sony is very consistent.
  • Options
    ericmedleyericmedley Posts: 4,177
    For the home theater receivers, the cs is calculated as follows:

    sum all of the bytes excluding the STX,

    subtract one from the sum,

    Checksum=BNOT(Checksum) BAND $FF

    I am not sure if your device is the same way, but Sony is very consistent.

    Thanks! That's an interesting check sum calculation.
  • Options
    DHawthorneDHawthorne Posts: 4,584
    For clarification: in a twos-complement conversion, you subtract one first, then flip the bits; in a ones-complement, you just flip the bits. They are usually used to show a signed number in an unsigned variable space ... positive numbers are normal, and the complement is for negative numbers. A ones-complement has two valid results for zero, and the twos only has one (which is where the subtracting one thing comes from).

    If Sony is using a twos-complement for the checksum, and you don't subtract that one first, all the checksums are going to be off. I had a problem with that particular issue while working on a Meridian piece - the docs said use ones-complement, but it was really looking for twos-complement, and I about went nuts wondering why my values were all off by one. Although, I have to admit, some part of me was happy to see even the Meridian techs didn't seem to know the difference.
  • Options
    ericmedleyericmedley Posts: 4,177
    DHawthorne wrote: »
    For clarification: in a twos-complement conversion, you subtract one first, then flip the bits; in a ones-complement, you just flip the bits. They are usually used to show a signed number in an unsigned variable space ... positive numbers are normal, and the complement is for negative numbers. A ones-complement has two valid results for zero, and the twos only has one (which is where the subtracting one thing comes from).

    If Sony is using a twos-complement for the checksum, and you don't subtract that one first, all the checksums are going to be off. I had a problem with that particular issue while working on a Meridian piece - the docs said use ones-complement, but it was really looking for twos-complement, and I about went nuts wondering why my values were all off by one. Although, I have to admit, some part of me was happy to see even the Meridian techs didn't seem to know the difference.

    Thanks for the clarification.
  • Options
    siebsieb Posts: 9
    Thanks guys, that was what I was looking for. -- Scott
  • Options
    ericmedleyericmedley Posts: 4,177
    DHawthorne wrote: »
    For clarification: in a twos-complement conversion, you subtract one first, then flip the bits; in a ones-complement, you just flip the bits. They are usually used to show a signed number in an unsigned variable space ... positive numbers are normal, and the complement is for negative numbers. A ones-complement has two valid results for zero, and the twos only has one (which is where the subtracting one thing comes from).

    Dave et al,

    As is the case when I'm corrected when wrong, I typically go and investigate my thinking. It was interesting that I too fell prey to the same thing you mentioned.

    I had my understanding of 2s comp vs 1 comp backwards. I traced back through the programs I did and found that there was a point when I did a Plasma display that said it used 2s comp in the manual, but in reality did 1s comp. I noted in my project notes that I lost a lot of time trying to figure out what the heck I did wrong with the check sum.

    I concluded in my notes that I had gotten 1s and 2s comps backwards and later figured it out. I now realize that my origianl understanding was correct and the manual was wrong and thus, I was now wrong and my origianl asumption, which I concluded was wrong, was in fact correct. :D I've been operating under the incorrect understanding for about a year now...

    I'm getting old... first thing to go is the mind...

    e
Sign In or Register to comment.