Baud rate adjustment method and device, equipment and storage medium
By selecting baud rate parameters based on preset default baud rate information and polling mechanism in the serial communication system, the problem of low baud rate adjustment efficiency in the existing technology is solved, and the stability and reliability of serial communication are improved. .
Patent Information
- Application Number
- CN202411014905.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-10-15
AI Technical Summary
Existing baud rate adjustment methods cannot adaptively find the optimal baud rate in serial communication equipment, resulting in low communication efficiency and reliability.
By establishing a communication link between the master node device and the slave node device based on the preset default baud rate information, and using the preset polling mechanism to select the baud rate parameters one by one in the baud rate parameter group until the communication status meets the preset Communication quality requirements.
It realizes the adaptive dynamic adjustment of the optimal communication baud rate of the serial communication system and improves the stability and reliability of communication.
Smart Images

Figure CN118784474A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a baud rate adjustment method, device, equipment and storage medium. Background Art
[0002] In order to meet most serial communication usage scenarios and be compatible with long-distance communication, the baud rate of serial communication devices is often set to a default value before leaving the factory. For example, major manufacturers usually set the baud rate to 9600bps by default. However, the baud rate of 9600bps will cause a very slow serial communication delay in scenarios with a large amount of communication data.
[0003] Existing baud rate adjustment methods often solve the problem of how to synchronize and achieve normal communication when the baud rates of serial communication devices are not synchronized. They cannot adaptively find the optimal baud rate and cannot guarantee the communication stability and reliability of the communication link.
[0004] Therefore, when the existing baud rate adjustment method is used to adjust or synchronize the baud rate of a serial communication device, there is a problem of low communication efficiency and reliability of the serial communication.
[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of the present application is to provide a baud rate adjustment method, device, equipment and storage medium, aiming to solve the technical problem that the existing baud rate adjustment method has low communication efficiency and reliability of serial communication when adjusting or synchronizing the baud rate of serial communication equipment.
[0007] To achieve the above object, the present application proposes a baud rate adjustment method, which is applied to a serial communication system, wherein the serial communication system includes a master node device and a plurality of slave node devices, and the method includes:
[0008] Based on the preset default baud rate information, establishing a communication link between the master node device and the slave node device;
[0009] Based on a preset polling mechanism, baud rate parameters are selected one by one in a preset baud rate parameter group in a predetermined order as first baud rate parameters;
[0010] Based on the first baud rate parameter and the communication link, the baud rates of the master node device and the slave node devices are adjusted until the communication status between the master node device and each slave node device meets the preset communication quality requirement.
[0011] In one embodiment, before the step of establishing a communication link between the master node device and the slave node device based on the preset default baud rate information, the step includes:
[0012] Based on a preset network topology, the master node device and the slave node device are connected via a bus;
[0013] After the power is turned on, the preset default baud rate information is obtained based on the preset initial state information.
[0014] In one embodiment, the step of adjusting the baud rates of the master node device and the slave node device based on the first baud rate parameter and the communication link until the communication status between the master node device and each slave node device meets the preset communication quality requirement includes:
[0015] Based on the first baud rate parameter and the communication link, adjusting the baud rates of the master node device and the slave node device;
[0016] Confirming the communication status between the master node device and each slave node device within a preset period;
[0017] Based on the communication status, a baud rate parameter is reselected from a preset baud rate parameter group to adjust the baud rates of the master node device and the slave node device until the communication status meets the preset communication quality requirement.
[0018] In one embodiment, the step of adjusting the baud rates of the master node device and the slave node device based on the first baud rate parameter and the communication link includes:
[0019] Based on the first baud rate parameter, generating a baud rate adjustment signal;
[0020] Based on the communication link, the master node device sends the baud rate adjustment signal to each slave node device, and performs baud rate adjustment according to the baud rate adjustment signal;
[0021] Based on the communication link, the slave node device receives the baud rate adjustment signal and performs baud rate adjustment according to the baud rate adjustment signal.
[0022] In one embodiment, the communication state includes a first communication state and a second communication state, and the step of confirming the communication state between the master node device and each slave node device within a preset period includes:
[0023] Within a preset period, the master node device polls and sends a communication request to each slave node device;
[0024] The slave node device receives the communication request and returns response data;
[0025] Based on the response data, confirm whether the master node device and each slave node device can communicate normally to obtain a first communication state; and / or
[0026] In a preset period, the slave node device collects voltage signals through the bus;
[0027] Based on the voltage signal, a signal distortion parameter is calculated;
[0028] Based on the preset signal distortion threshold and the signal distortion parameter, it is determined whether the distortion of the voltage signal is within the preset signal distortion threshold, and a second communication state is obtained.
[0029] In one embodiment, the predetermined order includes a first predetermined order and a second predetermined order, the first predetermined order is an order of baud rate parameters from low to high, and the second predetermined order is an order of baud rate parameters from high to low, and the step of reselecting a baud rate parameter in a preset baud rate parameter group based on the communication state to adjust the baud rates of the master node device and the slave node device until the communication state meets the preset communication quality requirement includes:
[0030] When the first communication state is that the master node device and each slave node device can communicate normally, the step of: based on a preset polling mechanism, selecting baud rate parameters in a preset baud rate parameter group as first baud rate parameters in accordance with the first predetermined order, until the first communication state is that the communication between the master node device and any slave node device is abnormal;
[0031] Based on the first baud rate parameter, the next baud rate parameter is selected as the second baud rate parameter in the preset baud rate parameter group according to the second predetermined order, and the baud rates of the master node device and the slave node device are adjusted to obtain the optimal baud rate parameter.
[0032] In one embodiment, after the step of selecting the next baud rate parameter as the second baud rate parameter in the preset baud rate parameter group according to the second predetermined order based on the first baud rate parameter, adjusting the baud rates of the master node device and the slave node device, and obtaining the optimal baud rate parameter, the step further includes:
[0033] Confirming the second communication state between the master node device and each slave node device within a preset period;
[0034] When the second communication state is that the distortion of the voltage signal is not within the preset signal distortion threshold, continue to execute the steps: based on the preset polling mechanism, select baud rate parameters one by one in the preset baud rate parameter group according to the second predetermined order as the second baud rate parameters until the second communication state is that the distortion of the voltage signal is within the preset signal distortion threshold.
[0035] In addition, to achieve the above purpose, the present application also proposes a baud rate adjustment device, which is applied to a serial communication system, wherein the serial communication system includes a master node device and a plurality of slave node devices, and the baud rate adjustment device includes:
[0036] An address allocation module, used for establishing a communication link between the master node device and the slave node device based on preset default baud rate information;
[0037] A selection module, configured to select baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as first baud rate parameters based on a preset polling mechanism;
[0038] The baud rate adjustment module is used to adjust the baud rates of the master node device and the slave node device based on the first baud rate parameter and the communication link until the communication status between the master node device and each slave node device meets the preset communication quality requirement.
[0039] In addition, to achieve the above-mentioned purpose, the present application also proposes a baud rate adjustment device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the baud rate adjustment method described above.
[0040] In addition, to achieve the above objectives, the present application also proposes a storage medium, which is a computer-readable storage medium, and stores a computer program on the storage medium. When the computer program is executed by a processor, the steps of the baud rate adjustment method described above are implemented.
[0041] One or more technical solutions proposed in this application have at least the following technical effects:
[0042] The baud rate adjustment method, apparatus, device and storage medium proposed in the embodiments of the present application specifically establish a communication link between the master node device and the slave node device based on preset default baud rate information; based on a preset polling mechanism, select baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as the first baud rate parameter; based on the first baud rate parameter and the communication link, adjust the baud rate of the master node device and the slave node device until the communication status between the master node device and each slave node device meets the preset communication quality requirements.
[0043] The present application establishes a communication link between the master and slave node devices in the serial communication system through pre-configured default baud rate information, and then based on a preset polling mechanism, selects different baud rate parameters from a preset baud rate parameter group by polling, and tests the status of the communication link established based on different baud rate parameters until the status of the communication link meets the preset communication quality requirements, thereby completing the adaptive dynamic adjustment of the optimal communication baud rate of the serial communication system, and effectively improving the communication stability and reliability of the serial communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0046] Figure 1 A flow chart of the baud rate adjustment method according to the present invention;
[0047] Figure 2 A flow chart of the second embodiment of the baud rate adjustment method of the present application;
[0048] Figure 3 A flowchart of the third embodiment of the baud rate adjustment method of the present application is provided;
[0049] Figure 4 A flowchart of a fourth embodiment of the baud rate adjustment method of the present application is provided;
[0050] Figure 5 A flowchart of a fifth embodiment of the baud rate adjustment method of the present application is provided;
[0051] Figure 6 A flowchart of a sixth embodiment of the baud rate adjustment method of the present application is provided;
[0052] Figure 7 This is a schematic diagram of the module structure of the baud rate adjustment device according to an embodiment of the present application;
[0053] Figure 8 A schematic diagram of the device structure of the hardware operating environment involved in the baud rate adjustment method in the embodiment of the present application;
[0054] Fig. 9 This is a schematic diagram of a bus voltage signal involved in Embodiment 4 of the present application.
[0055] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0056] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0057] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0058] The main solution of the embodiment of the present application is: based on the preset default baud rate information, establish a communication link between the master node device and the slave node device; based on the preset polling mechanism, select baud rate parameters one by one in the preset baud rate parameter group in a predetermined order as the first baud rate parameter; based on the first baud rate parameter and the communication link, adjust the baud rate of the master node device and the slave node device until the communication status between the master node device and each slave node device meets the preset communication quality requirements.
[0059] Technical terms involved in the embodiments of this application:
[0060] Serial communication: Serial communication is a communication method that transmits data one bit at a time. In serial communication, data is transmitted through a single transmission line (or a pair of differential lines), which is suitable for long-distance communication and low-cost occasions. Serial communication is widely used in embedded systems, industrial control, data acquisition and other fields.
[0061] Serial communication has the characteristics of simple communication lines, suitable for long-distance communication, and multiple interface standards. Commonly used serial communication interface standards include RS-232C, RS-422, RS-423 and RS-485. In serial communication, the relationship between master and slave node devices is the basis of the entire communication system.
[0062] Master node device: In serial communication, the master node device is usually responsible for controlling the entire communication process. The master node device controls the start and end of communication and the transmission of data. The master node device can initiate communication and send requests and commands to the slave node devices. The master node device is also responsible for configuring and managing the entire communication system, including the configuration and management of the slave node devices.
[0063] Slave node device: As a slave device, the main task of the slave node device is to respond to the requests and commands of the master node device and operate according to the instructions of the master node device. During the communication process, the slave node device will receive data from the master node device and send data to the master node device as needed.
[0064] Baud rate: Baud rate is a measure of the serial communication data transmission rate, indicating the number of binary bits transmitted per second (bits per second, bps). For example, 9600bps means that 9600 bits can be transmitted per second.
[0065] In serial communication, the baud rate directly affects the speed and quality of data transmission, and thus affects the communication quality. At the same time, both parties in communication must set the same baud rate, otherwise it will lead to communication failure. Common standard baud rates include 2400, 4800, 9600, 19200, 38400, 57600, 115200, etc.
[0066] RS485: RS485 is an electrical standard that defines the electrical characteristics in a multi-point communication network, enabling different devices to transmit data over the same twisted pair. RS485 is a commonly used half-duplex-asynchronous-serial communication bus and belongs to the Recommended Standard (RS) series.
[0067] RS485 uses differential signal transmission, so it has strong anti-interference ability and long transmission distance. Its transmission distance can usually reach 1200 meters, but the actual distance depends on the cable quality and environmental conditions. RS485 allows multiple devices to share the same communication line, generally supporting a maximum of 32 nodes. Nodes can exchange data and control equipment through Modbus or other industrial control protocols. RS485 supports a variety of network topologies, including bus, star and tree. RS485 is widely used in industrial automation, building automation, remote monitoring and data acquisition systems, and is favored for its reliability and flexibility.
[0068] ACK (Acknowledge character): ACK is used in communication protocols to indicate that the receiver has successfully received the data frame or control signal sent by the sender. The ACK signal is a simple feedback mechanism between the communicating parties to confirm the successful reception of data. If the receiver does not correctly receive the data frame or control signal, it will not send an ACK signal. The sender can perform retransmission or other error handling operations based on this situation.
[0069] Existing baud rate adjustment methods often focus on how to synchronously adjust the baud rate between master and slave node devices, without considering the communication efficiency and communication reliability of the communication link, and are unable to establish an optimal communication link. As a result, when the baud rate of the serial communication device is adjusted or synchronized, there are technical problems such as low communication efficiency and reliability of the serial communication.
[0070] The present application provides a solution, which establishes a communication link for master and slave node devices in a serial communication system through pre-configured default baud rate information, and then based on a preset polling mechanism, polls and selects different baud rate parameters from a preset baud rate parameter group, and tests the status of the communication link established based on different baud rate parameters until the status of the communication link meets the preset communication quality requirements, thereby completing the adaptive dynamic adjustment of the optimal communication baud rate of the serial communication system, and effectively improving the communication stability and reliability of the serial communication.
[0071] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a baud rate adjustment device that can realize the above functions, a serial communication system (such as a smart dimming device), etc. The following takes the serial communication system as an example to illustrate this embodiment and the following embodiments.
[0072] Based on this, the embodiment of the present application provides a baud rate adjustment method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the baud rate adjustment method of the present application.
[0073] In this embodiment, the method is applied to a serial communication system, the serial communication system includes a master node device and a plurality of slave node devices, and the baud rate adjustment method includes steps S110 to S130:
[0074] Step S110, establishing a communication link between the master node device and the slave node device based on preset default baud rate information;
[0075] It should be noted that the preset default baud rate information refers to the baud rate information pre-configured in the serial communication device by relevant personnel or equipment manufacturers based on the common industry standard baud rate before the equipment leaves the factory.
[0076] Specifically, according to the pre-configured default baud rate information, the serial communication system first assigns communication addresses to the master node device and several slave node devices one by one, and then establishes a communication link between the master node device and the slave node device according to the communication address of each device, so as to subsequently perform adaptive adjustment of the baud rate according to the communication link.
[0077] Step S120, based on a preset polling mechanism, selecting baud rate parameters in a preset baud rate parameter group one by one in a predetermined order as first baud rate parameters;
[0078] It should be noted that the preset polling mechanism refers to the polling adjustment process of the baud rate pre-set by relevant personnel based on the baud rate adaptive adjustment requirements, which is used to dynamically find the optimal baud rate parameters of the serial communication system; the preset baud rate parameter group refers to a group of baud rate parameter values pre-configured by relevant personnel based on industry experience or actual needs, including but not limited to common baud rate parameters, such as 2400, 4800, 9600, 19200, 38400, 57600, and 115200.
[0079] The predetermined order refers to the order pre-configured by relevant personnel according to actual needs, including any one of high to low, low to high, and custom order.
[0080] Specifically, the serial communication system selects a baud rate parameter from a preset baud rate parameter group in a predetermined order based on a pre-configured baud rate polling mechanism and preset default baud rate information, and sets the selected baud rate parameter as a first baud rate parameter, so that the baud rate adaptive adjustment of the serial communication system can be completed subsequently according to the first baud rate parameter.
[0081] Step S130: Based on the first baud rate parameter and the communication link, the baud rates of the master node device and the slave node devices are adjusted until the communication status between the master node device and each slave node device meets the preset communication quality requirement.
[0082] In this embodiment, the preset communication quality requirements refer to the relevant quality standards of the communication link of the serial communication system pre-set by relevant personnel based on the baud rate adaptive adjustment requirements, including the requirements for evaluation indicators of communication quality, communication efficiency, and communication stability, such as bit error rate, transmission rate, communication connection time, communication delay time and other indicators.
[0083] The communication status refers to the communication status of the communication link between the master node device and each slave node device, including but not limited to information on key indicators such as communication rate, communication delay duration, communication bit error rate, and communication connection status.
[0084] Specifically, the serial communication system adjusts the baud rates of the master node device and the slave node device through the first baud rate parameter obtained by polling and the communication link, so that the baud rates are modified to the first baud rate parameter. Then, it is confirmed whether the communication status between the master node device and the slave node device under the first baud rate parameter meets the preset communication quality requirement, so as to determine whether it is necessary to repeat the adjustment of the baud rate parameter, and re-polling in the preset baud rate parameter group to obtain a new first baud rate parameter.
[0085] Only when the communication status between the master node device and the slave node device under the first baud rate parameter meets the preset communication quality requirement, which means that the first baud rate parameter at this time is the optimal communication baud rate of the serial communication system, can the adjustment of the baud rate parameter be ended.
[0086] In a feasible implementation manner, step 130 may include steps A01 to A03:
[0087] Step A01, adjusting the baud rates of the master node device and the slave node device based on the first baud rate parameter and the communication link;
[0088] Specifically, the serial port communication system first transmits the selected first baud rate parameter that needs communication verification to the master node device, and then generates a baud rate adjustment instruction based on the first baud rate parameter information through the communication link between the master node device and each slave node device, and sends it to each slave node device, so that each slave node device adjusts the baud rate according to the baud rate adjustment instruction and modifies its baud rate value to the first baud rate parameter.
[0089] Step A02, confirming the communication status between the master node device and each slave node device within a preset period;
[0090] Step A03: Based on the communication status, reselect baud rate parameters in the preset baud rate parameter group to adjust the baud rates of the master node device and the slave node device until the communication status meets the preset communication quality requirement.
[0091] It should be noted that the preset cycle refers to the communication cycle pre-set in the serial communication according to the actual communication needs, which is used to determine the sending and receiving frequency of data packets, that is, how often the data is exchanged. The communication cycle is often a multiple of the clock cycle, and the clock cycle can generally be calculated based on the signal of the clock source in the serial communication.
[0092] Specifically, within a preset period, the serial port communication system confirms the communication status of the communication link between the master node device and each slave node device through communication evaluation indicators, such as communication rate, communication delay duration, communication bit error rate, communication connection status, communication signal distortion degree and other communication evaluation indicators.
[0093] It is understandable that in order to ensure the optimization of the communication efficiency of the serial communication system, the serial communication system can be implemented by adaptively adjusting the optimal universal baud rate.
[0094] Specifically, the serial communication system compares the communication state of the communication link under the first baud rate parameter with the preset communication quality requirement. When the preset communication quality requirement is not met, it is necessary to repeatedly adjust the baud rate parameters of the master and slave node devices, obtain the first baud rate parameter again, and reconfirm the communication state of the communication link under the first baud rate parameter until the communication state of the communication link under the first baud rate parameter meets the preset communication quality requirement, and the adaptive adjustment process of the optimal communication baud rate is completed. At this time, the first baud rate parameter is the optimal baud rate parameter of the serial communication system, that is, the optimal communication baud rate.
[0095] In this embodiment, by confirming whether the communication state of the communication link under the first baud rate parameter within a preset period meets the preset communication quality requirement, the optimal communication baud rate of the serial communication system is adaptively adjusted to ensure the optimization of the communication efficiency of the serial communication system and improve the reliability of communication.
[0096] This embodiment provides a baud rate adjustment method, by establishing a communication link between the master node device and the slave node device based on preset default baud rate information; based on a preset polling mechanism, selecting baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as a first baud rate parameter; based on the first baud rate parameter and the communication link, adjusting the baud rates of the master node device and the slave node device until the communication status between the master node device and each slave node device meets the preset communication quality requirements.
[0097] The present application establishes a communication link between the master and slave node devices in the serial communication system through pre-configured default baud rate information, and then based on a preset polling mechanism, selects different baud rate parameters from a preset baud rate parameter group by polling, and tests the status of the communication link established based on different baud rate parameters until the status of the communication link meets the preset communication quality requirements, thereby completing the adaptive dynamic adjustment of the optimal communication baud rate of the serial communication system, and effectively improving the communication stability and reliability of the serial communication.
[0098] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 2 , before the above step S110, it also includes steps S210 to S220:
[0099] Step S210, based on a preset network topology, connecting the master node device and the slave node device through a bus;
[0100] It should be noted that the preset network topology structure refers to the network topology connection type of the serial communication system that is pre-set by relevant personnel based on the baud rate adaptive adjustment requirements and the serial communication protocol type. Common network topology connection types include bus topology, star topology, ring topology, tree topology, etc.
[0101] In this embodiment, the master and slave node devices of the serial communication system select the communication standard of the RS485 protocol to perform serial communication.
[0102] Specifically, the RS485 protocol only supports a hand-in-hand network topology, that is, the preset network topology is a hand-in-hand structure, and the serial communication system physically connects the master node device and the slave node device in the hand-in-hand structure through the bus according to the RS485 protocol.
[0103] Among them, the bus refers to the communication cable used to transmit data and commands between the communicating parties to achieve interconnection between devices.
[0104] Step S220, after the power is turned on, the preset default baud rate information is obtained based on the preset initial state information.
[0105] It can be understood that in order to realize the communication between the master and slave node devices in the serial communication system, it is necessary to turn on the power supply and power on the master and slave node devices.
[0106] The preset initial status information refers to the device status information that is pre-configured in the serial communication device by relevant personnel or device manufacturers based on common industry standards or experience before the device leaves the factory, including but not limited to parameter information such as baud rate, data bits, stop bits and check bits.
[0107] Specifically, after the master and slave node devices are powered on, the serial port communication system parses and obtains the pre-configured default communication baud rate of each device according to the preset initial state information of each device.
[0108] It should be understood that, since the preset initial status information is configured by the device before leaving the factory, the preset default baud rate of each device is often the same, so as to ensure the communication connection between the devices after the master and slave node devices are powered on.
[0109] The present embodiment provides a baud rate adjustment method, which connects the master node device and the slave node device through a bus based on a preset network topology structure; after turning on the power, based on the preset initial state information, obtains the preset default baud rate information; based on the preset default baud rate information, establishes a communication link between the master node device and the slave node device; based on the preset polling mechanism, selects baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as the first baud rate parameter; based on the first baud rate parameter and the communication link, adjusts the baud rate of the master node device and the slave node device until the communication status between the master node device and each slave node device meets the preset communication quality requirement.
[0110] Through the above scheme, this embodiment physically connects the master and slave node devices in the serial communication system through a preset network topology structure, and obtains the preset default baud rate information through the preset initial state information analysis, so as to facilitate the subsequent normal serial communication based on the physical connection and the preset default baud rate information.
[0111] Based on the first embodiment and / or the second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the first embodiment and / or the second embodiment can refer to the above description, and will not be described in detail later. Figure 3 , the step A01 includes steps S310 to S330:
[0112] Step S310, generating a baud rate adjustment signal based on the first baud rate parameter;
[0113] Specifically, firstly, according to the first baud rate parameter selected by the polling, the state of the control signal (eg GPIO pin signal) predefined for baud rate adjustment is modified to generate a new control signal, ie, a baud rate adjustment signal.
[0114] Or the serial communication system generates a specific data packet containing the first baud rate parameter information, namely, a baud rate adjustment signal, wherein the baud rate adjustment signal is used to instruct to adjust the baud rate of the master and slave node devices.
[0115] Step S320: Based on the communication link, the master node device sends the baud rate adjustment signal to each slave node device, and performs baud rate adjustment according to the baud rate adjustment signal;
[0116] Step S330: Based on the communication link, the slave node device receives the baud rate adjustment signal and performs baud rate adjustment according to the baud rate adjustment signal.
[0117] Specifically, according to the communication link between the master and slave node devices previously established, the master node device actively sends a baud rate adjustment signal to each slave node device, and then at the next cycle moment, the master node device adjusts its baud rate according to the baud rate adjustment signal, thereby adjusting the baud rate of the master node device to the first baud rate parameter. Among them, the period is the communication period of the master and slave node devices in the serial communication.
[0118] According to the communication link between the master and slave node devices previously established, after the master node device actively sends a baud rate adjustment signal to the slave node device, each slave node device receives the baud rate adjustment signal, and then at the next cycle moment, the slave node device synchronously adjusts its baud rate according to the baud rate adjustment signal, thereby adjusting the baud rate of the slave node device to the first baud rate parameter.
[0119] The present embodiment provides a baud rate adjustment method, which establishes a communication link between the master node device and the slave node device based on preset default baud rate information; based on a preset polling mechanism, selects baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as a first baud rate parameter; based on the first baud rate parameter, generates a baud rate adjustment signal; based on the communication link, the master node device sends the baud rate adjustment signal to each slave node device, and adjusts the baud rate according to the baud rate adjustment signal; based on the communication link, the slave node device receives the baud rate adjustment signal, and adjusts the baud rate according to the baud rate adjustment signal; within a preset period, confirms the communication status between the master node device and each slave node device; based on the communication status, re-selects baud rate parameters in the preset baud rate parameter group to adjust the baud rates of the master node device and the slave node device until the communication status meets the preset communication quality requirements.
[0120] This embodiment uses the above solution to generate a baud rate adjustment signal so that the baud rate of the master and slave node devices is adjusted to the first baud rate parameter according to the baud rate adjustment information, so that the master and slave node devices communicate through the first baud rate parameter.
[0121] Based on the first embodiment and / or the second embodiment of the present application, in the fourth embodiment of the present application, the same or similar contents as those in the first embodiment and / or the second embodiment can refer to the above description and will not be described in detail later. Figure 4 , the communication state includes a first communication state and a second communication state, and the step A02 includes steps S410 to S460:
[0122] Step S410, within a preset period, the master node device polls and sends a communication request to each slave node device;
[0123] Step S420, the slave node device receives the communication request and returns response data;
[0124] Step S430, based on the response data, confirm whether the master node device and each slave node device can communicate normally, and obtain a first communication state;
[0125] In this embodiment, within a preset period, the master node device needs to evaluate the communication status of the communication link between the master node device and each slave node device. The communication status includes a first pass status, which can be obtained by evaluating the communication rate, communication delay time, communication connection status, etc.
[0126] Specifically, within a preset period, the master node device polls and sends a communication request to each slave node device, and each slave node device receives the communication request sent by the master node device and returns response data.
[0127] Then, according to the response data returned by each slave node device, by analyzing whether the response data contains the expected ACK character, it is confirmed whether the master node device and each slave node device can communicate normally, and the first communication state is obtained.
[0128] When the parsed response data is consistent with expectations and contains ACK characters, the master node device and each slave node device can communicate normally; when the parsed response data is inconsistent with expectations and does not contain ACK characters, the master node device and each slave node device cannot communicate normally.
[0129] It should be understood that due to the failure of the slave node device itself or its baud rate range does not support the first baud rate, after each slave node device receives a communication request, it is impossible to return response data within a preset period. In this case, it should be considered that the master node device and each slave node device cannot communicate normally.
[0130] Step S440, and / or within a preset period, the slave node device collects a voltage signal via a bus;
[0131] Step S450, calculating a signal distortion parameter based on the voltage signal;
[0132] Step S460: Based on the preset signal distortion threshold and the signal distortion parameter, determine whether the distortion of the voltage signal is within the preset signal distortion threshold, and obtain a second communication state.
[0133] It can be understood that in addition to checking whether the master and slave node devices communicate normally under the first baud rate parameter, the serial communication system can also confirm whether the first baud rate parameter is the optimal communication baud rate of the current system by checking the degree of distortion of the communication signal between the master and slave node devices under the first baud rate parameter.
[0134] Furthermore, the communication state also includes a second communication state.
[0135] In this embodiment, within a preset period, the serial communication system can send a communication signal from the master node device to the slave node device. After the communication signal is transmitted over a certain distance through the bus, the slave node device collects the voltage of the transmitted communication signal from the bus to obtain a voltage signal. Then, based on the collected voltage signal, according to the predefined signal distortion parameter rule, the signal distortion parameter of the current system communication is determined.
[0136] Among them, the signal distortion parameter is used to evaluate the degree of signal distortion, and the predefined signal distortion parameter rule refers to a mathematical operation rule for calculating the signal distortion parameter that is predefined by relevant personnel based on industry experience or actual needs.
[0137] Finally, by confirming whether the signal distortion parameter is within the preset signal distortion threshold, it is determined whether the distortion of the voltage signal is within the preset signal distortion threshold, and the second communication state is obtained. The preset signal distortion threshold is the value range of the signal distortion parameter that represents the distortion of the voltage signal meets the preset communication quality requirements.
[0138] When the signal distortion parameter is not within the preset signal distortion threshold, it is confirmed that the distortion of the voltage signal at this time is not within the preset signal distortion threshold; when the signal distortion parameter is within the preset signal distortion threshold, it is confirmed that the distortion of the voltage signal at this time is within the preset signal distortion threshold.
[0139] In one implementation, the serial communication system restores the voltage waveform by collecting the voltage signal of the bus. After the voltage waveform is restored, the threshold VH for judging the high level of the signal based on the RS485 chip is obtained, and the high level width T2 of the normal signal is calculated based on the bus baud rate in the current serial communication system:
[0140] T2=1 / B, where B is the baud rate of the bus, and the normal signal refers to the voltage signal collected under distortion-free communication conditions.
[0141] Reference Fig. 9 , when the bus differential voltage ( Fig. 9 After collecting the distorted signal, read Fig. 9 The difference T1 between two adjacent time points when V=VH in the distorted signal.
[0142] Then the signal distortion parameter α is calculated according to the following formula: α=|T2-T1| / T2.
[0143] Finally, a multi-bit signal distortion parameter operation is performed on the restored voltage signal. If the proportion of α not greater than a preset threshold (e.g., 0.05) in the multi-bit signal distortion parameter operation results is greater than a preset proportion (e.g., 90%), it means that the distortion of the voltage signal at this time is within the preset signal distortion threshold, and the communication stability and reliability of the serial communication system are guaranteed.
[0144] It should be understood that the preset threshold and the preset proportion in the above implementation can be dynamically adjusted according to actual conditions.
[0145] The present embodiment provides a baud rate adjustment method, which establishes a communication link between the master node device and the slave node device based on preset default baud rate information; based on a preset polling mechanism, selects baud rate parameters in a preset baud rate parameter group one by one in a predetermined order as a first baud rate parameter; based on the first baud rate parameter and the communication link, adjusts the baud rates of the master node device and the slave node device; within a preset period, the master node device polls and sends a communication request to each slave node device; the slave node device receives the communication request and returns a response data; based on the response data, confirms whether the master node device and each slave node device can communicate normally to obtain a first communication state; and / or within a preset period, the slave node device collects a voltage signal through a bus; based on the voltage signal, calculates a signal distortion parameter; based on a preset signal distortion threshold and the signal distortion parameter, determines whether the distortion of the voltage signal is within the preset signal distortion threshold, and obtains a second communication state; based on the communication state, re-selects a baud rate parameter in the preset baud rate parameter group to adjust the baud rates of the master node device and the slave node device until the communication state meets the preset communication quality requirement.
[0146] This embodiment adopts the above scheme, confirms the communication data of the master and slave node devices within a preset period, confirms whether the master and slave node devices can communicate normally, and further confirms whether the distortion of the voltage signal within the preset period meets the preset communication quality requirements, thereby obtaining the passage status between the master and slave node devices that communicate according to the first baud rate parameter, so as to subsequently realize adaptive dynamic adjustment of the communication baud rate according to the passage status, thereby ensuring that after the master and slave node devices synchronously adjust the baud rate, the communication efficiency and reliability of the serial communication remain at a high level.
[0147] Based on the first embodiment and / or the second embodiment and / or the fourth embodiment of the present application, in the fifth embodiment of the present application, the same or similar contents as those in the first embodiment, the second embodiment and / or the fourth embodiment can refer to the above description and will not be described in detail later. Figure 5The communication state includes a first communication state and a second communication state, the predetermined order includes a first predetermined order and a second predetermined order, the first predetermined order is an order of baud rate parameters from low to high, and the second predetermined order is an order of baud rate parameters from high to low, the step A03 includes steps S510 to S520:
[0148] Step S510, when the first communication state is that the master node device and each slave node device can communicate normally, executing the step of: based on a preset polling mechanism, selecting baud rate parameters in a preset baud rate parameter group as first baud rate parameters in accordance with the first predetermined order, until the first communication state is that the communication between the master node device and any slave node device is abnormal;
[0149] Step S520: Based on the first baud rate parameter, select the next baud rate parameter in the preset baud rate parameter group according to the second predetermined order as the second baud rate parameter, adjust the baud rates of the master node device and the slave node device, and obtain the optimal baud rate parameter.
[0150] It is understandable that in order to further improve the communication efficiency of the serial communication system and meet the scenario of large amount of data transmission, the serial communication system can adaptively find the optimal communication baud rate from the preset default baud rate in the preset baud rate parameter group in order from low to high.
[0151] Specifically, after confirming that a first communication state between the master node device and each slave node device is obtained based on polling the first baud rate parameter group, when the first communication state is that the master node device and each slave node device can communicate normally, it is necessary to continue to find the maximum baud rate that the serial communication system can support for communication, and then continue to execute the aforementioned step S120 according to the first predetermined order: based on the preset polling mechanism, baud rate parameters are selected one by one in the preset baud rate parameter group according to the first predetermined order as the first baud rate parameter, until the first baud rate parameter updated by polling exceeds the maximum baud rate that the serial communication system can support for communication for the first time. At this time, the first communication state is that the communication between the master node device and any slave node device is abnormal and normal communication is impossible.
[0152] Then, the serial communication system needs to find the baud rate parameter with the largest value in the preset baud rate parameter group and not exceeding the maximum baud rate supported by the system for communication in a second predetermined order corresponding to the opposite first baud rate parameter, that is, the order of the baud rate parameters from high to low, that is, according to the first baud rate parameter, in the preset baud rate parameter group, in order from high to low, to call back the last polled baud rate parameter, and use the selected baud rate parameter as the second baud rate parameter, and adjust the baud rates of the master node device and the slave node device to the second baud rate parameter. At this time, the second baud rate parameter is the maximum baud rate that the system can support for communication in the preset baud rate parameter group, that is, the optimal baud rate parameter.
[0153] This embodiment provides a baud rate adjustment method, which first performs a baud rate polling adjustment in a preset baud rate parameter group to confirm the maximum baud rate that the serial communication system can support, and completes the adaptive dynamic adjustment of the optimal communication baud rate of the serial communication system, thereby effectively improving the communication stability and reliability of the serial communication.
[0154] Based on the fifth embodiment of the present application, in the sixth embodiment of the present application, the same or similar contents as those in the fifth embodiment can be referred to the above description, and will not be described in detail later. Figure 6 , after the above step S520, further comprising steps S530 to S540:
[0155] Step S530, confirming the second communication state between the master node device and each slave node device within a preset period;
[0156] Step S540, when the second communication state is that the distortion of the voltage signal is not within the preset signal distortion threshold, continue to execute the steps: based on the preset polling mechanism, select baud rate parameters one by one in the preset baud rate parameter group according to the second predetermined order as the second baud rate parameters until the second communication state is that the distortion of the voltage signal is within the preset signal distortion threshold.
[0157] It should be understood that in order to ensure the communication quality of the serial communication system when communicating based on the adjusted baud rate and to maintain the communication stability and reliability at a high level, it is necessary to comprehensively consider the first communication state and the second communication state between the master node device and each slave node device.
[0158] Specifically, after adjusting the baud rate of the master and slave node devices according to the maximum baud rate that the system can support communication in the preset baud rate parameter group, that is, the second baud rate parameter, obtained by callback in step S520, it is confirmed within the preset period that the second communication state between the master node device and each slave node device whose baud rate is the second baud rate parameter is obtained.
[0159] Then, when the second communication state is that the distortion of the voltage signal is not within the preset signal distortion threshold, it is necessary to continue to find the optimal baud rate that the serial communication system can support, and then continue to execute the aforementioned step S120 according to the second predetermined order: based on the preset polling mechanism, baud rate parameters are selected one by one in the preset baud rate parameter group according to the second predetermined order as the second baud rate parameter, until the distortion of the voltage signal for communication based on the second baud rate parameter updated by polling is within the preset signal distortion threshold, and the second baud rate parameter at this time is the optimal baud rate of the current serial communication system.
[0160] The present embodiment provides a baud rate adjustment method, which first performs a baud rate polling adjustment in a preset baud rate parameter group to confirm that the maximum baud rate that the serial communication system can support communication is obtained, and then performs a second baud rate polling adjustment in the preset baud rate parameter group to obtain the optimal baud rate of the serial communication system, thereby completing the adaptive dynamic adjustment of the optimal communication baud rate of the serial communication system, and effectively improving the communication stability and reliability of the serial communication.
[0161] This application also provides a baud rate adjustment device, please refer to Figure 7 The baud rate adjustment device is applied to a serial communication system, the serial communication system includes a master node device and a plurality of slave node devices, and the baud rate adjustment device includes:
[0162] An address allocation module 10, configured to establish a communication link between the master node device and the slave node device based on preset default baud rate information;
[0163] A selection module 20, configured to select baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as first baud rate parameters based on a preset polling mechanism;
[0164] The baud rate adjustment module 30 is used to adjust the baud rates of the master node device and the slave node devices based on the first baud rate parameter and the communication link until the communication status between the master node device and each slave node device meets the preset communication quality requirement.
[0165] The baud rate adjustment device provided by the present application adopts the baud rate adjustment method in the above embodiment, which can solve the technical problem that the existing baud rate adjustment method has low communication efficiency and reliability of serial communication when adjusting or synchronizing the baud rate of the serial communication device. Compared with the prior art, the beneficial effects of the baud rate adjustment device provided by the present application are the same as the beneficial effects of the baud rate adjustment method provided by the above embodiment, and other technical features in the baud rate adjustment device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0166] The present application provides a baud rate adjustment device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the baud rate adjustment method in the above-mentioned embodiment.
[0167] Reference below Figure 8 , which shows a schematic diagram of the structure of a baud rate adjustment device suitable for implementing the embodiment of the present application. The baud rate adjustment device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The baud rate adjustment device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0168] like Figure 8 As shown, the baud rate adjustment device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the baud rate adjustment device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the baud rate adjustment device to communicate with other devices wirelessly or wired to exchange data. Although the baud rate adjustment device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0169] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0170] The baud rate adjustment device provided by the present application adopts the baud rate adjustment method in the above embodiment, which can solve the technical problem that the existing baud rate adjustment method has low communication efficiency and reliability of serial communication when adjusting or synchronizing the baud rate of the serial communication device. Compared with the prior art, the beneficial effects of the baud rate adjustment device provided by the present application are the same as the beneficial effects of the baud rate adjustment method provided by the above embodiment, and other technical features in the baud rate adjustment device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0171] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0172] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0173] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the baud rate adjustment method in the above-mentioned embodiment.
[0174] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0175] The computer-readable storage medium may be included in the baud rate adjustment device; or may exist independently without being assembled into the baud rate adjustment device.
[0176] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the baud rate adjustment device, the baud rate adjustment device: establishes a communication link between the master node device and the slave node device based on preset default baud rate information; selects baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as the first baud rate parameter based on a preset polling mechanism; and adjusts the baud rate of the master node device and the slave node device based on the first baud rate parameter and the communication link until the communication status between the master node device and each slave node device meets the preset communication quality requirements.
[0177] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0178] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0179] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0180] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned baud rate adjustment method, and can solve the technical problem that the existing baud rate adjustment method has low communication efficiency and reliability of serial communication when adjusting or synchronizing the baud rate of a serial communication device. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the baud rate adjustment method provided by the above-mentioned embodiment, and will not be repeated here.
[0181] An embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the baud rate adjustment method as described above when the computer program is executed by a processor.
[0182] The computer program product provided by the present application can solve the technical problem that the existing baud rate adjustment method has low communication efficiency and reliability of serial communication when adjusting or synchronizing the baud rate of a serial communication device. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of the present application are the same as the beneficial effects of the baud rate adjustment method provided by the above embodiment, which will not be described in detail here.
[0183] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A baud rate adjustment method, characterized in that: The method is applied to a serial communication system, the serial communication system includes a master node device and a plurality of slave node devices, and the method includes: Based on the preset default baud rate information, establishing a communication link between the master node device and the slave node device; Based on a preset polling mechanism, baud rate parameters are selected one by one in a preset baud rate parameter group in a predetermined order as first baud rate parameters; Based on the first baud rate parameter and the communication link, the baud rates of the master node device and the slave node devices are adjusted until the communication status between the master node device and each slave node device meets the preset communication quality requirement.
2. The method according to claim 1, characterized in that Before the step of establishing a communication link between the master node device and the slave node device based on the preset default baud rate information, the method includes: Based on a preset network topology, the master node device and the slave node device are connected via a bus; After the power is turned on, the preset default baud rate information is obtained based on the preset initial state information.
3. The method according to claim 1, characterized in that The step of adjusting the baud rates of the master node device and the slave node device based on the first baud rate parameter and the communication link until the communication status between the master node device and each slave node device meets the preset communication quality requirement includes: Based on the first baud rate parameter and the communication link, adjusting the baud rates of the master node device and the slave node device; Confirming the communication status between the master node device and each slave node device within a preset period; Based on the communication status, a baud rate parameter is reselected from a preset baud rate parameter group to adjust the baud rates of the master node device and the slave node device until the communication status meets the preset communication quality requirement.
4. The method according to claim 3, characterized in that The step of adjusting the baud rates of the master node device and the slave node device based on the first baud rate parameter and the communication link comprises: Based on the first baud rate parameter, generating a baud rate adjustment signal; Based on the communication link, the master node device sends the baud rate adjustment signal to each slave node device, and performs baud rate adjustment according to the baud rate adjustment signal; Based on the communication link, the slave node device receives the baud rate adjustment signal and performs baud rate adjustment according to the baud rate adjustment signal.
5. The method according to claim 3, characterized in that The communication state includes a first communication state and a second communication state, and the step of confirming the communication state between the master node device and each slave node device within a preset period includes: In a preset period, the master node device polls and sends a communication request to each slave node device; The slave node device receives the communication request and returns the response data; Based on the response data, confirm whether the master node device and each slave node device can communicate normally to obtain a first communication state; and / or In a preset period, the slave node device collects voltage signals through the bus; Based on the voltage signal, a signal distortion parameter is calculated; Based on the preset signal distortion threshold and the signal distortion parameter, it is determined whether the distortion of the voltage signal is within the preset signal distortion threshold, and a second communication state is obtained.
6. The method according to claim 5, characterized in that The predetermined order includes a first predetermined order and a second predetermined order, the first predetermined order is an order of baud rate parameters from low to high, and the second predetermined order is an order of baud rate parameters from high to low, and the step of reselecting a baud rate parameter from a preset baud rate parameter group based on the communication state to adjust the baud rates of the master node device and the slave node device until the communication state meets the preset communication quality requirement includes: When the first communication state is that the master node device and each slave node device can communicate normally, the step of: based on a preset polling mechanism, selecting baud rate parameters in a preset baud rate parameter group as first baud rate parameters in accordance with the first predetermined order, until the first communication state is that the communication between the master node device and any slave node device is abnormal; Based on the first baud rate parameter, the next baud rate parameter is selected as the second baud rate parameter in the preset baud rate parameter group according to the second predetermined order, and the baud rates of the master node device and the slave node device are adjusted to obtain the optimal baud rate parameter.
7. The method according to claim 6, characterized in that After the step of selecting the next baud rate parameter as the second baud rate parameter in the preset baud rate parameter group according to the second predetermined order based on the first baud rate parameter, adjusting the baud rates of the master node device and the slave node device to obtain the optimal baud rate parameter, the method further includes: Confirming the second communication state between the master node device and each slave node device within a preset period; When the second communication state is that the distortion of the voltage signal is not within the preset signal distortion threshold, continue to execute the steps: based on the preset polling mechanism, select baud rate parameters one by one in the preset baud rate parameter group according to the second predetermined order as the second baud rate parameters until the second communication state is that the distortion of the voltage signal is within the preset signal distortion threshold.
8. A baud rate adjustment device, characterized in that: The baud rate adjustment device is applied to a serial communication system, wherein the serial communication system includes a master node device and a plurality of slave node devices, and the baud rate adjustment device includes: An address allocation module, used for establishing a communication link between the master node device and the slave node device based on preset default baud rate information; A selection module, configured to select baud rate parameters one by one in a preset baud rate parameter group in a predetermined order as first baud rate parameters based on a preset polling mechanism; The baud rate adjustment module is used to adjust the baud rates of the master node device and the slave node device based on the first baud rate parameter and the communication link until the communication status between the master node device and each slave node device meets the preset communication quality requirement.
9. A baud rate adjustment device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the baud rate adjustment method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the baud rate adjustment method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Electric energy meter communication method and device, computer equipment, readable storage medium and program product
CN119276430A
Electric energy meter communication method, device, computer equipment, readable storage medium and program product
CN119276430B
Communication method, device and equipment of detonation plate slave and storage medium
CN120710822A
