A method for redundancy serial port input data security detection in embedded software
By obtaining serial port type and characteristic consistency confirmation, a serial communication protocol is formulated, and a redundancy data voting mechanism is used to solve the problem of security and validity of redundant serial port data in embedded software, thus ensuring the stability of device functions and flight safety.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-05
- Publication Date
- 2026-04-03
AI Technical Summary
In existing technologies, the security and validity of redundant serial port data received by embedded software cannot be guaranteed. This can easily lead to erroneous data misuse, causing device malfunctions and affecting flight safety.
By obtaining consistency confirmation of serial port type and characteristics, a serial communication protocol is formulated, single-redundant serial port data parsing and detection are performed, and a redundant data voting mechanism is used to ensure data security and validity.
It improves the security and validity of redundant serial port data, prevents misuse of erroneous data, ensures normal device operation, and enhances flight safety.
Smart Images

Figure CN121051764B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of software engineering design, and in particular relates to a method for detecting redundant serial port input data security in embedded software. Background Technology
[0002] Many airborne control systems in civil aviation products employ embedded software to implement crucial functions and operations. These systems often utilize external serial buses and their protocols to enable the software to periodically input and output data to external devices, ensuring real-time reception, processing, and computation of valid data. Examples include RS422A, RS232, and RS485 serial buses. However, when receiving data frames from external devices via the serial bus, imperfect detection mechanisms or methods can lead to errors and misinterpretations, causing device malfunctions.
[0003] Given that civil aviation products have stricter requirements for the safety and reliability of the equipment used in order to ensure the safety of air operations, in order to achieve the goal of safety and reliability, high-safety-level equipment often adopts redundancy design to achieve the goal of safe operation. That is, instead of using only one airborne equipment, two or three identical equipment are used at the same time. Through dual-redundancy or triple-redundancy design, air flight safety is guaranteed. Summary of the Invention
[0004] To address the aforementioned shortcomings in existing technologies, this invention provides a method for detecting redundant serial port input data in embedded software. This method solves the problem that existing input data security detection methods cannot ensure the security and validity of redundant serial port data received by embedded software, which can easily lead to misuse of erroneous data and cause device malfunctions, thereby affecting flight safety.
[0005] To achieve the above objectives, the technical solution adopted by this invention is: a method for detecting redundant serial port input data in embedded software, comprising the following steps:
[0006] S1. Obtain the serial port type received by the device and the serial port type and redundancy number sent by the external device, confirm the consistency of the serial port type and serial port characteristics, and formulate the serial port communication protocol.
[0007] S2. Based on the serial communication protocol, receive and store the redundancy serial port data of each serial port type, and use the preset detection method to parse and detect the single redundancy serial port data to obtain the detected redundancy serial port data and complete the preliminary security detection.
[0008] S3. Based on the redundancy number, formulate a redundancy data voting mechanism. In response to the end of the single redundancy serial port data detection for each serial port type, based on the detected redundancy serial port data, use the redundancy data voting mechanism to vote on the redundancy serial port data for each serial port type in the current period, and obtain the voted serial port data.
[0009] S4. Use the voted serial port data for embedded software calculation to complete the redundancy serial port input data security detection.
[0010] The beneficial effects of this invention are as follows: This invention uses a redundancy input serial port data validity and security detection mechanism. Specifically, it determines the correctness and validity of single-redundancy serial port received data through zero-prevention detection, frame header detection, frame count detection, and checksum detection. Then, through a voting mechanism for redundancy serial port data, it obtains the voted safe and valid serial port data to participate in subsequent program calculations. This improves the security and validity of the redundancy serial port data received by the embedded software and prevents the misuse of erroneous data from causing device malfunctions that affect flight safety.
[0011] Further, S1 includes the following steps:
[0012] S101. Obtain the serial port type received by the device and the serial port type and redundancy number sent by the external device, confirm the consistency of the received and sent serial port types and serial port characteristics, and obtain the detected serial port type.
[0013] S102. For redundant serial ports of different types in the detection serial port type, formulate a unified serial port communication protocol that includes serial port characteristics and communication data frame format.
[0014] Furthermore, the serial port characteristics include: communication transmission rate, data width, and parity bit;
[0015] The communication data frame format includes: a two-byte frame header, a one-byte data length, a one-byte frame count, a preset length of data, and a one-byte checksum.
[0016] The beneficial effects of the above-mentioned further solutions are as follows: By setting the consistency of the serial port type and serial port characteristics for receiving and sending, the present invention ensures that serial ports of the same type can communicate normally, and defines the communication data frame format, which facilitates the detection of the validity of data of this type of serial port. Furthermore, the communication data frame format, as a data validity detection item, improves the rationality and effectiveness of the format definition.
[0017] Furthermore, S2 includes the following steps:
[0018] S201. Based on the serial communication protocol, periodically accept redundant serial port data of each serial port type, and store the redundant serial port data of each serial port type in the buffer of the corresponding redundant serial port.
[0019] S202. In each cycle, set a serial port data communication fault count, perform zero-prevention detection on the single-redundant serial port data of each serial port type, and determine whether data has been received. If so, obtain the single-redundant serial port data that has passed the zero-prevention detection; otherwise, output the current redundant serial port data communication fault information.
[0020] S203. Set the serial port data reception fault count. Perform frame header detection on the single-redundancy serial port data that passes the zero-prevention detection. Determine whether the frame header is found. If it is, obtain the single-redundancy serial port data that passes the frame header detection. Otherwise, output the current redundancy serial port data reception fault information.
[0021] S204. Perform frame count detection on the single-redundancy serial port data that has passed the frame header detection, and determine whether the data frame has been updated. If so, obtain the single-redundancy serial port data that has passed the frame count detection; otherwise, output the current redundancy serial port data reception fault information.
[0022] S205. Perform a checksum check on the single-redundancy serial port data that has passed the frame count detection, and determine whether the checksum is consistent. If it is, obtain the single-redundancy serial port data that has passed the checksum detection; otherwise, output the current redundancy serial port data reception fault information.
[0023] S206. In response to the fact that the single-redundancy serial port data zero-prevention detection, frame header detection, frame count detection and checksum detection are all passed in each cycle, the single-redundancy serial port data that has passed the checksum detection is identified as valid, and the detection redundancy serial port data is obtained.
[0024] S207. Report the current redundancy serial port data communication failure information and the current redundancy serial port data reception failure information to complete the preliminary safety test.
[0025] Furthermore, S202 specifically includes:
[0026] In each cycle, a serial port data communication fault count is set, and zero-prevention detection is performed on the single-redundant serial port data of each serial port type. The data in the data buffer is detected by using a polling method, and it is determined whether all the data in the data buffer is zero. If so, the zero-prevention detection information is set to no data received, and the serial port data communication fault count is incremented by one.
[0027] If not, set the zero-prevention detection information to received data and clear the fault count to obtain single-redundancy serial port data that has passed the zero-prevention detection;
[0028] Based on the serial port data communication fault count, in response to the zero-prevention detection information not receiving data for at least ten consecutive cycles, the current redundancy serial port data communication fault information is output.
[0029] Furthermore, S203 specifically includes:
[0030] Set a serial port data reception fault count. Perform frame header detection on single-redundant serial port data that passes the zero-prevention detection. Use a polling method to confirm each byte in the data buffer in turn, and determine whether the current byte and the next byte in the buffer are frame header data. If not, set the frame header detection information to "frame header not found" and increment the serial port data reception fault count by one.
[0031] If so, set the frame header detection information to "frame header found", clear the serial port data reception fault count to zero, continue to obtain the data length value of the third byte, and read the complete data frame in the buffer according to the data length value of the third byte to obtain the single-redundancy serial port data that has passed the frame header detection.
[0032] Based on the serial port data reception fault count, in response to the frame header detection information being "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
[0033] Furthermore, S204 specifically includes:
[0034] For single-redundancy serial port data detected by the frame header, perform frame count detection to determine whether the current frame count is different from the previous frame count. If not, set the frame count detection information to data frame not updated and increment the serial port data reception fault count by one.
[0035] If so, set the frame count detection information to indicate that the data frame has been updated, and clear the serial port data reception fault count to zero, thus obtaining single-redundancy serial port data that has passed the frame count detection.
[0036] Based on the serial port data reception fault count, in response to the frame count detection information of "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
[0037] Furthermore, S205 specifically includes:
[0038] Checksum detection is performed on the single-redundant serial port data that passes the frame count detection. The checksum of the single-redundant serial port data that passes the frame count detection is calculated to obtain the current checksum. The checksum in the single-redundant serial port data of each serial port type is used as the received checksum. It is determined whether the current checksum is consistent with the received checksum. If not, the checksum detection information is set to the received data frame error, and the serial port data reception fault count is incremented by one.
[0039] If so, the checksum detection information is set to the correctness of the received data frame, and the serial port data reception fault count is cleared to zero, thus obtaining single-redundancy serial port data that has passed the checksum detection.
[0040] Based on the serial port data reception fault count, in response to the frame header detection information being "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
[0041] The beneficial effects of the above-mentioned further solutions are as follows: By using zero-prevention detection, frame header detection, frame count detection, and checksum detection methods, the present invention can comprehensively detect serial communication anomalies and received data anomalies. It will not overlook problems such as outdated data or nested frame data errors due to the lack of data frame count detection, or failure to detect serial communication anomalies in a timely manner due to the lack of zero-prevention detection. It effectively prevents equipment malfunctions caused by abnormal data reception from affecting flight safety.
[0042] Furthermore, the redundancy data voting mechanism is specifically as follows:
[0043] Configure a triple-redundant serial port containing redundancy 1, redundancy 2, and redundancy 3, and obtain the validity of the serial port input data of redundancy 1, redundancy 2, and redundancy 3.
[0044] In response to the fact that the serial input data of redundancy 1, redundancy 2, and redundancy 3 are all valid, a consistency check is performed on the data frames of the serial input data of redundancy 1, redundancy 2, and redundancy 3.
[0045] If the data frames of the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are all consistent, then the serial port input data of redundancy 1 will be used as the serial port data after voting.
[0046] If only the data frame of the serial port input data of redundancy 1 is consistent with the data frame of the serial port input data of redundancy 3, or if only the data frame of the serial port input data of redundancy 1 is consistent with the data frame of the serial port input data of redundancy 2, then the serial port input data of redundancy 1 will be used as the serial port data after voting.
[0047] If only the data frame of the serial port input data of redundancy 2 is consistent with that of the serial port input data of redundancy 3, then the serial port input data of redundancy 2 will be used as the serial port data after voting.
[0048] If the data frames of the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are inconsistent, then the serial port data that was voted in the previous cycle will be used as the voted serial port data.
[0049] In response to the fact that only the serial port input data of redundancy 1 and the serial port input data of redundancy 3 are valid, the consistency of the data frames of the serial port input data of redundancy 1 and the serial port input data of redundancy 3 is judged. If they are consistent, the serial port input data of redundancy 1 is used as the voted serial port data. If they are inconsistent, the serial port data voted in the previous cycle is used as the voted serial port data.
[0050] In response to the fact that only the serial port input data of redundancy 1 and the serial port input data of redundancy 2 are valid, the consistency of the data frames of the serial port input data of redundancy 1 and the serial port input data of redundancy 2 is judged. If they are consistent, the serial port input data of redundancy 1 is used as the voted serial port data. If they are inconsistent, the serial port data voted in the previous cycle is used as the voted serial port data.
[0051] In response to the fact that only the redundant 2 serial port input data and the redundant 3 serial port input data are valid, a consistency judgment is performed on the data frames of the redundant 2 serial port input data and the redundant 3 serial port input data. If they are consistent, the redundant 2 serial port input data is used as the voted serial port data. If they are inconsistent, the voted serial port data of the previous cycle is used as the voted serial port data.
[0052] If only one redundant serial port input data is valid, then the redundant serial port data is used as the voted serial port data;
[0053] If the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are all invalid, then the serial port data voted in the previous cycle will be used as the voted serial port data.
[0054] The beneficial effects of the above-mentioned further solutions are as follows: The present invention achieves accurate voting on redundant serial port received data through a redundant data voting mechanism, which further ensures the validity and security of the serial port data used in the end. Attached Figure Description
[0055] Figure 1 This is a flowchart of the method of the present invention.
[0056] Figure 2 This is a flowchart for troubleshooting device serial port data reception faults in this embodiment.
[0057] Figure 3 This is a flowchart of the redundant serial port data detection mechanism in this embodiment.
[0058] Figure 4 This is a topology diagram of the serial port data reception redundancy for each cycle in this embodiment.
[0059] Figure 5 This is a flowchart for zero-prevention detection of serial port data with redundancy in this embodiment.
[0060] Figure 6This is a flowchart for frame header detection of serial port data with redundancy in this embodiment.
[0061] Figure 7 This is a flowchart for frame counting detection of serial port data with redundancy in this embodiment.
[0062] Figure 8 This is a flowchart for verifying and detecting the serial port data of each redundancy in this embodiment. Detailed Implementation
[0063] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.
[0064] Example 1
[0065] This embodiment designs an effective and secure detection mechanism based on redundant input serial port data to ensure the security and effectiveness of redundant serial port data received by the embedded software and to prevent the misuse of erroneous data.
[0066] like Figure 1 As shown, this invention provides a method for detecting redundant serial port input data in embedded software, the implementation of which is as follows:
[0067] S1. Obtain the serial port type received by the device and the serial port type and redundancy value sent by the external device, confirm the consistency of the serial port type and serial port characteristics, and formulate the serial communication protocol. The specific steps are as follows:
[0068] S101. Obtain the serial port type received by the device and the serial port type and redundancy number sent by the external device, confirm the consistency of the received and sent serial port types and serial port characteristics, and obtain the detected serial port type.
[0069] S102. For redundant serial ports of different types in the detection serial port type, formulate a unified serial port communication protocol that includes serial port characteristics and communication data frame format.
[0070] In this embodiment, the consistency and input redundancy values of the serial port type used by the receiving device and the serial port type used by the external device are confirmed, and a reasonable and effective serial communication data frame format is defined, specifically as follows:
[0071] Determine the serial port type used by the device, the serial port type and redundancy of the external device being received, and ensure that the serial port type and characteristics of the received and transmitted serial ports are consistent to obtain the detected serial port type. The serial port characteristics include: the communication transmission rate (baud rate), data width, and the definition of the parity bit.
[0072] For redundant serial ports of different types within the detection serial port type, a reasonable and effective serial communication protocol should be established. The communication protocol for each redundant serial port within a single redundant serial port type should be consistent. An effective communication protocol, in addition to the characteristics of the serial port itself, also includes the communication data frame format. The definition of the communication data frame format typically includes:
[0073] A two-byte frame header, such as hexadecimal data EBH and 90H, ensures that the start position of each frame can be found in the buffer;
[0074] A data length of one byte ensures that a complete data frame is received in each cycle;
[0075] A one-byte frame count ensures that new data is received in each cycle and that the data is continuous and without omissions;
[0076] Data of a preset length, such as 10 bytes, will be 10 bytes here;
[0077] A one-byte checksum ensures that each received data frame is correct. The checksum is usually calculated by summing the data in the frame excluding the frame header and checksum, and then taking the two's complement of the lower 8 bits.
[0078] S2. Based on the serial communication protocol, receive and store the redundancy serial port data of each serial port type, and use a preset detection method to parse and detect the single redundancy serial port data to obtain the detected redundancy serial port data, thus completing the preliminary security detection. The specific steps are as follows:
[0079] S201. Based on the serial communication protocol, periodically accept redundant serial port data of each serial port type, and store the redundant serial port data of each serial port type in the buffer of the corresponding redundant serial port.
[0080] In this embodiment, data from each single-redundant serial port of each serial port type is received periodically. The data from each single-redundant serial port of each serial port type is combined into redundant serial port data and stored in a buffer for redundant serial port data of a dedicated serial port type. The length of the buffer for storing data is greater than the length of the received data frame and can store the next frame of data.
[0081] S202. In each cycle, set a serial port data communication fault count, perform zero-prevention detection on the single-redundancy serial port data of each serial port type, and determine whether data has been received. If so, obtain the single-redundancy serial port data that passed the zero-prevention detection; otherwise, output the current redundancy serial port data communication fault information. Specifically:
[0082] In each cycle, a serial port data communication fault count is set, and zero-prevention detection is performed on the single-redundant serial port data of each serial port type. The data in the data buffer is detected by using a polling method, and it is determined whether all the data in the data buffer is zero. If so, the zero-prevention detection information is set to no data received, and the serial port data communication fault count is incremented by one.
[0083] If not, set the zero-prevention detection information to received data and clear the fault count to obtain single-redundancy serial port data that has passed the zero-prevention detection;
[0084] Based on the serial port data communication fault count, in response to the zero-prevention detection information not receiving data for at least ten consecutive cycles, the current redundancy serial port data communication fault information is output.
[0085] In this embodiment, zero-prevention detection is performed in each cycle to determine whether data can be received:
[0086] Set a serial port data communication fault counter. Check whether all single redundant serial port data in the buffer are 0 in a polling manner. If they are all 0, it is considered that no data has been received, and the serial port data communication fault counter is incremented by 1. If they are not 0, it is considered that data has been received, the fault counter is cleared to zero, the single redundant serial port data that has passed the zero-prevention detection is obtained, and the data frame header detection continues.
[0087] Based on the serial port data communication failure count, if no data is received for at least 10 consecutive cycles, the current redundancy serial port data communication is considered to be faulty, and the current redundancy serial port data communication failure information is output.
[0088] S203. Set a serial port data reception fault count. For single-redundancy serial port data that passes the zero-prevention detection, perform frame header detection to determine if a frame header is found. If so, obtain the single-redundancy serial port data that passed the frame header detection; otherwise, output the current redundancy serial port data reception fault information. Specifically:
[0089] Set a serial port data reception fault count. Perform frame header detection on single-redundant serial port data that passes the zero-prevention detection. Use a polling method to confirm each byte in the data buffer in turn, and determine whether the current byte and the next byte in the buffer are frame header data. If not, set the frame header detection information to "frame header not found" and increment the serial port data reception fault count by one.
[0090] If so, set the frame header detection information to "frame header found", clear the serial port data reception fault count to zero, continue to obtain the data length value of the third byte, and read the complete data frame in the buffer according to the data length value of the third byte to obtain the single-redundancy serial port data that has passed the frame header detection.
[0091] Based on the serial port data reception fault count, in response to the frame header detection information being "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
[0092] In this embodiment, after a single redundant serial port data passes the zero-prevention detection, it is determined that data can be received, and frame header detection continues to determine whether a frame header has been found.
[0093] In the data buffer, each byte of single-redundancy serial port data that has passed the zero-prevention detection is checked sequentially using a polling method. When it is determined that the current byte and the next byte in the buffer are frame header data, it is considered that the frame header has been found. The data length value of the third byte is then obtained, and the complete data frame in the buffer is read according to the data length value to obtain the single-redundancy serial port data that has passed the frame header detection. If the frame header is not found, the serial port data reception fault count is incremented by 1.
[0094] If no frame header is found in the received data for at least 3 consecutive cycles, the data reception of the redundancy serial port is considered to be faulty; if a data frame header is found in any cycle, the fault count is cleared and the current redundancy serial port data reception fault information is output.
[0095] S204. Perform frame count detection on the single-redundancy serial port data detected by the frame header to determine whether the data frame has been updated. If so, obtain the single-redundancy serial port data that has passed the frame count detection; otherwise, output the current redundancy serial port data reception fault information. Specifically:
[0096] For single-redundancy serial port data detected by the frame header, perform frame count detection to determine whether the current frame count is different from the previous frame count. If not, set the frame count detection information to data frame not updated and increment the serial port data reception fault count by one.
[0097] If so, set the frame count detection information to indicate that the data frame has been updated, and clear the serial port data reception fault count to zero, thus obtaining single-redundancy serial port data that has passed the frame count detection.
[0098] Based on the serial port data reception fault count, in response to the frame count detection information of "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
[0099] In this embodiment, after a single redundant serial port data passes the frame header detection, it is determined that the data frame header is correct, and the frame count detection continues to determine whether the data frame has been updated.
[0100] Determine if the current frame count is different from the previous frame count. If they are different, it proves that the data frame has been updated, and obtain the single-redundancy serial port data detected by the frame count. If they are the same, it proves that the data has not been updated, and the data reception fault count is incremented by 1. If the data frame header is found in any cycle, the fault count is cleared to zero.
[0101] If the received data has not been updated for at least 3 consecutive cycles, the redundant serial port data reception is considered to be faulty, and the current redundant serial port data reception fault information is output.
[0102] S205. Perform a checksum check on the single-redundancy serial port data detected by frame counting, and determine whether the checksum is consistent. If it is, obtain the single-redundancy serial port data that passed the checksum check; otherwise, output the current redundancy serial port data reception fault information. Specifically:
[0103] Checksum detection is performed on the single-redundant serial port data that passes the frame count detection. The checksum of the single-redundant serial port data that passes the frame count detection is calculated to obtain the current checksum. The checksum in the single-redundant serial port data of each serial port type is used as the received checksum. It is determined whether the current checksum is consistent with the received checksum. If not, the checksum detection information is set to the received data frame error, and the serial port data reception fault count is incremented by one.
[0104] If so, the checksum detection information is set to the correctness of the received data frame, and the serial port data reception fault count is cleared to zero, thus obtaining single-redundancy serial port data that has passed the checksum detection.
[0105] Based on the serial port data reception fault count, in response to the frame header detection information being "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
[0106] In this embodiment, when a single redundant serial port data passes the frame count detection, it is determined that the data has been updated. The checksum detection continues, and the checksum of the single redundant serial port data that has passed the frame count detection is recalculated to obtain the current checksum. The checksums in the single redundant serial port data of each serial port type are used as the received checksum, and it is determined whether the checksums are consistent.
[0107] Determine if the current checksum matches the received checksum. If they match, the received data frame is considered correct, and redundant serial port data that has passed the checksum detection is obtained. If they do not match, the received data frame is considered incorrect, and the data reception fault count is incremented by 1. If a data frame header is found in any cycle, the fault count is cleared to zero.
[0108] If the received data has not been updated for at least 3 consecutive cycles, the redundant serial port data reception is considered to be faulty, and the current redundant serial port data reception fault information is output.
[0109] S206. In response to the fact that the single-redundancy serial port data zero-prevention detection, frame header detection, frame count detection and checksum detection are all passed in each cycle, the single-redundancy serial port data that has passed the checksum detection is identified as valid, and the detection redundancy serial port data is obtained.
[0110] S207. Report the current redundancy serial port data communication failure information and the current redundancy serial port data reception failure information to complete the preliminary safety test.
[0111] In this embodiment, if the single-redundancy serial port data zero-prevention detection, frame header detection, frame count detection, and checksum detection all pass in each cycle, then the single-redundancy serial port data of the current serial port type (i.e., the redundant serial port data after checksum detection) is considered to be received correctly and is deemed valid. The valid single-redundancy serial port data is integrated into valid redundant serial port data to obtain the detected redundant serial port data.
[0112] In this embodiment, as Figure 2 As shown, the current redundancy serial port data reception fault information and the current redundancy serial port data reception fault information are reported.
[0113] Based on the detection redundancy serial port data, the current redundancy serial port data reception fault information, and the current redundancy serial port data reception fault information, the device serial port data reception fault is judged. If all redundancy serial ports output the current redundancy serial port data reception fault information or all redundancy serial ports output the current redundancy serial port data communication fault information, the device serial port reception fault is judged.
[0114] If any redundant serial port in the redundant serial port does not output the current redundant serial port data reception fault information, it is determined that the device serial port reception is normal, and the judgment result is obtained.
[0115] Based on the judgment results, the device serial port data receiving failure is reported, the external device is notified that the device is malfunctioning, and safety measures are taken to complete the preliminary safety test.
[0116] Fault diagnosis explanation using a triple-redundancy serial port including redundancy 1, redundancy 2, and redundancy 3:
[0117] If all three redundant serial port input data are judged to be serial port data reception failure or serial port data communication failure, then the device serial port reception failure is judged; otherwise, if any redundant serial port input data reception is fault-free, then the device serial port reception is judged to be normal, and the judgment result is obtained.
[0118] Each cycle, the device reports a fault in receiving data via the serial port and notifies external devices of the device's malfunction, allowing for timely safety measures to be taken.
[0119] By setting up a fault reporting mechanism, timely warnings can be issued to peripheral equipment to enable effective responses and ensure flight safety. Through the fault diagnosis and reporting mechanism, timely warnings can be provided to peripheral equipment, allowing them to take timely measures to prevent abnormal situations and improve the timeliness of flight safety responses.
[0120] S3. Based on the redundancy count, establish a redundancy data voting mechanism. In response to the end of single-redundancy serial port data detection for each serial port type, the redundancy data voting mechanism is used to vote on the redundancy serial port data for each serial port type in the current period, and the voted serial port data is obtained.
[0121] In this embodiment, a redundancy data voting mechanism is established based on the redundancy number. After the single redundancy serial port data of each serial port type is detected, the redundancy serial port data of each serial port type in the current period is voted on based on the detected redundancy serial port data and the redundancy data voting mechanism is used to obtain the voted serial port data.
[0122] This embodiment uses a triple-redundancy serial port, including redundancy 1, redundancy 2, and redundancy 3, to illustrate the voting mechanism:
[0123] Based on the detection redundancy serial port data, obtain the validity of the redundancy 1 serial port input data, redundancy 2 serial port input data, and redundancy 3 serial port input data;
[0124] When the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are all valid:
[0125] Determine whether the data frames of the current cycle's redundant 1 serial port input data, redundant 2 serial port input data, and redundant 3 serial port input data are consistent. If they are consistent, then the redundant 1 serial port input data is used as the voted serial port data by default.
[0126] If only the data frame of the serial port input data of Redundancy 1 is consistent with the data frame of the serial port input data of Redundancy 3, or only the data frame of the serial port input data of Redundancy 1 is consistent with the data frame of the serial port input data of Redundancy 2, then the serial port input data of Redundancy 1 is used as the voted serial port data.
[0127] If only the data frames of the redundant 2 serial port input data and the redundant 3 serial port input data are consistent, then the redundant 2 serial port input data is used as the voted serial port data.
[0128] If the data frames of the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are inconsistent, then the valid serial port data of the previous period will be used as the voted serial port data of the current period.
[0129] When only the serial port input data of redundancy 1 and the serial port input data of redundancy 3 are valid, it is determined whether the data frames of the serial port input data of redundancy 1 and the serial port input data of redundancy 3 are consistent. If they are consistent, the serial port input data of redundancy 1 is used as the voted serial port data by default. If they are inconsistent, the voted serial port data that was valid in the previous period is used as the voted serial port data in the current period.
[0130] When only the serial port input data of Redundancy 1 and Redundancy 2 are valid, it is determined whether the data frames of the serial port input data of Redundancy 1 and Redundancy 2 are consistent. If they are consistent, the serial port input data of Redundancy 1 is used as the voted serial port data by default. If they are inconsistent, the voted serial port data that was valid in the previous period is used as the voted serial port data in the current period.
[0131] When only the redundant 2 serial port input data and the redundant 3 serial port input data are valid, it is determined whether the data frames of the redundant 2 serial port input data and the redundant 3 serial port input data are consistent. If they are consistent, the redundant 2 serial port input data is used as the voted serial port data by default. If they are inconsistent, the voted serial port data that was valid in the previous period is used as the voted serial port data in the current period.
[0132] When only one redundant serial port input data is valid, that redundant serial port data is used as the voted serial port data;
[0133] When the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are all invalid, the valid serial port data from the previous period is used as the voted serial port data for the current period.
[0134] S4. Use the voted serial port data for embedded software calculation to complete the redundancy serial port input data security detection.
[0135] In this embodiment, secure and valid voted serial port data is used for embedded software calculation to complete the security detection of redundant serial port input data.
[0136] Example 2
[0137] In this embodiment, the redundant serial port input data security detection method for embedded software based on Embodiment 1 is as follows: Figure 3 The detection method mechanism shown takes the reception of three RS422 bus data channels by an airborne device as an example, using the same data input as the device. The detection steps for receiving data using this method are as follows:
[0138] Define the RS422 serial bus communication data frame format, as shown in Table 1. Table 1 is the RS422 bus communication data frame format definition table.
[0139] Table 1
[0140]
[0141] According to Table 1, assume that the values of the 15 bytes of the RS422 data frame input for the current cycle with 3 redundancy inputs are all:
[0142] 0x55,0xAA,0x0F,0x02,0x00,0x00,0x61,0xA8,0xAF,0xC8,0xD6,0xD8,0xFD,0xE8,0xDC;
[0143] The values of bytes 7 and 8 are calculated as follows: 25 × 1000 = 25000 (decimal), which is 0x61A8 in hexadecimal. According to the communication characteristic of high byte first and low byte last, the value of the 7th byte is 0x61 and the value of the 8th byte is 0xA8. The calculation of other data is similar.
[0144] The final 15th byte checksum calculation: Starting from the 3rd byte 0x0F to the 14th byte 0xE8, the value of each byte is accumulated sequentially, finally resulting in 0x624. The lower 8 bits are taken as 0x24, and then the complement is taken as 0x100-0x24=0xDC, finally obtaining the checksum as 0xDC.
[0145] In this embodiment, as Figure 4 As shown, the redundant serial port data is received periodically and stored in the corresponding buffer.
[0146] like Figure 5 As shown, zero-prevention detection is performed for each redundancy in each cycle. When the fault is cleared to zero, it indicates that the communication in this cycle and redundancy is normal and data has been received.
[0147] In this embodiment, as Figure 6 As shown, for each redundancy that passes the zero-prevention detection in each cycle, a frame header detection is performed. When the frame header detection of the current redundancy data in this cycle passes, i.e. the fault is cleared, it indicates that the frame header of the current redundancy data in this cycle has been found.
[0148] like Figure 7 As shown, each redundancy that passes the frame header detection in each cycle is checked for frame count. When the frame count of the redundancy data in this cycle passes the detection, i.e. the fault is cleared, it indicates that the redundancy data in this cycle has been updated.
[0149] like Figure 8 As shown, the redundancy of each frame count detection in each cycle is checked and tested separately. When the redundancy data verification and detection of this cycle passes, i.e. the fault is cleared, it indicates that the redundancy data of this cycle is correct.
[0150] In this embodiment, as Figure 2As shown, the validity of the received data for each cycle and each redundancy is judged. If the zero-prevention detection, frame header detection, frame count detection, and checksum detection for each cycle and each redundancy all pass, the received data for this cycle and this redundancy is valid. Then, the device serial port data reception fault is judged, the judgment result is obtained and uploaded, and the preliminary security test is completed.
[0151] In this embodiment, each cycle performs redundancy data voting according to the 3-redundancy voting mechanism to obtain the voted serial port data, and completes the redundancy serial port input data security detection. The voting mechanism is shown in Table 2 below. Table 2 is the 3-redundancy data voting mechanism table.
[0152] Table 2
[0153]
[0154] The secure and valid serial port data obtained through voting was used for embedded software calculation, thus completing the final security detection of redundant serial port input data.
Claims
1. A method for detecting redundant serial port input data security in embedded software, characterized in that, Includes the following steps: S1. Obtain the serial port type received by the device and the serial port type and redundancy number sent by the external device, confirm the consistency of the serial port type and serial port characteristics, and formulate the serial port communication protocol. S2. Based on the serial communication protocol, receive and store the redundancy serial port data of various serial port types, and use a preset detection method to parse and detect the single redundancy serial port data to obtain the detected redundancy serial port data, thus completing the preliminary security detection. Specifically: S201. Based on the serial communication protocol, periodically accept redundant serial port data of each serial port type, and store the redundant serial port data of each serial port type in the buffer of the corresponding redundant serial port. S202. In each cycle, set a serial port data communication fault count, perform zero-prevention detection on the single-redundant serial port data of each serial port type, and determine whether data has been received. If so, obtain the single-redundant serial port data that has passed the zero-prevention detection; otherwise, output the current redundant serial port data communication fault information. S203. Set the serial port data reception fault count. Perform frame header detection on the single-redundancy serial port data that passes the zero-prevention detection. Determine whether the frame header is found. If it is, obtain the single-redundancy serial port data that passes the frame header detection. Otherwise, output the current redundancy serial port data reception fault information. S204. Perform frame count detection on the single-redundancy serial port data that has passed the frame header detection, and determine whether the data frame has been updated. If so, obtain the single-redundancy serial port data that has passed the frame count detection; otherwise, output the current redundancy serial port data reception fault information. S205. Perform a checksum check on the single-redundancy serial port data that has passed the frame count detection, and determine whether the checksum is consistent. If it is, obtain the single-redundancy serial port data that has passed the checksum detection; otherwise, output the current redundancy serial port data reception fault information. S206. In response to the fact that the single-redundancy serial port data zero-prevention detection, frame header detection, frame count detection and checksum detection are all passed in each cycle, the single-redundancy serial port data that has passed the checksum detection is identified as valid, and the detection redundancy serial port data is obtained. S207. Report the current redundancy serial port data communication failure information and the current redundancy serial port data reception failure information to complete the preliminary safety test; S3. Based on the redundancy number, formulate a redundancy data voting mechanism. In response to the end of the single redundancy serial port data detection for each serial port type, based on the detected redundancy serial port data, use the redundancy data voting mechanism to vote on the redundancy serial port data for each serial port type in the current period, and obtain the voted serial port data. S4. Use the voted serial port data for embedded software calculation to complete the redundancy serial port input data security detection.
2. The method for detecting redundant serial port input data in embedded software according to claim 1, characterized in that, S1 includes the following steps: S101. Obtain the serial port type received by the device and the serial port type and redundancy number sent by the external device, confirm the consistency of the received and sent serial port types and serial port characteristics, and obtain the detected serial port type. S102. For redundant serial ports of different types in the detection serial port type, formulate a unified serial port communication protocol that includes serial port characteristics and communication data frame format.
3. The method for detecting redundant serial port input data in embedded software according to claim 2, characterized in that, The serial port characteristics include: communication transmission rate, data width, and parity bit; The communication data frame format includes: a two-byte frame header, a one-byte data length, a one-byte frame count, a preset length of data, and a one-byte checksum.
4. The method for detecting redundant serial port input data in embedded software according to claim 1, characterized in that, Specifically, S202 is as follows: In each cycle, a serial port data communication fault count is set, and zero-prevention detection is performed on the single-redundant serial port data of each serial port type. The data in the data buffer is detected by using a polling method, and it is determined whether all the data in the data buffer is zero. If so, the zero-prevention detection information is set to no data received, and the serial port data communication fault count is incremented by one. If not, set the zero-prevention detection information to received data and clear the fault count to obtain single-redundancy serial port data that has passed the zero-prevention detection; Based on the serial port data communication fault count, in response to the zero-prevention detection information not receiving data for at least ten consecutive cycles, the current redundancy serial port data communication fault information is output.
5. The method for detecting redundant serial port input data in embedded software according to claim 1, characterized in that, Specifically, S203 is: Set a serial port data reception fault count. Perform frame header detection on single-redundant serial port data that passes the zero-prevention detection. Use a polling method to confirm each byte in the data buffer in turn, and determine whether the current byte and the next byte in the buffer are frame header data. If not, set the frame header detection information to "frame header not found" and increment the serial port data reception fault count by one. If so, set the frame header detection information to "frame header found", clear the serial port data reception fault count to zero, continue to obtain the data length value of the third byte, and read the complete data frame in the buffer according to the data length value of the third byte to obtain the single-redundancy serial port data that has passed the frame header detection. Based on the serial port data reception fault count, in response to the frame header detection information being "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
6. The method for detecting redundant serial port input data in embedded software according to claim 1, characterized in that, Specifically, S204 is: For single-redundancy serial port data detected by the frame header, perform frame count detection to determine whether the current frame count is different from the previous frame count. If not, set the frame count detection information to data frame not updated and increment the serial port data reception fault count by one. If so, set the frame count detection information to indicate that the data frame has been updated, and clear the serial port data reception fault count to zero, thus obtaining single-redundancy serial port data that has passed the frame count detection. Based on the serial port data reception fault count, in response to the frame count detection information of "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
7. The method for detecting redundant serial port input data in embedded software according to claim 1, characterized in that, Specifically, S205 is: Checksum detection is performed on the single-redundant serial port data that passes the frame count detection. The checksum of the single-redundant serial port data that passes the frame count detection is calculated to obtain the current checksum. The checksum in the single-redundant serial port data of each serial port type is used as the received checksum. It is determined whether the current checksum is consistent with the received checksum. If not, the checksum detection information is set to the received data frame error, and the serial port data reception fault count is incremented by one. If so, the checksum detection information is set to the correctness of the received data frame, and the serial port data reception fault count is cleared to zero, thus obtaining single-redundancy serial port data that has passed the checksum detection. Based on the serial port data reception fault count, in response to the frame header detection information being "frame header not found" for at least three consecutive cycles, the current redundancy serial port data reception fault information is output.
8. The method for detecting redundant serial port input data in embedded software according to claim 1, characterized in that, The redundancy data voting mechanism is as follows: Configure a triple-redundant serial port containing redundancy 1, redundancy 2, and redundancy 3, and obtain the validity of the serial port input data of redundancy 1, redundancy 2, and redundancy 3. In response to the fact that the serial input data of redundancy 1, redundancy 2, and redundancy 3 are all valid, a consistency check is performed on the data frames of the serial input data of redundancy 1, redundancy 2, and redundancy 3. If the data frames of the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are all consistent, then the serial port input data of redundancy 1 will be used as the serial port data after voting. If only the data frame of the serial port input data of redundancy 1 is consistent with the data frame of the serial port input data of redundancy 3, or if only the data frame of the serial port input data of redundancy 1 is consistent with the data frame of the serial port input data of redundancy 2, then the serial port input data of redundancy 1 will be used as the serial port data after voting. If only the data frame of the serial port input data of redundancy 2 is consistent with that of the serial port input data of redundancy 3, then the serial port input data of redundancy 2 will be used as the serial port data after voting. If the data frames of the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are inconsistent, then the serial port data that was voted in the previous cycle will be used as the voted serial port data. In response to the fact that only the serial port input data of redundancy 1 and the serial port input data of redundancy 3 are valid, the consistency of the data frames of the serial port input data of redundancy 1 and the serial port input data of redundancy 3 is judged. If they are consistent, the serial port input data of redundancy 1 is used as the voted serial port data. If they are inconsistent, the serial port data voted in the previous cycle is used as the voted serial port data. In response to the fact that only the serial port input data of redundancy 1 and the serial port input data of redundancy 2 are valid, the consistency of the data frames of the serial port input data of redundancy 1 and the serial port input data of redundancy 2 is judged. If they are consistent, the serial port input data of redundancy 1 is used as the voted serial port data. If they are inconsistent, the serial port data voted in the previous cycle is used as the voted serial port data. In response to the fact that only the redundant 2 serial port input data and the redundant 3 serial port input data are valid, a consistency judgment is performed on the data frames of the redundant 2 serial port input data and the redundant 3 serial port input data. If they are consistent, the redundant 2 serial port input data is used as the voted serial port data. If they are inconsistent, the voted serial port data of the previous cycle is used as the voted serial port data. If only one redundant serial port input data is valid, then the redundant serial port data is used as the voted serial port data; If the serial port input data of redundancy 1, redundancy 2, and redundancy 3 are all invalid, then the serial port data voted in the previous cycle will be used as the voted serial port data.
Citation Information
Patent Citations
Unmanned aerial vehicle flight control system architecture based on TTP / C bus
CN104122896A
Key test instruction system and method based on serial port redundancy strategy
CN106911530A