diff options
Diffstat (limited to 'src/serialport/qserialportinfo_mac.cpp')
-rw-r--r-- | src/serialport/qserialportinfo_mac.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp index c69a4a30..2c2564e9 100644 --- a/src/serialport/qserialportinfo_mac.cpp +++ b/src/serialport/qserialportinfo_mac.cpp @@ -63,7 +63,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts() { QList<QSerialPortInfo> serialPortInfoList; - static const int propertyCount = 6; + static const int propertyCount = 7; ::CFMutableDictionaryRef matching = ::IOServiceMatching(kIOSerialBSDServiceValue); @@ -90,6 +90,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts() ::CFTypeRef portName = 0; ::CFTypeRef description = 0; ::CFTypeRef manufacturer = 0; + ::CFTypeRef serialNumber = 0; ::CFTypeRef vendorIdentifier = 0; ::CFTypeRef productIdentifier = 0; @@ -159,6 +160,19 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts() } + if (!serialNumber) { + serialNumber = + ::IORegistryEntrySearchCFProperty(entry, + kIOServicePlane, + CFSTR(kUSBSerialNumberString), + kCFAllocatorDefault, + 0); + if (serialNumber) + ++matchingPropertiesCounter; + + } + + if (!vendorIdentifier) { vendorIdentifier = ::IORegistryEntrySearchCFProperty(entry, @@ -237,6 +251,16 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts() ::CFRelease(manufacturer); } + if (serialNumber) { + if (::CFStringGetCString(CFStringRef(serialNumber), + buffer.data(), + buffer.size(), + kCFStringEncodingUTF8)) { + serialPortInfo.d_ptr->serialNumber = QString::fromUtf8(buffer); + } + ::CFRelease(serialNumber); + } + quint16 value = 0; if (vendorIdentifier) { |