Boost logo

Boost Users :

From: victoriaames (victoriaames_at_[hidden])
Date: 2003-07-09 06:02:20


When I have tried examples using 16 or 32 bit truncated polynomials
this library works perfectly.

Example that works :
unsigned char const data[] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39 };
std::size_t const data_len = sizeof( data ) / sizeof( data[0] );
std::cout << "Expected CRC-CCITT : 29B1" << std::endl;
// Simulate CRC-CCITT with the optimal version
boost::crc_optimal<16, 0x1021, 0xFFFF, 0, false, false> crc_ccitt2;
crc_ccitt2 = std::for_each( data, data + data_len, crc_ccitt2 );
std::cout << "Optimal CRC-CCITT : " << std::hex << crc_ccitt2() <<
std::endl;

However, when I have tried examples using 8 bit truncated
polynomials I fail to get a meaningful checksum.

Example that doesn't work :
std::cout << "Expected CRC-8 : EA" << std::endl;
boost::crc_optimal<8, 0x9B, 0, 0, false, false> crc_8;
crc_8 = std::for_each( data, data + data_len, crc_8 );
std::cout << "Optimal CRC-8 : " << std::hex << crc_8() << std::endl;

The results I get are :

Expected CRC-CCITT : 29B1
Optimal CRC-CCITT : 29b1

Expected CRC-8 : EA
Optimal CRC-8 : Û

Does anyone know why the 8 bit example does not seem to work?

Victoria
 


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net