Edge protocol data processing method and system
Technical Field
The invention relates to the technical field of edge data processing, in particular to an edge protocol data processing method and an edge protocol data processing system.
Background
With the development of more and more edge terminal computing products, the edge computing of the internet of things system becomes more and more important. On the basis of the original basic communication protocol or the simple hardware protocol of the terminal, the special data interaction between the products is realized, the standard protocol is not the existing standard protocol, the data interaction of the terminal products has poor reusability and weak portability in the original software design framework, and the life cycle is short, so that each time a new terminal product is developed, the data interaction, the forwarding and the collection of the data between different ports can bring new difficulty in rewriting codes in software realization, the difficulty of adding different analysis protocols is increased, and the development period of the product is prolonged.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a method and a system for processing edge protocol data, which have the advantages of high reusability and good portability, and break through the bottleneck of forwarding and collecting different protocol data writing complexity of different ports of different terminal products.
In order to solve the technical problems, the invention is solved by the following technical scheme:
an edge protocol data processing method and system, comprising the following steps:
initializing a protocol interface and a configuration file of a communication interface to obtain an acquisition channel and a forwarding channel, and obtaining received data of the communication interface;
storing the received data into a receiving buffer area, and performing data characteristic splicing to obtain preprocessed data I;
judging the integrity of the first preprocessed data, and carrying out data marking on the complete first preprocessed data to obtain receiving queue data;
analyzing the receiving queue data, judging a packaging protocol of data packaging according to an analysis result, and packaging to obtain packaging data;
and inserting the encapsulated data into an acquisition channel or a forwarding channel to obtain channel data, performing transmission pretreatment on the channel data to obtain pretreated data II, and transmitting the pretreated data II through a communication interface.
Optionally, initializing a protocol interface and a configuration file of the communication interface to obtain an acquisition channel and a forwarding channel, including the following steps:
acquiring a protocol interface and a configuration file of a communication interface, and initializing the protocol interface and the configuration file to obtain an initialized protocol interface and an initialized configuration file;
and defining an acquisition channel and a forwarding channel according to the initialization protocol interface and the initialization configuration file.
Optionally, storing the received data in a receiving buffer area, and performing data feature splicing to obtain preprocessed data one, including the following steps:
reading a terminal communication port configuration protocol for receiving data, and acquiring a characteristic header field, a command field, a data length field and a characteristic tail field of the terminal communication port configuration protocol;
and splicing the characteristic header field, the command field, the data length field and the characteristic tail field in sequence to obtain preprocessed data one.
Optionally, determining the integrity of the preprocessed data one includes the following steps:
checking whether the preprocessed data I contains a characteristic header field, a command field, a data length field and a characteristic tail field;
if yes, preprocessing the data to be complete; if not, the data is incomplete with the mathematical data.
Optionally, determining the integrity of the preprocessed data one further includes the following steps:
if the preprocessed data is complete, marking the preprocessed data;
and if the preprocessed data is incomplete, re-acquiring the received data of the communication interface.
Optionally, the step of performing data marking on the complete preprocessed data to obtain receiving queue data includes the following steps:
marking the first preprocessed data according to the receiving channel of the first preprocessed data to form receiving queue data.
Optionally, parsing the receive queue data includes the following steps:
and acquiring one frame of data in the receiving queue data, and analyzing commands, states, actions and data attributes contained in the one frame of data by adopting a call analysis method.
Optionally, judging a packaging protocol of the data package according to the analysis result and packaging to obtain packaging data, including the following steps:
and judging the data to be transmitted according to the command, the state, the action and the data attribute of the frame of data, and encapsulating the data segment of the transmitted data according to a transmission protocol to obtain encapsulated data.
Optionally, the channel data is sent and preprocessed to obtain preprocessed data two, which comprises the following steps:
and acquiring a channel protocol characteristic header and a check field of the acquisition channel or the forwarding channel, and adding the channel protocol characteristic header and the check field into channel data to obtain preprocessed data II.
An edge protocol data processing system comprises an initialization module, a data receiving and transmitting module, a preprocessing module, a checking module, an analysis module and a packaging module;
the initialization module is used for initializing a protocol interface and a configuration file of the communication interface to obtain an acquisition channel and a forwarding channel;
the data receiving and transmitting module is used for acquiring the received data of the communication interface and transmitting the preprocessed data II;
the preprocessing module is used for performing data characteristic splicing on the received data stored in the receiving buffer area to obtain preprocessed data I, and is also used for performing transmission preprocessing on the channel data to obtain preprocessed data II;
the verification module is used for judging the integrity of the first preprocessed data, and carrying out data marking on the complete first preprocessed data to obtain receiving queue data;
the analysis module is used for analyzing the receiving queue data;
and the packaging module is used for judging a packaging protocol of the data package according to the analysis result and packaging the data package to obtain package data.
Compared with the prior art, the technical scheme provided by the invention has the following beneficial effects:
the common data acquisition protocol is updated to a modularized mode for processing, the processing content and mode of each module are set according to analysis rules, the problems of poor reusability, poor portability and short life cycle of an edge computing terminal product data interaction system are solved, when an edge intelligent multi-protocol analysis terminal product or data interaction with a new product terminal product is developed, the original data interaction is changed from inaccurate to incomplete to more accurate and more complete, the efficiency of protocol docking is improved, the writing period and the debugging period of software are shortened, the lead time of the product is shortened, and meanwhile, the problem of complexity in writing data of different protocols forwarded and acquired by different ports of different terminal products is solved, and on the other hand, the data acquisition of different communication ports, different terminal protocols and different terminal objects can be compatible, so that the complex data docking is simplified, transparent and efficient.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained according to these drawings without inventive faculty for a person skilled in the art.
Fig. 1 is a flowchart of a method and a system for processing edge protocol data according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the following examples, which are illustrative of the present invention and are not intended to limit the present invention thereto.
As shown in fig. 1, a method and a system for processing edge protocol data include the following steps: initializing a protocol interface and a configuration file of a communication interface to obtain a collection channel and a forwarding channel, acquiring received data of the communication interface, specifically acquiring the protocol interface and the configuration file of the communication interface, and initializing the protocol interface and the configuration file to obtain an initialized protocol interface and an initialized configuration file; according to the initialization protocol interface and the initialization configuration file, an acquisition channel and a forwarding channel are defined, and after the initialization is completed, the data of the channels of different communication hardware are read by calling the thread task of the operating system.
Storing the received data into a receiving buffer area, and performing data characteristic splicing to obtain preprocessed data I, wherein the method comprises the following steps: reading a terminal communication port configuration protocol for receiving data, and acquiring a characteristic header field, a command field, a data length field and a characteristic tail field of the terminal communication port configuration protocol; sequentially splicing the characteristic header field, the command field, the data length field and the characteristic tail field to obtain preprocessed data one
Because the operating system generates different reading or sending results in different operation processes of different communication parameters on different hardware interfaces, the terminal communication port configuration protocol of the received data needs to be read, and simultaneously, a unique and complete frame of data is obtained by sequentially splicing the characteristic header field, the command field, the data length field and the characteristic tail field, namely the preprocessed data one is distinguished.
Judging the integrity of the first preprocessed data, and carrying out data marking on the first preprocessed data to obtain receiving queue data, wherein the judging the integrity of the first preprocessed data comprises the following steps: checking whether the preprocessed data I contains a characteristic header field, a command field, a data length field and a characteristic tail field; if yes, preprocessing the first data completely, and marking the first preprocessed data; if not, the data is not completely preprocessed, and the received data of the communication interface is acquired again.
Judging the integrity of the first preprocessed data, judging whether the first preprocessed data contains a characteristic header field, a command field, a data length field and a characteristic tail field, if any one of the parameters is lacked, representing the first preprocessed data is incomplete, and re-acquiring the received data until the first preprocessed data is complete with the first mathematical data.
The method comprises the following steps of: the first preprocessing data is marked according to the receiving channel of the first preprocessing data to form receiving queue data, specifically, the first preprocessing data can be marked according to whether the first preprocessing data is the first preprocessing data which needs to be repeatedly sent, which channel the first preprocessing data is received from and which channel the first preprocessing data needs to be sent to, so as to obtain the receiving queue data.
Analyzing the received queue data, comprising the following steps: and acquiring one frame of data in the receiving queue data, analyzing the command, the state, the action and the data attribute covered in the one frame of data by adopting a call analysis method, judging whether to confirm forwarding of the receiving queue data or not according to the command, the state, the action and the data attribute, and judging a forwarding channel.
Judging a packaging protocol of the data package according to the analysis result and packaging to obtain packaging data, wherein the method comprises the following steps: and judging the data to be transmitted according to the command, the state, the action and the data attribute of one frame of data, and encapsulating the data segment of the transmitted data according to a transmission protocol to obtain encapsulated data.
Inserting the packaged data into an acquisition channel or a forwarding channel to obtain channel data, performing transmission pretreatment on the channel data to obtain pretreated data II, and transmitting the pretreated data II through a communication interface, wherein the transmission pretreatment is performed on the channel data to obtain pretreated data II, and the method comprises the following steps of: and acquiring a channel protocol characteristic header and a check field of the acquisition channel or the forwarding channel, and adding the channel protocol characteristic header and the check field into channel data to obtain preprocessed data II.
After the second preprocessing data is obtained, the second preprocessing data is transmitted through the communication interface, if the repeated transmission is needed or whether the frame transmission is correct or not is judged, whether the frame is confirmed or not is judged, and the second preprocessing data is used for retransmission here, and finally, a unified communication transmission interface which is packaged by the operating system is called to finish the transmission.
An edge protocol data processing system comprises an initialization module, a data receiving and transmitting module, a preprocessing module, a checking module, an analysis module and a packaging module; the initialization module is used for initializing a protocol interface and a configuration file of the communication interface to obtain an acquisition channel and a forwarding channel; the data receiving and transmitting module is used for acquiring the received data of the communication interface and transmitting the preprocessed data II; the preprocessing module is used for performing data characteristic splicing on the received data stored in the receiving buffer area to obtain preprocessed data I, and is also used for performing transmission preprocessing on the channel data to obtain preprocessed data II; the verification module is used for judging the integrity of the first preprocessed data, and carrying out data marking on the first preprocessed data to obtain receiving queue data; the analysis module is used for analyzing the received queue data; and the packaging module is used for judging a packaging protocol of the data package according to the analysis result and packaging the data package to obtain package data.
In this embodiment, the communication interface is composed of different hardware interfaces, such as a serial interface, a network interface, a CAN interface, and the like, and may have unified packages of hardware driving interfaces maintained by different operating systems, and the data transceiver module is configured to receive data sent from the terminal to the acquisition port, send data of a command for executing the terminal, receive data sent from the upper device to the forwarding port, send data converted from the terminal, implement data receiving or sending, and implement sending processing of data according to byte installation blocks by calling unified interfaces of different operating systems.
The preprocessing module is that the operating system generates different reading or sending results in the operation process of different communication parameters on different hardware interfaces and different lines, for example, all data are commonly read in frames, all the data are sent in frames, the read data are spliced, and according to a protocol configured by a terminal communication port, the complete frame of data of the configured protocol is spliced through a characteristic header field, a command field, a data length field, a characteristic tail field and the like in the protocol.
The checking module works in different protocol layers, performs checking judgment on data received from the terminal according to different configured protocols, such as CRC16 checking of Modbus protocol, IEC101 checking and the like, performs checking on data sent to the terminal according to different configured protocols, performs checking on the data according to different protocols, and adds the data to a checking field of a data frame.
The package module group is a receiving queue and a transmitting queue, and is used for queuing all correctly received data and marking special data description marks, such as whether repeated data frames need to be transmitted or not, which channel the received data come from is used for confirming which channel the data transmission is completed, and the data is placed at a certain position in the queue head or the queue by using a designed and completed queue method according to the emergency degree of the data, so that the data can be processed more quickly.
The analysis module analyzes the data frame of the queue data, extracts the characteristics of the data, such as tasks of state, command, display, action and the like, and further processes the data by initializing which channel is configured as an acquisition channel and which channel is configured as a forwarding channel, and then judging whether the data is confirmed, forwarded and the like according to the extracted data description.
In this embodiment, the system further includes a state monitoring module, configured to monitor state information, such as whether a communication link of the terminal is normal, an indication of a heartbeat, an operation failure of the terminal, and the like, where the information is feedback between communication interfaces, such as a representation of some information generated by hardware, and feedback between parsing units, such as information state transfer between protocol interactions.
In addition, the specific embodiments described in the present specification may differ in terms of parts, shapes of components, names, and the like. All equivalent or simple changes of the structure, characteristics and principle according to the inventive concept are included in the protection scope of the present invention. Those skilled in the art may make various modifications or additions to the described embodiments or substitutions in a similar manner without departing from the scope of the invention as defined in the accompanying claims.