Contiki-NG
Files | Functions
CRC16 calculation

The Cyclic Redundancy Check 16 is a hash function that produces a checksum that is used to detect errors in transmissions. More...

Files

file  crc16.c
 
    Implementation of the CRC16 calculcation

 

Functions

unsigned short crc16_add (unsigned char b, unsigned short crc)
 Update an accumulated CRC16 checksum with one byte. More...
 
unsigned short crc16_data (const unsigned char *data, int datalen, unsigned short acc)
 Calculate the CRC16 over a data area. More...
 

Detailed Description

The Cyclic Redundancy Check 16 is a hash function that produces a checksum that is used to detect errors in transmissions.

The CRC16 calculation module is an iterative CRC calculator that can be used to cumulatively update a CRC checksum for every incoming byte.

Function Documentation

◆ crc16_add()

unsigned short crc16_add ( unsigned char  b,
unsigned short  crc 
)

Update an accumulated CRC16 checksum with one byte.

Parameters
bThe byte to be added to the checksum
crcThe accumulated CRC that is to be updated.
Returns
The updated CRC checksum.
        This function updates an accumulated CRC16 checksum
        with one byte. It can be used as a running checksum, or
        to checksum an entire data block.

        \note The algorithm used in this implementation is
        tailored for a running checksum and does not perform as
        well as a table-driven algorithm when checksumming an
        entire data block.

Definition at line 47 of file crc16.c.

◆ crc16_data()

unsigned short crc16_data ( const unsigned char *  data,
int  datalen,
unsigned short  acc 
)

Calculate the CRC16 over a data area.

Parameters
dataPointer to the data
datalenThe length of the data
accThe accumulated CRC that is to be updated (or zero).
Returns
The CRC16 checksum.
        This function calculates the CRC16 checksum of a data area.

        \note The algorithm used in this implementation is
        tailored for a running checksum and does not perform as
        well as a table-driven algorithm when checksumming an
        entire data block.

Definition at line 66 of file crc16.c.