srecord
1.65.0
|
The crc16 class is used to represent the running value of a 16-bit cyclic redundancy check of series of bytes. More...
#include <crc16.h>
Public Types | |
enum | { polynomial_ccitt = 0x1021 , polynomial_ansi = 0x8005 , polynomial_dnp = 0x3D65 , polynomial_dect = 0x0589 , polynomial_t10_dif = 0x8BB7 } |
enum | seed_mode_t { seed_mode_ccitt , seed_mode_xmodem , seed_mode_broken } |
enum | bit_direction_t { bit_direction_most_to_least , bit_direction_least_to_most } |
Public Member Functions | |
virtual | ~crc16 () |
The destructor. More... | |
crc16 (seed_mode_t seed_mode=seed_mode_ccitt, bool augment=true, unsigned short polynomial=polynomial_ccitt, bit_direction_t bitdir=bit_direction_most_to_least) | |
The default constructor. More... | |
crc16 (const crc16 &) | |
The copy constructor. More... | |
crc16 & | operator= (const crc16 &) |
The assignment operator. More... | |
unsigned short | get () const |
The get method is used to obtain the running value of the cyclic redundancy check. More... | |
void | next (unsigned char) |
The next method is used to advance the state by one byte. More... | |
void | nextbuf (const void *, size_t) |
The nextbuf method is used to advance the state by a series of bytes. More... | |
void | print_table (void) const |
The print_table method may be used to print the table being used. More... | |
Static Public Member Functions | |
static int | polynomial_by_name (const char *name) |
The polynomial_by_name class method is used to take the name of a CRC-16 polynamlial, and return the value of the CRC-16 polynomial corresponding to that name. More... | |
The crc16 class is used to represent the running value of a 16-bit cyclic redundancy check of series of bytes.
Note: this CRC16 works for systems that process the leaast significant bit of each byte first, and working to wards the most significant bit.
If you were expecting MSB first (you may not even know it) this code will give you "wrong" answers. Try using the bitrev filter.
anonymous enum |
|
virtual |
The destructor.
srecord::crc16::crc16 | ( | seed_mode_t | seed_mode = seed_mode_ccitt , |
bool | augment = true , |
||
unsigned short | polynomial = polynomial_ccitt , |
||
bit_direction_t | bitdir = bit_direction_most_to_least |
||
) |
The default constructor.
seed_mode | This selects which CRC16 calculation seed is to be used. |
augment | This is true if the 16-zero-bit augmentation is desired. This is the default. False if no augmentation is desired. |
polynomial | The checksum polynomial. |
bitdir | The direction of bits in a characters as they pass through the algorithm. |
srecord::crc16::crc16 | ( | const crc16 & | ) |
The copy constructor.
|
static |
The polynomial_by_name class method is used to take the name of a CRC-16 polynamlial, and return the value of the CRC-16 polynomial corresponding to that name.
unsigned short srecord::crc16::get | ( | ) | const |
The get method is used to obtain the running value of the cyclic redundancy check.
void srecord::crc16::next | ( | unsigned char | ) |
The next method is used to advance the state by one byte.
void srecord::crc16::nextbuf | ( | const void * | , |
size_t | |||
) |
The nextbuf method is used to advance the state by a series of bytes.
void srecord::crc16::print_table | ( | void | ) | const |
The print_table method may be used to print the table being used.
This is principally for debugging the table generation process.