This library is intended to calculate the crc for a data string. This library was developed by Lammert Bies and readapt to LAR purposes. This lib contains source code for functions to calculate five commonly used CRC values: CRC-16, CRC-32, CRC-DNP, CRC-SICK, CRC-Kermit and CRC-CCITT. To calculate a CRC, the following three steps must be followed: 1. Initialize the CRC value. For CRC-16, CRC-SICK CRC-Kermit and CRC-DNP the initial value of the CRC is 0. For CRC-CCITT and CRC-MODBUS, the value 0xffff is used. CRC-32 starts with an initial value of 0xffffffffL. 2. For each byte of the data starting with the first byte, call the function update_crc_16(), update_crc_32(), update_crc_dnp(), update_crc_sick(), update_crc_kermit() or update_crc_ccitt() to recalculate the value of the CRC. 3. Only for CRC-32: When all bytes have been processed, take the one's complement of the obtained CRC value. 4. Only for CRC-DNP: After all input processing, the one's complement of the CRC is calcluated and the two bytes of the CRC are swapped. 5. Only for CRC-Kermit and CRC-SICK: After all input processing, the one's complement of the CRC is calcluated and the two bytes of the CRC are swapped. More...
![]() |
Files | |
file | crc.h |
header for this library. Defines public funtions prototypes this library makes available to other modules. | |
Defines | |
#define | CRC_VERSION "1.16" |
#define | FALSE 0 |
#define | TRUE 1 |
Functions | |
unsigned short | update_crc_16 (unsigned short crc, char c) |
unsigned long | update_crc_32 (unsigned long crc, char c) |
unsigned short | update_crc_ccitt (unsigned short crc, unsigned char c) |
unsigned short | update_crc_dnp (unsigned short crc, char c) |
unsigned short | update_crc_kermit (unsigned short crc, char c) |
unsigned short | update_crc_sick (unsigned short crc, char c, char prev_byte) |
This library is intended to calculate the crc for a data string. This library was developed by Lammert Bies and readapt to LAR purposes. This lib contains source code for functions to calculate five commonly used CRC values: CRC-16, CRC-32, CRC-DNP, CRC-SICK, CRC-Kermit and CRC-CCITT. To calculate a CRC, the following three steps must be followed: 1. Initialize the CRC value. For CRC-16, CRC-SICK CRC-Kermit and CRC-DNP the initial value of the CRC is 0. For CRC-CCITT and CRC-MODBUS, the value 0xffff is used. CRC-32 starts with an initial value of 0xffffffffL. 2. For each byte of the data starting with the first byte, call the function update_crc_16(), update_crc_32(), update_crc_dnp(), update_crc_sick(), update_crc_kermit() or update_crc_ccitt() to recalculate the value of the CRC. 3. Only for CRC-32: When all bytes have been processed, take the one's complement of the obtained CRC value. 4. Only for CRC-DNP: After all input processing, the one's complement of the CRC is calcluated and the two bytes of the CRC are swapped. 5. Only for CRC-Kermit and CRC-SICK: After all input processing, the one's complement of the CRC is calcluated and the two bytes of the CRC are swapped.
#define CRC_VERSION "1.16" |
Referenced by main().
#define FALSE 0 |
#define TRUE 1 |
unsigned short update_crc_16 | ( | unsigned short | crc, | |
char | c | |||
) |
References crc_tab16, crc_tab16_init, init_crc16_tab(), and tmp.
Referenced by main().
unsigned long update_crc_32 | ( | unsigned long | crc, | |
char | c | |||
) |
References crc_tab32, crc_tab32_init, init_crc32_tab(), and tmp.
Referenced by main().
unsigned short update_crc_ccitt | ( | unsigned short | crc, | |
unsigned char | c | |||
) |
References crc_tabccitt, crc_tabccitt_init, init_crcccitt_tab(), and tmp.
Referenced by calc_crc_16(), and main().
unsigned short update_crc_dnp | ( | unsigned short | crc, | |
char | c | |||
) |
References crc_tabdnp, crc_tabdnp_init, init_crcdnp_tab(), and tmp.
Referenced by main().
unsigned short update_crc_kermit | ( | unsigned short | crc, | |
char | c | |||
) |
References crc_tabkermit, crc_tabkermit_init, init_crckermit_tab(), and tmp.
Referenced by main().