From 574098ec0d928d8eb02cf997318c0168952297e9 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 6 May 2019 20:58:18 +0300 Subject: QSerialPortInfo: Fix enumeration of 'Gadget' serial devices on Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: André Hartmann Reviewed-by: Alex Blasche --- src/serialport/qserialportinfo_unix.cpp | 12 ++++++++++-- 1 file 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 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 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; } } -- cgit v1.2.1