From 85ec055cfec14370e088314eadb5fb0ad98a98f2 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sat, 14 Mar 2015 00:48:53 +0400 Subject: Fix QSPI::portName() on OSX The commit ab51ad6a5f4e533c31bd8e5b6f16a3bcd09a3ee6 changes a behavior of conversion from a device location to a device name and vice-versa. Now it is expected that the location as "/dev/cu.serial1" will be converted to the "cu.serial1" name and vice-versa. But currently the QSPI on OSX returns the name of device as "serial1" instead of "cu.serial1", that lead to failure of QSP::open() method. The reason is that a device name is queried from the dictionary with the "kIOTTYDeviceKey" key, which always returns a right part of name from a dot. Thus, we need to use QSPI::portNameFromSystemLocation() method instead. (cherry-picked from 3db7c8ac2484c5e5eb10150b87a9c4d81d20b51d) Change-Id: Id7dfb2476c4a52a4c320c64588341fe6d0a5fa7d Reviewed-by: Denis Shienkov --- src/serialport/qserialportinfo_mac.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp index 51864893..a1e9e0ef 100644 --- a/src/serialport/qserialportinfo_mac.cpp +++ b/src/serialport/qserialportinfo_mac.cpp @@ -97,11 +97,6 @@ static bool isCompleteInfo(const QSerialPortInfoPrivate &priv) && priv.hasVendorIdentifier; } -static QString devicePortName(io_registry_entry_t ioRegistryEntry) -{ - return searchStringProperty(ioRegistryEntry, QCFString(kIOTTYDeviceKey)); -} - static QString deviceSystemLocation(io_registry_entry_t ioRegistryEntry) { return searchStringProperty(ioRegistryEntry, QCFString(kIOCalloutDeviceKey)); @@ -171,11 +166,11 @@ QList QSerialPortInfo::availablePorts() QSerialPortInfoPrivate priv; forever { - if (priv.portName.isEmpty()) - priv.portName = devicePortName(serialPortService); - - if (priv.device.isEmpty()) + if (priv.device.isEmpty()) { priv.device = deviceSystemLocation(serialPortService); + if (!priv.device.isEmpty()) + priv.portName = QSerialPortInfoPrivate::portNameFromSystemLocation(priv.device); + } if (priv.description.isEmpty()) priv.description = deviceDescription(serialPortService); -- cgit v1.2.3