PCBUSB-Library icon indicating copy to clipboard operation
PCBUSB-Library copied to clipboard

PeakCanUSB is not found in QtCanBus PeakCan Plugin

Open OckyKristanto-TomTom opened this issue 2 years ago • 7 comments

PeakCanUSB is not scanned under QtCanBus PeakCan Plugin

Steps to reproduce:

  1. Ensure same Qt application running fine and able to connect PeakCan via QtCanBusPeakCanPlugin ("peakcan") on Linux (:+1:)
  2. Build same QtAppplication on MacOS (M1 Chip) + install https://github.com/mac-can/PCBUSB-Library/releases/download/v0.11.2/macOS_Library_for_PCANUSB_v0.11.2.tar.gz
  3. Observe that upon start, calling this snippet result on empty devices list (:-1:)
auto devices = QCanBus::instance()->availableDevices("peakcan", &errorString);

OckyKristanto-TomTom avatar Nov 10 '22 11:11 OckyKristanto-TomTom

Dear @OckyKristanto-TomTom,

to help you, we need more information.

  1. Which Peak CAN hardware are you using?
  2. Which Qt version is that?
  3. What does the variable errorString contain when the availableDevices() call fails?
  4. Can you please enable logging inside QtCanBus? E.g. by adding the following lines before creating QCoreApplication:
#include <QLoggingCategory>
...
QLoggingCategory::setFilterRules("qt.canbus* = true");

Then you should see the output in the Terminal or in QtCreator. Please post it here.

andre-hartmann avatar Nov 11 '22 17:11 andre-hartmann

Hi @andre-hartmann , just today I found the solution into it. Indeed in the errorString, it is mentioned that Qt can't find pcanbasic in any library locations.

This command solves the issue: sudo ln -s libPCBUSB.0.11.2.dylib pcanbasic.dylib

Maybe it is worth to be added into install.sh ?

OckyKristanto-TomTom avatar Nov 11 '22 19:11 OckyKristanto-TomTom

This command solves the issue: sudo ln -s libPCBUSB.0.11.2.dylib pcanbasic.dylib

Maybe it is worth to be added into install.sh ?

The name of the library is libPCBUSB. "PCAN" and "PCANBasic" are registered word marks of company PEAK-System Technik GmbH, Darmstadt.

If the symbolic link pcanbasic.dylib is a required for use with the Qt Serial Bus API, I can write a note in the installation instructions. @andre-hartmann Is this a prerequisite for working with the Qt Serial Bus API?

mac-can avatar Nov 11 '22 20:11 mac-can

The name of the library is libPCBUSB.

Which is what I expected:

        #ifdef Q_OS_MACOS
            pcanLibrary->setFileName(QStringLiteral("PCBUSB"));
        #else
            pcanLibrary->setFileName(QStringLiteral("pcanbasic"));
        #endif

is the code in https://code.qt.io/cgit/qt/qtserialbus.git/tree/src/plugins/canbus/peakcan/peakcan_symbols_p.h?h=6.4#n325

So what we originaly demanded was the unversioned name PCBUSB. Maybe that broke with MacOS on ARM CPUs, i.e. Q_OS_MACOS is no longer valid? Will need to check.

andre-hartmann avatar Nov 11 '22 21:11 andre-hartmann

@OckyKristanto-TomTom

Please tell us, which Qt version that is. Also, did you build Qt from source or did you download the binaries? Thanks!

andre-hartmann avatar Nov 12 '22 07:11 andre-hartmann

I used Qt5.12.6. Download the binaries (installer) Do you know in which Qt version does the fix being introduced? Once we know the version, then maybe we can write in the note that for Qt Version < <fixed-version> extra linkage is needed.

OckyKristanto-TomTom avatar Nov 12 '22 12:11 OckyKristanto-TomTom

Well, its getting complicated here.

Official support for PCBUSB 0.8 was added in Qt 5.14.0, and this support continues until now with the Qt 6 series.

Unfortunately, PCBUSB 0.9 changed the binary format of some API calls, and therefore we don't have official support from Qt side yet. I have a Qt patch ready for testing [1], but there is currently no review progress. Any help (especially testing) in that regard is welcome.

[1] https://codereview.qt-project.org/c/qt/qtserialbus/+/381442

andre-hartmann avatar Nov 12 '22 17:11 andre-hartmann