File syn_cobs.c¶
FileList > proto > syn_cobs.c
Go to the source code of this file
COBS packet framing implementation.
#include "../util/syn_assert.h"#include "syn_cobs.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| size_t | syn_cobs_decode (const void * src, size_t src_len, void * dst) Decode a COBS-encoded packet. |
| void | syn_cobs_decoder_feed (SYN_COBS_Decoder * dec, uint8_t byte) Feed a byte to the streaming decoder. |
| void | syn_cobs_decoder_init (SYN_COBS_Decoder * dec, uint8_t * buf, size_t buf_size, SYN_COBS_PacketCallback callback, void * ctx) Initialize streaming COBS decoder. |
| void | syn_cobs_decoder_reset (SYN_COBS_Decoder * dec) Reset the streaming decoder state. |
| size_t | syn_cobs_encode (const void * src, size_t src_len, void * dst) Encode data using COBS. |
Public Functions Documentation¶
function syn_cobs_decode¶
Decode a COBS-encoded packet.
Parameters:
srcCOBS-encoded data (without the 0x00 delimiter).src_lenEncoded length.dstOutput buffer (must be at least src_len).
Returns:
Number of decoded bytes, or 0 on error.
function syn_cobs_decoder_feed¶
Feed a byte to the streaming decoder.
When a 0x00 delimiter is received, the accumulated bytes are decoded and the callback is invoked with the decoded packet.
Parameters:
decDecoder.byteReceived byte.
function syn_cobs_decoder_init¶
Initialize streaming COBS decoder.
void syn_cobs_decoder_init (
SYN_COBS_Decoder * dec,
uint8_t * buf,
size_t buf_size,
SYN_COBS_PacketCallback callback,
void * ctx
)
Parameters:
decDecoder instance.bufReceive buffer for accumulating encoded bytes.buf_sizeBuffer capacity.callbackCalled when a complete packet is decoded.ctxUser context for callback.
function syn_cobs_decoder_reset¶
Reset the streaming decoder state.
Parameters:
decDecoder.
function syn_cobs_encode¶
Encode data using COBS.
Parameters:
srcInput data.src_lenInput length.dstOutput buffer (must be at least src_len + src_len/254 + 1).
Returns:
Number of bytes written to dst (excluding the trailing 0x00 delimiter).
The documentation for this class was generated from the following file src/syntropic/proto/syn_cobs.c