Comport, the I/O interface is known as a COM port that allows the connection for a serial device to a computer. COM ports are sometimes referred to as serial ports. COM ports are no longer commonly used on current computers, but many serial port devices that utilize the interface are still in use. Serial connections are frequently used in point-of-sale, medical, and laboratory systems.
The com ports COM1 and COM2 were used in older personal computers to connect a serial port device, like a modem or mouse. They were given the COM moniker because IBM-compatible-compatible computers used them as communication interfaces. When linked to a serial device, they are asynchronous interfaces that can send one bit of data simultaneously at a time.
What is a serial device
Electronic devices, known as serial devices, differ from other types of devices in how they send data.
Most recently produced desktop and laptop computers do not come standard with serial connections. One or more USB interfaces often take the place of the RS232 serial ports that are used in the past. This does not imply that a serial port device is not connected to a new computer. If a machine lacks installed serial interfaces, you can use a USB to serial converter to supply one or more COM ports. There are numerous options; most are affordable and simple to use. Numerous specific circumstances still make use of serial ports. Examples include tools used in industrial automation installations and surveillance cameras.
What are serial ports used for?
USB connectors have mainly supplanted COM ports have mainly been supplanted by USB connectors as a quicker method of doing serial data transmission. Most computers come with built-in modems, which negates the necessity for external serial devices. COM-connected mice are no longer often utilized as data input devices. Serial interfaces are used with null-modem cables to connect two computers. However, this technique is no longer commonly utilized.
How to read data from COM PORT in Python
Python is a practical language because of its ease of use, functionality, and lack of platform dependencies. This post will discuss using Python with serial ports so that you can use it to communicate with microcontrollers and other devices that support serial ports.
The simplicity with libraries that are installed with the PIP tool is one of Python's many appealing features. PIP should be entered when a terminal or command prompt is opened. Your PIP would not install if you experienced an unknown error. Ensure the Python installation process selects "Add to environmental variables "sure " Add to environmental variables" is selected throughout the Python installation process. Run the command below to install PySerial after confirming that PIP is operational.
pip install PySerial
pyserial: When utilizing PySerial, a few parameters need to be specified (in a similar approach to setting up UART peripherals on microcontrollers), and these include
- Baud rate: How quickly your COM port functions. Typically, Arduino projects run at 115200.
- Port: The port's name used(find this in the device manager).
- Parity bits: These are not typically used. However, they are used for error correction.
- Stop bits: In all cases, unless there are timing concerns, only one stop bit is utilized.
- Time out: In all cases, unless there are timing concerns, only one stop bit is utilized.
The serial module is imported in addition to setting the parameters depicted above. The excerpt of code that follows demonstrates how to import the serial module and set the UART port to utilize COM3 at 115200 baud with no parity, one stop bit, and a two-second timeout.
Using device manager, you may quickly identify the COM port where your USB-to-serial device is installed. Type "Device Manager" into the start menu to launch it. Locate and enlarge the "ports" area when device management has loaded. Don't use the default COM1 port on most Windows PCs, which is used for internal communication. Your microcontroller will use the second COM port if only one COM device is only one COM device connected.
Code for com port(serial)
ser = serial.Serial('/dev/ttyUSB1',115200, timeout=10)
print ser. name
data = 
This is how Python is designed to output the data.
I want the data to be added to a list that looks like this:
[abcd::abcd:0:0:0, 2387, 14, -9, 244, -44, 108]