Kapitel 10
value <<= 1;
if( old_val & 0x8000 ) value ^= CRC_POLY;
}
return value;
}
void main( void )
{
FILE
*out;
WORD
value;
int
k, i;
out = fopen( "crctab.c", "wt" );
if( out == NULL )
{
puts( "\ncannot generate crctab.c !!\n\n" );
return;
}
fprintf( out, "// put header here\n\n" );
fprintf( out, "#include \"cpu-dep.h\"\n\n" );
fprintf( out, "// XOR table for CRC algorithm, CRC-16, ITU.T X.25\n" );
fprintf( out, "// polynomial: h%4x\n\n", CRC_POLY );
fprintf( out, "const WORD crctab[256] = \n" );
fprintf( out, "
i = 0;
for( k=0; k<256; k++ )
{
value = get_crctab_val( k );
if( i == 0 )
fprintf( out, "\n
else if( k >= 248 && i >= 7 )
fprintf( out, " 0x%04x", value );
else
fprintf( out, " 0x%04x,", value );
if( ++i >= 8 ) i = 0;
}
fprintf( out, "\n
fclose( out );
}
10-18
Anhang
{" );
0x%04x,", value );
};\n\n" );
© SICK AG · Division Auto Ident · Germany · All rights reserved
Betriebsanleitung
Lasermesssystem LD OEM
8 010 327/0000/28-09-2004