mac-can / PCBUSB-Library

macOS® User-Space Driver for PCAN-USB Interfaces (Binaries only)
https://mac-can.com
Other
29 stars 0 forks source link

PeakCanUSB is not found in QtCanBus PeakCan Plugin #12

Open OckyKristanto-TomTom opened 1 year ago

OckyKristanto-TomTom commented 1 year ago

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);
andre-hartmann commented 1 year ago

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.

OckyKristanto-TomTom commented 1 year ago

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 ?

mac-can commented 1 year ago

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?

andre-hartmann commented 1 year ago

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 commented 1 year ago

@OckyKristanto-TomTom

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

OckyKristanto-TomTom commented 1 year ago

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.

andre-hartmann commented 1 year ago

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