[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: Trouble setting CM11 clock



Don't include the 0x9b in the checksum but only the final 6 bytes.

  for (int i = 1; i < setClk.Length; i++)

"Quina" <carias.joao@xxxxxxxxx> wrote:

>Yes I got it. But when I send the further code, apparently the checksum
>is not correct (0x87). If my calculations are rigth, the result should
>be 0x22...
>
>(...)
>
>// 7 bytes array definition
>byte[] setClk=new byte[7];
>
>//chksum definition and initialization to 0
>byte chksum=0;
>
> //Values assinged to the seven bytes with a cast to byte
> setClk[0] = (byte)(0x9b);
> setClk[1] = (byte)(0x13);
> setClk[2] = (byte)(0x40);
> setClk[3] = (byte)(0x0A);
> setClk[4] = (byte)(0x48);
> setClk[5] = (byte)(0x82);
> setClk[6] = (byte)(0x60);
>
>
> //cycle to calculate de  checksum
> for (int i = 0; i < setClk.Length; i++)
>     chksum += setClk[i];
> chksum &= 0xff;
>
>(...)
>
>After this, I send the "setClk" to the device and get a reply (the one
>mentioned above) from it.
>Am I making a mistake calculating the checksum?
>
>Note: the code is C#
>
>João Carias



comp.home.automation Main Index | comp.home.automation Thread Index | comp.home.automation Home | Archives Home