多功能嵌入式解码软件(2)

多功能嵌入式解码软件(2)

 验证类库

 通信协议

下面进行一个示例:

    下位机需要向上位机发送3中数据帧,数据帧以功能码来识别,每种数据帧的协议如下3个表格所示,上位机需要把这些数据按照协议解码出来,并进行保存以便分析。

通信协议:

 多功能嵌入式解码软件(2)

 多功能嵌入式解码软件(2)

多功能嵌入式解码软件(2)

准备协议文件

  按照通信协议编写协议文件
 

/*
this is a protocol
2019-03-28
正文中不可以出现注释
e.g. 正文//注释内容
e.g. 正文
//注释内容
正文开头第一行必须是frameType
*/
/*
目前最后一行必须是空行
*/
frameType=header2 function
header1=0xA0
header2=0xA1
body=1
function=0xB1
index=1,type=unsigned char
index=2,type=unsigned short
index=3,type=unsigned int
index=4,type=short
index=5,type=int
index=6,type=float
index=7,type=double
endbody
body=2
function=0xB2
index=1,type=unsigned char
index=2,type=unsigned short
index=3,type=unsigned int
index=4,type=short
index=5,type=int
index=6,type=float
index=7,type=double
endbody
body=3
function=0xB3
index=1,type=unsigned char
index=2,type=unsigned short
index=3,type=unsigned int
index=4,type=short
index=5,type=int
index=6,type=float
index=7,type=double
endbody
check=CRC-CCITT
-----END FILE-----

模拟下位机发送数据

  为了方便分析,这里使用虚拟串口助手在电脑上模拟出两个串口端口

  编写软件模拟下位机按照协议发送数据

多功能嵌入式解码软件(2)

多功能嵌入式解码软件(2)

多功能嵌入式解码软件(2)

 

发表于 2019-05-16 12:54 xutopia 阅读(...) 评论(...) 编辑 收藏
 

相关文章:

  • 2021-10-20
  • 2021-06-28
  • 2021-04-16
  • 2021-06-09
  • 2021-12-19
  • 2021-12-03
  • 2021-07-26
  • 2021-07-05
猜你喜欢
  • 2021-07-20
  • 2022-01-16
  • 2021-10-23
  • 2021-12-19
  • 2021-09-18
  • 2022-12-23
  • 2022-01-20
相关资源
相似解决方案