CN113672544A - Matching method for serial port communication transmission rate - Google Patents
Matching method for serial port communication transmission rate Download PDFInfo
- Publication number
- CN113672544A CN113672544A CN202111026653.3A CN202111026653A CN113672544A CN 113672544 A CN113672544 A CN 113672544A CN 202111026653 A CN202111026653 A CN 202111026653A CN 113672544 A CN113672544 A CN 113672544A
- Authority
- CN
- China
- Prior art keywords
- slave
- host
- serial port
- baud rate
- instruction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 32
- 230000005540 biological transmission Effects 0.000 title claims abstract description 25
- 238000007792 addition Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000010355 oscillation Effects 0.000 description 1
- 238000011897 real-time detection Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2213/00—Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F2213/0002—Serial port, e.g. RS232C
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Communication Control (AREA)
- Information Transfer Systems (AREA)
Abstract
The invention discloses a matching method of serial port communication transmission rate, which comprises the following steps: setting the host baud rate to be a value N on the host through a serial port debugging tool, periodically sending an instruction A to the slave through the serial port debugging tool, and restarting the slave to fix the slave baud rate to be the value N; sending a B instruction to the slave machine on the host machine through a serial port debugging tool to enable the slave machine to be in a debugging state; sending a C instruction to the slave machine on the host machine through a serial port debugging tool, and restarting the slave machine to modify the baud rate of the slave machine; and modifying the host baud rate on the host to make the host baud rate consistent with the modified slave baud rate. The matching method of the serial port communication transmission rate can quickly match the baud rate of the slave machine in a short time by using the serial port debugging tool through the host machine under the condition that the baud rate of the slave machine is unknown, so that the baud rates of the host machine and the slave machine can be modified and are consistent, the operation is simple, the baud rate matching speed is high, and the efficiency is high.
Description
Technical Field
The invention relates to the field of communication, in particular to a matching method of serial port communication transmission rate.
Background
In an information transmission channel, a signal unit carrying data information is called a symbol, the number of symbols transmitted through the channel per second is called a symbol transmission rate, which is referred to as a Baud rate for short, and the unit of the Baud rate is Baud (symbol/s), and the Baud rate is an index of a transmission channel bandwidth. Serial communication is widely used as one of information transmission methods. When the host computer and the slave computer communicate by adopting a serial port, data can be correctly received and sent, and the premise of realizing successful communication is that the baud rates of the serial ports of the host computer and the slave computer are required to be consistent. In actual operation, if the baud rate of the slave is known, the operation is simpler, and the baud rate of the master is only required to be set to be corresponding to the same value; most of the time, however, the baud rate of the slave is often unknown, and for this case, there are two methods for achieving successful communication:
one is the standard baud rate exhaustion method. Specifically, after the slave starts the communication program, the slave tries to receive specific characters sent by the master at different baud rates one by one until the specific characters can be received correctly. The method not only requires that the baud rate of the host side can only be changed between a limited number of fixed values, such as standard values between 300, 600, 1200, 2400, 4800, 9600, 14400 and 19200, but also requires that the working oscillation frequency of the slave side is known and stable, and simultaneously, because the method needs a software tool to identify the baud rate, the application of the method has certain limitation, and the baud rates are tried one by one, and the matching period is longer.
The other is a symbol width real-time detection method. The method requires the host to send certain data according to a convention, the slave machine measures the code element width of input data on an RXD pin through a timer of a single chip microcomputer, and then calculates the baud rate of the communication of the system to be measured. The method has higher requirements on the hardware structure of the slave machine side, and the slave machine equipment is required to have a code element width identification function.
In the two methods, no matter which method is used, some specific conditions are needed to ensure that the baud rates of the master and the slave are consistent, the communication is realized, the universality is poor, and the universal application cannot be realized.
Disclosure of Invention
The invention aims to provide a matching method for serial port communication transmission rate.
The technical scheme for realizing the purpose of the invention is as follows: a matching method of serial communication transmission rate is used for realizing serial communication between a host and a slave, wherein the baud rate of the slave is maintained as a numerical value N within a certain time after the slave is powered on, wherein the numerical value N is any natural number;
the matching method of the serial port communication transmission rate comprises the following steps:
s1, setting the baud rate of the host computer to be a value N on the host computer through a serial port debugging tool, and then periodically sending an instruction A to the slave computer through the serial port debugging tool;
s2, restarting the slave, initializing the slave, and fixing the baud rate of the slave to a numerical value N after the initialized slave receives the instruction A sent by the host;
s3, after the Baud rate of the slave is fixed to the value N, sending a B instruction to the slave on the host through a serial port debugging tool, receiving the B instruction sent by the host by the slave, and making a response indicating successful reception to enable the slave to be in a debugging state;
s4, after the slave is in the debugging state, sending a C instruction to the slave on the host through a serial port debugging tool, after receiving the C instruction sent by the host and making a response indicating successful reception, restarting the slave to modify the slave baud rate and operating at the modified slave baud rate;
and S5, modifying the host baud rate on the host through a serial port debugging tool to ensure that the host baud rate is consistent with the modified slave baud rate in the step S4.
Further, the value N is any one of 300, 600, 1200, 2400, 4800, 9600, 14400, and 19200. As the 300, 600, 1200, 2400, 4800, 9600, 14400, 19200 and the like belong to the conventional standard values of baud rate, the operation is more convenient after the standard values are set.
Further, the slave baud rate is maintained at a value of N for 1S of slave power up. The 1S time after the slave is restarted is usually enough for the slave to receive the A instruction sent by the host, so that the Baud rate of the slave is fixed at a value N, the 1S time is not long or short, the A instruction can be successfully received, and the operation of the step does not occupy too much time.
Further, in step S1, the cycle of periodically sending the a command to the slave via the serial port debug tool on the master is set to 0.2S. I.e. an a command is sent to the slave every 0.2S.
The matching method of the serial port communication transmission rate can quickly match the baud rate of the slave machine in a short time by using the serial port debugging tool through the host machine under the condition of not knowing the baud rate of the slave machine, so that the baud rates of the host machine and the slave machine can be modified and are consistent, thereby facilitating communication.
Drawings
Fig. 1 is a flowchart of a matching method of serial communication transmission rates according to the present invention.
Detailed Description
The following describes in detail a specific embodiment of the matching method for serial port communication transmission rate according to the present invention with reference to the accompanying drawings:
as shown in fig. 1, a matching method of serial communication transmission rate is used to realize serial communication between a host and a slave, and the slave baud rate is maintained at 9600 within 1S of power on of the slave; the matching method of the serial port communication transmission rate specifically comprises the following steps:
s1, setting the host baud rate to 9600 on the host through the serial port debugging tool, and then periodically sending an instruction "# AT" to the slave through the serial port debugging tool every 0.2S;
s2, restarting the slave, initializing the slave, and fixing the baud rate of the slave to 9600 after the initialized slave receives the instruction "# AT" sent by the master;
s3, after the baud rate of the slave is fixed at a value 9600, sending an instruction # echo to the slave on the master through a serial port debugging tool, receiving the instruction # echo sent by the master from the slave, and making a response "# OK" indicating successful reception to enable the slave to be in a debugging state;
s4, after the slave is in the debugging state, sending an instruction "# 115200, 8, N, 1" to the slave on the host through a serial port debugging tool, after the slave receives the instruction "# 115200, 8, N, 1" sent by the host and makes a response "# OK" indicating successful reception, restarting the slave to modify the baud rate of the slave and running at the modified slave baud rate;
and S5, modifying the host baud rate on the host through a serial port debugging tool to ensure that the host baud rate is consistent with the modified slave baud rate in the step S4.
In the above embodiment of the present invention, the value N is 9600, the a instruction is "# AT", the B instruction is "# echo", and the C instruction is "# 115200, 8, N, 1". The setting of the value N and the contents of the a, B and C commands may be, but not limited to, the above, and may be set or transmitted according to convention.
According to the matching method of the serial port communication transmission rate, after the host machine baud rate and the slave machine baud rate are consistent, communication can be achieved, and for example, debugging, parameter setting and the like are carried out on slave machine equipment by using protocols such as modbus and the like.
The matching method of the serial port communication transmission rate can quickly match the baud rate of the slave machine in a short time by using the serial port debugging tool through the host machine under the condition of not knowing the baud rate of the slave machine, so that the baud rates of the host machine and the slave machine can be modified and are consistent, thereby facilitating communication.
The invention provides a matching method of serial communication transmission rate, which can quickly match the baud rate of a host computer and the baud rate of a slave computer, so that the host computer and the slave computer can communicate with each other, and is extremely suitable for popularization.
It will be apparent to those skilled in the art that various modifications, additions, substitutions, and the like can be made without departing from the spirit of the invention and these are therefore considered to be within the scope of the invention.
Claims (4)
1. A matching method of serial communication transmission rate is used for realizing serial communication between a host and a slave, and is characterized in that: in a certain time of electrifying the slave, maintaining the baud rate of the slave to be a value N, wherein the value N is any natural number; the matching method of the serial port communication transmission rate comprises the following steps:
s1, setting the baud rate of the host computer to be a value N on the host computer through a serial port debugging tool, and then periodically sending an instruction A to the slave computer through the serial port debugging tool;
s2, restarting the slave, initializing the slave, and fixing the baud rate of the slave to a numerical value N after the initialized slave receives the instruction A sent by the host;
s3, after the Baud rate of the slave is fixed to the value N, sending a B instruction to the slave on the host through a serial port debugging tool, receiving the B instruction sent by the host by the slave, and making a response indicating successful reception to enable the slave to be in a debugging state;
s4, after the slave is in the debugging state, sending a C instruction to the slave on the host through a serial port debugging tool, after receiving the C instruction sent by the host and making a response indicating successful reception, restarting the slave to modify the slave baud rate and operating at the modified slave baud rate;
and S5, modifying the host baud rate on the host through a serial port debugging tool to ensure that the host baud rate is consistent with the modified slave baud rate in the step S4.
2. The matching method of serial port communication transmission rate according to claim 1, characterized in that: the value N is any one of 300, 600, 1200, 2400, 4800, 9600, 14400 and 19200.
3. The matching method of serial port communication transmission rate according to claim 1, characterized in that: the host and the slave are set to maintain the baud rate of the slave as a value N within 1S of the power-on of the slave.
4. The matching method of serial port communication transmission rate according to claim 1, characterized in that: in step S1, the cycle in which the serial port debug tool periodically sends the command a to the slave is set to 0.2S.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111026653.3A CN113672544B (en) | 2021-09-02 | 2021-09-02 | Matching method for serial port communication transmission rate |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111026653.3A CN113672544B (en) | 2021-09-02 | 2021-09-02 | Matching method for serial port communication transmission rate |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113672544A true CN113672544A (en) | 2021-11-19 |
CN113672544B CN113672544B (en) | 2024-05-17 |
Family
ID=78548311
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111026653.3A Active CN113672544B (en) | 2021-09-02 | 2021-09-02 | Matching method for serial port communication transmission rate |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113672544B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DE102013105706A1 (en) * | 2012-06-07 | 2013-12-12 | Samsung Electronics Co. Ltd. | Interface circuit for memory system used in computing system, has frame detection circuit that detects frame signal at one of output terminals of primary output terminals |
US20170288899A1 (en) * | 2016-03-29 | 2017-10-05 | Intel IP Corporation | Self-adapting baud rate |
CN111694785A (en) * | 2020-05-20 | 2020-09-22 | 哈尔滨工业大学 | Feedback UART self-adaptive baud rate system and method |
CN112463696A (en) * | 2020-08-11 | 2021-03-09 | 上海麦腾物联网技术有限公司 | Serial port baud rate self-adaption method |
-
2021
- 2021-09-02 CN CN202111026653.3A patent/CN113672544B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DE102013105706A1 (en) * | 2012-06-07 | 2013-12-12 | Samsung Electronics Co. Ltd. | Interface circuit for memory system used in computing system, has frame detection circuit that detects frame signal at one of output terminals of primary output terminals |
US20170288899A1 (en) * | 2016-03-29 | 2017-10-05 | Intel IP Corporation | Self-adapting baud rate |
CN111694785A (en) * | 2020-05-20 | 2020-09-22 | 哈尔滨工业大学 | Feedback UART self-adaptive baud rate system and method |
CN112463696A (en) * | 2020-08-11 | 2021-03-09 | 上海麦腾物联网技术有限公司 | Serial port baud rate self-adaption method |
Non-Patent Citations (1)
Title |
---|
孙夫文;郑采君;刘昕卓;许根瑞;郭向鑫;: "基于FPGA串口波特率自适应功能的设计与实现", 电子设计工程, no. 09 * |
Also Published As
Publication number | Publication date |
---|---|
CN113672544B (en) | 2024-05-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103957198A (en) | Sensor data receiving and converting method and system | |
CN107592250B (en) | Multi-rate self-adaptive test equipment based on aviation FC bus | |
CN105117319A (en) | Method for realizing real-time monitoring of multi-channel MDIO (Management Data Input Output) devices based on FPGA | |
CN113419983A (en) | Serial server and implementation method thereof | |
CN110311848A (en) | A kind of method that Modbus RTU communications protocol improves communication efficiency | |
CN113672544B (en) | Matching method for serial port communication transmission rate | |
WO2024113767A1 (en) | Power-on method and power-on apparatus for smart network interface cards | |
CN109726604B (en) | Data exchange communication method between contact card and terminal | |
WO2016179944A1 (en) | Function multiplexing method and apparatus for communication interface | |
US20040143781A1 (en) | System and method for non-intrusive loopback testing | |
CN116301676A (en) | Printing equipment connection method, device, equipment and storage medium | |
CN113630294B (en) | Switch modularization detection method and device | |
CN113556210B (en) | Upper computer and method for establishing communication connection | |
CN117200923A (en) | Asynchronous communication method and device | |
CN115599311A (en) | Polarity inversion method and apparatus, storage medium, and electronic apparatus | |
CN108196866B (en) | Firmware updating method and device | |
CN117834750B (en) | Device, method, system, equipment, medium and server for acquiring protocol data | |
CN109522256A (en) | A kind of serial port communication method, the network equipment, control equipment and storage medium | |
CN118170707A (en) | Method, apparatus, device and storage medium for asynchronous communication | |
CN112148321A (en) | Anti-interference upgrading system and method for automobile intelligent electronic equipment microcontroller | |
CN215773156U (en) | Ethernet development device | |
US11334437B2 (en) | Method to recover an error state in a serial communication with an integrated circuit card, corresponding system and computer program product | |
CN109587363B (en) | Modem | |
CN113722264B (en) | Communication method between singlechips | |
CN218886572U (en) | Simple peripheral bus system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |