CN111913905A - Variable self-adaptive serial port communication method, medium and electronic equipment - Google Patents

Variable self-adaptive serial port communication method, medium and electronic equipment Download PDF

Info

Publication number
CN111913905A
CN111913905A CN202010613405.8A CN202010613405A CN111913905A CN 111913905 A CN111913905 A CN 111913905A CN 202010613405 A CN202010613405 A CN 202010613405A CN 111913905 A CN111913905 A CN 111913905A
Authority
CN
China
Prior art keywords
data
data frame
parameter
value
communication protocol
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.)
Pending
Application number
CN202010613405.8A
Other languages
Chinese (zh)
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.)
AECC South Industry Co Ltd
Original Assignee
AECC South Industry 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 AECC South Industry Co Ltd filed Critical AECC South Industry Co Ltd
Priority to CN202010613405.8A priority Critical patent/CN111913905A/en
Publication of CN111913905A publication Critical patent/CN111913905A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter

Abstract

The invention discloses a variable self-adaptive serial port communication method, medium and equipment, wherein the method comprises the following steps: the sending system sends a data frame based on a variable self-adaptive serial port communication protocol, and carries out corresponding assignment on a marker used for identifying the matching state of parameter data in the sent data frame according to whether the data in the current data frame to be sent is different from the data in the historical data frame before sending; and the receiving system receives the data frame and reads the value of the identifier in the data frame, if the difference exists according to the value of the identifier, the data type in the received data frame is matched with the parameter type in a preset parameter library, and after the matching is finished, the data is transmitted and processed according to the communication protocol of the fixed data frame structure and the content. The invention reduces the workload of system updating when the transmission parameters are changed, ensures the effectiveness and convenience of the serial communication transmission parameter types, reduces the updating cost and has better engineering popularization and application value.

Description

Variable self-adaptive serial port communication method, medium and electronic equipment
Technical Field
The present invention relates to the field of serial interface digital communication, and in particular, to a variable adaptive serial communication method, medium, and electronic device.
Background
The information interaction among the aircraft engine control system, the aircraft engine health monitoring unit and the aircraft engine ground maintenance system is usually realized by adopting a serial port communication mode (such as RS232, RS485 or RS422 serial interfaces). The aero-engine system has various types and numbers of engine parameters, the working state of the engine is complicated, and parameter data interacted between different types and purposes of engine electronic equipment through serial port communication can be increased or reduced frequently in order to meet the change of design requirements. However, the currently commonly used serial communication protocol is a fixed data frame structure and content, including a data frame header, a frame length, a frame data content, and a frame check word/frame tail. In order to adapt to the increase of data content in a communication frame, enough backup data words need to be reserved when a serial port communication protocol is designed so as to adapt to the increase of communication interactive data, and further, the reserved backup data words are allocated for caching when a serial port in engine electronic equipment receives and analyzes a communication data frame, so that storage space is wasted, and redundant memory is occupied. If the reserved backup data words are not enough, the frame length of the serial port communication protocol needs to be changed, the frame structure needs to be redefined, the software code needs to be changed, the program needs to be debugged and rewritten, the workload of software design and implementation is increased, and the software development progress and the software development cost can be further influenced.
Disclosure of Invention
The invention provides a variable self-adaptive serial port communication method, which aims to solve the technical problems that the content of a communication data frame is changed and the change of a fixed communication protocol needs larger workload, which are caused by the fact that the structure and the content of the fixed data frame cannot be quickly adapted to the change of design requirements.
The technical scheme adopted by the invention is as follows:
a variable adaptive serial port communication method comprises the following steps:
the sending system sends a data frame based on a variable self-adaptive serial port communication protocol, and carries out corresponding assignment on a marker used for identifying the matching state of parameter data in the sent data frame according to whether the data in the current data frame to be sent is different from the data in the historical data frame before sending;
and the receiving system receives the data frame and reads the value of the identifier in the data frame, if the difference exists according to the value of the identifier, the data type in the received data frame is matched with the parameter type in a preset parameter library, after the matching is finished, the data is transmitted and analyzed according to the communication protocol of the fixed data frame structure and the content, and the parameter library comprises all appointed parameter types which are transmitted to the receiving system by the transmitting system through serial communication.
Further, the format of the variable adaptive serial communication protocol specifically includes:
a data frame header SyncWord and a frame check word Checksun;
the data length Number is used for marking the total data Number of data word contained in the current communication protocol;
the data state Status is used for identifying the matching state of the data DataWord and the parameter types in the parameter database;
position, which is used to identify the position of data DataWord to be matched in the current data frame;
the parameter ElementID is used for identifying a corresponding parameter ElementID in the parameter library, and the Position of the parameter in the communication protocol is the Position pointed by the Position;
and a plurality of data words for identifying the data transmitted in the current data frame.
Further, the parameter library stores a parameter ElementID and a parameter type corresponding to the parameter ElementID one by one.
Further, the parameter library also stores the parameter ElementID and the corresponding parameter type in groups according to the set rule.
Further, the format of the variable adaptive serial communication protocol further includes:
and the data Flag is used for identifying that the data DataWord in the current data frame corresponds to the grouping category in the parameter base.
Further, before the sending system sends the data frame based on the variable self-adaptive serial port communication protocol, the method also comprises the following steps:
establishing a communication relation between a sending system and a receiving system according to the requirement of a serial interface, and configuring port attributes including a baud rate, parity check, a data bit and a stop bit.
Further, the receiving system receives the data frame and reads the value of the identifier in the data frame, if the difference exists according to the value of the identifier, the data type in the received data frame is matched with the parameter type in a preset parameter library, and after the matching is completed, the data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content specifically comprises the following steps:
if a data packet is sent, receiving an ith data frame;
reading the value of a data state Status in the ith data frame, and judging whether the data in the ith data frame is different from the data in the historical data frame or not according to the value of the data state Status;
if the difference exists, reading the value of the position in the ith data frame, and determining the position of the data DataWord needing to be matched in the current data frame;
reading data DataWord corresponding to the value of the position;
reading a parameter ElementID corresponding to the value of the position in the ith data frame;
searching the parameter type in the parameter library according to the parameter ElementID;
matching data DataWord in the ith data frame with the parameter types in the parameter library;
repeating the steps until the matching of all data DataWord in all data frames is completed;
and after matching, carrying out data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content.
Further, the receiving system receives the data frame and reads the value of the identifier in the data frame, if the difference exists according to the value of the identifier, the data type in the received data frame is matched with the parameter type in a preset parameter library, and after the matching is completed, the data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content specifically comprises the following steps:
if a data packet is sent, receiving an ith data frame;
reading the value of a data state Status in the ith data frame, and judging whether the data in the ith data frame is different from the data in the historical data frame or not according to the value of the data state Status;
if the difference exists, reading the value of the position in the ith data frame, and determining the position of the data DataWord needing to be matched in the current data frame;
reading data DataWord corresponding to the value of the position;
reading the parameter ElementID corresponding to the value of the data Flag and the value of the position in the ith data frame;
searching the parameter type in the parameter library according to the data Flag and the parameter ElementID;
matching data DataWord in the ith data frame with the parameter types in the parameter library;
repeating the steps until the matching of all data DataWord in all data frames is completed;
and after matching, carrying out data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content.
According to another aspect of the present invention, there is also provided a storage medium, where the storage medium includes a stored program, and when the program runs, the storage medium controls a device in which the storage medium is located to execute the variable adaptive serial port communication method.
According to another aspect of the present invention, there is also provided an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the variable adaptive serial communication method when executing the program.
The invention has the following beneficial effects:
the invention realizes the variable self-adaptive communication of the data frame by setting the variable self-adaptive serial communication protocol, the parameter library and the parameter matching process based on the protocol and the parameter library, when the parameter in the serial communication changes according to the change of the design requirement, the parameter change in the serial communication protocol can be realized only by adjusting the content parameter of the communication data frame or the corresponding software of one of the receiving system or the sending system, thereby avoiding the larger workload of simultaneously changing the communication protocol and the software by the receiving system and the sending system, not only ensuring the effectiveness and the convenience of the serial communication transmission parameter type, but also reducing the workload, improving the updating speed and having better engineering popularization and application value.
In addition to the objects, features and advantages described above, other objects, features and advantages of the present invention are also provided. The present invention will be described in further detail below with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the invention and, together with the description, serve to explain the invention and not to limit the invention.
In the drawings:
fig. 1 is a schematic flow chart of a variable adaptive serial communication method according to a preferred embodiment of the present invention.
FIG. 2 is a schematic diagram of the components of a variable adaptive serial communication protocol according to a preferred embodiment of the present invention;
fig. 3 is a schematic diagram of a parameter library of the preferred embodiment of the present invention.
Fig. 4 is a schematic diagram of the parameter matching process of the receiving system according to the preferred embodiment of the present invention.
Fig. 5 is a schematic diagram of a parameter matching process of the receiving system according to another preferred embodiment of the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present invention will be described in detail below with reference to the embodiments with reference to the attached drawings.
Referring to fig. 1, a preferred embodiment of the present invention provides a variable adaptive serial port communication method, including the steps of:
s1, the sending system sends data frames based on the variable self-adaptive serial port communication protocol, and carries out corresponding assignment on the identifier used for identifying the parameter data matching state in the sent data frames according to whether the difference exists between the data in the current data frames to be sent and the data in the historical data frames before sending, for example, if the difference exists, the identifier is assigned with 0, otherwise, the identifier is assigned with 1;
and S2, the receiving system receives the data frame and reads the value of the identifier in the data frame, if the difference exists according to the value of the identifier, for example, the value of the read identifier is 0, the data type in the received data frame is matched with the parameter type in a preset parameter library, and after the matching is finished, the data is transmitted and analyzed according to the communication protocol of the fixed data frame structure and the content, wherein the parameter library comprises all appointed parameter types which are transmitted to the receiving system by the transmitting system through serial communication.
The variable adaptive serial communication method of the embodiment realizes the variable adaptive communication of the data frame by setting the variable adaptive serial communication protocol, the parameter library and the parameter matching process based on the protocol and the parameter library in the receiving system, and when the parameters in the serial communication change according to the change of the design requirement, the parameter change in the serial communication protocol can be realized only by adjusting the content parameters of the communication data frame of one of the receiving system or the sending system or corresponding software, thereby avoiding the larger workload of simultaneously changing the communication protocol and the software by the receiving system and the sending system, ensuring the effectiveness and the convenience of the type of the serial communication transmission parameters, reducing the workload, improving the system maintenance and the adjusting speed, and having better engineering popularization and application values.
The embodiment can be applied to a plurality of serial port communication transmission systems, such as between an aircraft engine control system and an aircraft engine health monitoring unit, and can also be applied to parameter data transmission between the aircraft engine ground maintenance system and the aircraft engine control system, the aircraft engine ground maintenance system can self-adaptively receive parameters transmitted by the aircraft engine control system through a serial port, and display the parameters after correct analysis, so that the aircraft engine ground maintenance system and software codes of the control system of the aircraft engine ground maintenance system are prevented from being changed along with the change of parameter data transmitted by the serial port of the engine control system, the safety and the reliability of the aircraft engine control system are effectively guaranteed, and the aircraft engine ground maintenance system has a very high practical application.
As shown in fig. 2, in a preferred embodiment of the present invention, the format of the variable adaptive serial communication protocol specifically includes:
the data frame head SyncWord and the frame check word Checksun are respectively arranged at the frame head and the frame tail;
the data length Number is used for marking the total data Number of data word contained in the current communication protocol;
the data state Status is used for identifying the matching state of the data DataWord and the parameter types in the parameter database;
the position is used for identifying the position of the data DataWord to be matched in the current data frame, specifically, the state of the position is determined by a sending system, if the data DataWord is matched for the first time, traversal of all the data datawords needs to be completed, and at the moment, the position of the next data frame is added with 1; if the sending system only changes the parameter matching of one or more datawords, the position of the next data frame points to the position of the next DataWord needing to be matched, and the parameter matching of the DataWord is completed through one or more data frames.
A data Flag for identifying that the data DataWord in the current data frame corresponds to a grouping category in the parameter base;
the parameter ElementID is used for identifying a corresponding parameter ElementID in the parameter library, and the Position of the parameter in the communication protocol is the Position pointed by the Position;
and the data DataWord is used for identifying the parameter data transmitted in the current data frame.
In this embodiment, the sending system and the receiving system communicate in a format of a variable adaptive serial communication protocol, and identify parameter data in each serial data frame by identifying a data frame header SyncWord, a data length Number, and a frame check word Checksun, where data1 to data n are n parameter data agreed by the sending system and the receiving system together.
In the prior art of communication protocol design for fixing Data frame structure and content, Data 1(Data word1) -Data n (Data word n) are fixed parameters, such as Data 1(Data word1) representing PLA and Data 2(Data word 2) representing NG, and Data 1-Data n are transmitted from a transmitting system to a receiving system according to a communication protocol through communication, and the receiving system receives and identifies corresponding Data for processing.
Due to the requirement of system design, when one Data n +1(Data n +1) is added for transmission or one Data x (Data x) is changed into another parameter, the communication protocol needs to be redefined by the sending system and the receiving system. If the system needs to frequently adjust the parameters in the communication protocol, the software codes of the sending system and the receiving system can only be modified to re-debug the programming, which results in a great increase of the workload.
In the variable adaptive serial port communication protocol of the embodiment, the data1 to the data n are set as adjustable data parameters, communication is realized by adjusting the content of a communication data frame of the sending system or corresponding software, the communication protocol does not need to be redefined, and the workload is effectively reduced.
Specifically, the variable adaptive serial communication protocol is configured as shown in table 1:
TABLE 1
Figure BDA0002561291840000081
In table 1, the data frame header Sync Word and the frame check Word Checknum are mainly used for parsing the data frame. The data state Status is respectively a value of 0 and a value of 1, wherein 1 represents that the data 1-data n are matched with the data of the parameter database, and the data are transmitted and analyzed according to a communication protocol that the data 1-data n are fixed data frame structures and contents; and 0 represents that the data 1-data n are not matched with the data in the parameter library, and the data can be transmitted and analyzed according to the communication protocol of the fixed data frame structure and the content after the matching is finished.
The data Flag indicates the data type (or multiple types), and represents the parameter type of the parameter library, such as 0 for class i parameter and 1 for class ii parameter, which can reduce the search time of the matching parameter.
The Position indicates the sequence and number of Data Word in the communication protocol, 1 for Position, 2 for Position and … … for Position.
The parameter Element ID represents a corresponding parameter Element ID in a parameter library, and the Position of the parameter in the communication protocol is the Position pointed by the Position. Such as: when the Element ID is 0x3000 and the Position is 1, the parameter ID indicating the Data 1Data Word1 is 0x3000, and when the Position is 2, the parameter ID indicating the Data 2Data Word 2 is 0x 3000.
The Data Word represents the Data to be matched with the parameters in the parameter library.
As shown in fig. 3, in the preferred embodiment of the present invention, the parameter library stores a parameter ElementID and a parameter type corresponding to the parameter ElementID one to one.
In this embodiment, before the sending system and the receiving system perform communication, parameter types that all the sending systems can send to the receiving system through serial communication are agreed, a parameter library is established, the parameter library can be set independently or can be used as a part of the receiving system, a corresponding Element ID is set for each parameter type in the parameter library, the Element ID corresponds to a parameter Element ID in a variable adaptive serial communication protocol, and the Element ID and the parameter types have uniqueness, that is, the Element ID is unique and represents a unique parameter type. Meanwhile, the parameter library also stores the parameter ElementID and the corresponding parameter types in groups according to different parameter types and set rules, and establishes a plurality of parameter lists, so that the searching efficiency is improved.
In a preferred embodiment of the present invention, before the sending system sends the data frame based on the variable adaptive serial communication protocol, the sending system further includes:
establishing a communication relation between a sending system and a receiving system according to the requirement of a serial interface, and configuring port attributes including a baud rate, parity check, a data bit and a stop bit. Thereby making necessary preparation for subsequent communication.
As shown in fig. 4, in a preferred embodiment of the present invention, the receiving system receives the data frame and reads the value of the identifier in the data frame, if it is determined that there is a difference according to the value of the identifier, the receiving system matches the data type in the received data frame with the parameter type in the preset parameter library, and after the matching is completed, the data transmission and analysis processing according to the communication protocol of the fixed data frame structure and content specifically includes the steps of:
if a data packet is sent, receiving an ith data frame;
reading the value of a data state Status in the ith data frame, and judging whether the data in the ith data frame is different from the data in the historical data frame or not according to the value of the data state Status;
if the difference exists, reading the value of the position in the ith data frame, and determining the position of the data DataWord needing to be matched in the current data frame;
reading data DataWord corresponding to the value of the position;
reading a parameter ElementID corresponding to the value of the position in the ith data frame;
searching the parameter type in the parameter library according to the parameter ElementID;
matching data DataWord in the ith data frame with the parameter types in the parameter library;
repeating the steps until the matching of all data DataWord in all data frames is completed;
and after matching, carrying out data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content.
This embodiment describes a parameter matching process of a receiving system in detail, where the sending system compares data parameters in a data frame that needs to be sent currently with data parameters in a data frame that is sent historically before sending data, if a difference is found, a data state Status in the data frame that needs to be sent currently is set to 0, otherwise, the data state Status is set to 1, and after the receiving system receives the data frame sent by the sending system, the receiving system reads a value of the data state Status, and if the value is 0, the receiving system matches the parameter library, where each frame only matches one data parameter, receives other data frames in sequence, until all data parameters are matched, and after matching is completed, performs parameter analysis or processing according to a communication protocol of a fixed data frame structure and content.
The state of position includes two cases:
for the first matching, traversal of all Data words needs to be completed, each frame only matches one Data parameter, the present embodiment traverses each Data word in the Data frame by using the Data state Status, the position points to the Data word1 first, so as to match the Data word1, and when the next frame, the Data word 2 needs to be matched, so that the position adds 1, takes a value of 2, so as to point to the Data word 2 for matching like a pointer, and so on, until the position is equal to n, the parameter matching including the Data word1 — the Data word n is completed.
When the sending system only changes the parameter matching of one or more data DataWord, the position of the next data frame points to the position of the next data DataWord needing to be matched, and the parameter matching of the data DataWord is completed through one or more data frames.
And when the Data k is matched specifically, the Data k (namely the Data word) and the parameter ElementID corresponding to the value k of the position in the current Data frame are read, then the corresponding parameter X is searched through the parameter ElementID, and after the parameter ElementID is found, the matching of the Data k in the current Data frame is completed. And by circulating the steps, after parameter matching of all the data frames is completed, the receiving system carries out parameter analysis or processing according to the communication protocol of the fixed data frame structure and the content.
It can be understood that, in this embodiment, through the parameter matching process based on the variable adaptive serial communication protocol and the parameter library, the variable adaptive communication of the data frame is realized, when the parameter data in the serial communication changes according to the change of the design requirement, after the parameter data of the data frame is searched and matched with the parameter library in the receiving system, the parameter analysis or processing is performed according to the communication protocol of the fixed data frame structure and content, so as to realize the parameter change in the serial communication protocol, thereby avoiding a large workload when the communication protocol and software need to be changed simultaneously for the receiving system and the sending system, ensuring the validity and convenience of the serial communication transmission parameter type, reducing the workload, and improving the speed of system maintenance and update.
As shown in fig. 5, in a preferred embodiment of the present invention, the receiving system receives the data frame and reads the value of the identifier in the data frame, if it is determined that there is a difference according to the value of the identifier, the receiving system matches the data type in the received data frame with the parameter type in the preset parameter library, and after the matching is completed, the data transmission and analysis processing according to the communication protocol of the fixed data frame structure and content specifically includes the steps of:
if a data packet is sent, receiving an ith data frame;
reading the value of a data state Status in the ith data frame, and judging whether the data in the ith data frame is different from the data in the historical data frame or not according to the value of the data state Status;
if the difference exists, reading the value of the position in the ith data frame, and determining the position of the data DataWord needing to be matched in the current data frame;
reading data DataWord corresponding to the value of the position;
reading the parameter ElementID corresponding to the value of the data Flag and the value of the position in the ith data frame;
searching the parameter type in the parameter library according to the data Flag and the parameter ElementID;
matching data DataWord in the ith data frame with the parameter types in the parameter library;
repeating the steps until the matching of all data DataWord in all data frames is completed;
and after matching, carrying out data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content.
This embodiment is different from the above embodiments in that: the embodiment further reads the value of the data Flag in the data frame, and meanwhile searches the parameter types in the parameter library according to the data Flag and the parameter ElementID, when the parameter types in the parameter library are more, firstly, the grouping of the parameter types is determined according to the value of the data Flag, the search range is narrowed, and then, the parameter types are searched and matched in the grouping, so that the search speed is increased.
Another embodiment of the present invention provides a storage medium including a stored program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the variable adaptive serial port communication method.
Another embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the variable adaptive serial communication method when executing the program.
In conclusion, the invention can effectively solve the problems that the content of the communication data frame is changed due to the fact that the fixed data frame structure and the content comprising the data frame head, the frame length, the frame data content and the frame check word/frame tail cannot be rapidly adapted to the change of the design requirement, and the change of the fixed communication protocol needs larger workload, realizes the variable self-adaptive communication of the data frame, can realize the parameter change in the serial communication protocol only by adjusting the content parameter of the communication data frame or corresponding software of one of a receiving system or a sending system when the parameter in the serial communication is changed according to the change of the design requirement, can be applied to various serial communication occasions, improves the adaptability and the reliability of the data transmission of the communication system, and has better engineering popularization application range and value.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than presented herein.
The functions of the method of the present embodiment, if implemented in the form of software functional units and sold or used as independent products, may be stored in one or more storage media readable by a computing device. Based on such understanding, part of the contribution of the embodiments of the present invention to the prior art or part of the technical solution may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computing device (which may be a personal computer, a server, a mobile computing device, a network device, or the like) to execute all or part of the steps of the method described in the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A variable adaptive serial port communication method is characterized by comprising the following steps:
the sending system sends a data frame based on a variable self-adaptive serial port communication protocol, and carries out corresponding assignment on a marker used for identifying the matching state of parameter data in the sent data frame according to whether the data in the current data frame to be sent is different from the data in the historical data frame before sending;
and the receiving system receives the data frame and reads the value of the identifier in the data frame, if the difference exists according to the value of the identifier, the data type in the received data frame is matched with the parameter type in a preset parameter library, after the matching is finished, the data is transmitted and analyzed according to the communication protocol of the fixed data frame structure and the content, and the parameter library comprises all appointed parameter types which are transmitted to the receiving system by the transmitting system through serial communication.
2. The variable adaptive serial communication method according to claim 1, wherein the format of the variable adaptive serial communication protocol specifically includes:
a data frame header SyncWord and a frame check word Checksun;
the data length Number is used for marking the total data Number of data word contained in the current communication protocol;
the data state Status is used for identifying the matching state of the data DataWord and the parameter types in the parameter database;
position, which is used to identify the position of data DataWord to be matched in the current data frame;
the parameter ElementID is used for identifying the corresponding ElementID in the parameter library, and the Position of the parameter in the communication protocol is the Position pointed by the Position;
and a plurality of data words for identifying the data transmitted in the current data frame.
3. The variable adaptive serial communication method according to claim 2,
the parameter library stores ElementID and parameter types corresponding to the ElementID one by one.
4. The variable adaptive serial communication method according to claim 3,
and the parameter library also stores the ElementID and the corresponding parameter type in a grouping mode according to a set rule.
5. The variable adaptive serial communication method according to claim 4,
the format of the variable adaptive serial port communication protocol further comprises:
and the data Flag is used for identifying that the data DataWord in the current data frame corresponds to the grouping category in the parameter base.
6. The variable adaptive serial communication method according to claim 1,
before the sending system sends the data frame based on the variable self-adaptive serial port communication protocol, the method also comprises the following steps:
establishing a communication relation between a sending system and a receiving system according to the requirement of a serial interface, and configuring port attributes including a baud rate, parity check, a data bit and a stop bit.
7. The variable adaptive serial communication method according to claim 2,
the receiving system receives the data frame and reads the value of the identifier in the data frame, if the difference exists according to the value of the identifier, the data type in the received data frame is matched with the parameter type in a preset parameter library, and after the matching is finished, the data transmission and analysis processing is carried out according to the communication protocol of the fixed data frame structure and the content, and the specific steps are as follows:
if a data packet is sent, receiving an ith data frame;
reading the value of a data state Status in the ith data frame, and judging whether the data in the ith data frame is different from the data in the historical data frame or not according to the value of the data state Status;
if the difference exists, reading the value of the position in the ith data frame, and determining the position of the data DataWord needing to be matched in the current data frame;
reading data DataWord corresponding to the value of the position;
reading a parameter ElementID corresponding to the value of the position in the ith data frame;
searching the parameter type in the parameter library according to the parameter ElementID;
matching data DataWord in the ith data frame with the parameter types in the parameter library;
repeating the steps until the matching of all data DataWord in all data frames is completed;
and after matching, carrying out data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content.
8. The variable adaptive serial port communication method according to claim 5, wherein the receiving system receives the data frame and reads the value of the identifier in the data frame, if it is determined that there is a difference according to the value of the identifier, the data type in the received data frame is matched with the parameter type in a preset parameter library, and after the matching is completed, the data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content specifically includes the steps of:
if a data packet is sent, receiving an ith data frame;
reading the value of a data state Status in the ith data frame, and judging whether the data in the ith data frame is different from the data in the historical data frame or not according to the value of the data state Status;
if the difference exists, reading the value of the position in the ith data frame, and determining the position of the data DataWord needing to be matched in the current data frame;
reading data DataWord corresponding to the value of the position;
reading the parameter ElementID corresponding to the value of the data Flag and the value of the position in the ith data frame;
searching the parameter type in the parameter library according to the data Flag and the parameter ElementID;
matching data DataWord in the ith data frame with the parameter types in the parameter library;
repeating the steps until the matching of all data DataWord in all data frames is completed;
and after matching, carrying out data transmission and analysis processing according to the communication protocol of the fixed data frame structure and the content.
9. A storage medium comprising a stored program, characterized in that the program, when executed, controls a device on which the storage medium is located to perform the variable adaptive serial communication method according to any one of claims 1 to 8.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the variable adaptive serial communication method according to any one of claims 1 to 8 when executing the program.
CN202010613405.8A 2020-06-30 2020-06-30 Variable self-adaptive serial port communication method, medium and electronic equipment Pending CN111913905A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010613405.8A CN111913905A (en) 2020-06-30 2020-06-30 Variable self-adaptive serial port communication method, medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010613405.8A CN111913905A (en) 2020-06-30 2020-06-30 Variable self-adaptive serial port communication method, medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN111913905A true CN111913905A (en) 2020-11-10

Family

ID=73227022

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010613405.8A Pending CN111913905A (en) 2020-06-30 2020-06-30 Variable self-adaptive serial port communication method, medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111913905A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113177014A (en) * 2021-05-24 2021-07-27 石家庄通合电子科技股份有限公司 Serial port communication method based on inspection mode and serial port chip
CN114866367A (en) * 2022-04-13 2022-08-05 深圳市三旺通信股份有限公司 CAN equipment communication method and device, CAN optical modem equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20000052508A (en) * 1998-12-18 2000-08-25 루센트 테크놀러지스 인크 Discontinuous transmission on high speed data channels
CN102098131A (en) * 2009-12-15 2011-06-15 航天科工惯性技术有限公司 Dynamic parameter configuration-based general framing and de-framing method for serial port data frames
CN109388417A (en) * 2018-09-30 2019-02-26 深圳市酷达通讯有限公司 A kind of update method of communication protocol, system and terminal device
CN110351242A (en) * 2019-05-31 2019-10-18 惠州市蓝微电子有限公司 The means of communication, device and the electronic equipment of compatible multi-protocols
CN111130690A (en) * 2019-11-12 2020-05-08 广西电网有限责任公司 Processing method and device for multiple communication protocols of IR46 smart electric meter

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20000052508A (en) * 1998-12-18 2000-08-25 루센트 테크놀러지스 인크 Discontinuous transmission on high speed data channels
CN102098131A (en) * 2009-12-15 2011-06-15 航天科工惯性技术有限公司 Dynamic parameter configuration-based general framing and de-framing method for serial port data frames
CN109388417A (en) * 2018-09-30 2019-02-26 深圳市酷达通讯有限公司 A kind of update method of communication protocol, system and terminal device
CN110351242A (en) * 2019-05-31 2019-10-18 惠州市蓝微电子有限公司 The means of communication, device and the electronic equipment of compatible multi-protocols
CN111130690A (en) * 2019-11-12 2020-05-08 广西电网有限责任公司 Processing method and device for multiple communication protocols of IR46 smart electric meter

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
佘立等: "基于Qt的多串口多协议数据接收解析软件的设计与实现", 《电子质量》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113177014A (en) * 2021-05-24 2021-07-27 石家庄通合电子科技股份有限公司 Serial port communication method based on inspection mode and serial port chip
CN113177014B (en) * 2021-05-24 2023-12-15 石家庄通合电子科技股份有限公司 Serial port communication method and serial port chip based on inspection mode
CN114866367A (en) * 2022-04-13 2022-08-05 深圳市三旺通信股份有限公司 CAN equipment communication method and device, CAN optical modem equipment and medium
CN114866367B (en) * 2022-04-13 2023-12-05 深圳市三旺通信股份有限公司 CAN equipment communication method and device, CAN optical cat equipment and medium

Similar Documents

Publication Publication Date Title
CN111913905A (en) Variable self-adaptive serial port communication method, medium and electronic equipment
US9110884B2 (en) Message publishing and subscribing method and apparatus
US20040054829A1 (en) Method, system and program for the transmission of modbus messages between networks
US20100211859A1 (en) Systems and methods for data alignment
JPS6170654A (en) Resource control system of decentralized processing system
CN107124421A (en) Communication means based on multi-protocols, multi-protocol gateway equipment and can storage medium
KR101400329B1 (en) Communication system
CN110011952A (en) A kind of method, service cluster and the client of data transmission
US5010514A (en) Structured fields at a data stream boundary for delimiting files
CN112069176B (en) Database design method, device and equipment of communication protocol and storage medium
CN111343148A (en) FGPA communication data processing method, system and device
US5038345A (en) Traffic pattern information for a local area network
CN112231906A (en) Service construction method based on ICD
US4937739A (en) Data transmission optimizer, including programmable symbol code point sorting feature
US7539215B2 (en) Subscriber device for a high-performance communication system
US5046025A (en) Data transmission optimizer including multi-pass symbol buffer optimization, trial generation feature and MDT reset voting feature
CN103368944A (en) Memory shared network architecture and protocol specifications for same
CN102075386A (en) Identification method and device
CN101159641B (en) Can bus extension method
CN111367842A (en) Multi-interface servo driving device, method and system based on object dictionary
CN114095306A (en) LIN message passing between LIN partitions separated by backbone communication network
CN109981725B (en) Communication method across security domains, server and readable storage medium
CN115145179A (en) Processing controller and processing method for data receiving and transmitting shared buffer area
FI123811B (en) Procedure for data transfer in distributed process control system
CN110730168A (en) Communication control method and device and server equipment

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20201110

RJ01 Rejection of invention patent application after publication