Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QCanBusDevice: Error "Network is down"
Qt 6.12 LTS is out! See what's new in the release blog

QCanBusDevice: Error "Network is down"

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MHermann
    wrote on last edited by MHermann
    #1

    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 via

    QCanBusDevice::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

    1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Qt has to stay free or it will die.

      M 1 Reply Last reply
      1
      • aha_1980A aha_1980

        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

        M Offline
        M Offline
        MHermann
        wrote on last edited by
        #3

        @aha_1980 :
        Yes. I am using SocketCAN. Setting up the CAN network is done at system startup by a little script.
        Otherwise

        QCanBusDevice::connectDevice()
        

        would fail.
        Or does a successful connect not indicate, that the CAN network setup is correct?

        1 Reply Last reply
        0
        • aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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?

          Qt has to stay free or it will die.

          M 1 Reply Last reply
          0
          • aha_1980A aha_1980

            @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?

            M Offline
            M Offline
            MHermann
            wrote on last edited by
            #5

            @aha_1980 :

            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.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt
            • Unsolved