summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-05-06 20:58:18 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-05-07 08:41:11 +0000
commit574098ec0d928d8eb02cf997318c0168952297e9 (patch)
tree9ab74f473e199a970d865481f334aba95e9661a8
parent72a80def162e7a3a56997c6080db58a9874a23b5 (diff)
downloadqtserialport-574098ec0d928d8eb02cf997318c0168952297e9.tar.gz
QSerialPortInfo: Fix enumeration of 'Gadget' serial devices on Linux
The 'gadget' serial devices have no parent nodes and were skipped from enumeration. We need to check the names of these devices against the 'ttyGS' prefix and then add matching devices to the enumeration. [ChangeLog] Fixed enumeration of 'Gadget' (/dev/ttyGS*) serial devices on Linux. Change-Id: I88afd80358153795152c1b2c929ca5bfb3adbabb Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/serialport/qserialportinfo_unix.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp
index 0f62a9d..105d10a 100644
--- a/src/serialport/qserialportinfo_unix.cpp
+++ b/src/serialport/qserialportinfo_unix.cpp
@@ -169,6 +169,12 @@ static bool isVirtualNullModemDevice(const QString &portName)
return portName.startsWith(QLatin1String("tnt"));
}
+// provided by the g_serial driver
+static bool isGadgetDevice(const QString &portName)
+{
+ return portName.startsWith(QLatin1String("ttyGS"));
+}
+
static QString ueventProperty(const QDir &targetDir, const QByteArray &pattern)
{
QFile f(QFileInfo(targetDir, QStringLiteral("uevent")).absoluteFilePath());
@@ -265,7 +271,8 @@ QList<QSerialPortInfo> availablePortsBySysfs(bool &ok)
const QString driverName = deviceDriver(targetDir);
if (driverName.isEmpty()) {
if (!isRfcommDevice(priv.portName)
- && !isVirtualNullModemDevice(priv.portName)) {
+ && !isVirtualNullModemDevice(priv.portName)
+ && !isGadgetDevice(priv.portName)) {
continue;
}
}
@@ -436,7 +443,8 @@ QList<QSerialPortInfo> availablePortsByUdev(bool &ok)
priv.productIdentifier = deviceProductIdentifier(dev.data(), priv.hasProductIdentifier);
} else {
if (!isRfcommDevice(priv.portName)
- && !isVirtualNullModemDevice(priv.portName)) {
+ && !isVirtualNullModemDevice(priv.portName)
+ && !isGadgetDevice(priv.portName)) {
continue;
}
}