Bosch Conettix D6600 Manual page 182

Computer interface of receiver/gateway
Table of Contents

Advertisement

Conettix D6600/D6100IPv6/D6100i | Computer Interface Manual | Appendix K: Cyclic Redundancy
Check (CRC) Calculation
CRC = 0;
count = 0;
printf("Input string for CRC calculation (<CR> to end): ");
ptr = gets(str);
while (ch = *ptr++)
{
CRC = calcCRC(CRC, ch); /* CALL CRC FUNCTION BELOW */
printf("\nChar %c [%2.2x] CRC is %4.4x, %2.2x count",
(ch > 32) ? ch : '.', ch, CRC, ++count);
}
}
unsigned int calcCRC(unsigned CRC, int ch)
{
int i;
unsigned char temp;
temp = (unsigned char)ch; /* TREAT LOCALLY AS UNSIGNED */
for (i = 0; i < 8; i++) /* DO 8 BITS */
{
temp ^= CRC & 1;
CRC >>= 1;
if (temp & 1)
CRC ^= 0xA001;
temp >>= 1;
}
return CRC;
}
Calculation Method 2
Alternatively, the routine calcCRC could be replaced by the following, faster routine:
void calcCRC2(unsigned int CRC, int ch)
{
static unsigned int crcTable[]= {
/* DEFINE THE FIRST ORDER POLINOMIAL TABLE */
0x0000,0xc0c1,0xc181,0x0140,0xc301,0x03c0,0x0280,0xc241,
0xc601,0x06c0,0x0780,0xc741,0x0500,0xc5c1,0xc481,0x0440,
0xcc01,0x0cc0,0x0d80,0xcd41,0x0f00,0xcfc1,0xce81,0x0e40,
0x0a00,0xcac1,0xcb81,0x0b40,0xc901,0x09c0,0x0880,0xc841,
0xd801,0x18c0,0x1980,0xd941,0x1b00,0xdbc1,0xda81,0x1a40,
0x1e00,0xdec1,0xdf81,0x1f40,0xdd01,0x1dc0,0x1c80,0xdc41,
0x1400,0xd4c1,0xd581,0x1540,0xd701,0x17c0,0x1680,0xd641,
0xd201,0x12c0,0x1380,0xd341,0x1100,0xd1c1,0xd081,0x1040,
0xf001,0x30c0,0x3180,0xf141,0x3300,0xf3c1,0xf281,0x3240,
0x3600,0xf6c1,0xf781,0x3740,0xf501,0x35c0,0x3480,0xf441,
0x3c00,0xfcc1,0xfd81,0x3d40,0xff01,0x3fc0,0x3e80,0xfe41,
0xfa01,0x3ac0,0x3b80,0xfb41,0x3900,0xf9c1,0xf881,0x3840,
0x2800,0xe8c1,0xe981,0x2940,0xbe01,0x2bc0,0x2a80,0xea41,
0xee01,0x2ec0,0x2f80,0xef41,0x2d00,0xedc1,0xec81,0x2c40,
0xe401,0x24c0,0x2580,0xe541,0x2700,0xe7c1,0xe681,0x2640,
0x2200,0xe2c1,0xe381,0x2340,0xe101,0x21c0,0x2080,0xe041,
182
Bosch Security Systems, Inc. | 2012.09 | 4998122703-05
/* PROCESS LSB */
/* SHIFT RIGHT */
/* IF LSB SET,ADD FEEDBACK */
/* GO TO NEXT BIT */

Advertisement

Table of Contents
loading

This manual is also suitable for:

Conettix d6100ipv6Conettix d6100i

Table of Contents