zoukankan      html  css  js  c++  java
  • 多功能嵌入式解码软件(2)

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

     验证类库

     通信协议

    下面进行一个示例:

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

    通信协议:

     

     

    准备协议文件

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

    /*
    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-----

    模拟下位机发送数据

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

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

  • 相关阅读:
    8/30 sql脚本
    navicat批量添加uuid去重
    循环向JsonArray添加对象
    java String字符串去除()里的内容
    工厂模式
    Thymeleaf学习
    SSH开发常用常见的src下建的包名
    04jQuery操作03
    04jQuery筛选jquery对象02
    04jQuery筛选jquery对象01
  • 原文地址:https://www.cnblogs.com/xutopia/p/10874960.html
Copyright © 2011-2022 走看看