Supercharge Your Innovation With Domain-Expert AI Agents!

Python-based serial port debugging method and system

A serial port debugging and serial port technology, which is applied in the field of serial port debugging based on Python, can solve problems such as communication delay, and achieve the effect of avoiding communication delay and solving blockage.

Pending Publication Date: 2022-02-15
四川泛华航空仪表电器有限公司
View PDF0 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

But at present, many Python serial port communications open COM3 when Python is running, and then prepare to get data from the keyboard and send it, and at the same time receive the data sent by the serial debugging assistant COM1. The serial debugging assistant uses COM1 and can display the data sent by the Python side. , when you click to send, the Python side will not display temporarily, because the method of reading the ke

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Python-based serial port debugging method and system
  • Python-based serial port debugging method and system

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0045] A kind of Python-based serial port debugging method of the present embodiment, such as figure 1 As shown, in this embodiment, a virtual serial port is selected, and attention should be paid when using readline(): a timeout should be specified when opening the serial port, otherwise, if the serial port does not receive a new line, it will wait forever. If there is no timeout, readline will report an exception. The pyserial library in this embodiment can see the identification of the first serial port, write data into the serial port, open the serial port, read num characters, read a line of data, end with / n, if there is no / n, keep reading until blocking, After setting the baud rate, check the status information of the current serial port, judge whether the current serial port is open, judge the currently received data, clear the data in the input buffer, stop the current output and clear the data in the output buffer, and obtain the data sent from other serial ports A...

Embodiment 2

[0047] This embodiment is further optimized on the basis of Embodiment 1. In this embodiment, in serial communication, the baud rate is used to describe the data transmission rate. The so-called baud rate is the number of binary digits transmitted per second, and its unit is bps (bitsper second). It is an important index to measure the speed of serial data. After the baud rate is specified, the input shift register / output shift register is shifted at the specified baud rate under the control of the receiving clock / sending clock. When the system Clock, that is, when the clock frequency that provides the clock for the serial port is 100M, the clock cycle is One clock cycle is counted once, and so on, and the bit rate is set according to the binary position transmitted per second. In this embodiment, the bit rate is selected to be 9800. After setting the baud rate, you also need to set the function and timeout time.

[0048] Other parts of this embodiment are the same as those...

Embodiment 3

[0050]This embodiment is further optimized on the basis of Embodiment 1. In this embodiment, if two serial ports are selected, that is, serial port 1 and serial port 2, after the connection number, serial port 1 can display the sending content of serial port 2, and serial port 2 It can also display the sending content of serial port 1, and continue to close a virtual serial port during the development process of the serial port host computer, and then use the software we are developing to open it. For example, close the serial port 2 here, then use our software to open the serial port 2, and then send data, if the serial port 1 can receive the data, it proves that the program we sent is correct. After the test is over, stop sending and close the serial port to develop a good habit. If both serial port 1 and serial port 2 can achieve data transmission and reception, it means that the entire experimental environment is installed correctly, and you can enter a higher-level experi...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention relates to the technical field of Python serial port debugging, and discloses a Python-based serial port debugging method, which comprises the following steps of: S1, installing a pyserial library for calling a serial port function, and presetting environments for verifying the pyserial library by a first test and a second test; s2, virtual serial ports are installed, the connection relation of the serial ports is indicated on the virtual serial ports, whether data can be transmitted between the serial ports or not is judged, if yes, the step S3 is executed, and if not, the connection relation of the serial ports is indicated again till the data can be transmitted between the serial ports; s3, presetting a non-blocking rule, and reading the keyboard according to the non-blocking rule; and S4, capturing a built-in exception condition through the Python serial port, obtaining an error point, feeding back error information, and processing the built-in exception. The invention further discloses a serial port debugging system based on the Python.

Description

technical field [0001] The invention relates to the technical field of Python serial port debugging, specifically, a Python-based serial port debugging method and system, which are used to avoid the problem of Python serial port communication delay. Background technique [0002] With the development of Python, Python serial communication is also very important. Python serial communication refers to a communication method that transmits data bit by bit between peripherals and computers through data signal lines, ground lines, control lines, etc. This communication method uses fewer data lines, which can save communication costs in long-distance communication, but its transmission speed is lower than parallel transmission. The serial port is a very common device communication protocol on the computer. But at present, many Python serial port communications open COM3 when Python is running, and then prepare to get data from the keyboard and send it, and at the same time receive...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F13/42G06F11/36
CPCG06F13/4282G06F11/362
Inventor 黎右翼薛双喜周蓉
Owner 四川泛华航空仪表电器有限公司
Features
  • R&D
  • Intellectual Property
  • Life Sciences
  • Materials
  • Tech Scout
Why Patsnap Eureka
  • Unparalleled Data Quality
  • Higher Quality Content
  • 60% Fewer Hallucinations
Social media
Patsnap Eureka Blog
Learn More