summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2016-02-14 17:46:11 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2016-02-15 14:31:52 +0000
commit26ea44e3b45de4a33515c826f6f5c9aa501f57fd (patch)
treee6857b8f0cc1f02657094dcc747f7062f07e76e8
parentc32a064349ddce1149afd8c524ac43f30cdddc80 (diff)
Enumerate dial-in devices on OS X
OS X divide serial ports into dialin (tty) and callout (cu) devices. QSPI did not return a list of dialin devices, that now has been fixed in this patch. Task-number: QTBUG-50895 Change-Id: I9f25b8f042ce1fdef9fd140896fc1d7093ee91a1 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r--src/serialport/qserialportinfo_osx.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/serialport/qserialportinfo_osx.cpp b/src/serialport/qserialportinfo_osx.cpp
index 4e73025e..5a0cdd8a 100644
--- a/src/serialport/qserialportinfo_osx.cpp
+++ b/src/serialport/qserialportinfo_osx.cpp
@@ -83,10 +83,10 @@ static quint16 searchShortIntProperty(io_registry_entry_t ioRegistryEntry,
return value;
}
-static bool isCompleteInfo(const QSerialPortInfoPrivate &priv)
+static bool isCompleteInfo(const QSerialPortInfoPrivate &priv, const QString &calloutDevice, const QString &dialinDevice)
{
- return !priv.portName.isEmpty()
- && !priv.device.isEmpty()
+ return !calloutDevice.isEmpty()
+ && !dialinDevice.isEmpty()
&& !priv.manufacturer.isEmpty()
&& !priv.description.isEmpty()
&& !priv.serialNumber.isEmpty()
@@ -94,11 +94,16 @@ static bool isCompleteInfo(const QSerialPortInfoPrivate &priv)
&& priv.hasVendorIdentifier;
}
-static QString deviceSystemLocation(io_registry_entry_t ioRegistryEntry)
+static QString calloutDeviceSystemLocation(io_registry_entry_t ioRegistryEntry)
{
return searchStringProperty(ioRegistryEntry, QCFString(kIOCalloutDeviceKey));
}
+static QString dialinDeviceSystemLocation(io_registry_entry_t ioRegistryEntry)
+{
+ return searchStringProperty(ioRegistryEntry, QCFString(kIODialinDeviceKey));
+}
+
static QString deviceDescription(io_registry_entry_t ioRegistryEntry)
{
QString result = searchStringProperty(ioRegistryEntry, QCFString(kIOPropertyProductNameKey));
@@ -162,12 +167,15 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
QSerialPortInfoPrivate priv;
+ QString calloutDevice;
+ QString dialinDevice;
+
forever {
- if (priv.device.isEmpty()) {
- priv.device = deviceSystemLocation(serialPortService);
- if (!priv.device.isEmpty())
- priv.portName = QSerialPortInfoPrivate::portNameFromSystemLocation(priv.device);
- }
+ if (calloutDevice.isEmpty())
+ calloutDevice = calloutDeviceSystemLocation(serialPortService);
+
+ if (dialinDevice.isEmpty())
+ dialinDevice = dialinDeviceSystemLocation(serialPortService);
if (priv.description.isEmpty())
priv.description = deviceDescription(serialPortService);
@@ -190,7 +198,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
priv.hasProductIdentifier);
}
- if (isCompleteInfo(priv)) {
+ if (isCompleteInfo(priv, calloutDevice, dialinDevice)) {
::IOObjectRelease(serialPortService);
break;
}
@@ -200,7 +208,15 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
break;
}
- serialPortInfoList.append(priv);
+ QSerialPortInfoPrivate calloutCandidate = priv;
+ calloutCandidate.device = calloutDevice;
+ calloutCandidate.portName = QSerialPortInfoPrivate::portNameFromSystemLocation(calloutDevice);
+ serialPortInfoList.append(calloutCandidate);
+
+ QSerialPortInfoPrivate dialinCandidate = priv;
+ dialinCandidate.device = dialinDevice;
+ dialinCandidate.portName = QSerialPortInfoPrivate::portNameFromSystemLocation(dialinDevice);
+ serialPortInfoList.append(dialinCandidate);
}
::IOObjectRelease(serialPortIterator);