diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2013-06-26 19:53:04 +0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-25 13:35:06 +0200 |
commit | 84df6ec29db5981d30d1149a8b4a091ecc7c5dce (patch) | |
tree | ee0031a46a1940dec1a72503c6193bdfcbcac1f2 | |
parent | a879b799635ff086156a213512a93963ce40fa28 (diff) |
Windows: Add PCI vendor and device identifier detectionv5.1.1
The PCI identifiers are different to the USB identifiers, as in:
* USB: VID_, PID_
* PCI: VEN_, DEV_
For more info see MSDN:
* USB: http://msdn.microsoft.com/en-us/library/windows/hardware/ff553356%28v=vs.85%29.aspx
* PCI: http://msdn.microsoft.com/en-us/library/windows/hardware/ff546262%28v=vs.85%29.aspx
Therefore, the method availablePorts() skipped processing of PCI prefixes.
Now, problem was resolved.
Task-number: QTBUG-32018
Change-Id: I098a35a170043b9c58b74cb278e4daff34b1f84e
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r-- | src/serialport/qserialportinfo_win.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp index 7ca1f5ef..b1ab76b8 100644 --- a/src/serialport/qserialportinfo_win.cpp +++ b/src/serialport/qserialportinfo_win.cpp @@ -142,9 +142,12 @@ static QString devicePortName(HDEVINFO deviceInfoSet, PSP_DEVINFO_DATA deviceInf QList<QSerialPortInfo> QSerialPortInfo::availablePorts() { - static const QString vendorIdentifierPrefix(QLatin1String("VID_")); + static const QString usbVendorIdentifierPrefix(QLatin1String("VID_")); + static const QString usbProductIdentifierPrefix(QLatin1String("PID_")); + static const QString pciVendorIdentifierPrefix(QLatin1String("VEN_")); + static const QString pciDeviceIdentifierPrefix(QLatin1String("DEV_")); + static const int vendorIdentifierSize = 4; - static const QString productIdentifierPrefix(QLatin1String("PID_")); static const int productIdentifierSize = 4; QList<QSerialPortInfo> serialPortInfoList; @@ -176,15 +179,27 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts() s = deviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_HARDWAREID).toStringList().first().toUpper(); - int index = s.indexOf(vendorIdentifierPrefix); - if (index != -1) - serialPortInfo.d_ptr->vendorIdentifier = s.mid(index + vendorIdentifierPrefix.size(), vendorIdentifierSize) - .toInt(&serialPortInfo.d_ptr->hasVendorIdentifier, 16); - - index = s.indexOf(productIdentifierPrefix); - if (index != -1) - serialPortInfo.d_ptr->productIdentifier = s.mid(index + productIdentifierPrefix.size(), productIdentifierSize) - .toInt(&serialPortInfo.d_ptr->hasProductIdentifier, 16); + int index = s.indexOf(usbVendorIdentifierPrefix); + if (index != -1) { + serialPortInfo.d_ptr->vendorIdentifier = s.mid(index + usbVendorIdentifierPrefix.size(), vendorIdentifierSize) + .toInt(&serialPortInfo.d_ptr->hasVendorIdentifier, 16); + } else { + index = s.indexOf(pciVendorIdentifierPrefix); + if (index != -1) + serialPortInfo.d_ptr->vendorIdentifier = s.mid(index + pciVendorIdentifierPrefix.size(), vendorIdentifierSize) + .toInt(&serialPortInfo.d_ptr->hasVendorIdentifier, 16); + } + + index = s.indexOf(usbProductIdentifierPrefix); + if (index != -1) { + serialPortInfo.d_ptr->productIdentifier = s.mid(index + usbProductIdentifierPrefix.size(), productIdentifierSize) + .toInt(&serialPortInfo.d_ptr->hasProductIdentifier, 16); + } else { + index = s.indexOf(pciDeviceIdentifierPrefix); + if (index != -1) + serialPortInfo.d_ptr->productIdentifier = s.mid(index + pciDeviceIdentifierPrefix.size(), productIdentifierSize) + .toInt(&serialPortInfo.d_ptr->hasProductIdentifier, 16); + } serialPortInfoList.append(serialPortInfo); } |