Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.0
-
9cfcc2f9868759dc679c0cf4532fb1c0883451d0
Description
In the function:
static void DRV_CALLBACK_TYPE ucanEnumCallback(DWORD index, BOOL isUsed, tUcanHardwareInfoEx *hardwareInfo, tUcanHardwareInitInfo *initInfo, void *args) { auto result = static_cast<QStringList *>(args); Q_UNUSED(isUsed); Q_UNUSED(hardwareInfo); Q_UNUSED(initInfo); result->append(QString::fromLatin1("can%1.0").arg(index)); if (USBCAN_CHECK_SUPPORT_TWO_CHANNEL(hardwareInfo)) result->append(QString::fromLatin1("can%1.1").arg(index)); }
The parameter "index" is used as the device number attributed in the string result.
Per the System Manual USB-CANmodule, page 62, the second parameter of UcanInitHardwareEx should be "Device number of the USB-CANmodul." Additionally, per p75, the m_bDeviceNr of the type tUcanHardwareInfoEx (here, this is hardwareInfo->m_bDeviceNr) holds this value. Per page 124, dwIndex_p just hold "an ongoing index which is incremented by the value 1 for each found USB-CANmodul."
In tests, I have experienced numerous cases using both my own code and the Qt Creator can example project in which hardwareInfo->m_bDeviceNr does not match index, and in all such cases, using hardwareInfo->m_bDeviceNr instead of index has proven to allow connection to the CANmodul. Using index results in the error:
Connection error: The module with the corresponding device number is not connected
I propose changing the above section of code to use hardwareInfo->m_bDeviceNr instead of index.
Attachments
For Gerrit Dashboard: QTBUG-63833 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
208817,4 | SystecCAN: Fix device number assignment in availableDevices() | 5.9 | qt/qtserialbus | Status: MERGED | -2 | 0 |