Vehicle-mounted control software communication protocol analysis method based on xml language

文档序号:1478684 发布日期:2020-02-25 浏览:2次 中文

阅读说明:本技术 一种基于xml语言的车载控制软件通信协议解析方法 (Vehicle-mounted control software communication protocol analysis method based on xml language ) 是由 谢黛茜 张波 魏源远 于 2019-10-31 设计创作,主要内容包括:本发明公开了一种基于xml语言的车载控制软件通信协议解析方法,包括:将通信协议转换成xml文件,在xml数据结构中寻找与接收的数据或者要发送的数据匹配的协议识别码;并读取该协议识别码的属性和值,赋给协议数据模型,协议数据模型根据接收的数据或者要发送的数据,传入需要解析的数据类型,调用对应的解析类,生成需要的数据。通过将接收的数据或者发送的数据与xml文件中的protocol节点匹配,获取protocol节点的属性和值,赋给定义的协议类,调用接收协议或发送协议的解析函数,传入需要解析的数据类型,调用并传入对应的解析类,生成需要的数据,实现了可以适用于所有通信协议的解析方法和解析规则。(The invention discloses a communication protocol analysis method of vehicle-mounted control software based on xml language, which comprises the following steps: converting a communication protocol into an xml file, and searching a protocol identification code matched with received data or data to be sent in an xml data structure; and reading the attribute and the value of the protocol identification code, assigning the attribute and the value to a protocol data model, and transmitting the data type to be analyzed by the protocol data model according to the received data or the data to be sent, calling the corresponding analysis class and generating the required data. The received data or the sent data are matched with the protocol nodes in the xml file, the attributes and the values of the protocol nodes are obtained, the attributes and the values are assigned to the defined protocol classes, the analysis functions of the receiving protocol or the sending protocol are called, the data types needing to be analyzed are transmitted, the corresponding analysis classes are called and transmitted, and the needed data are generated.)

1. An xml language-based vehicle-mounted control software communication protocol analysis method is characterized by comprising the following steps:

step A1: converting a communication protocol into an xml file, wherein the xml file comprises a protocol identification code of an xml data structure;

step A2: searching a protocol identification code matched with received data or data to be sent in an xml data structure, reading the attribute and the value of the protocol identification code, assigning a protocol data model defined in advance, and matching the protocol identification code with the protocol data model;

step A3: the protocol data model transmits a data type to be analyzed according to the received data, calls a corresponding analysis class and generates the required data; or according to the data to be sent, the data type to be analyzed is transmitted to call the corresponding analysis class, and the required data is generated.

2. The xml-language-based vehicle control software communication protocol parsing method according to claim 1, wherein the step a1 includes:

step A11: abstracting a coding mode of a communication protocol into a tree structure;

step A12: describing the tree structure by an xml language, wherein the tree structure comprises a root node, a child node and a leaf node; the child nodes correspond to protocol group data, the leaf nodes are protocol identification codes of a communication protocol, and the attributes and the values of the protocol identification codes are defined to form an xml file.

3. The xml-language-based vehicle-mounted control software communication protocol parsing method according to claim 2, wherein the protocol data model is a protocol class, and the attributes of the protocol class include a class name, a data identification code, a data type, transmitted data information, received data information, a received data conversion method and a transmitted data conversion method.

Technical Field

The invention relates to the technical field of vehicle-mounted control software communication protocols, in particular to a vehicle-mounted control software communication protocol analysis method based on an xml language.

Background

In order to realize the separation of protocol analysis and service logic, the currently used technology is ① reflecting data classes to an algorithm analysis module by utilizing a reflection principle to generate the required data classes, ② independently writing software is suitable for different scenes, but the protocol analysis rule can not be suitable for all protocols.

Disclosure of Invention

The invention aims to provide an xml language-based vehicle-mounted control software communication protocol analysis method, which is used for solving the problem that none of the vehicle-mounted control system management software communication protocols in the prior art can be suitable for protocol analysis rules of all protocols.

The invention solves the problems through the following technical scheme:

an xml language-based vehicle-mounted control software communication protocol analysis method comprises the following steps:

step A1: converting a communication protocol into an xml file, wherein the xml file comprises a protocol identification code of an xml data structure;

step A2: searching a protocol identification code matched with the received data or the data to be transmitted in an xml data structure; reading the attribute and the value of the protocol identification code, assigning a protocol data model defined in advance, and matching the protocol identification code with the protocol data model;

step A3: the protocol data model transmits a data type to be analyzed according to the received data, calls a corresponding analysis class and generates the required data; or according to the data to be sent, the data type to be analyzed is transmitted to call the corresponding analysis class, and the required data is generated.

The received data or the sent data are matched with the protocol identification code in the xml file converted by the communication protocol to obtain the attribute and the value of the data, the attribute and the value are assigned to a defined protocol class, an analysis function of the receiving protocol or the sending protocol is called, the data type needing to be analyzed is transmitted, the corresponding analysis class is called and transmitted to generate the needed data, and the analysis method and the analysis rule which can be suitable for all the communication protocols are realized.

Further, the step a1 includes:

step A11: abstracting a coding mode of a communication protocol into a tree structure;

step A12: describing the tree structure by an xml language, wherein the tree structure comprises a root node, a child node and a leaf node; the child nodes correspond to protocol group data, the leaf nodes are protocol identification codes of a communication protocol, the root nodes of the tree structure are described as 'root', the child nodes of the tree structure are described as 'group', the leaf nodes are described as 'protocol', attributes and values of the 'group' nodes and the 'protocol' nodes are defined, and an xml file is formed. The attribute value < protocol > nodes in the < group > nodes are all satisfied. The protocols can be summarized, classified and uniformly processed by using the digital structure recording protocol, so that the processing efficiency is improved. When the protocol is searched, the protocol can be quickly found by utilizing the traversal mode of the tree, all protocols do not need to be traversed, and the method is quicker.

Further, the protocol data model is a protocol class, and the attributes of the protocol class include a class name, a data identification code, a data type, transmitted data information, received data information, a received data conversion method, and a transmitted data conversion method.

Compared with the prior art, the invention has the following advantages and beneficial effects:

(1) the method and the device match the received data or the sent data with the protocol node in the xml file converted by the communication protocol, acquire the attribute and the value of the protocol node, assign the attribute and the value to a defined protocol class, call the analysis function of the receiving protocol or the sending protocol, transmit the data type required to be analyzed, call and transmit the corresponding analysis class to generate the required data, and realize the analysis method and the analysis rule which can be suitable for all communication protocols.

(2) The invention can use the digital structure recording protocol to summarize, classify and process the protocol uniformly, and improve the processing efficiency. When searching for the protocol, the protocol can be quickly found by using the traversal mode of the tree, all protocols do not need to be traversed, and the protocol is quicker

Drawings

Fig. 1 is a diagram of the protocol components of the present invention.

Detailed Description

The present invention will be described in further detail with reference to examples, but the embodiments of the present invention are not limited thereto.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种电力营销多渠道客户服务系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类