Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-63833

SystecCan appears to improperly use "index" as the device number

    XMLWordPrintable

Details

    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            aha_1980 André Hartmann
            dvntehn00bz Jacob Pennington
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes