Solved QCanBusDevice: Error "Network is down"
-
Hi all!
At the moment I am trying to use QCanBusDevice and QCanFrame for CAN communication.
I am able to set up the connection and to configure the device.
But if I try to send a message viaQCanBusDevice::writeFrame(const QCanBusFrame &frame)
I get the error
QCanBusDevice::WriteError (2)
which means
"Network is down".
Has anyone an idea what causes this error and how to solve it?
Regards,
MHermann -
Hi @MHermann, and welcome to the forum!
Which CAN plugin do you use? If you, for example, use SocketCAN, you will have to set up the CAN network before: http://doc.qt.io/qt-5/qtserialbus-socketcan-overview.html#socketcan-usage
-
@aha_1980 :
Yes. I am using SocketCAN. Setting up the CAN network is done at system startup by a little script.
OtherwiseQCanBusDevice::connectDevice()
would fail.
Or does a successful connect not indicate, that the CAN network setup is correct? -
@MHermann said in QCanBusDevice: Error "Network is down":
Or does a successful connect not indicate, that the CAN network setup is correct?
I can not tell you exactly at the moment, maybe it succeeds if the can device is present but not up.
You could try sending a test frame with cansend to see if you SocketCAN setup is correct.
Also please tell me: which Qt version are you using?
-
Thanks for your help.
I found the error. Now the CAN communication is working.The code for setting up the CAN network was correct, but the script was not executed at startup. :|
I think I would not have checked the script again without your hint.Btw. I am using Qt5.9.