Can bus using Peak Can
-
Hello, I need to use Pcan basic for comunicate on can bus.
I download the pcan-basic.zip from peak site, but I don't know how use it in QT.I need to include pcan dll in the project (which files dll, lib, h should I use??)
How include these files il a QT project ??I am using windows 10 and Qt 5.11.1 (MSVC 2015, 32 bit)
Thankyou
-
There is no difference using an external library in a Qt project or a plain C++ project. So I don't see a Qt problem here. Afaik the library brings some example on how to access it.
-
Hi @Giampietro,
have you already seen Qt CAN bus?
The Peak plugin is described here. In short - you need the device drivers and the DLL to run your program.
Regards.
-
Hello all,
I've already saw Qt CAN Bus
And I create a widget project fon comunication on can bus.
I imported the sample in the link pages :In the .pro file I used: QT += core gui widgets serialbus
in the form cpp file I used :
#include <QCanBus>and the code is :
if (QCanBus::instance()->plugins().contains(QStringLiteral("peakcan"))) {
// plugin available
qDebug() << "plugin "peakcan" available ";
}QString errorString; QCanBusDevice *device = QCanBus::instance()->createDevice( QStringLiteral("peakcan"), QStringLiteral("usb0"), &errorString); if (!device) { // Error handling goes here qDebug() << errorString; } else { device->connectDevice(); }
as illustrated into web page.
When I run the project I find into ouput this :plugin "peakcan" available
qt.canbus.plugins.peakcan: Cannot load library pcanbasic: Impossibile trovare il modulo specificato.
"Cannot load library pcanbasic: Impossibile trovare il modulo specificato."I find the pcanbasic.dll in peak website (download pcan-basic.zip) but I don't understand which files .h include in project.
there are header pcanbasic.h files for C#·, C++_Builder, C++_CLR, C++_MFC. which should I use??So, I understand that pcan basic is missing from the project: How import it with the relative .h ?
I used also sample find here : CAN Bus example
But I have the same answer in output : Cannot load library pcanbasic.How use pcanbasic.dll??
Thankyou for help
-
Hi @Giampietro,
I'd suggest you to try with the CAN bus example first.
- Have you installed the Peak device drivers? I.e. do you have the hardware successfully installed in device manager?
- QtSerialBus loads the
pcanbasic.dll
at runtime. So either copy it to the same folder your executable resides, or make sure it is in a directory which is contained in thePATH
environment variable.
That should be all you need, no header files, no lib files etc.
Regards
-
Hello aha_1980,
I find the solution :the problem was the wrong drivers:
I used 4.1.4.247 version driver. With this, the problem is present.
Now I use a 4.0.18.96 driver version (an older version), and the problem is solved.
My test application and also CAN bus example works fine.Thnkyou all for help!.
-
Hi @Giampietro
Glad you figured it out. So please mark this topic as SOLVED now. Thanks!
-