Imx6 apalis & ixora career board & Qt SocketCan reading can frames

Hello

I am trying to make an application with Qt to read CAN BUS frames.

I am able to capture CAN packages with High performance, low power Embedded Computing Systems | Toradex Developer Center these configurations on the terminal.

When I tried it with my application it continuously dumps on the screen only

“(Invalid)”

here is my simple CAN codes on Qt and this is the link that I followed https://doc.qt.io/qt-5.11/qtserialbus-socketcan-overview.html

alt text

Thanks for help, I am stuck on it !

The question is rather Qt specific and maybe better placed in a Qt forum.

Taken from this examples it seems that you should wait until a frame is available before reading it?

while (m_canDevice->framesAvailable()) {
    const QCanBusFrame frame = m_canDevice->readFrame();

Also consider checking the return value of connectDevice() and print ->errorString() if it fails… Implementing proper error handling is good practise and should be the first thing to check if code fails.