PDA

View Full Version : [serialport] QSerialPortInfo::availablePorts result



amreo
11th June 2016, 11:25
I use Qt5 on ubuntu 14.04

Why when I use QSerialPortInfo::availablePorts without a arduino plugged it return the all ports from /dev/ttyS0 to /dev/ttyS31 and when I use QSerialPortInfo::availablePorts with a arduino plugged it return ONLY /dev/ttyACM0?

anda_skoa
11th June 2016, 13:10
Are the other devices still visible in /dev in the second situation?

Cheers,
_

amreo
12th June 2016, 17:34
yes, there are

anda_skoa
12th June 2016, 18:58
If we look at the relevant code (https://code.woboq.org/qt5/qtserialport/src/serialport/qserialportinfo_unix.cpp.html#_ZN15QSerialPortInfo 14availablePortsEv) we see that it can try three different methods of finding serial devices, falling back one by one if the current method fails.

First it tries to get the information from udev, then from sysfs and only then falling back to device file nodes.

So maybe what happens is that if you list ports without the Arduino attached, it falls back more then when it is attached.

Cheers,
_