CN111385292A - Descriptor-based protocol message and data interaction method and system - Google Patents

Descriptor-based protocol message and data interaction method and system Download PDF

Info

Publication number
CN111385292A
CN111385292A CN202010141120.9A CN202010141120A CN111385292A CN 111385292 A CN111385292 A CN 111385292A CN 202010141120 A CN202010141120 A CN 202010141120A CN 111385292 A CN111385292 A CN 111385292A
Authority
CN
China
Prior art keywords
protocol
data
descriptor
module
messages
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202010141120.9A
Other languages
Chinese (zh)
Other versions
CN111385292B (en
Inventor
权磊
朱繁
寇强
刘乐盈
陈旭峰
李金玲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
XI'AN FLAG ELECTRONICS CO Ltd
Original Assignee
XI'AN FLAG ELECTRONICS CO Ltd
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 XI'AN FLAG ELECTRONICS CO Ltd filed Critical XI'AN FLAG ELECTRONICS CO Ltd
Priority to CN202010141120.9A priority Critical patent/CN111385292B/en
Publication of CN111385292A publication Critical patent/CN111385292A/en
Application granted granted Critical
Publication of CN111385292B publication Critical patent/CN111385292B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • 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/26Special purpose or proprietary protocols or architectures

Abstract

The invention provides a descriptor-based protocol message and data interaction method and a descriptor-based protocol message and data interaction system, wherein the method comprises the following steps: the communication main body runs a service logic cycle of receiving messages, analyzing messages, updating data, generating messages and sending messages; the interface module of the communication main body receives data messages from different data interfaces or outputs the output messages of the protocol module from a specified interface; the protocol module of the communication main body calls a corresponding mapping function according to the description of the descriptor to complete the interaction of the protocol message and the data parameter; and the service module of the communication main body completes the service logic of the communication main body and completes the update of the data or the protocol message. The invention reduces the difficulty of protocol matching, has high flexibility, good compatibility and easy upgrading and configuration, and can greatly reduce the development difficulty and save the development cost.

Description

Descriptor-based protocol message and data interaction method and system
Technical Field
The invention belongs to the technical field of embedded communication, and relates to a descriptor-based protocol message and data interaction method and system.
Background
With the development of micro-electro-mechanical systems, chip technologies and communication technologies, terminal acquisition equipment such as water meters and electricity meters also develop from traditional analog quantity acquisition and transmission to digitalization, intellectualization and integration, and particularly, in the equipment communication layer, analog transmission is converted into digital packet transmission. With the development of communication networks, a plurality of communication means such as a serial bus, an ethernet, a wireless wide area network, a dedicated dynamic network and the like appear in data transmission between a terminal and a master station, and when a network is actually built, a plurality of networks are often required to coexist or transmit terminal data in a segmented manner.
The mode of multi-network coexistence or segmented transmission can match the most practical network aiming at the current application scene, effectively improves the connectivity of the network, but also introduces the problem of protocol matching. On one hand, different communication means have different technical characteristics, so that different networks have a set of inherent communication protocols which are not completely compatible with each other; on the other hand, terminal devices of different types or models often have a set of own communication protocols, and the models are not completely compatible with each other, which puts higher requirements on a concentrator and a repeater in the middle layer of the network.
A typical water and electricity meter data acquisition network comprises a main station, a concentrator/repeater and an acquisition terminal, wherein the concentrator/repeater belongs to an intermediate device and is responsible for issuing commands of the main station and summarizing and reporting data of the acquisition terminal, so that the concentrator is required to be compatible with network interfaces of the main station such as an Ethernet, a 4G network and a private network, and the concentrator is required to be compatible with data formats of upper and lower equipment interfaces for data interfaces of different types such as a ModBUS and an MBUS, so that the existing concentrator is enabled to face the problems of high module coupling and difficulty in upgrading and maintaining: on one hand, all protocols are realized by different modules of one main program in order to share configuration data, and the main program needs to be combed again when any module is changed, so that the development difficulty is high, and the period is long; on the other hand, after the original protocol is changed or a new protocol is added, all protocols related to the program need to be retested to ensure that the shared configuration contents do not interfere with each other under different protocol conditions, so that the test period and the test cost are greatly increased.
Disclosure of Invention
In order to solve the above problems, the present invention provides a descriptor-based protocol packet and data interaction method, which resolves or generates a protocol packet according to a field set corresponding to a protocol by describing a mapping relationship between a unit field of the protocol and a data parameter by a descriptor, so as to realize interaction between the protocol packet and data, reduce difficulty in matching the protocol, have high flexibility, and have the advantages of good compatibility, easy upgrade and configuration, and at the same time, can greatly reduce difficulty in development, save development cost, and solve problems existing in the prior art.
Another objective of the present invention is to provide a descriptor-based protocol packet and data interaction system.
The technical scheme adopted by the invention is that a descriptor-based protocol message and data interaction method specifically comprises the following contents:
the communication main body runs a service logic cycle of receiving messages, analyzing messages, updating data, generating messages and sending messages;
the interface module of the communication main body receives data messages from different data interfaces or outputs the output messages of the protocol module from a specified interface;
the protocol module of the communication main body comprises one or more descriptor files, each descriptor file comprises one or more descriptors, the descriptors are used for describing the mapping relation between the unit field of the protocol and the data parameters, an interface is provided for the service logic by using the flexibility of the mapping function, and the protocol module calls the corresponding mapping function according to the description of the descriptors to complete the interaction of the protocol message and the data parameters;
and the service module of the communication main body completes the service logic of the communication main body and completes the update of the data or the protocol message.
A descriptor-based protocol message and data interaction system comprises:
the communication main body is used for operating a service logic cycle of receiving messages, analyzing messages, updating data, generating messages and sending messages; the communication main body comprises an interface module, a service module and a protocol module;
the interface module is used for receiving data messages from different data interfaces or outputting output messages of the protocol module from a specified interface;
the protocol module is used for calling a corresponding mapping function according to the description of the descriptor to complete the interaction of the protocol message and the data parameter; the protocol module comprises one or more description subfiles and one or more mapping function modules; each descriptor file comprises one or more descriptors, and the descriptors are used for describing the mapping relation between the unit field of the protocol and the data parameters and providing an interface for service logic by using the flexibility of a mapping function;
and the service module is used for finishing the service logic of the communication main body and finishing the updating of the data or the protocol message.
The invention has the beneficial effects that:
(1) the invention enables a plurality of protocol files to share one set of variable, and the variable is uniquely corresponding to the configuration data, thereby ensuring the uniqueness of the equipment state, avoiding the synchronization problem caused by a plurality of sets of data and having good data real-time property.
(2) The upgrade is simple and the safety is good; and describing the protocol through the description subfile, and providing a mapping function of the description by the function module. The original protocol can be changed only by changing the description subfile or the corresponding mapping function module, dynamic update, increase or decrease of the protocol are facilitated, and only the open protocol description subfile and the corresponding function module need to be updated in the updating process, so that the operation is simple and the safety is good.
(3) The compatibility is good, and the transportability is strong; the descriptor file is independent of the platform, can be compatible with various platforms, and is realized only by developing a mapping function of the descriptor under the transplanting platform in a targeted manner during transplanting, so that the portability is high.
(4) The development difficulty is small, and the maintenance cost is low; the protocol development can be completed by only paying attention to describing the protocol and adopting a simple script language, and the development difficulty is small. Each indivisible unit field in the protocol has a descriptor description, maintenance and modification only need to pay attention to a few descriptors and mapping functions, and maintenance cost is low.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a logical framework diagram of a communication agent in an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The existing technology has the defects that the intermediate equipment needs to use different protocols to read and modify the same configuration data, each protocol needs to read and modify the configuration data to meet the protocol rules, and a large number of uncontrollable factors are introduced. In fact, there are only a few parameters (network address, port, time) of the intermediate devices such as the concentrator (corresponding to hardware/header), different protocols adopt different formats/interactive modes, and the final operation is to acquire these parameters, so that the acquisition and configuration interfaces of the parameters can be unified, and the acquired parameters can be described according to a specific protocol by using another interpretation file, that is, by adopting a mode of separating configuration data and interpretation file, different protocol messages are regarded as different descriptions of the parameters, and the description of the parameters under one protocol is called as a descriptor of the parameters.
The embodiment of the invention discloses a descriptor-based protocol message and data interaction method, which specifically comprises the following contents:
the communication main body runs a service logic cycle of receiving messages, analyzing messages, updating data, generating messages and sending messages to realize the function of the communication main body; in this embodiment, the communication agent is a concentrator or a repeater in the middle layer of the network, and its main functions are to receive a message conforming to the upper layer protocol, parse the command, send a query instruction conforming to the lower layer protocol, receive and parse the received feedback message according to the lower layer protocol, update local information, repackage the updated information into a response message conforming to the upper layer protocol, and feed back the response message to the upper layer. The actual business logic is based on different protocols and can perform the following logic: (1) receiving an upper layer instruction, analyzing, executing the instruction and feeding back a result; (2) sending an instruction to a lower layer, receiving feedback information, and updating local data; (3) sending an instruction to the lower layer, receiving feedback information, and actively reporting to the upper layer; (4) and receiving an upper layer instruction, analyzing, sending a query instruction to a lower layer, receiving feedback information of the lower layer, packaging and feeding back the feedback information to the upper layer. The business logics all comprise the specific processes of receiving messages, analyzing messages, updating data, generating messages and sending messages.
The interface module of the communication main body receives data messages from different data interfaces or outputs the output messages of the protocol module from a specified interface, so that the functions of receiving messages and sending messages are realized; in this embodiment, the concentrator uses a 4G network interface to communicate with the master station network, and uses an industrial 485 interface to communicate with the subordinate header terminal, so that the interface module is responsible for receiving and sending a 4G network message to the top and is responsible for receiving and sending an industrial 485 message to the bottom.
The protocol module of the communication main body comprises one or more descriptors, the descriptors are used for describing mapping functions of unit fields and data parameters of a protocol, an interface is provided for service logic by using the flexibility of the mapping functions, and the protocol module calls the corresponding mapping functions according to the description of the descriptors to complete the interaction of protocol messages and the data parameters; completing message analysis, data updating and message generation;
s1, search field set: searching a field set in a descriptor file corresponding to the current protocol according to the name of the data parameter, wherein the field set consists of one or more descriptors;
s2, analyzing the field set: checking descriptor elements in a field set in sequence, expanding the descriptor elements belonging to a current protocol field set in sequence, reading the content of each descriptor element in sequence again, wherein each descriptor comprises a function name, a module name, a bit number, a default value and an attribute, the bit number field of the descriptor strictly defines that a variable is positioned in a certain section of a protocol message, acquiring a mapping function handle according to the module name and the function name, sequentially enqueuing the mapping function handles in sequence to form a descriptor mapping function handle queue, completing dynamic loading of a mapping function module, and acquiring a mapping function pointer;
s3, sequentially calling each mapping function in the descriptor mapping function handle queue, wherein the mapping function takes the current descriptor content, data parameter and message buffer as parameters to complete the interaction between the protocol message and the data parameter.
S31, judging whether the current field needs to be processed according to the state information in the data parameter; if the processing is not needed, skipping the field and processing the next field; if the processing is needed, calculating a start-stop interval of the current field in the message buffer by taking the bit as a unit according to the bit length (bitsN) attribute in the descriptor, and recording the start-stop interval as the current field interval;
s32, determining the logic direction according to the logic direction information in the data; if the current logic direction is that the message information is updated to the data, intercepting the data of the current field interval in a binary system form, converting the data into a variable with the same format as the corresponding parameter in the data, assigning the variable to the corresponding parameter in the data, and finishing the data updating; if the current logic direction is that the data is packed into a message according to a protocol, converting the corresponding parameters in the data into a binary bit sequence, filling the current field interval by using the bit sequence in the binary bit sequence, and discarding redundant bits to finish the updating of the message.
In this embodiment, the concentrator communicates with the master station by using a protocol a, communicates with the subordinate terminal by using a protocol B, and places a descriptor for describing a mapping function of a unit field and data parameters of the protocol a in a sub-description file of the protocol a and a descriptor for describing a mapping function of a unit field and data parameters of the protocol B in a sub-description file of the protocol B; and the protocol module finishes the interaction of the protocol message and the data parameters according to the mapping function corresponding to the descriptor in the corresponding descriptor file, namely updating the data according to the protocol message or packing the data into the datagram conforming to the protocol according to the constraint of the descriptor file.
The protocol message is a specific form of the protocol, for example, the IP protocol specifies that the header 20 bytes is a header, defines the meaning represented by each byte, such as 1-4 bytes is a source address, 5-8 bytes is a destination address, and the like, and the protocol message is a datagram or data frame conforming to the protocol.
And completing the service logic of the communication main body through the service module of the communication main body, and completing the updating of the data or the protocol message.
An example of a descriptor: { value ═ 0x68, bitsN ═ 8, modleName ═ funcName ═ atterb ═ const, }; each descriptor is a complete set of a function name funcName, a module name modleName, a bit number bitsN, a default value, and an attribute attrib, wherein: the function name defines the name of the function to be called when the field value is obtained, the function refers to the mapping function of message and data interaction, and the function is only identified by the function name and is reserved for the user to define as a character string; the module name defines the name of the module where the function name is located, and the name is the same as the function name, in the specific application, the module is an entity existing in a file form and exists in a file system, and the mapping function cannot exist in the file system independently, so the updating and the flexibility are realized by replacing the module file, one or more mapping functions can be arranged in the module file for calling, and the module is generally a file synthesized by a class of mapping function sets or a file organized by the mapping functions related to a protocol, and is a character string; the bit number defines the bit number occupied by the field and is a positive integer; the default value defines the default value of the field, the default value is generally set according to the characteristics of the field, the default value indicates that the variable has the value after the initialization is finished, on one hand, the default value can simplify the initialization work of the variable, and on the other hand, the condition that the initialized variable is an illegal value can be avoided and is a numerical value; the attribute defines an additional attribute of the field, and provides a parameter or basis for the execution of the mapping function corresponding to the field, the attribute value can also be defined by the user, for example, the existing definition, if the attribute is const, it indicates that the field is constant, any mapping function should not change it, if var, it indicates a variable, the mapping function needs to update it, and if table, it indicates that the field is another set, and when parsing, the set is opened, and so on.
The descriptor is used for describing the mapping relation between the protocol field and the data parameter and providing an interface for the service logic by using the flexibility of the mapping function, namely, a user can change the corresponding relation by replacing the name module name of the mapping function, thereby realizing that one part of data corresponds to different protocols. Each descriptor is a complete set of function name, module name, bit number, default value and attribute, the relationship in structural order is more emphasized, namely the bitsN fields of a plurality of descriptors strictly define which variable corresponds to which section of the message of the protocol, and then the data and the corresponding variable of the specific section are processed by the corresponding mapping function; the descriptor can accurately describe the corresponding relation between each bit of the protocol message and the internal parameters by using the parameters, and the descriptor strictly corresponds to the configuration parameters in the data parameters.
When the protocol is finally described, the analysis of the whole protocol is necessarily completed from a large field set, and the field set corresponds to the protocol, for example, the length field of the protocol in table 1 includes two parts, namely the protocol version and the content length. In practical application, the configuration parameters are related to equipment, such as time of a meter, communication parameters such as IP address, gateway, communication rate and the like; there are also proprietary, such as relay status of relay stations, etc., which are closely related to the specific application; the protocol is also different according to different scenes, for example, the protocol of the concentrator query instrument uses each data parameter such as serial port number, baud rate and the like, and the protocol of the concentrator reporting data uses data parameters such as IP address and the like. The field set corresponds to a field in the protocol, for example, the IP address may be a field set, and the IP address includes four segments, each of which may be described by a descriptor.
The descriptor corresponds to the smallest indivisible protocol field of the protocol, for example, the protocol field is an IP address, the IP address has 4 segments (e.g., 192.168.0.1), and the descriptor can describe each segment, but it is not necessary to divide one segment into two descriptors to describe; conversely, an IP address may be described by a descriptor, for example, an IP address may be represented by a 32-bit shaping, and then the descriptor may directly describe the whole, which of course requires that the mapping function corresponding to the descriptor has the capability of identifying the IP address represented by the 32-bit shaping, and may be defined by the user himself.
For corresponding protocol layering, a field set supports cross-referencing, and an element of the field set can be another field set; for example, a protocol is divided into three sections of a frame head, data and a frame tail, the data comprises three sections of a data identifier, data content and data verification, the data content can be specific parameters such as time and configuration parameters, and when the protocol is described, an inclusion relation exists, so that the protocol description can be simplified, the protocol description does not need to be described from the head to the tail, but is divided into blocks, hierarchical description and modularization, and the protocol is easy to write and process and is not easy to make mistakes; meanwhile, the elements in the field set are arranged in sequence, which corresponds to the sequence of the protocol message data; because some fields in the protocol need to be transmitted only under specific conditions, for example, the protocol requires that the uploading time and the uploading communication parameters of the lower computer correspond to different fields with different field lengths, absolute deviation cannot be determined, and the fields can only be arranged in a strict sequence.
Example of field set:
Figure BDA0002399130880000061
Figure BDA0002399130880000071
the attribute "var" represents that the attribute is a variable, ConstCode represents a mapping function name of a process constant, and ProtoCode represents a mapping function name of a process protocol version number.
Each function module comprises one or more mapping functions, each mapping function corresponds to a descriptor, and the mapping functions are used for completing conversion between data and message fields according to the descriptors. The descriptor and the variable are processed by the mapping function, and the completion logic of the descriptor and the variable can be defined by a user, for example, the descriptor describes content with variable length, so that the mapping function must intervene to change the length of the message, fill the content, use function name matching, reduce coupling to the maximum extent, give great flexibility to the user, and is a necessary design for upgrading the flexibility, for example, as follows:
the protocol module encapsulates the description files of different protocols in different files for the protocol module to analyze, and encapsulates the mapping function in different module files for the protocol module to call according to the function or the category or the protocol. In order to reuse codes and save memory, a common mapping function is packaged in a module file (a dynamic link library file, such as common.dll), then proprietary different protocol mapping functions are packaged in different module files (such as tcp.dll, serial.dll and 1553 B.dll), a program needs to load common.dll into the memory each time, but all dlls of different protocols are not needed to be loaded each time, and the loaded dll is used.
The program firstly arranges the protocol structure according to the protocol configuration file, at the moment, the operation of data and message is not needed, therefore, only the mapping function is needed to be checked whether to be loaded normally, the module can be unloaded after the loading test is finished, the mapping function is called when the real analysis is finished, and the operating system provides an interface for searching the calling mapping function by using the character string, therefore, the invention adopts the mode of matching the function names, has the advantages of low coupling and simplicity, and can use the function name with prompt meaning by a person writing the protocol script, so that the protocol configuration text is clearer and easier to understand, the protocol description is written with great care, only the name is determined by the person developing the mapping function, and the person developing the mapping function (dll file) only needs to pay attention to the updating relation of the descriptor and the variable, and the organizational structure of the protocol does not need to be concerned, the coupling difficulty is greatly reduced, and the development difficulty is also reduced.
The invention provides a descriptor-based protocol message and data interaction system, which comprises a communication main body based on an embedded architecture, a protocol message and data interaction module, a data processing module and a data processing module, wherein the communication main body is used for operating a service logic cycle of receiving a message, analyzing the message, updating data, generating the message and sending the message to realize the function of the communication main body, such as a concentrator; the communication main body comprises an interface module, a protocol module and a service module; the logical framework of the communication body is shown in fig. 1.
The interface module is used for receiving data messages from different data interfaces or outputting the output messages of the protocol module from a specified interface;
the protocol module is used for calling a corresponding mapping function according to the description of the descriptor to complete the interaction of the protocol message and the data parameter; the protocol module comprises one or more description subfiles and one or more mapping function modules; each descriptor file comprises one or more descriptors, and the descriptors are used for describing mapping relations of unit fields and data parameters of the protocol and providing interfaces for business logic by using the flexibility of mapping functions;
and the service module is used for finishing the service logic of the communication main body and finishing the updating of the data or the protocol message.
Examples
Taking a certain protocol header in a national power grid as an example, the protocol specifies that a message contains the following fields:
(1) start character: fixed value of 68H, 1 byte
(2) Byte length L: including protocol identification and user data length, consisting of 2 bytes, as in table 1;
TABLE 1
D7 D6 D5 D4 D3 D2 D1 D0
D15 D14 D13 D12 D11 D10 D9 D8
(2a) The specification identification is represented by two codes D0-D1 in Table 1;
(2b) user data length L1: D2-D15, representing the total number of bytes.
(3) Start character: fixed value of 68H, 1 byte
Then the corresponding descriptors are:
(1){attrib=const,value=0x68,modelName=“”,bitsN=8,funcName=ConstCode,}
(2a){attrib=var,value=1,modelName=“”,bitsN=2,funcName=ProtoCode,}
(2b){attrib=var,value=0,funcName=PackLength,bitsN=14,modelName=“”,}
(3){attrib=const,value=0x68,modelName=“”,bitsN=8,funcName=ConstCode,}
its descriptor file content can be expressed as:
Figure BDA0002399130880000081
Figure BDA0002399130880000091
taking the parsing step as an example, assuming that the field name of the adopted protocol is CFG, the received message content is {0x68,0x49,0x0,0x68 }; length indicates the subsequent Length of the message, and since the protocol is a part of interception, the content of the following 18 bytes is not written.
The logic steps of the protocol module for completing message and data interaction according to the descriptor are as follows:
and (3) searching field sets: and searching the field set CFG corresponding to the current protocol in the description subfile according to the field set name CFG in the configuration parameters.
Analyzing the field set, wherein the expanded field set is as follows:
Figure BDA0002399130880000092
the obtained mapping function handle queue is a mapping function handle queue containing function names of ConstCode, ProtoCode, PackLength and ConstCode in sequence.
And sequentially calling mapping functions with function names of ConstCode, ProtoCode, PackLength and ConstCode by using the mapping function handle, wherein the processing result of the message is as follows:
(1) start character: 68H
(2a) Protocol identification: d0 ═ 1; d1 ═ 0;
(2b) user data length L1: 01001000000000 denotes the length 18 from D2 to D15, respectively.
(3) Start character: 68H
Updating the protocol description only requires changing the protocol description file, e.g. changing the second start character to 16H, only the protocol description file needs to be changed to
Figure BDA0002399130880000093
Figure BDA0002399130880000101
Without any change to other programs and without upgrading the main program logic.
The advantages of the invention are as follows:
1. the invention makes the inseparable protocol field correspond to the data parameter by the descriptor in the way of mapping function, thus realizing the decoupling of the protocol description and the internal parameter; a plurality of variables and mapping functions are realized through description subfiles for describing the corresponding relation between different protocol fields and the variables, and a user writes the description subfiles of the protocols, so that the files can share one set of variables, and the variables are uniquely corresponding to configuration data, so that the uniqueness of the equipment state is ensured, the synchronization problem caused by the introduction of a plurality of sets of data is avoided, and the data real-time performance is good. In the prior art, protocols are independently realized, different protocols analyze a set of configuration data, the problem that one configuration data corresponds to a plurality of variables and a plurality of variable processing mapping functions and the plurality of variables need to be processed, and otherwise, the problem that the data and the protocols are not matched due to the asynchronous variables when the plurality of protocols are operated simultaneously occurs.
The output parameters of the water meter ammeter are generated by a set of variables which are not coincident, for example, a collection timestamp, a meter number, a current counting value, a meter state, an error number and the like can be shared, the power reading of the ammeter and the flow reading of the water meter need to be stored by two different variables, internal data are determined by a developer, and are packaged into a protocol format requested by a party according to a description sub-configuration file during output, for example, all water meters of 400 families of a building are hung below a concentrator, two different protocols are needed to read data below the concentrator, different report protocols of an ammeter company and a water meter company need to be connected above, generally speaking, query datagrams are constructed regularly, water and ammeter data are read and stored in a local database, who at the upper end queries and feeds back to whom, and the protocols are guaranteed to be corresponding when the datagrams are interacted.
2. On the basis of realizing a protocol structure, an interface is provided for service logic by using the flexibility of a mapping function, different service logics can be realized by describing different mapping functions, so that different protocols have different service logics under the same service framework; by modifying/replacing the descriptor, the field of the original protocol can be changed by modifying the organization form of the field set, and the protocol can be modified according to the configuration parameters; the method and the system are convenient for dynamically updating, increasing or reducing the protocol, only the public protocol description file and the corresponding mapping function module need to be updated in the updating process, other programs do not need to be changed, the logic of the main program does not need to be updated, the updating is simple, and the safety is good.
3. The protocol description mode provided by the invention has good portability, and the protocol can be analyzed according to the description subfile as long as a platform capable of analyzing the text can analyze the protocol; the expandability is strong, and when the description sub-attribute needs to be added, only the corresponding attribute processing mapping function needs to be added.
4. The protocol development only needs to pay attention to describing the protocol, so that developers who have to know the embedded operating system and the underlying mapping function interface codes can modify the protocol only by using a configuration file or a script language, and development difficulty is low. Each unit field of the protocol has a descriptor description, maintenance and modification only need to pay attention to a few descriptors and mapping functions, and maintenance cost is low.
Taking the practical development of a concentrator compatible with a certain ammeter protocol and a certain water meter protocol on an embedded linux system as an example, the ammeter protocol has 13 typical instructions and 23 data description formats and is used in combination according to function codes, and the water meter protocol has 8 instructions and 12 data description formats and is used in combination according to the function codes. By adopting a direct development mode, because the logic frameworks of the water meter protocol and the electric meter protocol are different, a service logic framework needs to be developed independently aiming at different protocol flows, in the embodiment, two sets of independent service logics are needed, code processing needs to be carried out on each condition, developers need to have linux bottom layer development capability and familiarity with protocol instruction and data description formats at the same time, maintenance and updating of the protocols need to carry out corresponding program development and need to be carried out by the personnel who are familiar with both bottom layer development and protocol contents, the development and maintenance difficulty and cost are high, and the period is generally calculated according to months. By adopting the method, a set of service calling logic is needed by using the description subfile to describe the relationship between the protocol field, the calling mapping function and the internal variable, a person with protocol development capability is needed to write a protocol description file, a developer with linux bottom layer development capability is needed to write a descriptor resolving module for resolving the description subfile, a calling interface is provided for the general service logic module to call, specific protocols do not need to be distinguished, the specific service logic is defined by a plurality of descriptors in the description subfile to be equal to the water meter service logic or the electric meter service logic, the developer does not need to have the linux bottom layer development capability and the protocol development capability at the same time, and the development difficulty is reduced; on the other hand, the protocol is maintained and updated without rewriting a protocol logic framework, only the description subfile and the corresponding mapping function module need to be changed, the maintenance and the update are simple, the cost is low, and the maintenance period can be shortened to a week or even a day.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (8)

1. A descriptor-based protocol message and data interaction method is characterized by specifically comprising the following steps:
the communication main body runs a service logic cycle of receiving messages, analyzing messages, updating data, generating messages and sending messages;
the interface module in the communication main body receives data messages from different data interfaces or outputs the output messages of the protocol module from a specified interface;
the protocol module in the communication body comprises one or more descriptor files, each descriptor file comprises one or more descriptors, each descriptor is used for describing the mapping relation between a unit field and a data parameter of a protocol and providing an interface for service logic by using the flexibility of a mapping function, and the protocol module calls the corresponding mapping function according to the description of the descriptor to complete the interaction of a protocol message and the data parameter;
and the service module in the communication main body completes the service logic of the communication main body and completes the update of the data or the protocol message.
2. The descriptor-based protocol packet and data interaction method according to claim 1, wherein the protocol packet and data parameter interaction specifically comprises:
s1, search field set: searching a field set in a descriptor file corresponding to the current protocol according to the field set name in the configuration data parameter, wherein the field set consists of one or more descriptors;
s2, analyzing the field set: checking descriptor elements in a field set in sequence, expanding the descriptor elements belonging to the current protocol field set in sequence, reading each descriptor element of the field set in sequence, wherein each descriptor comprises a function name, a module name, a bit number, a default value and an attribute, the bit number of the descriptor strictly defines that a variable is positioned in a certain section of a protocol message, acquiring a mapping function handle according to the module name and the function name, sequentially enqueuing the mapping function handles in sequence to form a descriptor mapping function handle queue, completing dynamic loading of a mapping function module, and acquiring a mapping function pointer;
s3, sequentially calling each mapping function in the descriptor mapping function handle queue, wherein the mapping function takes the current descriptor content, data parameter and message buffer as parameters to complete the interaction between the protocol message and the data parameter.
3. The descriptor-based protocol packet and data interaction method according to claim 1 or 2, wherein the step S3 specifically is:
s31, judging whether the current field needs to be processed according to the state information in the data parameter; if the processing is not needed, skipping the field and processing the next field; if the message needs to be processed, calculating a start-stop interval of the current field in the message buffer by taking the bit as a unit according to the bit length attribute in the descriptor, and recording the start-stop interval as the current field interval;
s32, determining the logic direction according to the logic direction information in the data; if the current logic direction is that the message information is updated to the data, intercepting the data of the current field interval in a binary system form, converting the data into a variable with the same format as the corresponding parameter in the data, assigning the variable to the corresponding parameter in the data, and finishing the data updating; if the current logic direction is that the data is packed into a message according to a protocol, converting the corresponding parameters in the data into a binary bit sequence, filling the current field interval by using the bit sequence in the binary bit sequence, and discarding redundant bits to finish the updating of the message.
4. The method according to claim 1, wherein a field set in the same descriptor file supports cross-referencing, and an element of a field set can be another field set; meanwhile, the elements in the field set are arranged in sequence, which corresponds to the sequence of the protocol message data.
5. The method according to claim 1, wherein the element field of the protocol is an indivisible minimum protocol field.
6. The descriptor-based protocol packet and data interaction method according to claim 1, wherein the protocol module encapsulates description files of different protocols in different files for the protocol module to parse, and encapsulates mapping functions in different module files according to functions or categories or protocols for the protocol module to call.
7. The descriptor-based protocol packet and data interaction method according to claim 1, wherein the communication subject is a concentrator or a repeater in an intermediate layer of a network.
8. A descriptor-based protocol message and data interaction system is characterized by comprising:
the communication main body is used for operating a service logic cycle of receiving messages, analyzing messages, updating data, generating messages and sending messages; the communication main body comprises an interface module, a service module and a protocol module;
the interface module is used for receiving data messages from different data interfaces or outputting output messages of the protocol module from a specified interface;
the protocol module is used for calling a corresponding mapping function according to the description of the descriptor to complete the interaction of the protocol message and the data parameter; the protocol module comprises one or more description subfiles and one or more mapping function modules; each descriptor file comprises one or more descriptors, and the descriptors are used for describing the mapping relation between the unit field of the protocol and the data parameters and providing an interface for service logic by using the flexibility of a mapping function;
and the service module is used for finishing the service logic of the communication main body and finishing the updating of the data or the protocol message.
CN202010141120.9A 2020-03-04 2020-03-04 Descriptor-based protocol message and data interaction method and system Active CN111385292B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010141120.9A CN111385292B (en) 2020-03-04 2020-03-04 Descriptor-based protocol message and data interaction method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010141120.9A CN111385292B (en) 2020-03-04 2020-03-04 Descriptor-based protocol message and data interaction method and system

Publications (2)

Publication Number Publication Date
CN111385292A true CN111385292A (en) 2020-07-07
CN111385292B CN111385292B (en) 2022-08-16

Family

ID=71221401

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010141120.9A Active CN111385292B (en) 2020-03-04 2020-03-04 Descriptor-based protocol message and data interaction method and system

Country Status (1)

Country Link
CN (1) CN111385292B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112883691A (en) * 2021-02-19 2021-06-01 四川腾盾科技有限公司 Unmanned aerial vehicle telemetry data protocol conversion method and system and data use method
CN113721577A (en) * 2021-11-02 2021-11-30 西安热工研究院有限公司 Data interaction method and system, equipment and storage medium for multitask cycle
CN115857420A (en) * 2023-03-03 2023-03-28 深圳市综科智控科技开发有限公司 IO (input/output) mutual control method between industrial control equipment
CN116719871A (en) * 2023-06-29 2023-09-08 上海中汇亿达金融信息技术有限公司 Data interaction method, device and system of transaction management system

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6879682B1 (en) * 2002-09-26 2005-04-12 Bellsouth Intellectual Property Corporation AIN to ISDN message mapping for intelligent peripheral service enhancement
CN102546442A (en) * 2012-03-09 2012-07-04 北京神州数码思特奇信息技术股份有限公司 Communication protocol conversion technology
CN106657149A (en) * 2017-01-24 2017-05-10 恒生电子股份有限公司 Communication protocol conversion method and device
CN108040040A (en) * 2017-11-30 2018-05-15 北京锐安科技有限公司 A kind of automation analysis method and device of application protocol message
CN108540477A (en) * 2018-04-13 2018-09-14 腾讯科技(成都)有限公司 The method and relevant device of data communication
CN109525364A (en) * 2018-10-30 2019-03-26 北京计算机技术及应用研究所 A kind of telecommunication data protocol generalization based on XML describes method
CN109768970A (en) * 2018-12-24 2019-05-17 通号通信信息集团有限公司 It is a kind of based on configurable puppy parc generation method
CN110719296A (en) * 2019-10-25 2020-01-21 福建网能科技开发有限责任公司 Method for automatically analyzing message data in terminal communication protocol
CN110839046A (en) * 2019-12-03 2020-02-25 睿哲科技股份有限公司 Multi-protocol intercommunication method and system

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6879682B1 (en) * 2002-09-26 2005-04-12 Bellsouth Intellectual Property Corporation AIN to ISDN message mapping for intelligent peripheral service enhancement
CN102546442A (en) * 2012-03-09 2012-07-04 北京神州数码思特奇信息技术股份有限公司 Communication protocol conversion technology
CN106657149A (en) * 2017-01-24 2017-05-10 恒生电子股份有限公司 Communication protocol conversion method and device
CN108040040A (en) * 2017-11-30 2018-05-15 北京锐安科技有限公司 A kind of automation analysis method and device of application protocol message
CN108540477A (en) * 2018-04-13 2018-09-14 腾讯科技(成都)有限公司 The method and relevant device of data communication
CN109525364A (en) * 2018-10-30 2019-03-26 北京计算机技术及应用研究所 A kind of telecommunication data protocol generalization based on XML describes method
CN109768970A (en) * 2018-12-24 2019-05-17 通号通信信息集团有限公司 It is a kind of based on configurable puppy parc generation method
CN110719296A (en) * 2019-10-25 2020-01-21 福建网能科技开发有限责任公司 Method for automatically analyzing message data in terminal communication protocol
CN110839046A (en) * 2019-12-03 2020-02-25 睿哲科技股份有限公司 Multi-protocol intercommunication method and system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112883691A (en) * 2021-02-19 2021-06-01 四川腾盾科技有限公司 Unmanned aerial vehicle telemetry data protocol conversion method and system and data use method
CN113721577A (en) * 2021-11-02 2021-11-30 西安热工研究院有限公司 Data interaction method and system, equipment and storage medium for multitask cycle
CN115857420A (en) * 2023-03-03 2023-03-28 深圳市综科智控科技开发有限公司 IO (input/output) mutual control method between industrial control equipment
CN116719871A (en) * 2023-06-29 2023-09-08 上海中汇亿达金融信息技术有限公司 Data interaction method, device and system of transaction management system
CN116719871B (en) * 2023-06-29 2024-03-19 上海中汇亿达金融信息技术有限公司 Data interaction method, device and system of transaction management system

Also Published As

Publication number Publication date
CN111385292B (en) 2022-08-16

Similar Documents

Publication Publication Date Title
CN111385292B (en) Descriptor-based protocol message and data interaction method and system
CN101893662B (en) Nuclear phase method for digital transformer substation
CN101651683B (en) Method for generating analysis source code of signaling message
US9864346B2 (en) Method for connecting a substation automation device according to IEC61850 to any industry automation field bus
CN103593326A (en) IEC61850 software library assembly for network processing unit chip and achieving method of IEC61850 software library assembly
CN103136107A (en) Variable debugging method of embedded program dynamic storage allocation
CN109194617A (en) The automatically parsing of XML message, packaging method and device
CN100511149C (en) Logic emulation testing system and method
CN100561476C (en) A kind of code generating method based on the ASN type object
CN113065314B (en) BIOS hardware adaptation method and device based on XML file format
CN113028603A (en) Equipment monitoring system applied to central air-conditioning system
CN112068808A (en) General processing system for multi-bus data conversion of avionics system
CN101312580B (en) Straight-forward station monitoring center and straight-forward station monitoring method
CN107483284A (en) The method of testing and device of the network equipment
CN114510357A (en) Satellite launching field test identification service message interaction method and system
CN113448590A (en) Method and device for quickly generating remote control injection data, computer equipment and medium
CN113505054A (en) Network data static test system and test method for unmanned aerial vehicle control station
CN103633736A (en) Online monitoring communication method from substation sub station to main station
CN112235316A (en) Data communication method for instrument integration
CN109656622A (en) A kind of packaging method for realizing network tester in communication equipment automatic test
CN115328679A (en) Automatic integration method of heterogeneous function library, computing equipment and system thereof
CN114115832A (en) Internet of things embedded equipment and cloud platform communication protocol implementation method
CN114116900A (en) Efficient trading system and development method based on MDD model
CN108305161A (en) A kind of paying taxes service interface carding method and device
CN109240672B (en) Artificial intelligence writing method for information transmission source code of single machine component of digital aircraft

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant