File syn_dlt645.c¶
FileList > proto > syn_dlt645.c
Go to the source code of this file
DL/T 645 Electricity Meter Communication Protocol Implementation.
#include "syn_dlt645.h"#include "../util/syn_assert.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| uint8_t | syn_dlt645_calc_checksum (const uint8_t * buf, size_t len) Compute DL/T 645 arithmetic modulo-256 checksum over buffer. |
| void | syn_dlt645_decoder_feed (SYN_DLT645_Decoder * dec, uint8_t rx_byte) Feed a single byte into the streaming decoder. |
| void | syn_dlt645_decoder_init (SYN_DLT645_Decoder * dec, SYN_DLT645_Ver version, SYN_DLT645_FrameCallback cb, void * ctx) Initialize a streaming DL/T 645 decoder. |
| size_t | syn_dlt645_encode (const SYN_DLT645_Frame * frame, uint8_t * out_buf, size_t out_capacity) Encode a DL/T 645 frame into a binary transmission buffer. |
| SYN_Status | syn_dlt645_parse (const uint8_t * in_buf, size_t len, SYN_DLT645_Ver version, SYN_DLT645_Frame * out_frame) Parse a raw byte buffer into a DL/T 645 frame. |
Public Functions Documentation¶
function syn_dlt645_calc_checksum¶
Compute DL/T 645 arithmetic modulo-256 checksum over buffer.
Parameters:
bufBuffer starting from SOF (0x68).lenLength of buffer from SOF to end of data field.
Returns:
Modulo-256 checksum byte.
function syn_dlt645_decoder_feed¶
Feed a single byte into the streaming decoder.
Parameters:
decDecoder instance.rx_byteSingle byte received from UART ISR.
function syn_dlt645_decoder_init¶
Initialize a streaming DL/T 645 decoder.
void syn_dlt645_decoder_init (
SYN_DLT645_Decoder * dec,
SYN_DLT645_Ver version,
SYN_DLT645_FrameCallback cb,
void * ctx
)
Parameters:
decDecoder instance.versionExpected protocol version.cbFrame received callback.ctxUser callback context.
function syn_dlt645_encode¶
Encode a DL/T 645 frame into a binary transmission buffer.
Parameters:
frameInput frame data.out_bufDestination output buffer.out_capacityOutput buffer capacity (min 20 bytes).
Returns:
Number of bytes written to out_buf (0 on error).
function syn_dlt645_parse¶
Parse a raw byte buffer into a DL/T 645 frame.
SYN_Status syn_dlt645_parse (
const uint8_t * in_buf,
size_t len,
SYN_DLT645_Ver version,
SYN_DLT645_Frame * out_frame
)
Parameters:
in_bufInput buffer containing the complete frame.lenLength of input buffer.versionProtocol version expected (1997 or 2007).out_frameDestination frame struct.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on validation failure.
The documentation for this class was generated from the following file src/syntropic/proto/syn_dlt645.c