rack
08-08-2008, 03:27 PM
Hi,
I try to identify a serial protocol for some devices.
The transmitted strings are in this form (example):
0180007A0405
the last 2 digit are the checksum modulo 256 (100h) of the previous digits as ascii characters (hex):
0=30+
1=31+
8=38+
0=30+
0=30+
0=30+
7=37+
A=41+
0=30+
4=34
summ = 205
CRC= 205 mod 100 = 05
the bytes 7A and 04 are another checksum (BCC) for the digits before those bytes (01 80 00).
This is the only description I've found about this check:
-----
Each message contains a Block Check Sum word BCC, composed by two
bytes ordered as BCC1 & BCC2 which are calculated, using one's complement arithmetic (a carry
resulting from a two byte sum is added to the result), with the following procedure:
- Initialize S1(0)=0 and S2(0)=0
- Perform partial calculation using all message's N bytes B(n) starting form first byte B(1)
S1(n) = S1(n-1) + B(n)
S2(n) = S2(n-1) + S1(n)
- Calculate checksum bytes as
BCC1 = - (S1(N) + S2(N))
BCC2 = S2(N)
-----
I've followed the above steps but the results are always wrong...
Any suggestions, please ?
Thanks in advance.
I try to identify a serial protocol for some devices.
The transmitted strings are in this form (example):
0180007A0405
the last 2 digit are the checksum modulo 256 (100h) of the previous digits as ascii characters (hex):
0=30+
1=31+
8=38+
0=30+
0=30+
0=30+
7=37+
A=41+
0=30+
4=34
summ = 205
CRC= 205 mod 100 = 05
the bytes 7A and 04 are another checksum (BCC) for the digits before those bytes (01 80 00).
This is the only description I've found about this check:
-----
Each message contains a Block Check Sum word BCC, composed by two
bytes ordered as BCC1 & BCC2 which are calculated, using one's complement arithmetic (a carry
resulting from a two byte sum is added to the result), with the following procedure:
- Initialize S1(0)=0 and S2(0)=0
- Perform partial calculation using all message's N bytes B(n) starting form first byte B(1)
S1(n) = S1(n-1) + B(n)
S2(n) = S2(n-1) + S1(n)
- Calculate checksum bytes as
BCC1 = - (S1(N) + S2(N))
BCC2 = S2(N)
-----
I've followed the above steps but the results are always wrong...
Any suggestions, please ?
Thanks in advance.