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

    模拟下位机发送数据

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

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

  • 相关阅读:
    【Vue】源码——编译过程
    FreeRADIUS 、DaloRADIUS 搭建记录
    docker 学习笔记
    wget 技巧
    Centos 部署Cobbler系统
    Cloudstack 安装记录
    利用Google GCM发送push通知到Android客户端
    利用ApnsPHP包向IOS推送消息
    Linux下SCP的使用
    Android Google购买PHP服务器端验证(订阅购买和一次性购买)
  • 原文地址:https://www.cnblogs.com/xutopia/p/10874960.html
Copyright © 2011-2022 走看看