基于状态机的DLT645协议解析

DLT645-2007协议格式如下:
在这里插入图片描述
/* 根据协议格式的状态定义 /
#define FRAME_STATES_DLT645_NULL 0 /
no synchronisation /
#define FRAME_STATES_DLT645_68 1 /
have the first Flag Byte received /
#define FRAME_STATES_DLT645_ADDR 2 /
have the length byte /
#define FRAME_STATES_DLT645_68_2 3 /
have the length byte /
#define FRAME_STATES_DLT645_C 4 /
have the control byte /
#define FRAME_STATES_DLT645_L 5 /
have the confirm length byte /
#define FRAME_STATES_DLT645_DATA 6 /
have the confirm length byte /
#define FRAME_STATES_DLT645_CS 7 /
wait for the CS /
#define FRAME_STATES_DLT645_END 8 /
wait for the 16H /
#define FRAME_STATES_DLT645_COMPLETE 9 /
complete frame */

/* 数据结构体定义 /
typedef struct _CHKFRAME {
int eFrameState; /
报文状态 /
uint8 nControlWord; /
普通报文中的控制字 /
time_t iUpdate_Time; /
更新时间 /
time_t iOvertime; /
报文等待超时时间*/
uint8 nChannelType; /* 报文信道来源类型 /
uint8 aBuffer[MAX_FRAME_LEN]; /
buffer, that hold the received bytes /
uint16 nFrameLen; /
actual length of the buffer */
uint8 pBufferPtr; / pointer to buffe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值