Go to the source code of this file.
Classes | |
| struct | hdlc_rx_state_t |
| struct | hdlc_rx_stats_t |
| struct | hdlc_tx_state_t |
Defines | |
| #define | _HDLC_H_ |
| #define | HDLC_MAXFRAME_LEN 400 |
Typedefs | |
| typedef void(*) | hdlc_frame_handler_t (void *user_data, int ok, const uint8_t *pkt, int len) |
| typedef void(*) | hdlc_underflow_handler_t (void *user_data) |
Functions | |
| uint32_t | crc_itu32_calc (const uint8_t *buf, int len, uint32_t crc) |
| Calculate the ITU/CCITT CRC-32 value in buffer. | |
| int | crc_itu32_append (uint8_t *buf, int len) |
| Append an ITU/CCITT CRC-32 value to a frame. | |
| int | crc_itu32_check (const uint8_t *buf, int len) |
| Check the ITU/CCITT CRC-32 value in a frame. | |
| uint16_t | crc_itu16_calc (const uint8_t *buf, int len, uint16_t crc) |
| Calculate the ITU/CCITT CRC-16 value in buffer. | |
| int | crc_itu16_append (uint8_t *buf, int len) |
| Append an ITU/CCITT CRC-16 value to a frame. | |
| int | crc_itu16_check (const uint8_t *buf, int len) |
| Check the ITU/CCITT CRC-16 value in a frame. | |
| hdlc_rx_state_t * | hdlc_rx_init (hdlc_rx_state_t *s, int crc32, int report_bad_frames, int framing_ok_threshold, hdlc_frame_handler_t handler, void *user_data) |
| Initialise an HDLC receiver context. | |
| int | hdlc_rx_get_stats (hdlc_rx_state_t *s, hdlc_rx_stats_t *t) |
| Get the current receive statistics. | |
| void | hdlc_rx_bit (hdlc_rx_state_t *s, int new_bit) |
| void | hdlc_rx_byte (hdlc_rx_state_t *s, int new_byte) |
| hdlc_tx_state_t * | hdlc_tx_init (hdlc_tx_state_t *s, int crc32, hdlc_underflow_handler_t handler, void *user_data) |
| Initialise an HDLC transmitter context. | |
| void | hdlc_tx_frame (hdlc_tx_state_t *s, const uint8_t *frame, int len) |
| void | hdlc_tx_preamble (hdlc_tx_state_t *s, int len) |
| int | hdlc_tx_getbit (hdlc_tx_state_t *s) |
| int | hdlc_tx_getbyte (hdlc_tx_state_t *s) |
| #define HDLC_MAXFRAME_LEN 400 |
HDLC_MAXFRAME_LEN is the maximum length of a stuffed HDLC frame, excluding the CRC.
| int crc_itu16_append | ( | uint8_t * | buf, | |
| int | len | |||
| ) |
Append an ITU/CCITT CRC-16 value to a frame.
| buf | The buffer containing the frame. This must be at least 2 bytes longer than the frame it contains, to allow room for the CRC value. | |
| len | The length of the frame. |
| uint16_t crc_itu16_calc | ( | const uint8_t * | buf, | |
| int | len, | |||
| uint16_t | crc | |||
| ) |
Calculate the ITU/CCITT CRC-16 value in buffer.
| buf | The buffer containing the data. | |
| len | The length of the frame. | |
| crc | The initial CRC value. This is usually 0xFFFF, or 0 for a new block (it depends on the application). It is previous returned CRC value for the continuation of a block. |
| int crc_itu16_check | ( | const uint8_t * | buf, | |
| int | len | |||
| ) |
Check the ITU/CCITT CRC-16 value in a frame.
| buf | The buffer containing the frame. | |
| len | The length of the frame. |
| int crc_itu32_append | ( | uint8_t * | buf, | |
| int | len | |||
| ) |
Append an ITU/CCITT CRC-32 value to a frame.
| buf | The buffer containing the frame. This must be at least 2 bytes longer than the frame it contains, to allow room for the CRC value. | |
| len | The length of the frame. |
| uint32_t crc_itu32_calc | ( | const uint8_t * | buf, | |
| int | len, | |||
| uint32_t | crc | |||
| ) |
Calculate the ITU/CCITT CRC-32 value in buffer.
| buf | The buffer containing the data. | |
| len | The length of the frame. | |
| crc | The initial CRC value. This is usually 0xFFFFFFFF, or 0 for a new block (it depends on the application). It is previous returned CRC value for the continuation of a block. |
| int crc_itu32_check | ( | const uint8_t * | buf, | |
| int | len | |||
| ) |
Check the ITU/CCITT CRC-32 value in a frame.
| buf | The buffer containing the frame. | |
| len | The length of the frame. |
| int hdlc_rx_get_stats | ( | hdlc_rx_state_t * | s, | |
| hdlc_rx_stats_t * | t | |||
| ) |
Get the current receive statistics.
| s | A pointer to an HDLC receiver context. | |
| t | A pointer to the buffer for the statistics. |
| hdlc_rx_state_t* hdlc_rx_init | ( | hdlc_rx_state_t * | s, | |
| int | crc32, | |||
| int | report_bad_frames, | |||
| int | framing_ok_threshold, | |||
| hdlc_frame_handler_t | handler, | |||
| void * | user_data | |||
| ) |
Initialise an HDLC receiver context.
| s | A pointer to an HDLC receiver context. | |
| crc32 | TRUE to use CRC32. FALSE to use CRC16. | |
| report_bad_frames | TRUE to request the reporting of bad frames. | |
| framing_ok_threshold | The number of flags needed to start the framing OK condition. | |
| handler | The function to be called when a good HDLC frame is received. | |
| user_data | An opaque parameter for the callback routine. |
| hdlc_tx_state_t* hdlc_tx_init | ( | hdlc_tx_state_t * | s, | |
| int | crc32, | |||
| hdlc_underflow_handler_t | handler, | |||
| void * | user_data | |||
| ) |
Initialise an HDLC transmitter context.
| s | A pointer to an HDLC transmitter context. | |
| handler | The callback function called when the HDLC transmitter underflows. | |
| user_data | An opaque parameter for the callback routine. |
1.4.7