diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2015-03-14 00:48:53 +0400 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2015-03-14 17:57:53 +0000 |
commit | 687dfa9312c1ef4894c32a1966b8ac968110b71e (patch) | |
tree | 1ded5919d84411359d7cf5c9c1627b86a996a381 | |
parent | 1739548c5a29e65d567857c327d2dbb79c216ca6 (diff) | |
download | qtserialport-687dfa9312c1ef4894c32a1966b8ac968110b71e.tar.gz |
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.
Change-Id: Id7dfb2476c4a52a4c320c64588341fe6d0a5fa7d
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r-- | src/serialport/qserialportinfo_mac.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp index 2a3c260..6c175f6 100644 --- a/src/serialport/qserialportinfo_mac.cpp +++ b/src/serialport/qserialportinfo_mac.cpp @@ -89,11 +89,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)); @@ -163,11 +158,11 @@ QList<QSerialPortInfo> 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); |