Using PeakCAN Backend



  • Hello there,
    I have noticed that in QT 5.6 support for PCAN has been added. So I headed to http://doc.qt.io/qt-5/qtserialbus-peakcan-overview.html and tried to make an example program. I have noticed that there is a mistake in the instructions in line:

    QCanBusDevice *device = QCanBus::createDevice("peakcan", QStringLiteral("usbbus1"));
    

    One forgot to call singleton through instance():

    QCanBusDevice *device = QCanBus::instance()->createDevice("peakcan", QStringLiteral("usbbus1"));
    

    Right after I noticed that it says that only USB PCAN interfaces are supported and I have a mini-pcie PCAN adapter. Hoped for a miracle I typed in "pcibus1" but was not able to connect. Could you please tell me either there are plans for adding pci backend? Also, is the api fully functional for now if I had the USB PCAN adapter? I would really apreciate all help regarding this matter.



  • As far I know, this were added for next 5.6.1 reelase: https://codereview.qt-project.org/#/c/155604/



  • Thank you for info. Any idea when is release going to go out?



  • I don't know when... but you can download the qtserialbus module and rebuild it and install via QtCreator.. Just open a project file, rebuild and then do: 'make install'.



  • @kuzulis So All I have to do it clone the qtserialbus repo and build the qt project that is there? Dont I need to put the compiled output inside the qt dir? Is there any instructions for doing this? I would appreciate help.
    Also I am not sure I have make under windows.



  • 1. git clone git://code.qt.io/qt/qtserialbus.git
    2. cd qtserialbus
    3. git checkout 5.6
    4. cd ..
    5. mkdir qtserialbus-build
    6. cd qtserialbus-build
    7. qmake ../qtserialbus/qtserialbus.pro
    8. make
    9. make install
    

    If you want to use QtCreator (that is preffered, because it sets desired Qt automatically from your Kit), then:

    1. instead of p. 4...8 just open the qtserialbus/qtserialbus.pro file with the desired Kit
    2. instead of p.9 just write to the empty project's make step field: install (to Projects -> Build Settings -> Build Steps -> Make -> Make Arguments)
    3. try to rebuild the project... it will compile and install a module to the desired Qt-instance automatically.


  • @kuzulis Thank you for the extended explanation, I will try this first thing in the morning and let you know.



  • @kuzulis Hi,
    When I am trying to build with Qt Creator, I get following error:

    :-1: error: Failed to run: perl -w B:\Qt\Qt5.6.0\5.6\mingw49_32\bin\syncqt.pl -module QtSerialBus -version 5.6.1 -outdir K:/build-qtserialbus-Desktop_Qt_5_6_0_MinGW_32bit-Debug K:/qtserialbus
    

    When I try to do it manually, I get another one:

    Microsoft Windows [Wersja 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. Wszelkie prawa zastrzeżone.
    
    K:\>git clone git://code.qt.io/qt/qtserialbus.git
    Cloning into 'qtserialbus'...
    remote: Counting objects: 6106, done.
    remote: Compressing objects: 100% (2892/2892), done.
    remote: Total 6106 (delta 3962), reused 4880 (delta 3186)
    Receiving objects: 100% (6106/6106), 1.18 MiB | 684.00 KiB/s, done.
    Resolving deltas: 100% (3962/3962), done.
    Checking connectivity... done.
    
    K:\>cd qtserialbus
    
    K:\qtserialbus>git checkout 5.6
    Branch 5.6 set up to track remote branch 5.6 from origin.
    Switched to a new branch '5.6'
    
    K:\qtserialbus>cd ..
    
    K:\>mkdir qtserialbus-build
    
    K:\>cd qtserialbus
    
    K:\qtserialbus>cd ..
    
    K:\>cd qtserialbus-build
    
    K:\qtserialbus-build>qmake ../qtserialbus/qtserialbus.pro
    Info: creating cache file K:\qtserialbus-build\.qmake.cache
    Checking for language... no
    Checking for socketcan... no
    Checking for socketcan_fd... no
    Project WARNING: Cannot compile the module with your compiler, missing C++11 language features.
    
    K:\qtserialbus-build>
    

    And I used it already to compile c++11 code. Do yoy know what could be the case?



  • Okay I simply installed perl and made the install through qt creator. The problem is that when I try to run this line:

    QCanBusDevice *device = QCanBus::instance()->createDevice("peakcan", QStringLiteral("pcibus1"));
    

    I get a message in the console:

    Failed to load the library: pcanbasic
    The PCAN runtime library is not found
    

    Do I need to place the libs/dll's in any special places or does the qtserialbus should have it already?

    EDIT: For some reason the qt application didnt want to pick up the DLL from System32. I placed the PCANBasic api dll next to the executable and it work now. Ill figure this out later. Thank you very much for your time.



  • Do I need to place the libs/dll's in any special places or does the qtserialbus should have it already?

    It is enough to add this library in same directory with the application executable... it is wrong to copy it to system32...



  • @Bremenpl have you been able to get PCAN working with QT example? I loaded the dll in the same folder as the executable as you did and when I am debugging I get a connection error and it shows to be "The transmit buffer in CAN controller is full"



  • @P3DR0 said:

    @Bremenpl have you been able to get PCAN working with QT example? I loaded the dll in the same folder as the executable as you did and when I am debugging I get a connection error and it shows to be "The transmit buffer in CAN controller is full"

    same issue


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.