Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use PCAN drivers or OpenCAN PCAN plugin (SOLVED?)
Forum Updated to NodeBB v4.3 + New Features

How to use PCAN drivers or OpenCAN PCAN plugin (SOLVED?)

Scheduled Pinned Locked Moved General and Desktop
14 Posts 2 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jako87
    wrote on last edited by
    #5

    Is maybe a problem of .dll location???

    1 Reply Last reply
    0
    • jensen82J Offline
      jensen82J Offline
      jensen82
      wrote on last edited by
      #6

      The path "$$PWD/PCAN-Basic API/Include" contains spaces...this could be the problem. Wrap it with "

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jako87
        wrote on last edited by
        #7

        Thanks for your help! Moving the include directory to the project directory, including in the .h file #include "windows.h" (DWORD definition) and next clearing the line in bold:
        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/x64/VC_LIB/ -lPCANBasic
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/x64/VC_LIB/ -lPCANBasicd

        INCLUDEPATH += $$PWD/Include
        DEPENDPATH += $$PWD/Include
        I don't know what this line mean. But if you don't erase this line the compiler says that -lPCANBasicd can't be found.
        So the final .pro is:
        QT += core gui

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        TARGET = pruebacan
        TEMPLATE = app

        SOURCES += main.cpp
        mainwindow.cpp

        HEADERS += mainwindow.h

        FORMS += mainwindow.ui

        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/x64/VC_LIB/ -lPCANBasic
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/x64/VC_LIB/ -lPCANBasicd

        INCLUDEPATH += $$PWD/Include
        DEPENDPATH += $$PWD/Include

        If anyone have an answer or question, please quote!

        1 Reply Last reply
        0
        • jensen82J Offline
          jensen82J Offline
          jensen82
          wrote on last edited by
          #8

          At first...what do you want to use? OpenCAN or just PCANBasic-API. OpenCAN needs the PCAN-Light-API and the PCAN_USB.dll while PCANBasic-API needs the PCANBasic.dll.

          I just use the PCANBASIC.dll with the include-files and no .lib-file. I'm calling the dll-functions directly. See the MFC-Sample in the PCANBASIC-Api. The sample uses the dll und and the lib only so you don't have to link the lib-file. Pretty simple.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jako87
            wrote on last edited by
            #9

            But when you add the libraries you must add the .lib, no?? How Can I use the .dll?? Sorry, but I'm a noob with this, you can take me an example of this use in Qt??
            I thought than the .dll is called by the .lib, but I see I mistaked. Must I include the .dll in the include path?? or in the .exe path??
            At the moment the compiler don't give me any error, but if you say me that is better use .dll .Maybe it sounds easy for you!! But I'm only a noob!
            Thanks!!!

            1 Reply Last reply
            0
            • jensen82J Offline
              jensen82J Offline
              jensen82
              wrote on last edited by
              #10

              Don't use the !!! so often. Take a look in at the PCAN-API. The example for Visual C++ (MFC) is the right for you. Just use the PCANBasicClass. In the class you'll find the funtion pointers to the dll. The function pointers are pointing to the corresponding function in the dll. That's all. Just remove the MFC-Calls and replace with Qt.

              Here are the function pointers for the dll:

              @// Function pointers
              //
              typedef TPCANStatus (__stdcall *fpInitialize)(TPCANHandle, TPCANBaudrate, TPCANType, DWORD, WORD);
              typedef TPCANStatus (__stdcall fpOneParam)(TPCANHandle);
              typedef TPCANStatus (__stdcall fpRead)(TPCANHandle, TPCANMsg, TPCANTimestamp
              );
              typedef TPCANStatus (__stdcall fpWrite)(TPCANHandle, TPCANMsg);
              typedef TPCANStatus (__stdcall *fpFilterMessages)(TPCANHandle, DWORD, DWORD, TPCANMode);
              typedef TPCANStatus (__stdcall fpGetSetValue)(TPCANHandle, TPCANParameter, void, DWORD);
              typedef TPCANStatus (__stdcall *fpGetErrorText)(TPCANStatus, WORD, LPSTR);

              // Re-define of name for better code-read
              //
              #define fpUninitialize fpOneParam
              #define fpReset fpOneParam
              #define fpGetStatus fpOneParam
              #define fpGetValue fpGetSetValue
              #define fpSetValue fpGetSetValue

              // PCANbasic dynamic-load class@

              1 Reply Last reply
              0
              • jensen82J Offline
                jensen82J Offline
                jensen82
                wrote on last edited by
                #11

                Solved?

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  Jako87
                  wrote on last edited by
                  #12

                  Thanks Jensen,
                  This afternoon I'll try to use it in this way. You're a master.
                  Keep in touch

                  1 Reply Last reply
                  0
                  • jensen82J Offline
                    jensen82J Offline
                    jensen82
                    wrote on last edited by
                    #13

                    Success?

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      Jako87
                      wrote on last edited by
                      #14

                      Sorry Jensen,
                      My PC's RAMs Crashes Sunday at night, and today I've just bought new ones. As soon as I finish to colocate it I'll tray. Thanks for all. I hope it works. I look forward to try it.
                      Thanks

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved