ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
Loading...
Searching...
No Matches
hdlc_decoder.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "hdlc_common.h"
Include dependency graph for hdlc_decoder.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hdlc_decode_stats_t
 Cumulative HDLC decode failure reason counters. More...
 

Functions

bool hdlc_decode (const HDLC_FRAME_T *frame, uint8_t *payload, const size_t out_capacity, size_t *payload_length, bool lsb_first)
 Decode an HDLC bit-stuffed frame.
 
bool hdlc_decode_byte (const HDLC_FRAME_T *frame, uint8_t *payload, const size_t out_capacity, size_t *payload_length)
 Decode a byte-escaped HDLC frame compatibility path.
 
void hdlc_decode_stats_snapshot (hdlc_decode_stats_t *out_stats)
 Copy cumulative HDLC decode statistics.
 
void hdlc_decode_stats_reset (void)
 Reset cumulative HDLC decode statistics.
 

Function Documentation

◆ hdlc_decode()

bool hdlc_decode ( const HDLC_FRAME_T frame,
uint8_t *  payload,
const size_t  out_capacity,
size_t *  payload_length,
bool  lsb_first 
)

Decode an HDLC bit-stuffed frame.

Parameters
frameInput HDLC frame.
payloadOutput payload buffer.
out_capacityCapacity of payload in bytes.
payload_lengthOutput payload length.
lsb_firstBit order selector matching encoder/PIO path.
Returns
true on successful decode and CRC validation.

Definition at line 171 of file hdlc_decoder.c.

References hdlc_decode_stats_t::crc_mismatch, HDLC_BIT_EOF, HDLC_BIT_ERR, hdlc_crc16(), hdlc_decode_stats, HDLC_FLAG_BYTE, hdlc_get_byte(), hdlc_decode_stats_t::invalid_frame, HDLC_FRAME_T::length, LOG_DEBUG, HDLC_FRAME_T::payload, hdlc_decode_stats_t::payload_too_long, hdlc_decoder_t::raw_bit_index, hdlc_decode_stats_t::too_short, and hdlc_decode_stats_t::unstuff_error.

Referenced by decode_hdlc_to_udp_tx(), and event_dispatch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdlc_decode_byte()

bool hdlc_decode_byte ( const HDLC_FRAME_T frame,
uint8_t *  payload,
const size_t  out_capacity,
size_t *  payload_length 
)

Decode a byte-escaped HDLC frame compatibility path.

Parameters
frameInput HDLC frame.
payloadOutput payload buffer.
out_capacityCapacity of payload in bytes.
payload_lengthOutput payload length.
Returns
true on successful decode and CRC validation.

Definition at line 45 of file hdlc_decoder.c.

References hdlc_decode_stats_t::crc_mismatch, hdlc_crc16(), hdlc_decode_stats, HDLC_ESCAPE_BYTE, HDLC_ESCAPE_XOR, HDLC_FLAG_BYTE, hdlc_decode_stats_t::invalid_frame, HDLC_FRAME_T::length, LOG_DEBUG, HDLC_FRAME_T::payload, hdlc_decode_stats_t::payload_too_long, and hdlc_decode_stats_t::too_short.

Here is the call graph for this function:

◆ hdlc_decode_stats_reset()

void hdlc_decode_stats_reset ( void  )

Reset cumulative HDLC decode statistics.

Definition at line 246 of file hdlc_decoder.c.

References hdlc_decode_stats.

◆ hdlc_decode_stats_snapshot()

void hdlc_decode_stats_snapshot ( hdlc_decode_stats_t out_stats)

Copy cumulative HDLC decode statistics.

Parameters
out_statsDestination pointer.

Definition at line 237 of file hdlc_decoder.c.

References hdlc_decode_stats.

Referenced by update_statistics().

Here is the caller graph for this function: