WO2018165902A1 - 一种通信协议解析代码自动生成方法及系统 - Google Patents

一种通信协议解析代码自动生成方法及系统 Download PDF

Info

Publication number
WO2018165902A1
WO2018165902A1 PCT/CN2017/076762 CN2017076762W WO2018165902A1 WO 2018165902 A1 WO2018165902 A1 WO 2018165902A1 CN 2017076762 W CN2017076762 W CN 2017076762W WO 2018165902 A1 WO2018165902 A1 WO 2018165902A1
Authority
WO
WIPO (PCT)
Prior art keywords
communication protocol
code
protocol
instruction information
data query
Prior art date
Application number
PCT/CN2017/076762
Other languages
English (en)
French (fr)
Inventor
王大勇
刘建东
李涛
Original Assignee
深圳中兴力维技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳中兴力维技术有限公司 filed Critical 深圳中兴力维技术有限公司
Priority to CN201780002446.XA priority Critical patent/CN108141464B/zh
Priority to PCT/CN2017/076762 priority patent/WO2018165902A1/zh
Publication of WO2018165902A1 publication Critical patent/WO2018165902A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]

Definitions

  • the present invention relates to the field of power environment monitoring technologies, and in particular, to a method and system for automatically generating a communication protocol analysis code.
  • the Modbus communication protocol is a general-purpose language applied to electronic controllers (smart devices) and has become a general industry standard. Through this protocol, controllers can communicate with each other and between controllers via a network (such as Ethernet) and other devices.
  • the Modbus communication protocol parsing burst has the following problems:
  • the main object of the present invention is to provide a method and system for automatically generating a communication protocol analysis code, which aims to solve the problems existing in the prior art.
  • a first aspect of the embodiments of the present invention provides a method for automatically generating a communication protocol parsing code, where the method includes the following steps:
  • control instruction configuration information control instruction configuration information
  • monitoring amount analysis information
  • the input data query instruction information, the control instruction information, and the monitoring quantity instruction information and generate a protocol configuration file corresponding to the communication protocol.
  • the method further includes:
  • the data query instruction information, the control instruction information, and the monitoring amount instruction f ⁇ information of the abnormal input are modified.
  • the device communication protocol parsing code formed by the combination is written into the divided device communication protocol framework code source file.
  • the communication protocol is a fixed format communication protocol.
  • a second aspect of the embodiments of the present invention provides a communication protocol parsing code from The system includes: a protocol configuration file generation module, a data query processing module, a control command processing module, a data analysis processing module, and a protocol code generation module;
  • the protocol configuration file generating module is configured to generate a protocol configuration file corresponding to the communication protocol according to the device communication protocol;
  • control command processing module is configured to read and analyze the protocol configuration file, obtain control command configuration information of the device communication protocol, and configure information according to the obtained control instruction of the device communication protocol. Generating a control instruction code;
  • the protocol code generating module is configured to combine the data query instruction code, the control instruction code, and the monitoring analysis code to form the device communication protocol parsing code.
  • the protocol configuration file generating module includes an input unit and a generating unit
  • the generating unit is configured to generate, according to a communication protocol of the device, the data query instruction information, the control instruction information, and the monitoring amount instruction information input by the input unit, to generate a protocol configuration file corresponding to the communication protocol.
  • the protocol configuration file generating module further includes a determining unit and a modifying unit;
  • the determining unit is configured to check and determine whether the input data query instruction information, the control instruction information, and the monitoring amount instruction information are abnormal;
  • the modifying unit is configured to modify the data query instruction information, the control instruction information, and the monitoring amount instruction information of the abnormal input if the determination result of the determining unit is abnormal.
  • the dividing module is configured to split a device communication protocol framework code source file
  • the protocol code generating module is further configured to write the device communication protocol parsing code formed by the combination, and write the score The cut device communication protocol framework code source file.
  • the communication protocol is a fixed format communication protocol.
  • a method and system for automatically generating a communication protocol parsing code realizes automatic generation of a communication protocol parsing code, can quickly generate a style, parse and process a unified communication protocol parsing code, and can also ensure a communication protocol. The accuracy of the parsing improves the maintainability of the protocol code.
  • FIG. 1 is a schematic flowchart of a method for automatically generating a communication protocol analysis code according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of an abnormal input flow in a method for automatically generating a communication protocol analysis code according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of another method for automatically generating a communication protocol analysis code according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a communication protocol analysis code automatic generation system according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a protocol configuration file generation module in a communication protocol parsing code automatic generation system according to an embodiment of the present invention
  • FIG. 6 is another schematic structural diagram of a communication protocol parsing code automatic generation system according to an embodiment of the present invention.
  • first, second, and the like in the present invention are used for the purpose of description only, and are not to be construed as indicating or implying their relative importance or implicitly indicating the number of technical features indicated.
  • features defining “first” and “second” may include at least one of the features, either explicitly or implicitly.
  • the technical solutions between the various embodiments may be combined with each other, but must be based on the realization of those skilled in the art, and when the combination of the technical solutions is contradictory or impossible to implement, it should be considered that the combination of the technical solutions does not exist. It is also within the scope of protection required by the present invention.
  • a first embodiment of the present invention provides a method for automatically generating a communication protocol parsing code, where the method includes the following steps:
  • the communication protocol is a fixed format communication protocol, such as: Modbus communication protocol, and electrical communication protocol.
  • the step may include:
  • the input control instruction information can be as shown in the following table:
  • the input monitoring amount instruction information may be as shown in the following table:
  • [0063] 104 Generate, according to a communication protocol of the device, the input data query instruction information, the control instruction information, and the monitoring instruction information, to generate a protocol configuration file corresponding to the communication protocol.
  • control instruction code includes a remote command code and/or a remote command code.
  • the method further includes the steps of:
  • the split device communication protocol framework code source file may be divided into a plurality of different parts, and may mainly include a data query instruction sending part, a control instruction sending (a remote command transmission, a remote command sending),
  • the monitoring data parsing part is designed to facilitate the insertion of the generated protocol code.
  • the 4 is a communication protocol analysis code automatic generation system according to a second embodiment of the present invention.
  • the system includes: a protocol configuration file generation module 20, a data query processing module 21, and a control command processing module. 22.
  • the protocol profile generating module 20 may include an input unit 201 and a generating unit 202;
  • an input unit 201 configured to input data query instruction information, control instruction information, and monitoring amount instruction information
  • the input data query instruction information may be as shown in the following table:
  • the input control instruction information can be as shown in the following table:
  • the protocol profile generating module 20 may further include a determining unit 203 and a modifying unit 204;
  • the modifying unit 204 is configured to modify the data query instruction information, the control instruction information, and the monitoring amount instruction information of the abnormal input if the determination result of the determining unit 203 is abnormal.
  • the split device communication protocol framework code source file may be divided into a plurality of different parts, and may mainly include a data query instruction sending part, a control instruction sending (a remote command transmission, a remote command sending),
  • the monitoring amount data parsing part is for facilitating corresponding insertion of the protocol code generated by the protocol code generating module.
  • the communication protocol parsing code automatic generation system provided by the embodiment provides automatic generation of communication protocol parsing code, can quickly generate style, parsing and processing unified communication protocol parsing code, and can ensure accurate communication protocol parsing. Sex, peers improve the maintainability of the protocol code.
  • a method and system for automatically generating a communication protocol parsing code provided by an embodiment of the present invention, which realizes automatic generation of a communication protocol parsing code, can quickly generate a style, parse and process a unified communication protocol parsing code, and can also ensure a communication protocol. The accuracy of the parsing improves the maintainability of the protocol code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Communication Control (AREA)
  • Computer And Data Communications (AREA)
  • Maintenance And Management Of Digital Transmission (AREA)

Abstract

本发明公开了一种通信协议解析代码自动生成方法及系统,该方法包括步骤:根据设备通信协议,生成该通信协议对应的协议配置文件;读取并分析协议配置文件,获取到设备通信协议的数据查询配置信息、控制指令配置信息以及监测量解析信息;生成数据查询指令代码、控制指令代码以及监测量解析代码;将数据查询指令代码、控制指令代码以及监测量解析代码,组合形成设备通信协议解析代码。本发明公开的通信协议解析代码自动生成方法及系统,实现了通信协议解析代码自动生成,能够快速生成风格、解析处理统一的通信协议解析代码,还能够保证通信协议解析的准确性,同时提高了协议代码的可维护性。

Description

一种通信协议解析代码自动生成方法及系统 技术领域
[0001] 本发明涉及动力环境监控技术领域, 尤其涉及一种通信协议解析代码自动生成 方法及系统。
背景技术
[0002] Modbus通信协议是应用于电子控制器 (智能设备)上的一种通用语言, 已经成为 一种通用工业标准。 通过此协议, 控制器相互之间、 控制器经由网络 (例如以 太网) 和其它设备之间可以通信。
[0003] 为了对提供 Modbus协议的动力设备实现接入, 目前动环监控行业 (即动力环 境监控行业) 通常的做法是首先实现针对 Modbus协议的框架, 在此框架基础上 , 进行命令循环发送及数据解析, 每类 Modbus设备均需根据 Modbus协议规约进 行协议解析幵发。
[0004] 目前 Modbus通信协议解析幵发存在如下问题:
[0005] 1) 工作量大: 每一种新设备均需由幵发人员进行命令发送、 解析代码进行幵 发。
[0006] 2) 易出错: 代码由人工进行编写, 经常会复制、 粘贴代码, 相应变量没进行 修改而导致解析异常问题。
[0007] 3) 代码维护复杂: 如果设备通信协议进行升级或设备通讯出现问题进行维护 吋, 需再次对设备 Modbus通信协议进行阅读、 理解, 并结合源代码再进行修改 或调试。
[0008] 4) 代码规范难统一: 不同协议幵发人员的代码缩进、 调用方法等很难做到统 一, 提高了后期维护成本。
技术问题
[0009] 本发明的主要目的在于提出一种通信协议解析代码自动生成方法及系统, 旨在 解决现有技术存在的问题。 问题的解决方案 技术解决方案
[0010] 为实现上述目的, 本发明实施例第一方面提供一种通信协议解析代码自动生成 方法, 所述方法包括步骤:
[0011] 根据设备通信协议, 生成该通信协议对应的协议配置文件;
[0012] 读取并分析所述协议配置文件, 获取到所述设备通信协议的数据査询配置信息
、 控制指令配置信息以及监测量解析信息;
[0013] 根据获取的的所述设备通信协议的数据査询配置信息、 控制指令配置信息以及 监测量解析信息, 生成数据査询指令代码、 控制指令代码以及监测量解析代码
[0014] 将所述数据査询指令代码、 控制指令代码以及监测量解析代码, 组合形成所述 设备通信协议解析代码。
[0015] 进一步地, 所述步骤根据设备的通信协议, 生成该通信协议对应的协议配置文 件包括:
[0016] 输入数据査询指令信息、 控制指令信息以及监测量指令信息;
[0017] 根据设备的通信协议, 输入的数据査询指令信息、 控制指令信息以及监测量指 令信息, 生成该通信协议对应的协议配置文件。
[0018] 进一步地, 所述步骤输入数据査询指令信息、 控制指令信息以及监测量指令信 息之后还包括:
[0019] 检査并判断输入的数据査询指令信息、 控制指令信息以及监测量指令信息是否 有异常;
[0020] 若有异常则修改异常输入的数据査询指令信息、 控制指令信息以及监测量指令 f π息。
[0021] 进一步地, 所述方法还包括步骤:
[0022] 分割设备通信协议框架代码源文件;
[0023] 将组合形成的设备通信协议解析代码, 写入分割后的设备通信协议框架代码源 文件。
[0024] 进一步地, 所述通信协议为固定格式通信协议。
[0025] 此外, 为实现上述目的, 本发明实施例第二方面提供一种通信协议解析代码自 动生成系统, 所述系统包括: 协议配置文件生成模块、 数据査询处理模块、 控 制命令处理模块、 数据解析处理模块及协议代码生成模块;
[0026] 所述协议配置文件生成模块, 用于根据设备通信协议, 生成该通信协议对应的 协议配置文件;
[0027] 所述数据査询处理模块, 用于读取并分析所述协议配置文件, 获取到所述设备 通信协议的数据査询配置信息, 根据获取的的所述设备通信协议的数据査询配 置信息, 生成数据査询指令代码;
[0028] 所述控制命令处理模块, 用于读取并分析所述协议配置文件, 获取到所述设备 通信协议的控制指令配置信息, 根据获取的的所述设备通信协议的控制指令配 置信息, 生成控制指令代码;
[0029] 所述数据解析处理模块, 用于读取并分析所述协议配置文件, 获取到所述设备 通信协议的监测量解析信息, 根据获取的的所述设备通信协议的监测量解析信 息, 生成监测量解析代码;
[0030] 所述协议代码生成模块, 用于将所述数据査询指令代码、 控制指令代码以及监 测量解析代码, 组合形成所述设备通信协议解析代码。
[0031] 进一步地, 所述协议配置文件生成模块包括输入单元和生成单元;
[0032] 所述输入单元, 用于输入数据査询指令信息、 控制指令信息以及监测量指令信 息;
[0033] 所述生成单元, 用于根据设备的通信协议, 输入单元输入的数据査询指令信息 、 控制指令信息以及监测量指令信息, 生成该通信协议对应的协议配置文件。
[0034] 进一步地, 所述协议配置文件生成模块还包括判断单元和修改单元;
[0035] 所述判断单元, 用于检査并判断输入的数据査询指令信息、 控制指令信息以及 监测量指令信息是否有异常;
[0036] 所述修改单元, 用于若所述判断单元的判断结果为异常, 则修改异常输入的数 据査询指令信息、 控制指令信息以及监测量指令信息。
[0037] 进一步地, 所述系统还包括分割模块;
[0038] 所述分割模块, 用于分割设备通信协议框架代码源文件;
[0039] 所述协议代码生成模块, 还用于将组合形成的设备通信协议解析代码, 写入分 割后的设备通信协议框架代码源文件。
[0040] 进一步地, 所述通信协议为固定格式通信协议。
发明的有益效果
有益效果
[0041] 本发明实施例提供的一种通信协议解析代码自动生成方法及系统, 实现了通信 协议解析代码自动生成, 能够快速生成风格、 解析处理统一的通信协议解析代 码, 还能够保证了通信协议解析的准确性, 同吋提高了协议代码的可维护性。 对附图的简要说明
附图说明
[0042] 图 1为本发明实施例提供的通信协议解析代码自动生成方法流程示意图;
[0043] 图 2为本发明实施例提供的通信协议解析代码自动生成方法中异常输入流程示 意图;
[0044] 图 3为本发明实施例提供的通信协议解析代码自动生成方法另一流程示意图; [0045] 图 4为本发明实施例提供的通信协议解析代码自动生成系统结构示意图;
[0046] 图 5为本发明实施例提供的通信协议解析代码自动生成系统中协议配置文件生 成模块结构示意图;
[0047] 图 6为本发明实施例提供的通信协议解析代码自动生成系统另一结构示意图。
[0048] 本发明目的的实现、 功能特点及优点将结合实施例, 参照附图做进一步说明。
本发明的实施方式
[0049] 应当理解, 此处所描述的具体实施例仅仅用以解释本发明, 并不用于限定本发 明。
[0050] 现在将参考附图描述实现本发明各个实施例的。 在后续的描述中, 使用用于表 示元件的诸如 "模块"、 "部件 "或"单元"的后缀仅为了有利于本发明的说明, 其本 身并没有特定的意义。
[0051] 还应当进一步理解, 在本发明说明书和所附权利要求书中使用的术语 "和 /或"是 指相关联列出的项中的一个或多个的任何组合以及所有可能组合, 并且包括这 些组合。
[0052] 在本发明中涉及"第一"、 "第二"等的描述仅用于描述目的, 而不能理解为指示 或暗示其相对重要性或者隐含指明所指示的技术特征的数量。 由此, 限定有 "第 一"、 "第二 "的特征可以明示或者隐含地包括至少一个该特征。 另外, 各个实施 例之间的技术方案可以相互结合, 但是必须是以本领域普通技术人员能够实现 为基础, 当技术方案的结合出现相互矛盾或无法实现吋应当认为这种技术方案 的结合不存在, 也不在本发明要求的保护范围之内。
[0053] 如图 1所示, 本发明第一实施例提供的一种通信协议解析代码自动生成方法, 该方法包括步骤:
[0054] 10、 根据设备通信协议, 生成该通信协议对应的协议配置文件。
[0055] 在本实施例中, 通信协议为固定格式通信协议, 例如: Modbus通信协议、 电 总通信协议。
[0056] 参考图 2所示, 在本实施例中, 该步骤可包括:
[0057] 101、 输入数据査询指令信息、 控制指令信息以及监测量指令信息。
[0058] 作为示例地, 输入的数据査询指令信息可如下表格所示:
Figure imgf000007_0001
作为示例地, 输入的控制指令信息可如下表格所示:
[]
Figure imgf000007_0002
[0060] 作为示例地, 输入的监测量指令信息可如下表格所示:
[]
Figure imgf000008_0001
[0061] 102、 检査并判断输入的数据査询指令信息、 控制指令信息以及监测量指令信 息是否有异常。
[0062] 103、 若有异常则修改异常输入的数据査询指令信息、 控制指令信息以及监测 量指令信息。
[0063] 104、 根据设备的通信协议, 输入的数据査询指令信息、 控制指令信息以及监 测量指令信息, 生成该通信协议对应的协议配置文件。
[0064] 11、 读取并分析协议配置文件, 获取到设备通信协议的数据査询配置信息、 控 制指令配置信息以及监测量解析信息。
[0065] 12、 根据获取的的设备通信协议的数据査询配置信息、 控制指令配置信息以及 监测量解析信息, 生成数据査询指令代码、 控制指令代码以及监测量解析代码
[0066] 在本实施例中, 控制指令代码包括遥调命令代码和 /或遥控命令代码。
[0067] 13、 将数据査询指令代码、 控制指令代码以及监测量解析代码, 组合形成所述 设备通信协议解析代码。
[0068] 请参考图 3所示, 进一步地, 该方法还包括步骤:
[0069] 14、 分割设备通信协议框架代码源文件; 将组合形成的设备通信协议解析代码
, 写入分割后的设备通信协议框架代码源文件。
[0070] 在本实施例中, 分割设备通信协议框架代码源文件可分割成多个不同部分, 主 要可包括数据査询指令发送部分、 控制指令发送 (遥调命令发送、 遥控命令发送) 部分、 监测量数据解析部分, 目的是方便插入生成的协议代码。
[0071] 本实施例提供的一种通信协议解析代码自动生成方法, 实现了通信协议解析代 码自动生成, 能够快速生成风格、 解析处理统一的通信协议解析代码, 还能够 保证了通信协议解析的准确性, 同吋提高了协议代码的可维护性。
[0072] 本发明进一步提供一种系统。
[0073] 参照图 4, 图 4为本发明第二实施例提供的一种通信协议解析代码自动生成系统 , 该系统包括: 协议配置文件生成模块 20、 数据査询处理模块 21、 控制命令处 理模块 22、 数据解析处理模块 23及协议代码生成模块 24;
[0074] 协议配置文件生成模块 20, 用于根据设备通信协议, 生成该通信协议对应的协 议配置文件。
[0075] 在本实施例中, 通信协议为固定格式通信协议, 例如: Modbus通信协议、 电 总通信协议。
[0076] 参考图 5所示, 在本实施例中, 协议配置文件生成模块 20可包括输入单元 201和 生成单元 202;
[0077] 输入单元 201, 用于输入数据査询指令信息、 控制指令信息以及监测量指令信 息;
[0078] 作为示例地, 输入的数据査询指令信息可如下表格所示:
Figure imgf000009_0001
作为示例地, 输入的控制指令信息可如下表格所示:
[]
Figure imgf000009_0002
[0080] 作为示例地, 输入的监测量指令信息可如下表格所示: []
Figure imgf000010_0001
[0081] 生成单元 202, 用于根据设备的通信协议, 输入单元 201输入的数据査询指令信 息、 控制指令信息以及监测量指令信息, 生成该通信协议对应的协议配置文件
[0082] 参考图 5所示, 在本实施例中, 协议配置文件生成模块 20还可包括判断单元 203 和修改单元 204;
[0083] 判断单元 203, 用于检査并判断输入的数据査询指令信息、 控制指令信息以及 监测量指令信息是否有异常;
[0084] 修改单元 204, 用于若判断单元 203的判断结果为异常, 则修改异常输入的数据 査询指令信息、 控制指令信息以及监测量指令信息。
[0085] 数据査询处理模块 21, 用于读取并分析协议配置文件, 获取到设备通信协议的 数据査询配置信息, 根据获取的的设备通信协议的数据査询配置信息, 生成数 据査询指令代码。
[0086] 控制命令处理模块 22, 用于读取并分析协议配置文件, 获取到设备通信协议的 控制指令配置信息, 根据获取的的设备通信协议的控制指令配置信息, 生成控 制指令代码。
[0087] 在本实施例中, 控制指令代码包括遥调命令代码和 /或遥控命令代码。
[0088] 数据解析处理模块 23, 用于读取并分析协议配置文件, 获取到设备通信协议的 监测量解析信息, 根据获取的的设备通信协议的监测量解析信息, 生成监测量 解析代码。
[0089] 协议代码生成模块 24, 用于将数据査询指令代码、 控制指令代码以及监测量解 析代码, 组合形成设备通信协议解析代码。
[0090] 请参考图 6所示, 进一步地, 系统还可包括分割模块 25 ; [0091] 分割模块 25, 用于分割设备通信协议框架代码源文件;
[0092] 在本实施例中, 分割设备通信协议框架代码源文件可分割成多个不同部分, 主 要可包括数据査询指令发送部分、 控制指令发送 (遥调命令发送、 遥控命令发送) 部分、 监测量数据解析部分, 目的是方便对应地插入协议代码生成模块生成的 协议代码。
[0093] 协议代码生成模块 24, 还用于将组合形成的设备通信协议解析代码, 写入分割 后的设备通信协议框架代码源文件。
[0094] 本实施例提供的一种通信协议解析代码自动生成系统, 实现了通信协议解析代 码自动生成, 能够快速生成风格、 解析处理统一的通信协议解析代码, 还能够 保证了通信协议解析的准确性, 同吋提高了协议代码的可维护性。
[0095] 需要说明的是, 在本文中, 术语"包括"、 "包含 "或者其任何其他变体意在涵盖 非排他性的包含, 从而使得包括一系列要素的过程、 方法、 物品或者装置不仅 包括那些要素, 而且还包括没有明确列出的其他要素, 或者是还包括为这种过 程、 方法、 物品或者装置所固有的要素。 在没有更多限制的情况下, 由语句 "包 括一个 ...... "限定的要素, 并不排除在包括该要素的过程、 方法、 物品或者装置 中还存在另外的相同要素。
[0096] 以上仅为本发明的优选实施例, 并非因此限制本发明的专利范围, 凡是利用本 发明说明书及附图内容所作的等效结构或等效流程变换, 或直接或间接运用在 其他相关的技术领域, 均同理包括在本发明的专利保护范围内。
工业实用性
[0097] 本发明实施例提供的一种通信协议解析代码自动生成方法及系统, 实现了通信 协议解析代码自动生成, 能够快速生成风格、 解析处理统一的通信协议解析代 码, 还能够保证了通信协议解析的准确性, 同吋提高了协议代码的可维护性。

Claims

权利要求书
[权利要求 1] 一种通信协议解析代码自动生成方法, 其中, 所述方法包括步骤: 根据设备通信协议, 生成该通信协议对应的协议配置文件; 读取并分析所述协议配置文件, 获取到所述设备通信协议的数据査询 配置信息、 控制指令配置信息以及监测量解析信息;
根据获取的的所述设备通信协议的数据査询配置信息、 控制指令配置 信息以及监测量解析信息, 生成数据査询指令代码、 控制指令代码以 及监测量解析代码;
将所述数据査询指令代码、 控制指令代码以及监测量解析代码, 组合 形成所述设备通信协议解析代码。
[权利要求 2] 根据权利要求 1所述的一种通信协议解析代码自动生成方法, 其中, 所述步骤根据设备的通信协议, 生成该通信协议对应的协议配置文件 包括:
输入数据査询指令信息、 控制指令信息以及监测量指令信息; 根据设备的通信协议, 输入的数据査询指令信息、 控制指令信息以及 监测量指令信息, 生成该通信协议对应的协议配置文件。
[权利要求 3] 根据权利要求 2所述的一种通信协议解析代码自动生成方法, 其中, 所述步骤输入数据査询指令信息、 控制指令信息以及监测量指令信息 之后还包括:
检査并判断输入的数据査询指令信息、 控制指令信息以及监测量指令 信息是否有异常;
若有异常则修改异常输入的数据査询指令信息、 控制指令信息以及监 测量指令信息。
[权利要求 4] 根据权利要求 1所述的一种通信协议解析代码自动生成方法, 其中, 所述方法还包括步骤:
分割设备通信协议框架代码源文件;
将组合形成的设备通信协议解析代码, 写入分割后的设备通信协议框 架代码源文件。
[权利要求 5] 根据权利要求 1所述的一种通信协议解析代码自动生成方法, 其中, 所述通信协议为固定格式通信协议。
[权利要求 6] —种通信协议解析代码自动生成系统, 其中, 所述系统包括: 协议配 置文件生成模块、 数据査询处理模块、 控制命令处理模块、 数据解析 处理模块及协议代码生成模块;
所述协议配置文件生成模块, 用于根据设备通信协议, 生成该通信协 议对应的协议配置文件;
所述数据査询处理模块, 用于读取并分析所述协议配置文件, 获取到 所述设备通信协议的数据査询配置信息, 根据获取的的所述设备通信 协议的数据査询配置信息, 生成数据査询指令代码;
所述控制命令处理模块, 用于读取并分析所述协议配置文件, 获取到 所述设备通信协议的控制指令配置信息, 根据获取的的所述设备通信 协议的控制指令配置信息, 生成控制指令代码; 所述数据解析处理模块, 用于读取并分析所述协议配置文件, 获取到 所述设备通信协议的监测量解析信息, 根据获取的的所述设备通信协 议的监测量解析信息, 生成监测量解析代码;
所述协议代码生成模块, 用于将所述数据査询指令代码、 控制指令代 码以及监测量解析代码, 组合形成所述设备通信协议解析代码。
[权利要求 7] 根据权利要求 6所述的一种通信协议解析代码自动生成系统, 其中, 所述协议配置文件生成模块包括输入单元和生成单元;
所述输入单元, 用于输入数据査询指令信息、 控制指令信息以及监测 量指令信息;
所述生成单元, 用于根据设备的通信协议, 输入单元输入的数据査询 指令信息、 控制指令信息以及监测量指令信息, 生成该通信协议对应 的协议配置文件。
[权利要求 8] 根据权利要求 7所述的一种通信协议解析代码自动生成系统, 其中, 所述协议配置文件生成模块还包括判断单元和修改单元;
所述判断单元, 用于检査并判断输入的数据査询指令信息、 控制指令 信息以及监测量指令信息是否有异常;
所述修改单元, 用于若所述判断单元的判断结果为异常, 则修改异常 输入的数据査询指令信息、 控制指令信息以及监测量指令信息。
[权利要求 9] 根据权利要求 6所述的一种通信协议解析代码自动生成系统, 其中, 所述系统还包括分割模块;
所述分割模块, 用于分割设备通信协议框架代码源文件;
所述协议代码生成模块, 还用于将组合形成的设备通信协议解析代码 , 写入分割后的设备通信协议框架代码源文件。
[权利要求 10] 根据权利要求 6所述的一种通信协议解析代码自动生成系统, 其中, 所述通信协议为固定格式通信协议。
PCT/CN2017/076762 2017-03-15 2017-03-15 一种通信协议解析代码自动生成方法及系统 WO2018165902A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201780002446.XA CN108141464B (zh) 2017-03-15 2017-03-15 一种通信协议解析代码自动生成方法及系统
PCT/CN2017/076762 WO2018165902A1 (zh) 2017-03-15 2017-03-15 一种通信协议解析代码自动生成方法及系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/076762 WO2018165902A1 (zh) 2017-03-15 2017-03-15 一种通信协议解析代码自动生成方法及系统

Publications (1)

Publication Number Publication Date
WO2018165902A1 true WO2018165902A1 (zh) 2018-09-20

Family

ID=62400278

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/076762 WO2018165902A1 (zh) 2017-03-15 2017-03-15 一种通信协议解析代码自动生成方法及系统

Country Status (2)

Country Link
CN (1) CN108141464B (zh)
WO (1) WO2018165902A1 (zh)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110557377B (zh) * 2019-08-01 2021-08-27 福建星云电子股份有限公司 动力电池配对修复设备兼容多种通信协议的方法及系统
CN111221532A (zh) * 2019-12-23 2020-06-02 北京轩宇信息技术有限公司 一种动态链接库的生成方法及装置
CN111083168A (zh) * 2019-12-31 2020-04-28 广东嘉泰智能技术有限公司 可配置的物联网平台网关的数据传输方法、装置和网关
CN112714044B (zh) * 2020-12-28 2022-06-07 北京恒光信息技术股份有限公司 基于形式语言协议的网络数据解析方法、装置及存储介质
CN113377363B (zh) * 2021-07-14 2022-03-08 深圳市集贤科技有限公司 对多种电控端私有协议自动生成源代码的云端实现方法
CN114449061A (zh) * 2021-12-23 2022-05-06 深圳市长龙铁路电子工程有限公司 一种可配置式的协议解析方法、装置、设备及存储介质
CN114500350B (zh) * 2021-12-27 2024-02-06 中国航天空气动力技术研究院 地面站指令验证系统
CN114115833B (zh) * 2022-01-25 2022-06-28 北京安帝科技有限公司 协议审计代码自动生成方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030084112A1 (en) * 2001-04-02 2003-05-01 Curray Timothy G. Ethernet communications for power monitoring system
CN103139025A (zh) * 2011-12-05 2013-06-05 艾默生网络能源系统北美公司 Modbus设备的接入方法及系统
CN105812368A (zh) * 2016-03-15 2016-07-27 山东超越数控电子有限公司 一种多种通讯协议通用编程方法
CN106339249A (zh) * 2016-08-23 2017-01-18 上海创景计算机系统有限公司 动态配置编程方法
CN106412086A (zh) * 2016-10-31 2017-02-15 武汉斗鱼网络科技有限公司 一种利用协议描述文件自动生成通信代码的方法及系统

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2003200935A1 (en) * 2002-03-14 2003-10-02 E State Automation Pty Ltd An interface between the modbus protocol and SMS text messaging protocol
CN102055770B (zh) * 2011-01-17 2014-07-16 西安电子科技大学 一种基于xml描述的安全协议代码自动实现系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030084112A1 (en) * 2001-04-02 2003-05-01 Curray Timothy G. Ethernet communications for power monitoring system
CN103139025A (zh) * 2011-12-05 2013-06-05 艾默生网络能源系统北美公司 Modbus设备的接入方法及系统
CN105812368A (zh) * 2016-03-15 2016-07-27 山东超越数控电子有限公司 一种多种通讯协议通用编程方法
CN106339249A (zh) * 2016-08-23 2017-01-18 上海创景计算机系统有限公司 动态配置编程方法
CN106412086A (zh) * 2016-10-31 2017-02-15 武汉斗鱼网络科技有限公司 一种利用协议描述文件自动生成通信代码的方法及系统

Also Published As

Publication number Publication date
CN108141464A (zh) 2018-06-08
CN108141464B (zh) 2019-04-05

Similar Documents

Publication Publication Date Title
WO2018165902A1 (zh) 一种通信协议解析代码自动生成方法及系统
CN111083225B (zh) 在物联网平台中的数据处理方法、装置及物联网平台
CN108351636B (zh) 工程设计工具、系统及模块
EP3042254B1 (en) Systems and methods for virtualizing a programmable logic controller
US8640096B2 (en) Configuration of componentized software applications
US8726298B1 (en) Cloud-based instrument driver system
CN111414407A (zh) 数据库的数据查询方法、装置、计算机设备及存储介质
US11150896B2 (en) Automated generation of service definitions for message queue application clients
WO2021197350A1 (zh) 基于区块链的质量追溯系统、方法及计算机可读存储介质
CN114385759B (zh) 配置文件的同步方法、装置、计算机设备及存储介质
WO2020015191A1 (zh) 业务规则的发布管理方法、电子装置及可读存储介质
CN111061464B (zh) 解析代码生成方法、装置、设备及存储介质
WO2020232707A1 (zh) 分布式系统中通信协议版本号的更新
EP2804361B1 (en) Integrated interface system for power-system monitoring and control system
WO2013097481A1 (zh) 一种文件类型识别方法及系统
CN112817935A (zh) 基于字段类型的数据处理方法、装置、设备及存储介质
US20180123900A1 (en) Scenario driven, technology agnostic network simulation
US20180123899A1 (en) Technology agnostic network simulation
JP2014203138A (ja) 電子装置、検証方法及び検証プログラム
JP2014217186A (ja) 電子装置、検証方法及び検証プログラム
US20180336171A1 (en) System and method for constructing extensible event log with javascript object notation (json) encoded payload data
WO2018170866A1 (zh) 数据采集方法和装置
CN114968822A (zh) 接口测试方法、装置、计算机设备及存储介质
CN114329097A (zh) 批量注册产品标识的方法和装置、电子设备和存储介质
CN108429741B (zh) 一种实现ncsi协议的方法及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17900575

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17900575

Country of ref document: EP

Kind code of ref document: A1