Frame header detection method and system, electronic equipment and readable storage medium

By intercepting data segments in serial communication and generating reference values, sliding the position to reduce the amount of CRC calculation, the problem of high CPU resource consumption during frame header detection is solved and the system response speed is improved.

CN120301564APending Publication Date: 2025-07-11SHENZHEN INVT ELECTRIC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510567961.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

In serial communication, frequent CRC operations due to data loss during frame head detection seriously consume CPU resources of the receiver device, causing system response delays, especially in high-speed communication or continuous packet loss scenarios.

Method used

By intercepting the data segment of the preset interval as candidate data segments in the received data stream, generating a reference value based on the data to be removed and the target verification data, sliding the position of the preset interval, reducing the amount of CRC calculation, and using incremental update verification values instead of full calculations, reducing CPU load.

Benefits of technology

It effectively reduces the calculation amount of the receiving end device during the frame head detection process, improves the system response speed, reduces CPU resource usage, and optimizes resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120301564A_ABST
    Figure CN120301564A_ABST
Patent Text Reader

Abstract

The invention discloses a frame header detection method and system, electronic equipment and a readable storage medium, and relates to the field of communication, the frame header detection method comprises the following steps: intercepting a data segment of a preset interval from a received data stream as a current candidate data segment; when the calculation verification value of the current candidate data segment is not matched with the corresponding target verification data, generating a reference value based on the to-be-removed data in the current candidate data segment, the calculation verification value and the corresponding target verification data, and sliding the position of the preset interval, removing the to-be-removed data from the new candidate data segment and incorporating the new candidate data segment into corresponding target verification data, and determining the reference value as a calculation verification value of the new candidate data segment; and when the calculation verification value of the new candidate data segment is matched with the corresponding target verification data, determining the first data in the new candidate data segment as an effective frame header. According to the invention, the calculation amount of the receiving end equipment in the frame header detection process can be reduced, and the response speed of the system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and particularly to a frame header detection method, system, electronic device, and readable storage medium. Background Art

[0002] In serial communication, a data frame consists of multiple data, with a CRC (Cyclic Redundancy Check) check value fixed at the end and the frame header at the beginning being dynamically variable to increase the proportion of effective data. The receiving device needs to locate the starting boundary of the data through the check relationship of the dynamic frame header, that is, calculate the CRC for the candidate data segment and match it with the subsequent check bits to correctly split the data frame.

[0003] When communication interference causes data loss, frame header misalignment will occur. At this time, the receiving device needs to traverse all m possible frame header candidate positions (i.e., from the 1st to the mth data), intercept m - 1 data for each candidate position to recalculate the CRC value, and match it with the check value at the next position until a match is successful. This process requires m CRC operations, with each operation involving m - 1 data, and the total calculation amount is as high as (m - 1)×m. In high-speed communication or continuous packet loss scenarios, frequent large-scale CRC operations will seriously consume the CPU (Central Processing Unit) resources of the receiving device, resulting in system response delays.

[0004] Therefore, how to provide a solution to the above technical problems is an issue that those skilled in the art need to solve currently. Summary of the Invention

[0005] The purpose of the present invention is to provide a frame header detection method, system, electronic device, and readable storage medium, which can reduce the calculation amount during frame header detection of the receiving device and improve the response speed of the system.

[0006] To solve the above technical problems, the present invention provides a frame header detection method, including:

[0007] Intercept a data segment within a preset interval in the received data stream as the current candidate data segment;

[0008] When the calculated check value of the current candidate data segment does not match the target check data corresponding to the current candidate data segment, generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, slide the position of the preset interval so that the new candidate data segment removes the data to be removed and includes the target check data corresponding to the current candidate data segment, and determine the reference value as the calculated check value of the new candidate data segment;

[0009] When the calculated check value of the new candidate data segment matches the target check data corresponding to the new candidate data segment, the first data in the new candidate data segment is determined as the valid frame header.

[0010] Optionally, the process of generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data includes:

[0011] Performing influence correlation processing on the calculated check value of the current candidate data segment based on the target check data corresponding to the current candidate data segment to obtain an intermediate check value;

[0012] Performing influence exclusion processing on the intermediate check value based on the data to be removed in the current candidate data segment to obtain a reference value.

[0013] Optionally, performing influence correlation processing on the calculated check value of the current candidate data segment based on the target check data corresponding to the current candidate data segment to obtain an intermediate check value includes:

[0014] Obtaining a first correspondence relationship, where the first correspondence relationship includes the correspondence relationship between multiple first check values and multiple first input values;

[0015] Using the calculated check value of the current candidate data segment and the corresponding target check data to obtain the current first input value, determining the current first check value that matches the current first input value in the first correspondence relationship, and taking the current first check value as the intermediate check value.

[0016] Optionally, performing influence exclusion processing on the intermediate check value based on the data to be removed in the current candidate data segment to obtain a reference value includes:

[0017] Obtaining a second correspondence relationship, where the second correspondence relationship is determined based on the first correspondence relationship and the data frame length, and the second correspondence relationship includes the correspondence relationship between multiple second input values and multiple second check values;

[0018] Taking the data to be removed in the current candidate data segment as the current second input value, and determining the current second check value that matches the current second input value in the second correspondence relationship;

[0019] Using the current second check value and the intermediate check value to obtain a reference value.

[0020] Optionally, the step of determining the second correspondence relationship based on the first correspondence relationship and the data frame length includes:

[0021] Determining a preset bit width range based on the first correspondence relationship;

[0022] For each input value within the preset bit width range, calculate an initial intermediate parameter through the first corresponding relationship, perform m - 1 recursive updates on the initial intermediate parameter to obtain a final intermediate parameter, and obtain a second check value corresponding to the input value according to the logical combination result of the final intermediate parameter, where m is the data frame length;

[0023] Use all the input values and their corresponding second check values to obtain the second corresponding relationship.

[0024] Optionally, the frame header detection method further includes:

[0025] When the calculated check value of the new candidate data segment does not match the target check data corresponding to the new candidate data segment, increment the sliding calculation count.

[0026] Generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, including:

[0027] When the sliding calculation count is not equal to the preset count, generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data.

[0028] Optionally, the frame header detection method further includes:

[0029] When the sliding calculation count is equal to the preset count, set the sliding calculation count to the initial value;

[0030] When the sliding calculation count is the initial value, the calculated check value of the candidate data segment is obtained by performing a check calculation on the valid data subset in the candidate data segment.

[0031] To solve the above technical problems, the present invention also provides a frame header detection system, including:

[0032] A processing module for intercepting a data segment within a preset interval in the received data stream as the current candidate data segment;

[0033] A sliding calculation module for, when the calculated check value of the current candidate data segment does not match the target check data corresponding to the current candidate data segment, generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, sliding the position of the preset interval so that the new candidate data segment removes the data to be removed and incorporates the target check data corresponding to the current candidate data segment, and determining the reference value as the calculated check value of the new candidate data segment;

[0034] A frame header determination module, configured to determine the first data in a new candidate data segment as a valid frame header when the calculated check value of the new candidate data segment matches the target check data corresponding to the new candidate data segment.

[0035] To solve the above technical problems, the present invention also provides an electronic device, including:

[0036] A memory, configured to store a computer program;

[0037] A processor, configured to implement the steps of the frame header detection method as described in any one of the above when executing the computer program.

[0038] To solve the above technical problems, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the frame header detection method as described in any one of the above are implemented.

[0039] The present invention provides a frame header detection method. After the receiving device receives a data stream, if the calculated check value of the current candidate data segment does not match the corresponding target check data, at this time, the calculated check value of the new candidate data segment that slides backward is calculated through the calculated check value of the current candidate data segment, the target check data, and the data to be removed. There is no need to perform a full-scale check calculation on the new candidate data segment. Instead of the traditional full-scale calculation, the check value is updated incrementally, reducing the calculation amount of the CPU of the receiving device during the frame header detection process and improving the response speed of the system.

[0040] The present invention also provides a frame header detection system, an electronic device, and a computer-readable storage medium, which have the same beneficial effects as the above frame header detection method. Description of the Drawings

[0041] To more clearly illustrate the embodiments of the present invention, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0042] Figure 1 It is a flowchart of the steps of a frame header detection method provided by an embodiment of the present invention;

[0043] Figure 2 It is a flowchart for obtaining a second correspondence relationship provided by an embodiment of the present invention;

[0044] Figure 3 It is a schematic diagram of a data frame structure and frame header detection in the related art;

[0045] Figure 4 It is a flowchart for detecting the serial communication frame header in the related art;

[0046] Figure 5 It is a flowchart of steps of another frame header detection method provided by an embodiment of the present invention;

[0047] Figure 6 It is a schematic diagram showing the comparison of the CRC calculation amounts between the conventional frame header detection and the fast frame header detection provided by an embodiment of the present invention;

[0048] Figure 7 It is a schematic structural diagram of a frame header detection system provided by an embodiment of the present invention;

[0049] Figure 8 It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention;

[0050] Figure 9 It is a schematic structural diagram of a computer-readable storage medium provided by an embodiment of the present invention. Specific embodiments

[0051] The core of the present invention is to provide a frame header detection method, system, electronic device and readable storage medium, which can reduce the calculation amount during the frame header detection of the receiving end device and improve the response speed of the system.

[0052] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0053] In a first aspect, please refer to Figure 1 , the present invention provides a frame header detection method, including:

[0054] S101: In the received data stream, intercept a data segment in a preset interval as the current candidate data segment.

[0055] In this embodiment, the received data stream is the data stream received by the receiving-end device and sent by the sending-end device. The data stream includes multiple data frames, and each data frame includes multiple data. To accurately identify the frame header of a valid data frame, that is, the valid frame header in this embodiment, this embodiment first intercepts a data segment in the preset interval in the data stream as the current candidate data segment. Among them, a data frame is usually composed of a valid data part and a check bit. To directly intercept the corresponding valid data, the length of the preset interval in this embodiment can be determined by the data frame structure. For example, if the length of a certain data frame is m, and the data frame is composed of m - 1 valid data and 1 check bit, then the length of the preset interval can be determined as m - 1. Intercepting according to this length can directly correspond to the valid data part in the data frame, and the check bit is used as an independent target check data for comparison. Exemplarily, assume that the data stream includes data A, B, C, D, E, F, G, H, I, J, and the data frame length m = 4, then the length of the preset interval is 3. Then, it is possible to intercept the data segment A, B, C as the current candidate data segment, or it is possible to intercept the data segment B, C, D as the current candidate data segment, or other data segments composed of three consecutive data as the current candidate data segment.

[0056] As an alternative embodiment, after the receiving-end device receives the data stream, when intercepting the data segment for the first time, a continuous data segment with a preset interval (length m - 1) can be intercepted from the starting position of the data stream as the first current candidate data segment, that is, the initial candidate data segment. For example, when the data frame length m = 4, the preset interval length is 3, and the first 3 data (such as data A, B, C) in the data stream are intercepted as the initial candidate data segment for the first time. It can be understood that in the communication initialization stage, the receiving-end device usually has no prior information to determine the position of the valid frame header. Intercepting the initial candidate data segment from the starting position of the data stream can immediately start the detection process without waiting or guessing the frame header position, significantly reducing the initial detection delay. In addition, when the data stream arrives suddenly, intercepting from the starting position can immediately process the earliest-arrived data and avoid the risk of buffer overflow. Even if the data stream is out of order due to transmission problems, the valid frame header can be reliably located by gradually sliding the detection from the starting position.

[0057] S102: When the calculated check value of the current candidate data segment does not match the target check data corresponding to the current candidate data segment, a reference value is generated based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data. Slide the position of the preset interval so that the new candidate data segment removes the data to be removed and includes the target check data corresponding to the current candidate data segment, and determine the reference value as the calculated check value of the new candidate data segment.

[0058] In this embodiment, after intercepting the current candidate data segment according to the preset interval, it may further include an operation of determining whether the current candidate data segment meets the preset conditions. The preset conditions include that the calculated check value of the current candidate data segment matches the target check data corresponding to the current candidate data segment. It can be understood that a data frame is composed of a valid data part and a check value, and the check value is obtained by performing a check calculation on the valid data part (such as cyclic redundancy check CRC, Hamming Code, Parity Check, Checksum, etc.). The candidate data segment in this embodiment is the valid data part of a hypothetical data frame. After determining the current candidate data segment, the target check data corresponding to the current candidate data segment is determined. The position of the target check data corresponding to the current candidate data segment in the data frame is determined based on the data frame structure. Assume that the data frame structure is composed of m - 1 valid data and 1 check bit. The first m - 1 data in the data frame are valid data, and the first m - 1 data are the candidate data segments in this embodiment. The mth data in the data frame is the check bit. Then, the target check data corresponding to the candidate data segment is the next data after the tail data (the last data) of the candidate data segment. Still taking the data stream received by the receiving device including data A, B, C, D, E, F, G, H, I, J, the data frame length m = 4, and the length of the preset interval being 3 as an example, the current candidate data segment is A, B, C, and the tail data of the current candidate data segment is C. Then, the target check data of this candidate data segment is the next data after the tail data of the candidate data segment, that is, the target check data is D. Under the above data frame structure, the target check data is the data in the data frame that is adjacent to and after the candidate data segment.

[0059] The data frame structure can be other structures in addition to the above structure. For example, a certain data frame structure can be [Header, Data, CRC], where Header includes check bit offset information. Parse Header to obtain the check bit offset and dynamically determine the check bit position. Assume that Header indicates that the check bit is the kth data after Data. The candidate data segment is Data, and the target check bit is the kth data after Data. Of course, in addition to the above structure, it can also be other structures, which can be selected according to actual engineering needs. This embodiment does not make specific limitations here.

[0060] After determining the current candidate data segment and the target check data corresponding to the current candidate data segment, determine whether the calculated check value of the current candidate data segment matches the target check data corresponding to the current candidate data segment. If the calculated check value of the candidate data segment is exactly the same as the corresponding target check data, it means that the calculated check value and the target check value match, and the current candidate data segment meets the preset conditions. If the calculated check value of the current candidate data segment is not exactly the same as the corresponding target check data, it means that the calculated check value and the target check data do not match, and the current candidate data segment does not meet the preset conditions. Of course, for some data streams, it is allowed that some bits (such as high / low byte) of the calculated check value are the same as the target check data. For example, only check whether the high byte is consistent. If it is consistent, it is determined that the calculated check value and the target check data match. A fault tolerance threshold can be set, such as allowing at most two bits to be different, etc. The matching condition can also be dynamically adjusted according to the communication transmission environment. For example, in a high signal-to-noise ratio environment, strict full matching is required. In a low signal-to-noise ratio environment, partial bit differences are allowed or the check intensity is reduced. The matching condition can be set according to the actual engineering needs, and this embodiment does not make specific limitations here.

[0061] In this embodiment, if the currently intercepted current candidate data segment does not meet the above preset conditions, it means that the first data of the current candidate data segment is not a valid frame header. At this time, perform a sliding check calculation until the new candidate data segment after sliding meets the preset conditions. The sliding check calculation includes generating a reference value based on at least one data to be removed in the candidate data segment, the calculated check value, and the corresponding target check data, sliding the position of the preset interval, so that the new candidate data segment removes the data to be removed and incorporates the target check data of the current candidate data segment, and enters the step of determining whether the new candidate data segment meets the preset conditions.

[0062] Among them, the number of data to be removed in the current candidate data segment is determined based on the sliding position of the preset interval. Assuming that the preset interval slides backward by one bit, the data to be removed in the candidate data segment only includes one, that is, the data to be removed is the first data in the candidate data segment. If the preset interval slides backward by two bits, the data to be removed in the candidate data segment includes two, that is, the data to be removed includes the first two data in the candidate data segment, and so on.

[0063] It can be understood that by sliding the position of the preset interval, a new candidate data segment can be obtained. The new candidate data segment removes the data to be removed and incorporates the target verification data. Exemplarily, still taking the data stream received by the receiving-end device including data A, B, C, D, E, F, G, H, I, J as an example, the data frame structure is that the first m - 1 data are the valid data part, the mth data is the check bit, the data frame length m = 4, and the length of the preset interval is 3. Assume that the current candidate data segment of the currently intercepted preset interval is A, B, C. By sliding the position of the preset interval, such as sliding one bit backward, the new candidate data segment obtained is B, C, D. The new candidate data segment removes the data A to be removed in the current candidate data segment and incorporates the target verification data D corresponding to the current candidate data segment. In this embodiment, when the currently intercepted candidate data segment does not meet the preset conditions, a reference value is generated based on at least one data to be removed in the candidate data segment, the calculated check value, and the corresponding target verification data. The reference value is actually the check value obtained by adjusting the calculated check value of the candidate data segment according to a certain increment adjustment rule based on the data to be removed that needs to be removed in the new candidate data segment and the target verification data newly introduced in the new candidate data segment. The increment adjustment rule corresponds to the sliding rule of the preset interval. Therefore, in this embodiment, the reference value generated from the relevant data of the candidate data segment can be directly used as the calculated check value of the new candidate data segment, without having to re-verify and calculate all the data in the new candidate data segment, reducing the CPU occupancy rate of the receiving-end device for frame header detection and improving the response speed of the system.

[0064] Exemplarily, still taking the data stream received by the receiving device including data A, B, C, D, E, F, G, H, I, J as an example, the data frame structure is that the first m - 1 data are the valid data part, the mth data is the check bit, the data frame length m = 4, and the length of the preset interval is 3. Assume that the initial candidate data segment is A, B, C. Since it is the starting calculation and there is no prior data, therefore, the calculated check value vCRC(0) of the initial candidate data segment [A, B, C] can be calculated based on the full - amount check calculation method. If vCRC(0) does not match D, move the preset interval one bit backward to get a new candidate data segment [B, C, D]. The calculated check value of the new candidate data segment [B, C, D] is vCRC(1) obtained by adjusting vCRC(0) based on A and D according to the preset incremental adjustment rule. Then, perform the step of determining whether the candidate data segment meets the preset conditions. The current candidate data segment is the candidate data segment [B, C, D], and the target check data corresponding to this candidate data segment [B, C, D] is E. Determine whether vCRC(1) matches E. If it does not match, move the preset interval one bit backward to get a new candidate data segment [C, D, E]. The calculated check value of the new candidate data segment [C, D, E] is vCRC(2) obtained by adjusting vCRC(1) based on B and E according to the preset incremental adjustment rule. Then, perform the step of determining whether the candidate data segment meets the preset conditions. The current candidate data segment is the candidate data segment [C, D, E], and the target check data corresponding to this candidate data segment [C, D, E] is F. Determine whether vCRC(2) matches F. If it does not match, loop and execute the above steps.

[0065] As an alternative embodiment, this embodiment can also set the end condition of the above - mentioned loop calculation, such as the loop count reaches the preset number of times or the calculated check value of the candidate data segment matches its corresponding target check data, etc. If it still fails to identify that the calculated check value of a certain candidate data segment matches its corresponding target check data when the loop count reaches the preset number of times, at this time, the above - mentioned sliding check calculation is no longer executed, but other check calculation methods are used to calculate the calculated check value of this candidate data segment, eliminating the error accumulation of the sliding check calculation, avoiding the influence caused by the error accumulation of the sliding check calculation resulting in infinite loop calculation, achieving a balance between efficient incremental update and necessary full - amount check, and optimizing resource utilization.

[0066] As another alternative embodiment, if the calculated check value of the current candidate data segment matches the corresponding target check data, then determine the first data in the current candidate data segment as the valid frame header.

[0067] S103: When the calculated check value of the new candidate data segment matches the target check data corresponding to the new candidate data segment, determine the first data in the new candidate data segment as the valid frame header.

[0068] In this embodiment, when the calculated check value of a certain candidate data segment matches its corresponding target check value, it indicates that the candidate data segment meets the preset conditions. The candidate data segment is a valid data part with a complete data frame, and then the first data of the candidate data segment is determined as the valid frame header.

[0069] It can be seen that in this embodiment, after the receiving device receives the data stream, if the calculated check value of the current candidate data segment does not match the corresponding target check data, at this time, based on the calculated check value of the current candidate data segment, the target check data, and the data to be removed, calculate the calculated check value of the new candidate data segment that slides backward. There is no need to perform a full-scale check calculation on the new candidate data segment. By incrementally updating the check value to replace the traditional full-scale calculation, the computational load of the CPU of the receiving device during the frame header detection process is reduced, and the response speed of the system is improved.

[0070] Based on the above embodiments:

[0071] In an exemplary embodiment, the process of generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data includes:

[0072] Perform an influence association process on the calculated check value of the current candidate data segment based on the corresponding target check data of the current candidate data segment to obtain an intermediate check value;

[0073] Perform an influence exclusion process on the intermediate check value based on the data to be removed in the current candidate data segment to obtain a reference value.

[0074] It can be understood that the data to be removed from the current candidate data segment is the data to be removed in the new candidate data segment, and the target verification data is the data to be incorporated in the new candidate data segment. Therefore, by adjusting the calculated verification value of the current candidate data segment according to the incremental adjustment rule based on the data to be removed from the current candidate data segment and the corresponding target candidate data, the calculated verification value of the new candidate data segment can be obtained. Specifically, since the target verification data is the data to be incorporated in the new candidate data segment, the influence of the target verification data corresponding to the current candidate data segment on the calculated verification value of the current candidate data segment is associated, so as to increase the influence factor of the target verification data in the calculated verification value of the current candidate data segment. At least one piece of data to be removed from the candidate data segment is the data to be removed in the new candidate data segment. Therefore, it is also necessary to perform influence exclusion processing on the intermediate verification value based on the data to be removed from the current candidate data segment, so as to exclude the influence factor of the data to be removed from the current candidate data segment in the calculated verification value of the current candidate data segment. The reference value obtained thereby can be used as the calculated verification value of the new candidate data segment. Correspondingly, the incremental adjustment rule in this embodiment includes introducing the influence factor of the target verification data into the calculated verification value of the candidate data segment and excluding the influence factor of the data to be removed.

[0075] Considering that the calculation direction of the verification calculation for the data stream is usually from left to right (i.e., the transmission direction of the data stream), this embodiment adopts a solution of first introducing the influence factor of the target verification data corresponding to the current candidate data segment and then excluding the influence factor of the data to be removed from the current candidate data segment, continuing the original forward calculation process, reducing the risk of intermediate state anomalies, and further improving the recognition efficiency of the valid frame header.

[0076] Of course, it is also possible to adopt a solution of first excluding the influence factor of the data to be removed from the current candidate data segment and then introducing the influence factor of the target verification data corresponding to the current candidate data segment. It can be selected according to the actual engineering needs, and this embodiment does not make specific limitations here.

[0077] In an exemplary embodiment, performing influence association processing on the calculated verification value of the current candidate data segment based on the target verification data corresponding to the current candidate data segment to obtain an intermediate verification value includes:

[0078] Obtain a first correspondence relationship, where the first correspondence relationship includes the correspondence relationship between multiple first verification values and multiple first input values;

[0079] Use the calculated verification value of the current candidate data segment and the corresponding target verification data to obtain the current first input value, determine the current first verification value that matches the current first input value in the first correspondence relationship, and use the current first verification value as the intermediate verification value.

[0080] It can be understood that the first correspondence relationship is determined based on the polynomial used for the current verification calculation. For example, if CRC verification is adopted, the first correspondence relationship is generated based on the CRC polynomial. The first correspondence relationship is used to map the first input value to the CRC verification value (i.e., the first verification value in this embodiment). In this embodiment, the first correspondence relationship can be established in advance based on different first input values and the mapped CRC verification values, and the forward lookup table crcTable is obtained based on the first correspondence relationship and stored in the receiving device for subsequent calls.

[0081] Exemplarily, the CRC verification value is essentially the remainder after the modulo-two division of the data polynomial by the generating polynomial. The CRC algorithm satisfies linear superposition, that is: , and due to this characteristic, the update of the calculated verification value of the current candidate data segment can be achieved through an exclusive OR operation.

[0082] In this embodiment, the current first input value of the forward lookup table crcTable is obtained by performing an exclusive OR operation on the calculated verification value of the current candidate data segment and the target verification data. The influence factor of the target verification data corresponding to the current candidate data segment is introduced into the calculated verification value of the current candidate data segment through the exclusive OR operation, and then the current first input value is used to match among the various first verification values in the forward lookup table crcTable to obtain the current first verification value. In this embodiment, the current first verification value is used as the intermediate verification value.

[0083] As an optional embodiment, the calculation method of the intermediate verification value is represented by the first relational expression:

[0084] , where is the intermediate verification value, is the calculated verification value of the current candidate data segment, is the target verification data corresponding to the current candidate data segment, is the exclusive OR calculation, is the current first input value, is the first data of crcTable.

[0085] In an exemplary embodiment, the influence of the data to be removed from the current candidate data segment on the intermediate verification value is excluded to obtain a reference value, including:

[0086] Obtain a second correspondence relationship, which is determined based on the first correspondence relationship and the data frame length. The second correspondence relationship includes the correspondence relationship between multiple second input values and multiple second verification values;

[0087] Use the data to be removed from the current candidate data segment as the current second input value, and determine the current second verification value that matches the current second input value in the second correspondence relationship;

[0088] Obtain a reference value by using the current second check value and the intermediate check value.

[0089] In this embodiment, the role of the second correspondence is to quickly eliminate the historical influence of the data to be removed on the calculation of the check value. The second correspondence is generated based on the first correspondence and the data frame length, specifically generated based on the inverse operation of the polynomial for generating the first correspondence. The reverse compensation value corresponding to each data to be removed (i.e., the second check value in this embodiment) is pre-calculated. The second correspondence includes the correspondence between the second input value (data to be removed) and the second check value. Based on the second correspondence, the reverse lookup table rcrcTable is obtained and stored in the receiving device for subsequent calls.

[0090] In this embodiment, the data to be removed in the current candidate data segment is used as the current second input value to be matched in the reverse lookup table rcrcTable to obtain the current second check value. The current second check value and the intermediate check value are XOR-operated to exclude the influence factor of the data to be removed in the current candidate data segment from the intermediate check value. The obtained reference value is the check value that introduces the influence factor of the target check data and excludes the influence factor of the data to be removed. Therefore, it can be directly used as the calculation check value of the new candidate data segment that introduces the target check data and removes the data to be removed.

[0091] Adopting the solution of this embodiment, when obtaining the calculation check value of the new candidate data segment, only two look-up table operations and two XOR operations are required. The calculation amounts of the intermediate check value and the reference value are equivalent to the CRC value calculation amounts of 2 data, which is much smaller than the calculation amount of calculating the CRC value for all data in the new candidate data segment. Thus, the CPU calculation amount during frame header detection by the receiving device is reduced, and the system response speed is improved.

[0092] As an optional embodiment, the calculation method of the reference value is represented by a second relational expression:

[0093] , where is the reference value, is the intermediate check value, is the data to be removed in the candidate data segment, is the current second check value.

[0094] Exemplarily, still taking the data stream received by the receiving device including data A, B, C, D, E, F, G, H, I, J, the data frame structure being that the first m - 1 data are the valid data part, the mth data is the check bit, the data frame length m = 4, and the length of the preset interval being 3 as an example. Assume that the first candidate data segment is [A, B, C]. Since it is the starting calculation and there is no prior data, therefore, the calculated check value vCRC(0) of the initial candidate data segment [A, B, C] can be calculated based on the traditional check calculation method. If vCRC(0) does not match D, perform at least one round of sliding check calculation until the candidate data segment meets the preset conditions, referring to Calculate the intermediate check value, the intermediate check value is an intermediate quantity obtained by introducing the influence factor of D on the basis of vCRC(0), and then referring to Calculate the reference value, and take as the calculated check value vCRC(1) of the second candidate data segment [B, C, D], and determine whether vCRC(1) matches E. If not, referring to Calculate the intermediate check value, the intermediate check value is an intermediate quantity obtained by introducing the influence factor of E on the basis of vCRC(1), and then referring to Calculate the reference value, and take as the calculated check value vCRC(2) of the third candidate data segment [C, D, E], and determine whether vCRC(2) matches F. If not, repeat the above steps. Among them, represents the reference value in the kth round of sliding check calculation, represents the intermediate check value in the kth round of sliding check calculation, , represents the calculated check value of the data segment, .

[0095] In an exemplary embodiment, the step of determining the second correspondence relationship based on the first correspondence relationship and the data frame length includes:

[0096] Determine the preset bit width range based on the first correspondence relationship;

[0097] For each input value within the preset bit width range, calculate the initial intermediate parameter through the first correspondence relationship, perform m - 1 times of recursive update on the initial intermediate parameter to obtain the final intermediate parameter, and obtain the second check value corresponding to the input value according to the logical combination result of the final intermediate parameter, where m is the data frame length;

[0098] Use all input values and their corresponding second check values to obtain the second correspondence relationship.

[0099] In this embodiment, the bit width range of the second correspondence is determined based on the preset bit width range of the first correspondence. Exemplarily, if the preset bit width range of the first correspondence is [0, 255], then the bit width range of the second correspondence is [0, 255]. For each input value i within the preset bit width range, the initial intermediate parameter is calculated through the first correspondence, and the initial intermediate parameter is recursively updated m - 1 times to obtain the final intermediate parameter. According to the logical combination result of the final intermediate parameter, the second check value corresponding to the input value is obtained.

[0100] Specifically, referring to Figure 2 , Figure 2 the calculation process of rcrcTable with CRC8 as an example is as follows:

[0101] Traverse all input values i within the preset bit width range and perform the following operations:

[0102] Initialize the intermediate variables x and y to 0;

[0103] Calculate the initial intermediate value through the forward lookup table:

[0104] ; ;

[0105] For each input value i, execute the inner loop, , and update the intermediate variables:

[0106] ;

[0107] ;

[0108] When, according to the exclusive - OR result of the final intermediate variables x and y, generate the second check value corresponding to the input value i:

[0109] ;

[0110] Generate the second correspondence according to the second check values corresponding to all input values i, and finally obtain the reverse lookup table , in this embodiment, the number of inner loop times is determined by m - 1, which is directly related to the data frame length to ensure that the reverse lookup table adapts to different window structures.

[0111] In an exemplary embodiment, the frame header detection method further includes:

[0112] When the calculated check value of the new candidate data segment does not match the target check data corresponding to the new candidate data segment, increment the sliding calculation times;

[0113] Generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, including:

[0114] When the number of sliding calculations is not equal to the preset number, generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data.

[0115] In this embodiment, a variable k is preset in advance to record the number of sliding check calculations, that is, the number of sliding calculations in this embodiment. The initial value of k can be set to 1. Each time entering a sliding check calculation, increment the number of sliding calculations. It can be incremented by referring to the method. In this embodiment, a preset number is also preset in advance. When the number of sliding calculations does not reach the preset number, execute the step of generating a reference value based on at least one piece of data to be removed, the calculated check value, and the corresponding target check data in the current candidate data segment. It can be understood that each time of sliding, incremental update may introduce tiny errors. After sliding m - 1 times, the cumulative error may exceed the check tolerance range and needs to be reset. Therefore, the preset number in this embodiment is used to represent that the cumulative error of the sliding check calculation may affect the calculation result. The preset number can be set according to experience or based on the data frame length. For example, set the preset number to m - 1 to ensure that after the candidate data segment slides to cover all possible starting positions of the original data frame, a full - scale check calculation is performed, such as a full - scale CRC operation, to avoid cross - frame error interference.

[0116] In an exemplary embodiment, the frame header detection method further includes:

[0117] When the number of sliding calculations is equal to the preset number, set the number of sliding calculations to the initial value;

[0118] When the number of sliding calculations is the initial value, the calculated check value of the candidate data segment is obtained by performing a check calculation on the valid data subset in the candidate data segment.

[0119] Considering that the sliding check calculation in this embodiment is based on the incremental update rule (lookup table + exclusive - OR operation), its correctness depends on the following conditions: the compensation value pre - calculated in the reverse lookup table (rcrcTable) is accurate and / or there is no abnormal data in the data stream caused by continuous packet loss or burst interference. If the above conditions are not met, the check value error may gradually accumulate after multiple slides, resulting in all subsequent incremental update results deviating from the true value, and finally unable to match the valid frame header, falling into an infinite loop. Therefore, in this embodiment, when the number of sliding calculations reaches m - 1, reset the number of sliding calculations to the initial value 1, and when the number of sliding calculations is 1, use the original full - scale check calculation to regenerate the check value.

[0120] It can be understood that by adopting the solution of this embodiment, the cumulative error during the sliding process can be eliminated, the accuracy of subsequent detection can be ensured, the complete verification operation can be directly performed on the data in the current candidate data segment, the influence of historical incremental updates can be ignored, the calculation verification value can be reset to an accurate state, and error transmission can be avoided.

[0121] Taking CRC check as an example, the frame header detection processes in the present invention and related technologies will be described separately below.

[0122] Combined with Figure 3 and Figure 4 , Figure 3 is a schematic diagram of a data frame structure and frame header detection in related technologies. Figure 4 is a flowchart of serial communication frame header detection in related technologies. When the communication is normal, after device 2 performs CRC calculation on the first to the (m - 1)th data in the received data packet, and confirms that the CRC calculation value is equal to the mth data, it is detected that the frame is a valid frame, and thus the first data is confirmed as the frame header of the current valid frame.

[0123] If one or some data are lost due to interference or other reasons during communication, such as Figure 2 the 10th data is lost, the general process of device 2 for frame header detection is as shown in Figure 3 : First, perform CRC calculation on the first to the 9th data, the 11th to the mth data, a total of (m - 1) data. After confirming that the CRC calculation value is not equal to the (m + 1)th data; then perform CRC calculation on the second to the 9th data, the 11th to the (m + 1)th data, a total of (m - 1) data. After confirming that the CRC calculation value is not equal to the (m + 2)th data... until perform CRC calculation on the (m + 1)th to the (2m - 1)th data, a total of (m - 1) data, and confirm that the CRC calculation value is equal to the 2mth data, then a valid frame can be detected, and thus the (m + 1)th data is confirmed as the frame header of the current valid frame. It can be seen that in the above process of detecting the frame header, each time CRC calculation is performed on (m - 1) data, and a total of m times of calculation are performed. Therefore, the CRC calculation amount is (m - 1) × m. If there is a large amount of CRC calculation in frame header detection in the case of data loss, it will occupy the CPU resources of the device. Especially in the case of fast communication rate and a large number of lost data, the occupancy rate of CPU resources will be more serious, and it will even affect the response speed of other functions.

[0124] Please refer to Figure 5 , Figure 5The flowchart of a frame header detection scheme provided by this embodiment is as follows: First, perform CRC calculation on a total of m - 1 data from the nth to the (n + m - 2)th to obtain vCRC, and then determine whether vCRC is equal to the (n + m - 1)th data. If they are equal, the m - 1 data from the nth to the (n + m - 2)th are the valid data of the current valid frame, and thus it is determined that the frame header of this valid frame is the nth data; if they are not equal, perform sliding CRC calculation on the m - 1 data from the (n + 1)th to the (n + m - 1)th based on vCRC.

[0125] As Figure 5 shown in the sliding CRC calculation, k is the number of sliding calculations. After sliding m - 2 times, it is necessary to perform CRC calculation on a total of m - 1 data from the nth to the (n + m - 2)th again according to the conventional method (that is, after sliding m - 2 times, at the subsequent m - 1th time, calculate CRC again according to the conventional method). Each time the sliding CRC calculation is executed, , .

[0126] Figure 5 In the sliding CRC calculation of the flowchart shown, when it is determined that k is equal to m - 1, let k = 1. When it is determined that k is not equal to m - 1, calculate vCRCa using the obtained vCRC value and the (n + m - 2)th data. Then calculate vCRCb using vCRCa, the (n - 1)th data, and the sliding CRC lookup table rcrcTable prepared during program initialization, and update the vCRC value to vCRCb. The calculation amounts of VCRCa and vCRCb are equivalent to the CRC value calculation amounts of 2 data.

[0127] The calculation method of the above vCRCa is as follows:

[0128] (1);

[0129] In formula (1), is the exclusive OR operation, represents the th data in the data stream Data, , represents the first data in the data stream Data, crcTable is the forward lookup table for CRC calculation, represents the th data in crcTable, , represents the first data in crcTable.

[0130] The calculation method of the above vCRCb is as follows:

[0131] (2);

[0132] In formula (2), Indicates the n-1th data in the data stream Data. Indicates the first data, The first data in rcrcTable represented by rcrcTable is calculated based on m and crcTable.

[0133] In summary, if there is data loss in the first frame of two adjacent frames, for example Figure 3 After the 10th data is lost, if the sliding CRC calculation method is used, the CRC calculation amount of the frame header detection is , the first term "(m-1)" is the amount of calculation for the first regular CRC calculation, the second term "2(m-2)" is the amount of calculation for m-2 sliding calculations, the third term "(m-1)" is the amount of calculation for re-performing the regular CRC after the sliding calculation times k reaches m-2, and the fourth term "2" is the amount of calculation for the last sliding calculation. Therefore, the amount of calculation for the frame header detection CRC using the sliding CRC method is 3(m-1).

[0134] like Figure 6 As shown, Figure 6 The CRC calculation amount of conventional frame header detection and fast frame header detection of different frame lengths m is compared when the first frame in two adjacent frames has data loss. The frame header detection method and the fast frame header detection method provided by the present invention can effectively reduce the calculation amount of the CPU of the receiving device, thereby reducing the main frequency requirement of the control chip and reducing the equipment cost, or can improve the stability of program operation when the chip main frequency is constant.

[0135] Exemplarily, assuming that the data frame length is 16 and the CRC8 verification method is adopted, when the program is initialized, the sliding CRC lookup table (ie, the reverse lookup table) rcrcTable is calculated as shown in Table 1.

[0136] Table 1 Sliding CRC lookup table for frame length m of 16

[0137]

[0138] Assuming that the number of each data bit is 8 bits, the data sent by device 1 to device 2 at a certain time is shown in Table 2.

[0139] Table 2 Schematic diagram of data frame sent from device 1 to device 2

[0140]

[0141] Due to interference and other reasons, device 1 loses the data numbered 10 sent by device 1. When the number of data received by device 2 reaches 32, as shown in Table 3.

[0142] Table 3 Schematic Table of the First 32 Data Received by Device 2

[0143]

[0144] Device 2 starts to perform frame header detection on these 32 data according to Figure 5 the frame header detection method shown. During the frame header detection process, Figure 5 Some calculated values in the process are shown in Table 4. When n is 16, the vCRC value is equal to the (n + m - 1)-th data. Therefore, it is determined that the valid frame header is the 16th data. During the entire fast frame header detection process, the calculation amount of CRC is 45, while if conventional detection is adopted, the calculation amount of CRC is 240.

[0145] Table 4 Schematic Table of Some Calculated Values during Fast Frame Header Detection

[0146]

[0147] In a second aspect, please refer to Figure 7 , the present invention further provides a frame header detection system, including:

[0148] A processing module 11, configured to intercept a data segment in a preset interval in the received data stream as the current candidate data segment;

[0149] A sliding calculation module 12, configured to, when the calculated check value of the current candidate data segment does not match the target check data corresponding to the current candidate data segment, generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, slide the position of the preset interval, so that the new candidate data segment removes the data to be removed and incorporates the target check data corresponding to the current candidate data segment, and determine the reference value as the calculated check value of the new candidate data segment;

[0150] A frame header determination module 13, configured to, when the calculated check value of the new candidate data segment matches the target check data corresponding to the new candidate data segment, determine the first data in the new candidate data segment as the valid frame header.

[0151] In an exemplary embodiment, the process of generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data includes:

[0152] Performing influence correlation processing on the calculated check value of the current candidate data segment based on the target check data corresponding to the current candidate data segment to obtain an intermediate check value;

[0153] Performing influence exclusion processing on the intermediate check value based on the data to be removed in the current candidate data segment to obtain a reference value.

[0154] In an exemplary embodiment, impact association processing is performed on the calculated check value of the current candidate data segment based on the target check data corresponding to the current candidate data segment to obtain an intermediate check value, including:

[0155] Obtain a first correspondence relationship, where the first correspondence relationship includes the correspondence relationship between multiple first check values and multiple first input values;

[0156] Use the calculated check value of the current candidate data segment and the corresponding target check data to obtain the current first input value, determine the current first check value that matches the current first input value in the first correspondence relationship, and use the current first check value as the intermediate check value.

[0157] In an exemplary embodiment, impact exclusion processing is performed on the intermediate check value based on the data to be removed of the current candidate data segment to obtain a reference value, including:

[0158] Obtain a second correspondence relationship, where the second correspondence relationship is determined based on the first correspondence relationship and the data frame length, and the second correspondence relationship includes the correspondence relationship between multiple second input values and multiple second check values;

[0159] Use the data to be removed of the current candidate data segment as the current second input value, and determine the current second check value that matches the current second input value in the second correspondence relationship;

[0160] Use the current second check value and the intermediate check value to obtain the reference value.

[0161] In an exemplary embodiment, the step of determining the second correspondence relationship based on the first correspondence relationship and the data frame length includes:

[0162] Determine a preset bit width range based on the first correspondence relationship;

[0163] For each input value within the preset bit width range, calculate an initial intermediate parameter through the first correspondence relationship, perform m - 1 times of recursive update on the initial intermediate parameter to obtain a final intermediate parameter, and obtain the second check value corresponding to the input value according to the logical combination result of the final intermediate parameter, where m is the data frame length;

[0164] Use all input values and their corresponding second check values to obtain the second correspondence relationship.

[0165] In an exemplary embodiment, the frame header detection system further includes:

[0166] A recording module, configured to increment the sliding calculation count when the calculated check value of the new candidate data segment does not match the target check data corresponding to the new candidate data segment;

[0167] Generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, including:

[0168] When the number of sliding calculations is not equal to the preset number, generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data.

[0169] In an exemplary embodiment, the recording module is further configured to set the number of sliding calculations to the initial value when the number of sliding calculations is equal to the preset number;

[0170] The frame header detection system further includes:

[0171] The full calculation module is configured to, when the number of sliding calculations is the initial value, obtain the calculated check value of the candidate data segment by performing a check calculation on the valid data subset in the candidate data segment.

[0172] In a third aspect, please refer to Figure 8 , the present invention further provides an electronic device, including:

[0173] A memory 21 for storing a computer program;

[0174] A processor 22 for implementing the steps of the frame header detection method described in any of the above embodiments when executing the computer program.

[0175] The electronic device further includes:

[0176] An input interface 23 connected to the processor 22 via a communication bus 26 for obtaining externally imported computer programs, parameters, and instructions, and storing them in the memory 21 under the control of the processor 22. The input interface can be connected to an input device to receive parameters or instructions manually input by the user. The input device can be a touch layer covering the display screen, or a button, trackball, or touchpad provided on the terminal housing.

[0177] A display unit 24 connected to the processor 22 via a communication bus 26 for displaying the data sent by the processor 22. The display unit can be a liquid crystal display screen or an electronic ink display screen, etc.

[0178] A network port 25 connected to the processor 22 via a communication bus 26 for communicating and connecting with external terminal devices. The communication technology used for this communication connection can be a wired communication technology or a wireless communication technology, such as Mobile High-Definition Link technology, Universal Serial Bus, High-Definition Multimedia Interface, Wi-Fi technology, Bluetooth communication technology, Low-Energy Bluetooth communication technology, communication technology based on IEEE802.11s, etc.

[0179] For the introduction of an electronic device provided by the present invention, please refer to the above-mentioned embodiments, and the present invention will not be elaborated herein.

[0180] An electronic device provided by the present invention has the same beneficial effects as the above frame header detection method.

[0181] Fourthly, please refer to Figure 9 , the present invention further provides a computer-readable storage medium 30, on which a computer program 31 is stored. When the computer program 31 is executed by a processor, it implements the steps of the frame header detection method described in any one of the above embodiments.

[0182] The computer-readable storage medium 30 may include: various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc that can store program codes.

[0183] For the introduction of a computer-readable storage medium 30 provided by the present invention, please refer to the above-mentioned embodiments, and the present invention will not be elaborated herein.

[0184] A computer-readable storage medium 30 provided by the present invention has the same beneficial effects as the above frame header detection method.

[0185] Fifthly, the present invention further provides a computer program product, including a computer program / instructions. When the computer program / instructions are executed by a processor, it implements the steps of the frame header detection method described in any one of the above embodiments.

[0186] For the introduction of a computer program product provided by the present invention, please refer to the above-mentioned embodiments, and the present invention will not be elaborated herein.

[0187] A computer program product provided by the present invention has the same beneficial effects as the above frame header detection method.

[0188] It should also be noted that in this specification, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising said element.

[0189] The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A frame header detection method, characterized in that, Including: In the received data stream, intercept a data segment in a preset interval as the current candidate data segment; When the calculated check value of the current candidate data segment does not match the target check data corresponding to the current candidate data segment, generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, slide the position of the preset interval, so that the new candidate data segment removes the data to be removed and incorporates the target check data corresponding to the current candidate data segment, and determine the reference value as the calculated check value of the new candidate data segment; When the calculated check value of the new candidate data segment matches the target check data corresponding to the new candidate data segment, determine the first data in the new candidate data segment as the valid frame header.

2. The frame header detection method according to claim 1, wherein The process of generating a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data includes: Perform influence correlation processing on the calculated check value of the current candidate data segment based on the target check data corresponding to the current candidate data segment to obtain an intermediate check value; Perform influence exclusion processing on the intermediate check value based on the data to be removed in the current candidate data segment to obtain a reference value.

3. The frame header detection method according to claim 2, characterized in that Performing influence correlation processing on the calculated check value of the current candidate data segment based on the target check data corresponding to the current candidate data segment to obtain an intermediate check value includes: Obtain a first correspondence relationship, where the first correspondence relationship includes the correspondence relationship between multiple first check values and multiple first input values; Use the calculated check value of the current candidate data segment and the corresponding target check data to obtain the current first input value, determine the current first check value that matches the current first input value in the first correspondence relationship, and use the current first check value as the intermediate check value.

4. The frame header detection method according to claim 3, wherein Performing influence exclusion processing on the intermediate check value based on the data to be removed in the current candidate data segment to obtain a reference value includes: Obtain a second correspondence relationship, where the second correspondence relationship is determined based on the first correspondence relationship and the data frame length, and the second correspondence relationship includes the correspondence relationship between multiple second input values and multiple second check values; Use the data to be removed in the current candidate data segment as the current second input value, and determine the current second check value that matches the current second input value in the second correspondence relationship; Use the current second check value and the intermediate check value to obtain a reference value.

5. The frame header detection method according to claim 4, wherein The step of determining the second correspondence relationship based on the first correspondence relationship and the data frame length includes: Determine a preset bit width range based on the first correspondence relationship; For each input value within the preset bit width range, calculate an initial intermediate parameter through the first correspondence relationship, perform m - 1 recursive updates on the initial intermediate parameter to obtain a final intermediate parameter, and obtain the second check value corresponding to the input value according to the logical combination result of the final intermediate parameter, where m is the data frame length; Use all the input values and their corresponding second check values to obtain the second correspondence relationship.

6. The frame header detection method according to any one of claims 1-5, characterized in that, The frame header detection method further includes: When the calculated check value of the new candidate data segment does not match the target check data corresponding to the new candidate data segment, increment the sliding calculation count; Generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, including: When the sliding calculation count is not equal to the preset count, generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data.

7. The frame header detection method according to claim 6, characterized in that The frame header detection method further includes: When the sliding calculation count is equal to the preset count, set the sliding calculation count to the initial value; When the sliding calculation count is the initial value, the calculated check value of the candidate data segment is obtained by performing a check calculation on the valid data subset in the candidate data segment.

8. A frame header detection system, characterized in that, Including: A processing module, configured to intercept a data segment in a preset interval in the received data stream as the current candidate data segment; A sliding calculation module, configured to, when the calculated check value of the current candidate data segment does not match the target check data corresponding to the current candidate data segment, generate a reference value based on the data to be removed in the current candidate data segment, the calculated check value of the current candidate data segment, and the corresponding target check data, slide the position of the preset interval, so that the new candidate data segment removes the data to be removed and incorporates the target check data corresponding to the current candidate data segment, and determine the reference value as the calculated check value of the new candidate data segment; A frame header determination module, configured to, when the calculated check value of the new candidate data segment matches the target check data corresponding to the new candidate data segment, determine the first data in the new candidate data segment as the valid frame header.

9. An electronic device, characterized in that, Including: A memory, configured to store a computer program; A processor, configured to implement the steps of the frame header detection method according to any one of claims 1-7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the frame header detection method according to any one of claims 1-7 are implemented.