File syn_dlt645.h¶
FileList > proto > syn_dlt645.h
Go to the source code of this file
DL/T 645 Electricity Meter Communication Protocol (1997 & 2007). More...
#include "../common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_DLT645_Decoder Streaming byte-at-a-time decoder state. |
| struct | SYN_DLT645_Frame Decoded DL/T 645 frame representation. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_DLT645_Cmd |
| typedef void(* | SYN_DLT645_FrameCallback Frame received callback. |
| enum | SYN_DLT645_Ver |
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. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_DLT645_ADDR_LEN 6 |
| define | SYN_DLT645_EOF 0x16 |
| define | SYN_DLT645_OFFSET 0x33 |
| define | SYN_DLT645_PREAMBLE 0xFE |
| define | SYN_DLT645_SOF 0x68 |
Detailed Description¶
Implements DL/T 645-1997 and DL/T 645-2007 master-slave request/response encoding, decoding, checksum validation, and streaming reception.
Public Types Documentation¶
enum SYN_DLT645_Cmd¶
enum SYN_DLT645_Cmd {
SYN_DLT645_CMD_READ_DATA = 0x11,
SYN_DLT645_CMD_READ_DATA_RESP = 0x91,
SYN_DLT645_CMD_WRITE_DATA = 0x14,
SYN_DLT645_CMD_WRITE_DATA_RESP = 0x94,
SYN_DLT645_CMD_READ_ADDR = 0x13,
SYN_DLT645_CMD_READ_ADDR_RESP = 0x93,
SYN_DLT645_CMD_WRITE_ADDR = 0x15,
SYN_DLT645_CMD_WRITE_ADDR_RESP = 0x95,
SYN_DLT645_CMD_CHANGE_BAUD = 0x17,
SYN_DLT645_CMD_CHANGE_BAUD_RESP = 0x97,
SYN_DLT645_CMD_ERROR_RESP = 0xD1
};
typedef SYN_DLT645_FrameCallback¶
Frame received callback.
enum SYN_DLT645_Ver¶
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.
Macro Definition Documentation¶
define SYN_DLT645_ADDR_LEN¶
define SYN_DLT645_EOF¶
define SYN_DLT645_OFFSET¶
define SYN_DLT645_PREAMBLE¶
define SYN_DLT645_SOF¶
The documentation for this class was generated from the following file src/syntropic/proto/syn_dlt645.h