Can Bus does not transmit (writeFrame)
-
I'm using Qt 6.6 + QSerialBus plugin , with a USB Peak PCAN adapter. Qt sees the plugin (outputs "Using PCAN-API version: 4.8.0.030"), and setting the bitrate works.
However, writeFrame doesn't do anything.. I don't see any activity using a scope, nor does the receiving PC's PCAN-View show any data.
If I open PCAN-View (on the Qt computer) after executing the line 'device->connectDevice()' , it says another application [Qt] has configured the device.
The only anomalies I can see is that it says "<optimized out> on one line for some reason. Also whenever I stop the debugger, popups appear saying: "Could not connect to the in-process QML Debugger".
I verified the hardware is good, by using PCAN-View on both computers and I can send messages back and forth.
-
@NoobyLost Check the return values of the QCanBusDevice functions and do proper error handling to find out what's going wrong.
-
@Christian-Ehrlicher The writeFrame/connectDevice functions don't have a return.. and errorString is empty.
-
@NoobyLost
Without knowing anything aboutQCanBusDevice
I can see void QCanBusDevice::errorOccurred(QCanBusDevice::CanBusError) signal? -
@NoobyLost said in Can Bus does not transmit (writeFrame):
@Christian-Ehrlicher The writeFrame/connectDevice functions don't have a return..
The have: https://doc.qt.io/qt-6/qcanbusdevice.html#connectDevice
I also doubt you can directly read afterwards. Use framesReceived signal.
-
@Christian-Ehrlicher Sorry, you're right.. it returns True (success).
Also, just as a check, if I don't plug in the USB PCAN, it returns False.. and the Application Output is
"Cannot initialize hardware: The value of a handle (PCAN-Channel, PCAN-Hardware, PCAN-Net, PCAN-Client)
is invalid" -
@NoobyLost So did you connect the frameReceived() message and do you send to message to yourself?
-
Hi @NoobyLost,
have you already tried the CAN Manager example?
I've used it with a PCAN-USB-Pro FD, one channel connected to PCAN-View and the other to the example and could receive and trasnsmit frames between both channels.
My PCAN-API version is 4.5.4.508, Qt version 6.6.3, MinGW 11.2.0 x64.
-
And I've now tried the Qt 6.7 CAN Manager example with PCAN-Basic 4.8.2.897. Sending and receiving works like a charm.
@NoobyLost Do you have an event loop running?