Cyclic Redundancy Check
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) |
Detailed Description
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.
- Author:
- dgameiro
- Version:
- 1.0
- Date:
- 27 April 2010
Define Documentation
#define CRC_VERSION "1.16" |
Definition at line 72 of file crc.h.
Definition at line 73 of file crc.h.
Definition at line 74 of file crc.h.
Function Documentation
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 | |
|
) |
| | |