Python/Serial: Difference between revisions
< Python
(Created page with "== List Windows COM Ports == <pre> # https://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python import serial.tools.list_ports for device in serial.tools.list_ports.comports(): #print(dir(device)) print(device) # COM9 - USB Serial Port (COM9) print(f'description: {device.description}') # USB Serial Port (COM9) print(f'device: {device.device}') # COM9 print(f'hwid: {device.hwid}') # USB VID:PID=0403:6011 SER=FT78U7W3C print(f'interfac...") |
(No difference)
|
Revision as of 02:27, 23 July 2025
List Windows COM Ports
# https://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python
import serial.tools.list_ports
for device in serial.tools.list_ports.comports():
#print(dir(device))
print(device) # COM9 - USB Serial Port (COM9)
print(f'description: {device.description}') # USB Serial Port (COM9)
print(f'device: {device.device}') # COM9
print(f'hwid: {device.hwid}') # USB VID:PID=0403:6011 SER=FT78U7W3C
print(f'interface: {device.interface}') # None
print(f'location: {device.location}') # None
print(f'manufacturer: {device.manufacturer}') # FTDI
print(f'name: {device.name}') # COM9
print(f'pid: {device.pid}') # 24593
print(f'product: {device.product}') # None
print(f'serial_number: {device.serial_number}') # FT78U7W3C
print(f'usb_description: {device.usb_description}') # object
print(f'usb_info: {device.usb_info}') # object
print(f'vid: {device.vid}') # 1027
# 'description', 'device', 'hwid', 'interface', 'location', 'manufacturer',
# 'name', 'pid', 'product', 'serial_number', 'usb_description', 'usb_info', 'vid'
print('----')