CN113672544B - Matching method for serial port communication transmission rate - Google Patents
Matching method for serial port communication transmission rate Download PDFInfo
- Publication number
- CN113672544B CN113672544B CN202111026653.3A CN202111026653A CN113672544B CN 113672544 B CN113672544 B CN 113672544B CN 202111026653 A CN202111026653 A CN 202111026653A CN 113672544 B CN113672544 B CN 113672544B
- Authority
- CN
- China
- Prior art keywords
- slave
- baud rate
- serial port
- host
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 31
- 230000005540 biological transmission Effects 0.000 title claims abstract description 24
- 230000010355 oscillation Effects 0.000 description 1
- 238000011897 real-time detection Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
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 baud rate of the host computer to be a numerical value N through a serial port debugging tool on the host computer, periodically sending an A instruction to the slave computer through the serial port debugging tool, restarting the slave computer, and fixing the baud rate of the slave computer to be the numerical value N; b, sending a B instruction to the slave machine on the host machine through a serial port debugging tool, so that the slave machine is in a debugging state; c instructions are sent to the slave machine on the host machine through a serial port debugging tool, and the slave machine is restarted, so that the baud rate of the slave machine is modified; the master baud rate is modified on the master so that the master baud rate is consistent with the modified slave baud rate. According to the method for matching the serial port communication transmission rate, the slave baud rate can be quickly matched in a short time by using the serial port debugging tool through the host under the condition that the baud rate of the slave is not known, so that the baud rates of the host and the slave are both modified and 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 serial port communication transmission rate matching method.
Background
In the information transmission channel, the number of symbols transmitted through the channel per second is called symbol transmission rate, abbreviated as baud rate, which is an index of the bandwidth of the transmission channel, and the unit is baud (Baud, symbol/s). Serial communication is widely used as one of information transmission methods. When the serial port is adopted for communication between the host computer and the slave computer, data can be correctly received and transmitted, and the premise of realizing successful communication is that the serial port baud rate of the host computer and the slave computer must be kept consistent. In actual operation, if the baud rate of the slave is known, the operation is simpler, and only the baud rate of the master is required to be set to be the same value correspondingly; most of the time, however, the baud rate of the slave is often unknown, and for this case, there are two existing methods to achieve 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 host at different baud rates one by one until the specific characters can be received correctly. This method requires that not only the baud rate of the master side can only be varied between a limited number of fixed values, such as standard values between 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, but also the operating oscillation frequency of the slave side must be known and stable, and that the method requires a software tool for baud rate identification, so that the application thereof has a certain limitation, and that the baud rate is tried one by one, and the matching period is also long.
The other is a symbol width real-time detection method. The method requires a host to send certain data according to convention, a slave measures the code element width of input data on an RXD pin through a timer of a singlechip, and then the baud rate of communication of a system to be measured is calculated. The method has higher requirements on the hardware structure of the slave side, and the slave equipment is required to have a code element width identification function.
In the two methods, no matter which method, certain specific conditions are needed to ensure the baud rate of the master-slave machine to be consistent, so that the communication is realized, the universality is poor, and the universal applicability cannot be realized.
Disclosure of Invention
The invention aims to provide a matching method for serial communication transmission rate.
The technical scheme for realizing the aim of the invention is as follows: the method is used for realizing serial communication between a host and a slave, and the slave baud rate is maintained to be a value N within a certain period of time when the slave is electrified, 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 a host computer to be a numerical value N through a serial port debugging tool on the host computer, and periodically sending an A instruction to a slave computer through the serial port debugging tool;
s2, restarting the slave, initializing the slave, and fixing the slave baud rate at a numerical value N after the initialized slave receives an A instruction sent by the host;
s3, after the baud rate of the slave is fixed at the value N, sending a B instruction to the slave through a serial port debugging tool on the host, and after the slave receives the B instruction sent by the host and makes a response indicating successful reception, enabling the slave to be in a debugging state;
S4, after the slave is in a debugging state, sending a C instruction to the slave through a serial port debugging tool on the host, and after the slave receives the C instruction sent by the host and makes a response indicating successful reception, restarting the slave, so that the slave baud rate is modified and operates at the modified slave baud rate;
S5, modifying the baud rate of the host computer through a serial port debugging tool on the host computer, so that the baud rate of the host computer is consistent with the baud rate of the slave computer modified in the step S4.
Further, the number N is any one of 300, 600, 1200, 2400, 4800, 9600, 14400, 19200. Since 300, 600, 1200, 2400, 4800, 9600, 14400, 19200 and the like belong to the conventional standard values of baud rates, the operation is more convenient after the standard values are set.
Further, in 1S of the slave power-on, the slave baud rate is maintained as a value N. The 1S time after the slave machine is restarted is usually enough for the slave machine to receive the A instruction sent by the host machine, so that the baud rate of the slave machine is fixed at the value N, the 1S time is not long or short, the A instruction can be smoothly received, and the operation does not occupy excessive time.
Further, in step S1, the period of periodically sending an a instruction to the slave through the serial port debug tool on the master is set to 0.2S. I.e. every 0.2S sends an a instruction to the slave.
According to the method for matching the serial communication transmission rate, the slave baud rate can be quickly matched in a short time by using the serial debugging tool through the host under the condition that the baud rate of the slave is not known, so that the baud rates of the host and the slave are both modified and consistent, communication is convenient, the operation steps are simple, the operation setting is simple, the master baud rate and the slave baud rate are very easy to operate, the matching speed of the master baud rate and the slave baud rate is high, and the efficiency is high.
Drawings
Fig. 1 is a flow chart of a method for matching transmission rates of serial communication according to the present invention.
Detailed Description
The following describes in detail a specific embodiment of the serial port communication transmission rate matching method according to the present invention with reference to the accompanying drawings:
as shown in fig. 1, a method for matching serial communication transmission rate is used for implementing serial communication between a host and a slave, and the slave baud rate is maintained to 9600 in 1S of power-on of the slave; the serial port communication transmission rate matching method specifically comprises the following steps:
s1, setting the baud rate of a host to 9600 through a serial port debugging tool on the host, and periodically sending an instruction "#AT" to a slave AT intervals of 0.2S through the serial port debugging tool;
S2, restarting the slave, initializing the slave, and fixing the baud rate of the slave AT 9600 after the initialized slave receives an instruction "#AT" sent by the host;
S3, after the baud rate of the slave is fixed at a numerical value 9600, transmitting an instruction "# echo" to the slave through a serial port debugging tool on the host, and after the slave receives the instruction "# echo" transmitted by the host and makes a response "# OK" indicating successful reception, enabling the slave to be in a debugging state;
s4, after the slave is in a debugging state, transmitting instructions "#115200,8, N,1" to the slave through a serial port debugging tool on the host, and after the slave receives the instructions "#115200,8, N,1" transmitted by the host and makes a response "# OK" indicating successful reception, restarting the slave, so that the baud rate of the slave is modified and running at the modified baud rate of the slave;
S5, modifying the baud rate of the host computer through a serial port debugging tool on the host computer, so that the baud rate of the host computer is consistent with the baud rate of the slave computer modified 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 instruction, the B instruction, and the C instruction may be, but not limited to, the above, and the related instructions may be set or transmitted according to conventions.
The method for matching the serial port communication transmission rate can be used for communication after the master baud rate is consistent with the slave baud rate, such as debugging, parameter setting and the like of slave equipment by using protocols such as modbus and the like.
According to the method for matching the serial communication transmission rate, the slave baud rate can be quickly matched in a short time by using the serial debugging tool through the host under the condition that the baud rate of the slave is not known, so that the baud rates of the host and the slave are both modified and consistent, communication is convenient, the operation steps are simple, the operation setting is simple, the master baud rate and the slave baud rate are very easy to operate, the matching speed of the master baud rate and the slave baud rate is high, and the efficiency is high.
The invention provides a method for matching serial port communication transmission rate, which can be used for rapidly matching the baud rate of a master computer and the baud rate of a slave computer, so that the master computer and the slave computer can communicate, and is extremely suitable for popularization.
It will be apparent to those skilled in the art that several simple deductions or substitutions can be made by the present invention without departing from the spirit of the invention, and the invention is to be considered as falling within the scope of the invention.
Claims (4)
1. A serial port communication transmission rate matching method is used for realizing serial port communication of a host and a slave, and is characterized in that: the slave baud rate is maintained to be a numerical value N within a certain period of power-on of the slave, 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 a host computer to be a numerical value N through a serial port debugging tool on the host computer, and periodically sending an A instruction to a slave computer through the serial port debugging tool;
s2, restarting the slave, initializing the slave, and fixing the slave baud rate at a numerical value N after the initialized slave receives an A instruction sent by the host;
s3, after the baud rate of the slave is fixed at the value N, sending a B instruction to the slave through a serial port debugging tool on the host, and after the slave receives the B instruction sent by the host and makes a response indicating successful reception, enabling the slave to be in a debugging state;
S4, after the slave is in a debugging state, sending a C instruction to the slave through a serial port debugging tool on the host, and after the slave receives the C instruction sent by the host and makes a response indicating successful reception, restarting the slave, so that the slave baud rate is modified and operates at the modified slave baud rate;
S5, modifying the baud rate of the host computer through a serial port debugging tool on the host computer, so that the baud rate of the host computer is consistent with the baud rate of the slave computer modified in the step S4.
2. The method for matching transmission rates of serial communication according to claim 1, wherein: the number N is any one of 300, 600, 1200, 2400, 4800, 9600, 14400, 19200.
3. The method for matching transmission rates of serial communication according to claim 1, wherein: the master and the slave are set so that the slave baud rate is maintained to be a value N within 1S of the power on of the slave.
4. The method for matching transmission rates of serial communication according to claim 1, wherein: in step S1, the period for periodically transmitting an a instruction to the slave through the serial port debug tool on the master 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 CN113672544A (en) | 2021-11-19 |
CN113672544B true 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 (3)
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 |
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 |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10038569B2 (en) * | 2016-03-29 | 2018-07-31 | Intel IP Corporation | Self-adapting baud rate |
-
2021
- 2021-09-02 CN CN202111026653.3A patent/CN113672544B/en active Active
Patent Citations (3)
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 |
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串口波特率自适应功能的设计与实现;孙夫文;郑采君;刘昕卓;许根瑞;郭向鑫;;电子设计工程(第09期) * |
Also Published As
Publication number | Publication date |
---|---|
CN113672544A (en) | 2021-11-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106462528B (en) | The power save mode of USB power transmission source device | |
CN102855169B (en) | Compliance mode detection from limited information | |
JP4741149B2 (en) | Interface between modem and subscriber interface modules | |
US20200265004A1 (en) | Serial connection between management controller and microcontroller | |
RU2678715C2 (en) | Data transmission protocol with protocol exception state | |
CN110704265A (en) | Early warning information active reporting method and system based on Modbus protocol | |
CN107592250B (en) | Multi-rate self-adaptive test equipment based on aviation FC bus | |
CN113672544B (en) | Matching method for serial port communication transmission rate | |
CN110311848A (en) | A kind of method that Modbus RTU communications protocol improves communication efficiency | |
CN113419983A (en) | Serial server and implementation method thereof | |
CN111885022A (en) | Mimicry communication method based on communication interface, communication architecture and terminal equipment | |
CN113411102B (en) | Data transmission method, device and system and storage medium | |
CN108196866B (en) | Firmware updating method and device | |
CN102662716A (en) | Method for realizing startup guiding control in computer system by using interface access | |
CN110504799B (en) | External four-wire motor control system and data recording method and circuit thereof | |
CN107346294B (en) | Data flow control system and method based on SPI protocol | |
CN108173699B (en) | CPU high-efficiency processing method based on Marvell exchange chip when obtaining message source port | |
US5469153A (en) | Method of serially processing binary characters asynchronously received by an electrical energy meter | |
CN117834750B (en) | Device, method, system, equipment, medium and server for acquiring protocol data | |
CN215773156U (en) | Ethernet development device | |
CN112363962B (en) | Data communication method, system, electronic device and computer storage medium | |
CN114338530B (en) | Method and device for adjusting equipment state, storage medium and electronic device | |
US11334437B2 (en) | Method to recover an error state in a serial communication with an integrated circuit card, corresponding system and computer program product | |
CN118170707A (en) | Method, apparatus, device and storage medium for asynchronous communication | |
CN109587363B (en) | Modem |
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 |