CN113778796A - Method for monitoring serial port communication through USB - Google Patents
Method for monitoring serial port communication through USB Download PDFInfo
- Publication number
- CN113778796A CN113778796A CN202110999168.8A CN202110999168A CN113778796A CN 113778796 A CN113778796 A CN 113778796A CN 202110999168 A CN202110999168 A CN 202110999168A CN 113778796 A CN113778796 A CN 113778796A
- Authority
- CN
- China
- Prior art keywords
- mcu
- internet
- communication module
- things
- usb
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3089—Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Information Transfer Systems (AREA)
Abstract
The invention provides a method for monitoring serial port communication through a USB, which comprises the steps of determining a USB end, a Tx end and an Rx end on a USB-to-UART serial port data line, and the Tx end and the Rx end of an MCU and an Internet of things communication module respectively; the method comprises the steps that a USB end on a USB-to-UART serial port data line is connected into a monitoring device, and then a Tx end on the USB-to-UART serial port data line, a Tx end of an MCU and a Tx end of an Internet of things communication module are combined in pairs and respectively connected into a first AND gate circuit, a second AND gate circuit and a third AND gate circuit and correspondingly connected into an Rx end which does not participate in combination; judging whether the MCU and the Internet of things communication module realize communication or not according to the signal change of the monitoring equipment, and if so, outputting the display data of the monitoring equipment as UART communication data; according to the invention, the checking of communication data and the issuing of the control instruction data of the monitoring equipment can be realized under the condition that the normal communication between the MCU and the communication module of the Internet of things is not influenced.
Description
Technical Field
The invention relates to the technical field of communication information monitoring of the Internet of things, in particular to a method for monitoring serial port communication through a USB.
Background
In an embedded system, a UART serial port communication mode is generally adopted between the MCU and the communication module of the internet of things. The UART serial port communication only needs two data lines for transmitting data between two UART hosts. Because data flows from the Tx pin of the transmitting UART to the Rx pin of the receiving UART, the UART has simple hardware, fast communication speed and universal and simple software programming; and almost all MCUs have integrated one or several UART interfaces, so the UART serial ports still have the advantage of high commonality. At present, however, the common UART can only realize one-to-one communication due to the limitation of hardware principles.
When carrying out communication test to thing networking terminal equipment, can't directly look over the UART communication data between microcontroller MCU and the thing networking communication module, can't look over directly to communication quality, even the communication error of MCU and thing networking communication module, also can't fix a position the problem place directly perceivedly. Therefore, it is highly desirable to be able to check the communication data without affecting the normal communication between the MCU and the communication module of the internet of things.
In addition, when communication test is performed on the terminal device of the internet of things, if a communication error between the MCU and the communication module of the internet of things is found due to a program error or other reasons, debugging cannot be directly performed, so it is imperative to debug by directly sending instruction data without affecting communication between the MCU and the communication module of the internet of things.
Disclosure of Invention
The technical problem to be solved by the embodiment of the invention is to provide a method for monitoring serial port communication through a USB, which can realize the checking of communication data and the issuing of instruction data under the condition of not influencing the normal communication between an MCU and an Internet of things communication module, and solve the problem that debugging data in the UART serial port debugging is not intuitive.
In order to solve the above technical problem, an embodiment of the present invention provides a method for monitoring serial port communication through a USB, which is used for realizing an MCU and an internet of things communication module interconnected through a UART serial port communication manner, and the method includes the following steps:
determining a USB end, a Tx end and an Rx end on a preset USB-to-UART serial port data line, and the respective Tx end and Rx end of the MCU and the Internet of things communication module;
the method comprises the steps that a USB end on the USB-to-UART serial port data line is connected into a preset monitoring device, a Tx end on the USB-to-UART serial port data line and a Tx end of an MCU are simultaneously connected into a first AND gate circuit and a Rx end of an Internet of things communication module through the first AND gate circuit, the Tx end on the USB-to-UART serial port data line and the Tx end of the Internet of things communication module are simultaneously connected into a second AND gate circuit and a Rx end of the MCU through the second AND gate circuit, and the Tx end of the MCU and the Tx end of the Internet of things communication module are further simultaneously connected into a third AND gate circuit and a Rx end on the USB-to-UART serial port data line through the third AND gate circuit;
judging whether communication is realized between the MCU and the communication module of the Internet of things according to the signal change condition on the monitoring equipment, and outputting data displayed on the monitoring equipment as UART (universal asynchronous receiver/transmitter) communication data between the MCU and the communication module of the Internet of things when the communication is judged to be realized between the MCU and the communication module of the Internet of things;
and inputting instruction data to the monitoring equipment to enable the Rx end corresponding to the MCU and the Internet of things communication module to generate corresponding level change, and enabling the MCU and the Internet of things communication module to receive the corresponding instruction data to enable the MCU or the Internet of things communication module to execute a specific function.
The two Tx ends simultaneously accessed by the first AND gate circuit, the second AND gate circuit and the third AND gate circuit are not interfered with each other during data transmission.
The specific steps of judging whether the communication between the MCU and the Internet of things communication module is realized according to the signal change condition on the monitoring equipment comprise:
if the signal on the monitoring equipment is not changed, judging that the MCU and the Internet of things communication module are not communicated with each other; otherwise, if the signal on the monitoring equipment changes, the MCU and the Internet of things communication module are judged to realize communication.
Wherein, whether the signal on the monitoring equipment changes is reflected by a high-low level signal.
The method comprises the following steps of inputting instruction data to the monitoring equipment, enabling the MCU and the Rx end corresponding to the Internet of things communication module to generate corresponding level change, enabling the MCU and the Internet of things communication module to receive the corresponding instruction data, and enabling the MCU or the Internet of things communication module to execute specific functions, wherein the specific steps comprise:
and enabling the command data to generate level change through a Tx end on the USB-to-UART serial port data line, and enabling an Rx end of the Internet of things communication module and an Rx end of the MCU to generate corresponding level change through the first AND gate circuit and the second AND gate circuit respectively, so that the Internet of things communication module and the MCU receive corresponding command data simultaneously.
Wherein, the monitoring equipment is a notebook computer or a desktop computer.
The embodiment of the invention has the following beneficial effects:
1. according to the invention, another USB-to-UART serial port is added between the UART serial port of the MCU and the serial port of the communication module of the Internet of things, so that data can be visually checked on monitoring equipment (such as a notebook computer or a desktop computer), the checking of communication data and the issuing of instruction data can be realized under the condition that the communication between the MCU and the communication module of the Internet of things is not influenced, and the problem that the communication data is not visual in the debugging of the UART serial port is solved;
2. the invention is realized by using an AND gate circuit, and has the characteristics of simple and reliable circuit, strong compatibility, high communication speed and the like;
3. the invention can be applied to the communication of other three or more UART serial port hosts and has certain popularization.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is within the scope of the present invention for those skilled in the art to obtain other drawings based on the drawings without inventive exercise.
Fig. 1 is a flowchart of a method for monitoring serial port communication via a USB according to an embodiment of the present invention;
fig. 2 is a schematic connection diagram of a USB-to-UART serial port data line, an MCU, and an internet of things communication module connected in series via an and circuit in an application scenario of the method for monitoring serial port communication via a USB according to the embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the accompanying drawings.
As shown in fig. 1, in an embodiment of the present invention, a method for monitoring serial port communication through a USB is provided, where the method is used for an MCU (not shown) and an internet of things communication module (not shown) that can be interconnected in a UART serial port communication manner, and the method includes the following steps:
step S1, determining a USB end, a Tx end and an Rx end on a preset USB-to-UART serial port data line, and the respective Tx end and Rx end of the MCU and the Internet of things communication module;
step S2, accessing the USB end on the USB-to-UART serial data line to a preset monitoring device, simultaneously accessing the Tx end on the USB-to-UART serial data line and the Tx end of the MCU to a first and-gate circuit and accessing the Rx end of the communication module of the internet of things through the first and-gate circuit, and further simultaneously accessing the Tx end on the USB-to-UART serial data line and the Tx end of the communication module of the internet of things to a second and-gate circuit and accessing the Rx end of the MCU through the second and-gate circuit, and further simultaneously accessing the Tx end of the MCU and the Tx end of the communication module of the internet of things to a third and-gate circuit and accessing the Rx end on the USB-to-UART serial data line through the third and-gate circuit;
step S3, judging whether the MCU and the Internet of things communication module realize communication according to the signal change condition on the monitoring equipment, and outputting data displayed on the monitoring equipment as UART communication data between the MCU and the Internet of things communication module when judging that the MCU and the Internet of things communication module realize communication;
step S4, inputting instruction data to the monitoring equipment, enabling the Rx end corresponding to the MCU and the Internet of things communication module to generate corresponding level change, and enabling the MCU or the Internet of things communication module to execute specific functions after the MCU and the Internet of things communication module receive the corresponding instruction data.
The specific process is that, in step S1, in order to enable checking of communication data without affecting communication between the MCU and the communication module of the internet of things, a USB-to-UART serial port data line is added in advance between the serial port of the MCU and the serial port of the communication module of the internet of things to enable checking of communication data and issuing of instruction data, thereby solving the problem that communication data is not intuitive in debugging of the UART serial port.
At this time, the USB end, the Tx end, and the Rx end on the USB-to-UART serial port data line, and the Tx end and the Rx end of the MCU and the communication module of the internet of things need to be determined, so as to facilitate correct connection between subsequent cables.
In step S2, first, the USB port of the USB-to-UART serial data line is connected to a preset monitoring device (e.g., a laptop or a desktop computer with a USB port for communication); then, simultaneously accessing a Tx end on the USB-to-UART serial port data line and a Tx end of the MCU into a first AND gate circuit and accessing an Rx end of the Internet of things communication module through the first AND gate circuit, and simultaneously accessing a Tx end on the USB-to-UART serial port data line and a Tx end of the Internet of things communication module into a second AND gate circuit and accessing an Rx end of the MCU through the second AND gate circuit; and finally, simultaneously accessing the Tx end of the MCU and the Tx end of the Internet of things communication module into a third AND gate circuit and accessing the Rx end on a USB-to-UART serial port data line through the third AND gate circuit. The two Tx ends simultaneously accessed by the first AND gate circuit, the second AND gate circuit and the third AND gate circuit are not interfered with each other during data transmission. That is, by the above method, every two TX signals can be transmitted to one RX without the two TX signals interfering with each other.
At this time, the requirement for implementing interconnection and interworking by the UART serial port is to terminate all other Tx ends to the Rx end of the receiving end, and all Tx ends do not affect each other. Because the Tx end defaults to high level when the UART serial port does not transmit data, and low level occurs when the UART serial port transmits data, the and circuit in the digital circuit can transmit data of all Tx ends to the Rx end for reception, and the Tx ends do not affect each other.
In one embodiment, as shown in fig. 2a to 2d, the USB terminal, the Tx terminal, and the Rx terminal on the USB-to-UART serial port data line are respectively represented by USB, USB _ Tx, and USB _ Rx in fig. 2, the Tx terminal and the Rx terminal of the MCU are respectively represented by UART1_ Tx and UART1_ Rx in fig. 2, and the Tx terminal and the Rx terminal of the communication module of the internet of things are respectively represented by UART2_ Tx and UART2_ Rx in fig. 2.
At this time, after the Tx end USB _ Tx on the USB-to-UART serial data line and the Tx end UART1_ Tx of the MCU are simultaneously connected to the first and circuit Y1, the Rx end UART2_ Rx of the communication module of the internet of things is connected, as shown in fig. 2 b.
After the Tx end USB _ Tx on the USB-to-UART serial data line and the Tx end UART2_ Tx of the communication module of the internet of things are simultaneously connected to the second and circuit Y2, the Rx end UART1_ Rx of the MCU is connected, as shown in fig. 2 c.
After the Tx end UART1_ Tx of the MCU and the Tx end UART2_ Tx of the communication module of the internet of things are simultaneously connected to the third and circuit Y3, the Rx end USB _ Rx on the serial data line of the USB-to-UART is connected, as shown in fig. 2 d.
In step S3, first, if it is found that the signal on the monitoring device does not change, it is determined that communication between the MCU and the communication module of the internet of things is not implemented; otherwise, if the signal on the monitoring equipment is found to change, the MCU is judged to be communicated with the Internet of things communication module. Whether the signal changes on the monitoring equipment is reflected through a high-low level signal, if the waveform of the high-level signal is detected through the waveform, communication between the MCU and the communication module of the Internet of things is not realized, otherwise, when the waveform of the low-level signal is detected through the waveform, communication between the MCU and the communication module of the Internet of things is not realized.
Then, when judging that the communication between the MCU and the communication module of the Internet of things is realized, the data displayed on the monitoring equipment is output as UART communication data between the MCU and the communication module of the Internet of things, namely, the UART communication data is checked.
In step S4, the command data generates level changes through the Tx end USB _ Tx end on the USB to UART serial data line, and the and circuit respectively enables the Rx end UART2_ Rx of the communication module of the internet of things and the Rx end UART1_ Rx of the MCU to generate corresponding level changes, so that the MCU and the communication module of the internet of things can receive the command data sent by the Tx end USB _ Tx on the USB to UART serial data line, i.e., the command data is issued.
The embodiment of the invention has the following beneficial effects:
1. according to the invention, another USB-to-UART serial port is added between the UART serial port of the MCU and the serial port of the communication module of the Internet of things, so that data can be visually checked on monitoring equipment (such as a notebook computer or a desktop computer), the checking of communication data and the issuing of instruction data can be realized under the condition that the communication between the MCU and the communication module of the Internet of things is not influenced, and the problems of non-visual debugging data and issuing of external control instructions in the debugging of the UART serial port are solved;
2. the invention is realized by using an AND gate circuit, and has the characteristics of simple and reliable circuit, strong compatibility, high communication speed and the like;
3. the invention can be applied to the communication of other three or more UART serial port hosts and has certain popularization.
While the invention has been described in connection with what is presently considered to be the most practical and preferred embodiment, it is to be understood that the invention is not to be limited to the disclosed embodiment, but on the contrary, is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims (6)
1. A method for monitoring serial port communication through a USB is used for an MCU and an Internet of things communication module which can realize interconnection in a UART serial port communication mode, and is characterized by comprising the following steps:
determining a USB end, a Tx end and an Rx end on a preset USB-to-UART serial port data line, and the respective Tx end and Rx end of the MCU and the Internet of things communication module;
the method comprises the steps that a USB end on the USB-to-UART serial port data line is connected into a preset monitoring device, a Tx end on the USB-to-UART serial port data line and a Tx end of an MCU are simultaneously connected into a first AND gate circuit and a Rx end of an Internet of things communication module through the first AND gate circuit, the Tx end on the USB-to-UART serial port data line and the Tx end of the Internet of things communication module are simultaneously connected into a second AND gate circuit and a Rx end of the MCU through the second AND gate circuit, and the Tx end of the MCU and the Tx end of the Internet of things communication module are further simultaneously connected into a third AND gate circuit and a Rx end on the USB-to-UART serial port data line through the third AND gate circuit;
judging whether communication is realized between the MCU and the communication module of the Internet of things according to the signal change condition on the monitoring equipment, and outputting data displayed on the monitoring equipment as UART (universal asynchronous receiver/transmitter) communication data between the MCU and the communication module of the Internet of things when the communication is judged to be realized between the MCU and the communication module of the Internet of things;
and inputting instruction data to the monitoring equipment to enable the Rx end corresponding to the MCU and the Internet of things communication module to generate corresponding level change, and enabling the MCU and the Internet of things communication module to receive the corresponding instruction data to enable the MCU or the Internet of things communication module to execute a specific function.
2. The method for monitoring serial port communication through the USB according to claim 1, wherein two Tx ports simultaneously accessed by the first and gate circuit, the second and gate circuit, and the third and gate circuit do not interfere with each other during data transmission.
3. The method for monitoring serial port communication through the USB according to claim 1, wherein the specific step of determining whether the communication between the MCU and the communication module of the internet of things is implemented according to the signal variation on the monitoring device comprises:
if the signal on the monitoring equipment is not changed, judging that the MCU and the Internet of things communication module are not communicated with each other; otherwise, if the signal on the monitoring equipment changes, the MCU and the Internet of things communication module are judged to realize communication.
4. The method according to claim 1, wherein the step of inputting command data to the monitoring device to cause the Rx ends of the MCU and the communication module of the internet of things to generate corresponding level changes, and the step of causing the MCU or the communication module of the internet of things to perform a specific function includes the steps of:
and enabling the command data to generate level change through a Tx end on the USB-to-UART serial port data line, and enabling an Rx end of the Internet of things communication module and an Rx end of the MCU to generate corresponding level change through the first AND gate circuit and the second AND gate circuit respectively, so that the Internet of things communication module and the MCU receive corresponding command data simultaneously.
5. The method of claim 3, wherein the monitoring of the signal changes on the device is reflected by high and low signals.
6. The method for monitoring serial port communication via USB of claim 4, wherein the monitoring device is a laptop or desktop computer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110999168.8A CN113778796A (en) | 2021-08-28 | 2021-08-28 | Method for monitoring serial port communication through USB |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110999168.8A CN113778796A (en) | 2021-08-28 | 2021-08-28 | Method for monitoring serial port communication through USB |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113778796A true CN113778796A (en) | 2021-12-10 |
Family
ID=78839765
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110999168.8A Pending CN113778796A (en) | 2021-08-28 | 2021-08-28 | Method for monitoring serial port communication through USB |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113778796A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114676078A (en) * | 2022-03-25 | 2022-06-28 | 惠州高盛达智显科技有限公司 | UART interface signal-based automatic identification method |
-
2021
- 2021-08-28 CN CN202110999168.8A patent/CN113778796A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114676078A (en) * | 2022-03-25 | 2022-06-28 | 惠州高盛达智显科技有限公司 | UART interface signal-based automatic identification method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100511171C (en) | Test approach for debugging serial port function with single board and system thereof | |
CN107907814B (en) | Method for improving mass production test efficiency of chips | |
CN103714029A (en) | Novel two-line synchronous communication protocol and application | |
CN1963778A (en) | System and method for testing serial port of mainboard | |
US5414712A (en) | Method for transmitting data using a communication interface box | |
CN108563595B (en) | System and method for long-distance transmission of USB data | |
CN113778796A (en) | Method for monitoring serial port communication through USB | |
CN102355380A (en) | Hardware testing device and method for synchronous asynchronous serial interface | |
CN101907683B (en) | Automatic circuit testing structure of I2C module in digital baseband chip and method thereof | |
CN114297134A (en) | Chip architecture and signal integrity test method | |
KR100801759B1 (en) | Device and system for debugging device using control bus | |
CN110502381B (en) | Mobile terminal, serial port debugging method thereof and computer readable medium | |
US8738818B2 (en) | Apparatus and method for analyzing bidirectional data exchanged between two electronic devices | |
KR101084060B1 (en) | The data-transmittable non-polarity RS-485 communication device of BMS controller by automatic polarity discrimination | |
US7006117B1 (en) | Apparatus for testing digital display driver and method thereof | |
CN116319475A (en) | Signal analysis method, device, equipment and storage medium | |
CN113986600B (en) | Test method and device for chip serial interface and chip | |
US7000170B2 (en) | Method and apparatus for generating CRC/parity error in network environment | |
CN211906270U (en) | 485 device and RS485 interface of self-adaptation serial bus polarity | |
JP2024508592A (en) | USB interface multiplexing method, circuit, electronic equipment and storage medium | |
US20230101045A1 (en) | Introduction and Detection of Erroneous Stop Condition in a Single UART | |
CN116471216B (en) | Hardware platform for MIPI protocol layer verification and verification method thereof | |
US20050256984A1 (en) | Implementation of a master loopback mode | |
CN116185936B (en) | SPI communication data receiving and transmitting abnormity detection control system and detection method | |
CN116437070B (en) | Terminal state detection system, method, computer equipment and storage medium |
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 |