Unsolved Do not succeed in reading and writting frames with peak system
-
@Jules31 said in Do not succeed in reading and writting frames with peak system:
while(1)
{
device->writeFrame(frame);
//Sleep(500);
}Please do not use endless-loops with Qt!
-
You are right. I've done a hundred tests trying to solve this issue.
-
@Jules31 writeFrame() returns a bool - did you check what you get?
Also, there are two methods to get error code/string - did you check them? -
I've done these tests with the following source code:
while(1) { qDebug()<<device->writeFrame(frame); qDebug()<<device->errorString(); Sleep(500); }
writFrame() returns "true".
error() returns "QCanBusDevice::NoError". -
Hi @Jules31,
please try the CAN example first. You can also start it from Qt Creator.
Note that for 64 bit Qt you will need a 64 bit
pcanbasic.dll
.As said before, don't use
sleep
in event driven programs. It will block the event loop and that blocks the correct program execution.Regards
-
Hi,
The example does not compile.
I now use a signal but it still does not word:
connect(device, &QCanBusDevice::framesReceived, this, &can::onFramesReceived); void can::onFramesReceived() { qDebug() << "[Frame received] !"; }
-
@Jules31 Are you sure the other side is responding?
-
Hi @Jules31,
The example does not compile.
Please post the exact compiler error. The example should compile and run just fine.
Also, in your first post you wrote:
Then, I imported PCANBasic.lib from the PCAN_Basic_API into my Qt Project
That is not needed. The
pcanbasic.dll
is loaded dynamically at runtime. -
I disabled the "ResetCanController" option and I now get the error "Cannot load library pcanbasic".
-
@jsulm
Yes, it is responding because I receivre frames with Pcan-View. -
@Jules31 said in Do not succeed in reading and writting frames with peak system:
I disabled the "ResetCanController" option
What is that? Are you using a newer example than the one provided with Qt 5.12?
and I now get the error "Cannot load library pcanbasic".
As said, check that the DLL has the correct bitness.
Regards
-
@aha_1980
That works, I put the correct dll:However, it still does not work in my Qt Project.
-
Another question: Does the PCAN-Basic_API also works with the PCAN-Ethernet Gateway DR from peak system ?
Thanks in advance.
-
Hi @Jules31,
However, it still does not work in my Qt Project.
Then please incorporate the fixes we mentioned above and show your modified code.
Does the PCAN-Basic_API also works with the PCAN-Ethernet Gateway DR from peak system ?
Currently not. Do you have such a device and could provide the needed adoptions to the peakcan plugin?
Regards
-
Hi,
I will incorporate your fixes today.
I've just checked on peak-system website and it seems that the access to the CAN channels of a PCAN-Gateway is enabled via the new PCAN-LAN hardware type from PCAN-Basic library:
https://www.peak-system.com/PCAN-Basic.239.0.html?&L=1
Does anyone has tested to use P-CAN-Gateway with PCAN-Basic library yet ?
Thank you