|
|
View previous topic :: View next topic |
Author |
Message |
delene Guest
|
check sum |
Posted: Fri Jul 25, 2003 12:33 am |
|
|
I have a string which is
0x01
0x02
0x02
0x00
0x00
0xb9
0xb8
the b9 and b8 are the chechsums for the string. Does anyone have any idea how this check sum was created. I need to be able to send a response back with the correct check sum and am unsure as to how it was created.
Another sample is
0x01
0x02
0x02
0x01
0x01
0x78
0xe8
with 0x78 and 0xe8 being the check sum
Thanks
Delene
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516339 |
|
|
R.J.Hamlett Guest
|
Re: check sum |
Posted: Fri Jul 25, 2003 3:31 am |
|
|
:=I have a string which is
:=0x01
:=0x02
:=0x02
:=0x00
:=0x00
:=0xb9
:=0xb8
:=
:=the b9 and b8 are the chechsums for the string. Does anyone have any idea how this check sum was created. I need to be able to send a response back with the correct check sum and am unsure as to how it was created.
:=
:=Another sample is
:=0x01
:=0x02
:=0x02
:=0x01
:=0x01
:=0x78
:=0xe8
:=
:=with 0x78 and 0xe8 being the check sum
:=
:=Thanks
:=Delene
I'm afraid you are going to need some more examples, and a lot of thought... The first thing to do, is get some combinations of string pairs, where only a single character changes. If you can get the checksum for '1 2 2 1 0', and look for the changes in the output value from the first example above, and the second, you will find how many bits change in the checksum, and the locations. If you can then get a version with a single change of the same value, but at a different point in the string (like '1 2 2 0 1'), the difference in bit position between the changes, will tell you how much the checksum is rotated between each character. I'd guess, it is a simple combination of rotating the incoming character, and adding this to the checksum value, and possibly rotating this as well. I'd also think that the incoming value is probably added more than once. So something like:
csum=csum+((int16)chr<<5)+((int16)chr<<12);
rotate_left(&csum,2);
This is a fairly typical polynomial CRC, but the shift values applied (usually one is even, and the other odd), have a lot of permuations.
The rotation on the checksum, also probably wants to be a rotation, rather than a shift (bits going out the top, are fed back into the bottom). However whether the same is true of the rotations on the incoming bytes is more questionable.
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516345 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
CRC 16 check/verify |
Posted: Fri Jul 25, 2003 9:52 am |
|
|
<font face="Courier New" size=-1>:=I have a string which is
:=0x01
:=0x02
:=0x02
:=0x00
:=0x00
:=0xb9
:=0xb8
:=
:=the b9 and b8 are the chechsums for the string. Does anyone have any idea how this check sum was created. I need to be able to send a response back with the correct check sum and am unsure as to how it was created.
:=
:=Another sample is
:=0x01
:=0x02
:=0x02
:=0x01
:=0x01
:=0x78
:=0xe8
:=
:=with 0x78 and 0xe8 being the check sum
:=
:=Thanks
:=Delene
It might be something like this.
#inline
void Check_CRC(void)
{ int8 msgptr, msglen, crcdata, c;
int16 crcacc;
#byte crcacc_lo = crcacc
#byte crcacc_hi = crcacc + 1
#bit LS_BIT_crcdata = crcdata.0
#bit LS_BIT_crcacc = crcacc.0
good_crc = 0;
msglen = PacketIndex-1;
crcacc = 0xFFFF;
msgptr = 0;
while(msgptr < msglen)
{ crcdata = PacketBuffer[msgptr];
for(c=8;c>0;c--)
{ if(LS_BIT_crcdata != LS_BIT_crcacc)
crcacc = (crcacc >> 1)^0xA001;
else
crcacc = crcacc >> 1;
crcdata = crcdata >> 1;
}
msgptr++;
}
if((crcacc_lo == PacketBuffer[msglen]) && (crcacc_hi == PacketBuffer[PacketIndex]))
{ good_crc = 1
}
}
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516359 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|