I'm new to python and I need a list of available serial ports to choose one of them in a program. According to This, the serial.tools.list_ports
module can do that for me by executing serial.tools.list_ports.comports()
method. Accordingly,I executed the following code in python interpreter:
import serial.tools.list_ports
a=serial.tools.list_ports.comports()
print(a)
the result is:
[<serial.tools.list_ports_linux.SysFS object at 0x7f2503d27be0>]
while when I use the following command in ubuntu
terminal
python3 -m serial.tools.list_ports
it returns what I want:
/dev/ttyUSB0
1 ports found
where is the problem?
print(a[0])
output? – Ellname
,device
and ... .In pyserial docs it said the output is aListPortInfo
object. but here isSysFs
and it has no__bases__
attribute. – Humbert