I am looking for an easy way to list the entire available COM port on a PC.
I found this method, but it is specific to Windows: List of serial ports (COM) on Windows?
I am using Python 3 with pySerial on a Windows 7 PC.
I found in the pySerial API ( http://pyserial.sourceforge.net/pyserial_api.html ) the serial.tools.list_ports.comports() ) function that lists COM ports (exactly what I want).
import serial.tools.list_ports print(list(serial.tools.list_ports.comports()))
But it does not seem to work. When my COM USB gateway is connected to a PC (I see COM5 in the device manager), this COM port is not included in the list returned by list_ports.comports() . Instead, I only get COM4, ββwhich seems to be connected to the modem (I don't see it in the COM & LPT section of the device manager)!
Do you know why this does not work? Do you have another solution that is not system specific?
python pyserial
doom Aug 23 '12 at 11:25 2012-08-23 11:25
source share