Baud rate identification and packet acquisition methods, devices, computer equipment and storage media

By employing edge timing capture mode and reverse parsing technology, the problems of baud rate misjudgment and packet loss were solved, enabling accurate baud rate identification and complete packet acquisition even in electromagnetic interference environments.

CN123122744APending Publication Date: 2026-11-17GUANGZHOU POWER SUPPLY BUREAU GUANGDONG POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610987329.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-03
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In existing technologies, baud rate identification schemes are susceptible to electromagnetic interference at substation sites, leading to misjudgments. Furthermore, full-range polling testing is time-consuming and cannot accurately obtain complete printed messages from relay protection devices.

Method used

By disabling the hardware serial port receive mode, configuring the receive pin to edge timing capture mode, collecting level transition timing data, filtering candidate baud rates based on the theoretical baud rate and preset error threshold, reverse parsing the fixed pre-feature byte sequence, verifying the target baud rate, and writing the fixed pre-feature byte sequence into the start position of the receive buffer, the complete print message acquisition is completed.

Benefits of technology

It improves the accuracy of baud rate recognition, ensures the acquisition of complete printed messages, avoids misjudgment problems caused by electromagnetic interference and continuous waveforms at the same level, and shortens the recognition time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123122744A_ABST
    Figure CN123122744A_ABST
Patent Text Reader

Abstract

This application relates to a baud rate identification and message acquisition method, apparatus, computer device, and storage medium. It includes: disabling the hardware serial port receive mode, configuring the receive pin to edge timing capture mode, and acquiring level transition timing data; determining the theoretical baud rate based on the level transition timing data; selecting a candidate baud rate set from a preset standard baud rate list based on the theoretical baud rate and a preset error threshold; parsing a fixed pre-signal byte sequence from the level transition timing data, verifying the candidate baud rate set, and determining the target baud rate; switching the hardware serial port to hardware serial port receive mode and configuring the communication rate of the hardware serial port to the target baud rate; writing the fixed pre-signal byte sequence to the starting position of the receive buffer, and receiving subsequent real-time printing data through the hardware serial port to obtain a complete printed message. This method can accurately identify the baud rate and acquire a complete printed message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power system relay protection monitoring technology, and in particular to a baud rate identification and message acquisition method, device, computer equipment and storage medium. Background Technology

[0002] Existing serial port adaptive baud rate identification schemes are mainly divided into two categories: waveform calculation and full-range polling test reception. When relying solely on electrical signal waveforms to calculate the baud rate, strong electromagnetic interference exists at the substation site, and continuous waveforms with the same level are prone to appear during message transmission, which can easily lead to misjudgment of the baud rate. The full-range polling test reception method is time-consuming and easily misses the characteristic commands sent by the device instantaneously. Both types of schemes have obvious drawbacks: on the one hand, baud rate identification errors occur frequently; on the other hand, due to inaccurate baud rate identification and missing the preceding characteristic commands, it is impossible to recover the preceding frame header of the relay protection device's printed message, and ultimately it is difficult to obtain a complete printed message containing a complete frame header. Summary of the Invention

[0003] Therefore, it is necessary to provide a baud rate identification and message acquisition method, apparatus, computer equipment, and storage medium that can accurately identify the baud rate and acquire the complete printed message, addressing the aforementioned technical problems.

[0004] Firstly, this application provides a method for baud rate identification and packet acquisition, including:

[0005] Disable the hardware serial port receive mode, configure the receive pin to edge timing capture mode, and collect the level transition timing data output by the serial port of the relay protection device.

[0006] The theoretical baud rate is determined based on the aforementioned level transition timing data;

[0007] Based on the theoretical baud rate and the preset error threshold, a set of candidate baud rates is obtained by filtering from the preset standard baud rate list;

[0008] Based on the level transition timing data, the fixed pre-signature byte sequence of the relay protection device's printed message is reverse-parsed.

[0009] The candidate baud rate set is verified using the fixed pre-feature byte sequence to determine the target baud rate that matches the fixed pre-feature byte sequence;

[0010] Switch the hardware serial port to hardware serial port receive mode and configure the communication rate of the hardware serial port to the target baud rate;

[0011] The fixed pre-feature byte sequence is written into the starting position of the receive buffer, and subsequent real-time printing data is received through the hardware serial port to obtain a complete print message.

[0012] In one embodiment, configuring the receiving pin to edge timing capture mode and acquiring the level transition timing data output from the serial port of the relay protection device includes:

[0013] Configure the receive pin as a dual-edge external interrupt to achieve the edge timing capture mode;

[0014] Set the acquisition window duration, and use a microsecond-level high-precision timer to record the timestamp of each level transition within the acquisition window duration, thereby acquiring the level transition timing data.

[0015] In one embodiment, determining the theoretical baud rate based on the level transition timing data includes:

[0016] Based on each group of adjacent level transition data in the level transition timing data, a level duration pulse width is calculated to obtain multiple level duration pulse widths;

[0017] From the plurality of sustained pulse widths, remove idle sustained pulse widths whose duration exceeds a preset duration threshold, and use the minimum value among the remaining valid sustained pulse widths as the single-bit reference duration.

[0018] The theoretical baud rate is calculated based on the single-bit reference duration.

[0019] In one embodiment, the step of selecting a candidate baud rate set from a preset standard baud rate list based on the theoretical baud rate and a preset error threshold includes:

[0020] The preset standard baud rate list includes multiple commonly used communication rates for industrial serial ports.

[0021] The theoretical baud rate is compared with each standard baud rate in the preset standard baud rate list. From the preset standard baud rate list, multiple standard baud rates with a comparison error less than a preset error threshold are determined to determine the candidate baud rate set.

[0022] In one embodiment, the step of reversibly parsing the fixed pre-signature byte sequence inherent in the relay protection device's printed message based on the level transition timing data includes:

[0023] The level transition timing data is divided according to the duration of a single bit to obtain a serial byte data stream;

[0024] The fixed prefix feature byte sequence is obtained by identifying the inherent byte combination at the beginning of the message from the serial byte data stream.

[0025] In one embodiment, the step of verifying the candidate baud rate set using the fixed pre-feature byte sequence to determine the target baud rate matching the fixed pre-feature byte sequence includes:

[0026] Each candidate baud rate in the candidate baud rate set is selected sequentially and a reverse parsing operation is performed.

[0027] If a reverse parsing operation is performed based on the first candidate baud rate to parse out the fixed pre-feature byte sequence, then the first candidate baud rate is determined as the matching target baud rate.

[0028] In one embodiment, if the fixed pre-feature byte sequence is not parsed after traversing all candidate baud rates, an exception retry step is executed:

[0029] Extend the acquisition window duration for acquiring the level transition timing data, and re-execute the steps of acquiring the level transition timing data, filtering the candidate baud rate set, and performing reverse parsing operations;

[0030] If the maximum allowed number of abnormal retries is not reached, a reverse parsing operation is performed based on the second candidate baud rate to parse out the fixed pre-feature byte sequence, and then the second candidate baud rate is determined as the target baud rate.

[0031] If the fixed pre-feature byte sequence is still not parsed after reaching the maximum allowed number of abnormal retries, the hardware serial port is configured with a preset spare baud rate.

[0032] Secondly, this application also provides a baud rate and complete printed message determination device, comprising:

[0033] The data acquisition module is used to disable the hardware serial port receiving mode, configure the receiving pin to edge timing capture mode, and acquire the level transition timing data output by the serial port of the relay protection device.

[0034] The baud rate determination module is used to determine the theoretical baud rate based on the level transition timing data; to filter a candidate baud rate set from a preset standard baud rate list based on the theoretical baud rate and a preset error threshold; to reverse-parse the fixed pre-signature byte sequence of the relay protection device's printed message based on the level transition timing data; and to verify the candidate baud rate set using the fixed pre-signature byte sequence to determine the target baud rate that matches the fixed pre-signature byte sequence.

[0035] The complete print message determination module is used to switch the hardware serial port to hardware serial port receiving mode and configure the communication rate of the hardware serial port to the target baud rate; write the fixed pre-feature byte sequence into the starting position of the receive buffer, and receive subsequent real-time print data through the hardware serial port to obtain a complete print message.

[0036] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any of the first aspects.

[0037] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the first aspects.

[0038] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the method as described in any of the first aspects.

[0039] In the above baud rate identification and message acquisition method, the hardware serial port receiving mode can be turned off, the receiving pin can be configured to edge timing capture mode, and the level transition timing data of the relay protection device's printed serial port output can be acquired; the theoretical baud rate can be determined based on the level transition timing data; based on the theoretical baud rate and a preset error threshold, a candidate baud rate set can be obtained by filtering from a preset standard baud rate list; the fixed pre-feature byte sequence of the relay protection device's printed message can be reverse-parsed based on the level transition timing data; the fixed pre-feature byte sequence can be used to verify the candidate baud rate set and determine the target baud rate that matches the fixed pre-feature byte sequence; the hardware serial port can be switched to hardware serial port receiving mode, and the communication rate of the hardware serial port can be configured to the target baud rate; the fixed pre-feature byte sequence can be written into the starting position of the receive buffer, and subsequent real-time printed data can be received through the hardware serial port to obtain a complete printed message. This scheme first bypasses the automatic parsing logic of the serial port hardware, using edge capture to fully acquire the original level transition timing. Then, based on the timing data, the theoretical baud rate is calculated, narrowing down the candidate baud rate range and significantly reducing the time consumption caused by full-range polling. Next, the inherent pre-signature byte sequence of the message is extracted through reverse parsing of the timing data to verify each candidate baud rate, avoiding baud rate misjudgments caused by substation electromagnetic interference and continuous waveforms with the same level. After calibrating the accurate target baud rate, the pre-parsed pre-signature byte sequence is added to the buffer header before receiving real-time messages, compensating for the message start frame header lost during the hardware reception stage. This improves the accuracy of baud rate determination and yields a complete printed message. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 This is a diagram illustrating the application environment of a method for determining baud rate and complete printed message in one embodiment.

[0042] Figure 2 This is a flowchart illustrating a method for determining baud rate and complete printed message in one embodiment;

[0043] Figure 3 This is a flowchart illustrating the process of determining the theoretical baud rate in one embodiment;

[0044] Figure 4 This is a flowchart illustrating the method for determining baud rate and complete printed message in another embodiment;

[0045] Figure 5 This is a block diagram of a baud rate and complete printed message determination device in one embodiment;

[0046] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0048] The baud rate identification and packet acquisition method provided in this application embodiment can be applied to, for example... Figure 1 The application environment shown. Among them, Figure 1 The application environment shown includes: protection devices, MAX232, and MCU. Among them, Figure 1 The protection device shown is a relay protection device. The MAX232 is an RS232 (serial communication standard RS232 interface) level conversion chip, used to convert between the ±12V industrial serial port level on the relay protection device side and the 3.3VTTL (transistor-to-transistor logic level) on the MCU side. Alternatively, a similar SP3232 (wide voltage RS232 transceiver level conversion chip) chip can be used. The baud rate identification and message acquisition method provided in this application embodiment... Figure 1 This is executed in the MCU shown, which integrates all the hardware required to implement the method. The MCU includes:

[0049] Core: Processor core, the internal computing and processing core of the MCU, responsible for executing all baud rate identification and message acquisition logic in this application;

[0050] RAM: Random Access Memory, used for temporary storage of acquired level transition timing data, message buffers, and intermediate variables for calculations;

[0051] Hardware serial port: Universal Asynchronous Receiver / Transmitter (UART), a serial port hardware peripheral that normally receives printed messages;

[0052] EXTI: External Interrupt / Event Controller, used to configure the receive pin's dual-edge capture mode and acquire level transition signals;

[0053] TIM: Timer, a high-precision hardware timer that provides microsecond-level timestamps to record the moment each level transition occurs.

[0054] For example, Figure 1 This MCU can be a GigaDevice 32-bit (GD32) general-purpose microcontroller. The GD32 series MCU system has a main frequency of 72MHz and a built-in TIM prescaler set to 71, which can achieve 1μs high-precision timing and accurately capture the tiny pulse width changes of the serial port at the single bit level. The RS232 industrial ±12V level and the MCU 3.3VTTL level are electrically isolated and level converted through the MAX232 or SP3232 chip.

[0055] Figure 1 In the pin RX, the data receive pin is indicated; RTS indicates the request send pin, which is the serial port hardware flow control signal pin and works with the serial port transmission link to complete signal interaction.

[0056] In practical applications, the relay protection device outputs a serial port signal for printing. After the signal is converted from industrial level to microcontroller TTL level by MAX232, it is sent to the MCU's receiving pin. During the MCU's power-on initialization phase, the Core schedules the TIM and EXTI peripherals, closes the hardware serial port, and switches to edge timing capture mode, continuously recording all level transition timestamps of the receiving pin. After the acquisition window ends, the Core calculates the theoretical baud rate and filters the candidate baud rate set based on all level transition timing data. Then, it reverse-analyzes the timing of each candidate baud rate to verify the matching result. If the match is successful, the Core switches the peripheral to hardware serial port receiving mode, writes the fixed pre-feature byte sequence restored from the timing into the starting position of the receiving buffer in RAM, continuously receives the converted real-time printing data, and outputs a complete printing message. If the match fails, the acquisition window is extended, and the entire timing acquisition process is re-executed.

[0057] The execution entity of the baud rate identification and message acquisition method provided in this application embodiment can be a baud rate identification and message acquisition device or a computer device. The baud rate identification and message acquisition device can be a functional module or functional entity within the computer device used to implement the baud rate identification and message acquisition method. An exemplary baud rate identification and message acquisition device can be... Figure 1 The MCU shown can be a substation back-end maintenance industrial control computer, a portable laptop maintenance terminal, an embedded industrial tablet, a power field intelligent data acquisition gateway, etc.

[0058] In one exemplary embodiment, such as Figure 2 As shown, a method for baud rate identification and packet acquisition is provided, based on the method... Figure 1 The following steps are illustrated using the MCU execution example shown:

[0059] 201. Disable the hardware serial port receiving mode, configure the receiving pin to edge timing capture mode, and collect the level transition timing data output by the serial port of the relay protection device.

[0060] Among them, the MCU has a built-in hardware serial port (UART) peripheral native working mode, which is the hardware serial port receiving mode. In this mode, the hardware automatically parses the serial port bytes according to the standard baud rate.

[0061] The above edge timing capture mode is a working mode that disables the automatic serial port parsing function and records every high-low level transition completely through an external interrupt.

[0062] The aforementioned receiving pin is the signal input pin connected to the MAX232 level conversion chip on the MCU side.

[0063] The aforementioned level transition timing data includes timestamps and level state combinations corresponding to each level transition, recorded by a high-precision timer. This data can completely reconstruct the original serial port waveform.

[0064] During the MCU power-on initialization phase, the native serial port reception function can be disabled first, and the receiving pin can be configured to a dual-edge external interrupt trigger mode to achieve edge timing capture mode. Then, the internal microsecond-level high-precision timer can be started, and a fixed-duration acquisition window can be set. As long as the receiving pin produces a level transition within the window, the current timer timestamp and pin level can be recorded immediately. After the window expires, the interrupt acquisition will stop, and all recorded content can be summarized to obtain the level transition timing data.

[0065] In some implementations, configuring the receiving pin to edge timing capture mode and acquiring the level transition timing data output by the serial port of the relay protection device includes: configuring the receiving pin as a dual-edge external interrupt to achieve the edge timing capture mode; setting the acquisition window duration, and using a microsecond-level high-precision timer to record the timestamp of each level transition within the acquisition window duration, thereby acquiring the level transition timing data.

[0066] Among them, dual-edge external interrupt refers to the triggering method of the MCU's external interrupt peripheral, which can trigger the interrupt on both rising and falling edges, with no level transition omissions; microsecond-level high-precision timer refers to the TIM hardware built into the MCU, whose timing accuracy can reach 1μs, and can accurately distinguish the short pulse width of a single bit in the serial port; the acquisition window duration can refer to the preset continuous waveform acquisition time period, which is used to completely capture the pre-set characteristic instruction waveform issued by the relay protection device.

[0067] In the above implementation, the receiving pin register is configured with dual-edge triggered interrupt logic to switch to edge timing capture mode; the timer is configured with a timing unit of microseconds and a fixed acquisition window duration is set. Before the window timing ends, each pin level change will trigger an interrupt and read the timer timestamp. After all timing records are completed, they are stored in a unified manner to form complete level transition timing data.

[0068] 202. Determine the theoretical baud rate based on the level transition timing data.

[0069] The theoretical baud rate refers to the initial value of the serial port rate obtained solely through mathematical calculation of the waveform pulse width, without undergoing standard baud rate matching and protocol verification; the single-bit reference duration refers to the duration of the level corresponding to a single binary bit in the serial port, which is the core parameter for converting the baud rate.

[0070] In step 202 above, all level transition timing data are traversed, the level duration between two adjacent transitions is calculated, invalid pulse widths corresponding to excessively long idle levels are removed, and the minimum value of the remaining effective pulse width is taken as the single-bit reference duration. The theoretical baud rate is calculated by the ratio of the single-bit reference duration to the reference duration.

[0071] 203. Based on the theoretical baud rate and the preset error threshold, a set of candidate baud rates is obtained by filtering from the preset standard baud rate list.

[0072] Among them, the preset error threshold can be the allowable baud rate calculation deviation range for industrial serial port crystal oscillator temperature drift and level transmission distortion; the preset standard baud rate list can be the set of general serial port rates for substation relay protection printing ports; the candidate baud rate set can be the standard baud rates with theoretical baud rate deviations within the threshold range, used to narrow down the subsequent verification range.

[0073] In step 203 above, a pre-stored list of standard baud rates can be read, and the calculated theoretical baud rate can be compared with the difference of each standard baud rate in the list in turn. Standard baud rates with a comparison error less than a preset error threshold are selected, and all selection results are summarized to form a candidate baud rate set.

[0074] In some implementations, the step of selecting a candidate baud rate set from a preset standard baud rate list based on the theoretical baud rate and a preset error threshold includes: the preset standard baud rate list includes multiple commonly used communication rates for industrial serial ports; comparing the theoretical baud rate with each standard baud rate in the preset standard baud rate list, and determining multiple standard baud rates from the preset standard baud rate list whose comparison error is less than a preset error threshold, thereby determining the candidate baud rate set.

[0075] Among them, the commonly used communication rate for industrial serial ports can be the general baud rate setting for power equipment printing interfaces.

[0076] For example, common communication rates for industrial serial ports can include eight levels of general communication rates for substation relay protection printing interfaces: 2400, 4800, 9600, 19200, 38400, 57600, 115200, and 230400. The preset error threshold is set to ±5% to accommodate the rate deviation caused by industrial crystal oscillator temperature drift and long-distance RS232 transmission. The preset duration threshold for eliminating invalid waveforms is set to 4000μs; levels with a duration exceeding 4000μs are considered bus idle noise and are not included in the single-bit duration calculation.

[0077] The aforementioned comparison error can refer to the proportion of the numerical difference between the theoretical baud rate and the standard baud rate to the standard baud rate.

[0078] In the above implementation, the preset standard baud rate list stores multiple common serial port rates in the power industry. The relative error between the theoretical baud rate and the rate in the list can be calculated one by one, and only the standard baud rates with errors not exceeding the preset threshold are retained and combined into a candidate baud rate set, which greatly reduces the number of subsequent verifications.

[0079] 204. Based on the level transition timing data, the fixed pre-feature byte sequence of the relay protection device's printed message is reverse-parsed.

[0080] Among them, reverse parsing refers to reconstructing the serial port byte stream by relying solely on the original timing waveform and the single-bit duration corresponding to a certain baud rate, without relying on the hardware serial port; the fixed pre-feature byte sequence can be a fixed double-byte reset instruction output before the relay protection device prints the message, which is the unique identifier to distinguish valid messages; the serial byte data stream can be a continuous hexadecimal byte sequence reconstructed according to the UART frame format.

[0081] In step 204 above, for any rate within the candidate baud rate set, the complete level transition timing waveform is cut using the single-bit duration corresponding to that rate. The waveform is split according to the standard UART frame format of 1 start bit + 8 data bits + 1 stop bit to restore the continuous serial byte data stream. The fixed output prefix byte combination of the device is retrieved in the data stream to extract the fixed prefix feature byte sequence.

[0082] In some implementations, the step of reverse parsing the fixed pre-feature byte sequence of the relay protection device's printed message based on the level transition timing data includes: segmenting the level transition timing data according to the single-bit duration to obtain a serial byte data stream; and identifying the inherent byte combination at the beginning of the message from the serial byte data stream to obtain the fixed pre-feature byte sequence.

[0083] Among them, the single-bit duration can be the duration of the level of a single binary bit under a certain standard baud rate; the inherent byte combination at the beginning of the message can be a unique instruction byte that is fixedly issued by the relay protection device before each printing of the setting value, and will not change with the device model.

[0084] In the above implementation, the single bit duration corresponding to a certain candidate baud rate can be selected as the segmentation unit, the timing waveform can be segmented and the complete byte stream can be restored, and the device-specific fixed byte combination can be searched in the starting area of ​​the byte stream. Once found, it is used as a fixed pre-feature byte sequence.

[0085] For example, the inherent byte combination at the beginning of the message can be an ESC (escape character) / P (printer) reset instruction, consisting of two consecutive hexadecimal bytes 0x1B and 0x40. During reverse parsing and reconstruction of the serial byte data stream, waveform cutting and byte reconstruction are uniformly performed according to the standard 8-data-bit, no-parity, 1-stop-bit UART frame format (1 start bit + 8 data bits + 1 stop bit), conforming to the serial port output protocol specification for relay protection devices. Here, ESC / P is the standard control instruction set for dot matrix printers, and it is the communication protocol followed by substation relay protection devices when printing settings and report messages.

[0086] 205. Verify the candidate baud rate set using the fixed pre-feature byte sequence to determine the target baud rate that matches the fixed pre-feature byte sequence.

[0087] Among them, baud rate verification can use a fixed pre-prefix feature byte sequence as the criterion to verify whether the candidate baud rate is the actual communication rate of the device; the target baud rate can be the actual serial port rate that can reconstruct the complete fixed pre-prefix feature byte sequence.

[0088] In step 205 above, each candidate baud rate in the candidate baud rate set can be traversed sequentially, and the timing reverse parsing operation can be performed in turn. If a complete fixed pre-feature byte sequence is successfully retrieved when the byte stream is restored using the current candidate baud rate, then the candidate baud rate is determined to be the actual communication rate of the device and is used as the target baud rate, and the remaining candidate baud rate verification is stopped.

[0089] In some implementations, the step of verifying the candidate baud rate set using the fixed pre-feature byte sequence to determine the target baud rate matching the fixed pre-feature byte sequence includes:

[0090] Each candidate baud rate in the candidate baud rate set is selected sequentially and a reverse parsing operation is performed; if the reverse parsing operation is performed based on the first candidate baud rate and the fixed pre-feature byte sequence is parsed out, then the first candidate baud rate is determined as the matching target baud rate.

[0091] The first candidate baud rate mentioned above can be any rate to be verified that is traversed sequentially within the candidate baud rate set; the reverse parsing operation can be the complete operation process of cutting the waveform and restoring the byte stream with the single bit duration of the current candidate baud rate.

[0092] In the above implementation, the rates in the candidate baud rate set are extracted one by one in sequence for reverse parsing; when traversing the first candidate baud rate, if the complete fixed pre-feature byte sequence is successfully restored, the rate is directly set as the target baud rate, without the need to verify the remaining candidate baud rates, which can shorten the recognition time.

[0093] 206. Switch the hardware serial port to hardware serial port receive mode and configure the communication rate of the hardware serial port to the target baud rate.

[0094] The hardware serial communication rate refers to the serial port transmit / receive rate configured in the hardware serial port register, which is consistent with the actual baud rate of the device.

[0095] In step 206 above, after completing the baud rate verification and locking the target baud rate, the MCU peripheral register can be modified to switch the receiving pin from edge interrupt capture mode back to hardware serial port receiving mode. At the same time, the communication rate parameter of the hardware serial port register is configured to the determined target baud rate, so that the hardware serial port has the conditions to receive and print messages normally.

[0096] 207. Write the fixed pre-feature byte sequence into the starting position of the receive buffer, and receive subsequent real-time printing data through the hardware serial port to obtain a complete print message.

[0097] Among them, the receive buffer refers to the data storage area allocated in the MCU's on-chip RAM, used to temporarily store print messages; the starting position of the receive buffer can be the first address of the buffer array; the real-time print data can be the set values ​​and layout print bytes continuously sent by the relay protection device after the hardware serial port switching is completed; the complete print message can be the full message of the original ESC / P containing the pre-set feature reset instruction and the subsequent set value content.

[0098] In step 207 above, the fixed pre-feature byte sequence obtained from the reverse parsing of the timing waveform can be stored at the front end of the receiving buffer array; the real-time printing data subsequently sent by the hardware serial port continuous acquisition device is started, and the new received bytes are appended to the end of the buffer in sequence. All the data in the buffer is combined into a complete printing message, which can be directly sent to the fixed value parsing module for processing.

[0099] An exemplary implementation scenario uses a relay protection device as an example. The standard baud rate of the device's printing port is 9600bps. When printing a set value upon power-up, it prioritizes outputting the 0x1B and 0x40 characteristic bytes. Using this method, a 10ms acquisition window is sufficient to completely capture the characteristic waveform. After pulse width filtering and calculation, the accurate theoretical baud rate is obtained. Only a single candidate baud rate verification is needed to lock the true rate, eliminating the need for multi-level polling and preventing the loss of pre-set reset instructions. Furthermore, this solution is compatible with similar relay protection devices from multiple brands such as XJ and Sifang, and one acquisition terminal can adapt to all printing interfaces in the field. Specifically, 0x1B is a hexadecimal ESC escape character, and 0x40 is a hexadecimal @ symbol character; their consecutive combination forms the printer reset initialization instruction specified by the ESC / P protocol.

[0100] The above embodiments can first acquire the original waveform completely through edge timing, narrow down the candidate baud rate range by relying on waveform coarse screening, and then lock the true baud rate by relying on the device's exclusive fixed pre-feature byte sequence for double verification. This greatly reduces the problem of baud rate misjudgment caused by substation electromagnetic interference and continuous waveforms at the same level. At the same time, the pre-feature byte of the message is extracted in advance and added to the buffer header, solving the defect of permanent loss of message frame header after switching serial ports in traditional solutions. This shortens the baud rate identification time and completely restores the original printed message of relay protection.

[0101] In one exemplary embodiment, such as Figure 3 The diagram illustrates a process for determining the theoretical baud rate, which includes the following steps:

[0102] 301. Based on each group of adjacent level transition data in the level transition timing data, calculate a level duration pulse width to obtain multiple level duration pulse widths.

[0103] Among them, adjacent level transition data: two timestamp records corresponding to two consecutive level transitions in the timing record; level duration pulse width: the microsecond duration of the same level state, which is calculated from the difference of the timestamps of two adjacent transitions.

[0104] Step 301 above can iterate through all level transition timing records, take the timestamps of two adjacent transitions in sequence and perform difference calculations. Each difference corresponds to a level duration pulse width. After the traversal is completed, the total level duration pulse width array is obtained.

[0105] 302. From the plurality of sustained pulse widths, remove idle sustained pulse widths whose duration exceeds a preset duration threshold, and use the minimum value among the remaining valid sustained pulse widths as the single-bit reference duration.

[0106] Among them, the preset duration threshold can be used as a threshold to distinguish between long idle levels and effective bit levels on the bus; the idle level duration pulse width is the ultra-long pulse width generated during message gaps and device standby, which is not included in the baud rate calculation; the effective level duration pulse width can be the short-time pulse width generated by the serial port binary bits.

[0107] Step 302 above can iterate through all continuous pulse widths, remove idle long-level pulse widths whose values ​​exceed the preset duration threshold, compare all remaining valid pulse widths, and the minimum value is the reference duration corresponding to a single bit of the serial port.

[0108] 303. The theoretical baud rate is obtained by converting the single-bit reference duration.

[0109] The conversion process can be achieved by dividing the total number of microseconds in one second by the single-bit reference duration to obtain the theoretical serial port rate calculated from the waveform.

[0110] In step 303 above, 1,000,000 μs can be divided by the single-bit reference duration to calculate the theoretical baud rate based solely on waveform measurement, which can then be used as the basis for subsequent screening of candidate baud rates.

[0111] This embodiment distinguishes between long idle levels and effective bit pulse widths, filtering out invalid waveform data caused by substation bus idleness and electromagnetic glitches. It calculates the theoretical baud rate based solely on the shortest actual bit pulse width, avoiding interference from long idle levels in the initial value calculation and improving the accuracy of subsequent candidate baud rate selection.

[0112] In one exemplary embodiment, such as Figure 4 As shown, a baud rate identification and packet acquisition method is provided, which includes the following steps:

[0113] 401. Set the acquisition window duration. Within the acquisition window duration, use a microsecond-level high-precision timer to record the timestamp of each level transition, thereby acquiring the level transition timing data.

[0114] The aforementioned acquisition window duration is used to capture the fixed acquisition cycle of the preceding feature instruction waveform; microsecond-level high-precision timer: the MCU has built-in timing hardware to ensure the accuracy of pulse width calculation.

[0115] Step 402 above can pre-configure a fixed waveform acquisition duration, start dual-edge interrupts and high-precision timers, continuously record all level transition timestamps within the window, and summarize and generate level transition timing data after acquisition ends.

[0116] 402. Determine the theoretical baud rate based on the level transition timing data.

[0117] 403. Based on the theoretical baud rate and the preset error threshold, a set of candidate baud rates is obtained by filtering from the preset standard baud rate list.

[0118] 404. Based on the level transition timing data, the fixed pre-feature byte sequence of the relay protection device's printed message is reverse-parsed.

[0119] 405. Select each candidate baud rate in the candidate baud rate set in sequence and perform reverse parsing operation.

[0120] 406. Determine whether the reverse parsing operation based on the first candidate baud rate has parsed out the fixed pre-feature byte sequence.

[0121] 407. The first candidate baud rate is determined as the matching target baud rate.

[0122] In some implementations, the step of verifying the candidate baud rate set using the fixed pre-feature byte sequence to determine the target baud rate that matches the fixed pre-feature byte sequence includes: sequentially selecting each candidate baud rate in the candidate baud rate set and performing a reverse parsing operation; if the fixed pre-feature byte sequence is parsed out based on the first candidate baud rate, then the first candidate baud rate is determined as the matching target baud rate.

[0123] The descriptions of steps 402 to 407 above can refer to the relevant descriptions of steps 202 to 205 above, and will not be repeated here.

[0124] 408. Extend the acquisition window duration for acquiring the level transition timing data, and re-execute the steps of acquiring the level transition timing data, filtering the candidate baud rate set, and performing reverse parsing operations.

[0125] Among them, extending the acquisition window duration can be done by expanding the waveform acquisition period to accommodate longer message waveforms when the original acquisition window duration has not captured the complete preceding feature waveform; abnormal retry: compensation acquisition process after all candidate baud rate verifications fail.

[0126] In step 408 above, if no fixed pre-feature byte sequence is found after traversing all candidate baud rates, it is determined that the acquisition window duration is insufficient. The acquisition window time is extended, and the entire process of timing acquisition, theoretical baud rate calculation, candidate baud rate screening, and baud rate reverse verification is re-executed.

[0127] 409. If the maximum allowed number of abnormal retries is not reached, a reverse parsing operation is performed based on the second candidate baud rate to parse out the fixed pre-feature byte sequence, and then the second candidate baud rate is determined as the target baud rate.

[0128] Among them, the maximum number of abnormal retries can refer to the preset upper limit of waveform re-acquisition; the second candidate baud rate is the rate to be verified in the candidate set after the second acquisition.

[0129] After executing the retry process, if the preset maximum number of retries has not been reached, the new candidate baud rate set will continue to be traversed. If the preceding byte sequence is successfully parsed during the verification, the current rate will be set as the target baud rate.

[0130] 410. If the fixed pre-feature byte sequence is still not parsed after reaching the maximum allowed number of abnormal retries, the hardware serial port is configured with a preset backup baud rate.

[0131] Among them, the preset backup baud rate can be the most common standard baud rate of substation relay protection devices, serving as a fallback parameter for identification failure.

[0132] In step 410 above, the acquisition window duration can be extended multiple times for retry. If the fixed pre-feature byte sequence still cannot be matched after multiple attempts, the pre-stored spare baud rate is read directly, and the hardware serial port is configured to enter the receiving mode to ensure that the message acquisition process is not interrupted.

[0133] In some implementations, if the fixed pre-signature byte sequence is not parsed after traversing all candidate baud rates, an abnormal retry step is performed: extending the acquisition window duration for acquiring the level transition timing data, re-executing the steps of acquiring the level transition timing data, filtering the candidate baud rate set, and performing reverse parsing; if the maximum allowed number of abnormal retries is not reached, a reverse parsing operation is performed based on the second candidate baud rate to parse the fixed pre-signature byte sequence, and then the second candidate baud rate is determined as the target baud rate; if the fixed pre-signature byte sequence is still not parsed after reaching the maximum allowed number of abnormal retries, the hardware serial port is configured using a preset backup baud rate.

[0134] The abnormal retry step may include compensation processing logic after the baud rate verification fails completely; the maximum number of abnormal retries may be the upper limit of the maximum number of times the system allows the waveform to be re-acquired.

[0135] In the above implementation, if no matching result is found in the first round of verification of all candidate baud rates, a retry process can be initiated, the acquisition window can be extended, and the complete calculation can be performed again. If the retry limit is not reached, new candidate baud rates can be continuously verified. If no matching result is found after reaching the retry limit, the hardware serial port with the preset backup baud rate can be directly enabled to ensure the normal operation of the acquisition process.

[0136] For example, the system defaults to a basic acquisition window duration of 10ms, which is expanded to 15ms after a recognition failure. The system sets the maximum number of allowed abnormal retries to 2. After both retries fail, the hardware serial port is automatically configured with 9600bps as the preset backup baud rate. 9600bps is the most common printing baud rate for substation relay protection devices.

[0137] In the above embodiments, dynamic expansion of the waveform acquisition window and a fault tolerance mechanism for multiple retries are added to adapt to the delayed message delivery and incomplete waveform conditions of old relay protection devices; when identification fails completely, an industry-standard backup baud rate is used as a fallback to avoid interruption of the acquisition process due to the loss of instantaneous waveform, thereby improving the adaptability of multiple models of old protection devices in substations and the stability of on-site acquisition.

[0138] The solution in this application embodiment, after on-site testing at 110kV and 220kV strong electromagnetic fields in substations, shows that the baud rate recognition accuracy of this solution is improved from 75% to 99.5% compared to the 220ms time taken for a single polling at 8 baud rates. The single-round recognition time of this solution is less than 15ms, which can accurately capture the instantaneously issued feature commands. On-site maintenance time is reduced by 70%, and there is no need to carry multiple acquisition devices with different baud rates. The hardware only reuses the native peripherals of the MCU, eliminating the need for dedicated Field Programmable Gate Array (FPGA) chips. The overall hardware bill of materials (BOM) cost is reduced by 60%, and it can also be stably adapted to old non-standard timing relay protection devices.

[0139] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0140] Based on the same inventive concept, this application also provides a baud rate identification and message acquisition device for implementing the baud rate identification and message acquisition method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations of one or more baud rate identification and message acquisition device embodiments provided below can be found in the limitations of the baud rate identification and message acquisition method described above, and will not be repeated here.

[0141] In one exemplary embodiment, such as Figure 5 As shown, a baud rate identification and message acquisition device is provided, comprising:

[0142] The data acquisition module 501 is used to disable the hardware serial port receiving mode, configure the receiving pin to edge timing capture mode, and acquire the level transition timing data output by the serial port of the relay protection device.

[0143] The baud rate determination module 502 is used to determine the theoretical baud rate based on the level transition timing data; to filter a candidate baud rate set from a preset standard baud rate list based on the theoretical baud rate and a preset error threshold; to reverse-parse the fixed pre-signature byte sequence of the relay protection device's printed message based on the level transition timing data; and to verify the candidate baud rate set using the fixed pre-signature byte sequence to determine the target baud rate that matches the fixed pre-signature byte sequence.

[0144] The complete print message determination module 503 is used to switch the hardware serial port to hardware serial port receiving mode and configure the communication rate of the hardware serial port to the target baud rate; write the fixed pre-feature byte sequence into the starting position of the receive buffer, and receive subsequent real-time print data through the hardware serial port to obtain a complete print message.

[0145] In one embodiment, the data acquisition module 501 is specifically used to: configure the receiving pin as a dual-edge external interrupt to realize the edge timing capture mode; set the acquisition window duration, and use a microsecond-level high-precision timer to record the timestamp of each level transition within the acquisition window duration, thereby acquiring the level transition timing data.

[0146] In one embodiment, the baud rate determination module 502 is specifically used to: calculate a level duration pulse width based on each group of adjacent level transition data in the level transition timing data to obtain multiple level duration pulse widths; remove idle level duration pulse widths whose duration exceeds a preset duration threshold from the multiple level duration pulse widths, and take the minimum value of the remaining effective level duration pulse widths as the single-bit reference duration; and calculate the theoretical baud rate based on the single-bit reference duration.

[0147] In one embodiment, the baud rate determination module 502 is specifically used for: the preset standard baud rate list includes multiple commonly used communication rates for industrial serial ports;

[0148] The theoretical baud rate is compared with each standard baud rate in the preset standard baud rate list. From the preset standard baud rate list, multiple standard baud rates with a comparison error less than a preset error threshold are determined to determine the candidate baud rate set.

[0149] In one embodiment, the baud rate determination module 502 is specifically used to: divide the level transition timing data according to the duration of a single bit to obtain a serial byte data stream;

[0150] The fixed prefix feature byte sequence is obtained by identifying the inherent byte combination at the beginning of the message from the serial byte data stream.

[0151] In one embodiment, the baud rate determination module 502 is specifically used to: sequentially select each candidate baud rate in the candidate baud rate set and perform a reverse parsing operation;

[0152] If a reverse parsing operation is performed based on the first candidate baud rate to parse out the fixed pre-feature byte sequence, then the first candidate baud rate is determined as the matching target baud rate.

[0153] In one embodiment, the baud rate identification and packet acquisition device is further configured to: if the fixed pre-feature byte sequence is not parsed after traversing all candidate baud rates, then perform an abnormal retry step:

[0154] Extend the acquisition window duration for acquiring the level transition timing data, and re-execute the steps of acquiring the level transition timing data, filtering the candidate baud rate set, and performing reverse parsing operations;

[0155] If the maximum allowed number of abnormal retries is not reached, a reverse parsing operation is performed based on the second candidate baud rate to parse out the fixed pre-feature byte sequence, and then the second candidate baud rate is determined as the target baud rate.

[0156] If the fixed pre-feature byte sequence is still not parsed after reaching the maximum allowed number of abnormal retries, the hardware serial port is configured with a preset spare baud rate.

[0157] Each module in the aforementioned baud rate identification and message acquisition device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0158] In one exemplary embodiment, a computer device is provided, the internal structure of which can be as shown in the figure. Figure 6As shown, the computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements the baud rate and complete printed message determination method in the above method embodiment.

[0159] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0160] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0161] Disable the hardware serial port receive mode, configure the receive pin to edge timing capture mode, and collect the level transition timing data output by the serial port of the relay protection device.

[0162] The theoretical baud rate is determined based on the aforementioned level transition timing data;

[0163] Based on the theoretical baud rate and the preset error threshold, a set of candidate baud rates is obtained by filtering from the preset standard baud rate list;

[0164] Based on the level transition timing data, the fixed pre-signature byte sequence of the relay protection device's printed message is reverse-parsed.

[0165] The candidate baud rate set is verified using the fixed pre-feature byte sequence to determine the target baud rate that matches the fixed pre-feature byte sequence;

[0166] Switch the hardware serial port to hardware serial port receive mode and configure the communication rate of the hardware serial port to the target baud rate;

[0167] The fixed pre-feature byte sequence is written into the starting position of the receive buffer, and subsequent real-time printing data is received through the hardware serial port to obtain a complete print message.

[0168] In one embodiment, configuring the receiving pin to edge timing capture mode and acquiring the level transition timing data output from the serial port of the relay protection device includes:

[0169] Configure the receive pin as a dual-edge external interrupt to achieve the edge timing capture mode;

[0170] Set the acquisition window duration, and use a microsecond-level high-precision timer to record the timestamp of each level transition within the acquisition window duration, thereby acquiring the level transition timing data.

[0171] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0172] Based on each group of adjacent level transition data in the level transition timing data, a level duration pulse width is calculated to obtain multiple level duration pulse widths;

[0173] From the plurality of sustained pulse widths, remove idle sustained pulse widths whose duration exceeds a preset duration threshold, and use the minimum value among the remaining valid sustained pulse widths as the single-bit reference duration.

[0174] The theoretical baud rate is calculated based on the single-bit reference duration.

[0175] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0176] The preset standard baud rate list includes multiple commonly used communication rates for industrial serial ports.

[0177] The theoretical baud rate is compared with each standard baud rate in the preset standard baud rate list. From the preset standard baud rate list, multiple standard baud rates with a comparison error less than a preset error threshold are determined to determine the candidate baud rate set.

[0178] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0179] The level transition timing data is divided according to the duration of a single bit to obtain a serial byte data stream;

[0180] The fixed prefix feature byte sequence is obtained by identifying the inherent byte combination at the beginning of the message from the serial byte data stream.

[0181] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0182] Each candidate baud rate in the candidate baud rate set is selected sequentially and a reverse parsing operation is performed.

[0183] If a reverse parsing operation is performed based on the first candidate baud rate to parse out the fixed pre-feature byte sequence, then the first candidate baud rate is determined as the matching target baud rate.

[0184] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0185] Extend the acquisition window duration for acquiring the level transition timing data, and re-execute the steps of acquiring the level transition timing data, filtering the candidate baud rate set, and performing reverse parsing operations;

[0186] If the maximum allowed number of abnormal retries is not reached, a reverse parsing operation is performed based on the second candidate baud rate to parse out the fixed pre-feature byte sequence, and then the second candidate baud rate is determined as the target baud rate.

[0187] If the fixed pre-feature byte sequence is still not parsed after reaching the maximum allowed number of abnormal retries, the hardware serial port is configured with a preset spare baud rate.

[0188] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the baud rate and complete print message determination method as described in the above method embodiments.

[0189] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the baud rate and complete printed message determination method as described in the above method embodiments.

[0190] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0191] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0192] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for determining baud rate and complete printed message, characterized in that, The method includes: Disable the hardware serial port receive mode, configure the receive pin to edge timing capture mode, and collect the level transition timing data output by the serial port of the relay protection device. The theoretical baud rate is determined based on the aforementioned level transition timing data; Based on the theoretical baud rate and the preset error threshold, a set of candidate baud rates is obtained by filtering from the preset standard baud rate list; Based on the level transition timing data, the fixed pre-signature byte sequence of the relay protection device's printed message is reverse-parsed. The candidate baud rate set is verified using the fixed pre-feature byte sequence to determine the target baud rate that matches the fixed pre-feature byte sequence; Switch the hardware serial port to hardware serial port receive mode and configure the communication rate of the hardware serial port to the target baud rate; The fixed pre-feature byte sequence is written into the starting position of the receive buffer, and subsequent real-time printing data is received through the hardware serial port to obtain a complete print message.

2. The method according to claim 1, characterized in that, The step of configuring the receiving pin to edge timing capture mode and acquiring the level transition timing data output from the serial port of the relay protection device includes: Configure the receive pin as a dual-edge external interrupt to achieve the edge timing capture mode; Set the acquisition window duration, and use a microsecond-level high-precision timer to record the timestamp of each level transition within the acquisition window duration, thereby acquiring the level transition timing data.

3. The method according to claim 1, characterized in that, The determination of the theoretical baud rate based on the level transition timing data includes: Based on each group of adjacent level transition data in the level transition timing data, a level duration pulse width is calculated to obtain multiple level duration pulse widths; From the plurality of sustained pulse widths, remove idle sustained pulse widths whose duration exceeds a preset duration threshold, and use the minimum value among the remaining valid sustained pulse widths as the single-bit reference duration. The theoretical baud rate is calculated based on the single-bit reference duration.

4. The method according to claim 1, characterized in that, The process of selecting a candidate baud rate set from a preset standard baud rate list based on the theoretical baud rate and a preset error threshold includes: The preset standard baud rate list includes multiple commonly used communication rates for industrial serial ports. The theoretical baud rate is compared with each standard baud rate in the preset standard baud rate list. From the preset standard baud rate list, multiple standard baud rates with a comparison error less than a preset error threshold are determined to determine the candidate baud rate set.

5. The method according to claim 1, characterized in that, The fixed pre-signature byte sequence of the relay protection device's printed message, obtained by reverse parsing the level transition timing data, includes: The level transition timing data is divided according to the duration of a single bit to obtain a serial byte data stream; The fixed prefix feature byte sequence is obtained by identifying the inherent byte combination at the beginning of the message from the serial byte data stream.

6. The method according to any one of claims 1 to 5, characterized in that, The step of verifying the candidate baud rate set using the fixed pre-feature byte sequence to determine the target baud rate matching the fixed pre-feature byte sequence includes: Each candidate baud rate in the candidate baud rate set is selected sequentially and a reverse parsing operation is performed. If a reverse parsing operation is performed based on the first candidate baud rate to parse out the fixed pre-feature byte sequence, then the first candidate baud rate is determined as the matching target baud rate.

7. The method according to claim 6, characterized in that, If the fixed pre-feature byte sequence is not parsed after traversing all candidate baud rates, then an exception retry step is executed: Extend the acquisition window duration for acquiring the level transition timing data, and re-execute the steps of acquiring the level transition timing data, filtering the candidate baud rate set, and performing reverse parsing operations; If the maximum allowed number of abnormal retries is not reached, a reverse parsing operation is performed based on the second candidate baud rate to parse out the fixed pre-feature byte sequence, and then the second candidate baud rate is determined as the target baud rate. If the fixed pre-feature byte sequence is still not parsed after reaching the maximum allowed number of abnormal retries, the hardware serial port is configured with a preset spare baud rate.

8. A baud rate and complete printed message determination device, characterized in that, The device includes: The data acquisition module is used to disable the hardware serial port receiving mode, configure the receiving pin to edge timing capture mode, and acquire the level transition timing data output by the serial port of the relay protection device. The baud rate determination module is used to determine the theoretical baud rate based on the level transition timing data; to filter a candidate baud rate set from a preset standard baud rate list based on the theoretical baud rate and a preset error threshold; to reverse-parse the fixed pre-signature byte sequence of the relay protection device's printed message based on the level transition timing data; and to verify the candidate baud rate set using the fixed pre-signature byte sequence to determine the target baud rate that matches the fixed pre-signature byte sequence. The complete print message determination module is used to switch the hardware serial port to hardware serial port receiving mode and configure the communication rate of the hardware serial port to the target baud rate; write the fixed pre-feature byte sequence into the starting position of the receive buffer, and receive subsequent real-time print data through the hardware serial port to obtain a complete print message.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.