Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. bool QCanBusDevice::connectDevice and QCanBus's createDevice always return true?
QtWS25 Last Chance

bool QCanBusDevice::connectDevice and QCanBus's createDevice always return true?

Scheduled Pinned Locked Moved Solved General and Desktop
qcanbusqcanbusdevicecan
7 Posts 3 Posters 2.6k 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
    MrBrightSide8
    wrote on last edited by MrBrightSide8
    #1

    Why are QCanBus's createDevice and QCanBusDevice's connectDevice always returning true even though no CAN device is plugged in?
    Even in the CAN bus example ( ran using QT creator), the bottom of the application will always state "Backend: vectorcan, connected to can0 at 500kBit/s" when there's no connection.

    Please let me know if I'm not understanding their functionalities correctly. Cheers

    p/s: I'm using QT 5.9 MSVC 2013

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

      Hi and welcome to devnet,

      Please add the version of Qt you are using as well as the platform you are running on.

      Your can setup details would also be a good idea.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M MrBrightSide8

        Why are QCanBus's createDevice and QCanBusDevice's connectDevice always returning true even though no CAN device is plugged in?
        Even in the CAN bus example ( ran using QT creator), the bottom of the application will always state "Backend: vectorcan, connected to can0 at 500kBit/s" when there's no connection.

        Please let me know if I'm not understanding their functionalities correctly. Cheers

        p/s: I'm using QT 5.9 MSVC 2013

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by aha_1980
        #3

        @MrBrightSide8

        IIRC, vectorcan has two simulated (virtual) channels. If no other CAN hardware is present, can0 will be the first of them. In Qt 5.9, the ConnectDialog shows you the available devices and should have printed "virtual" for can0 already.

        Qt has to stay free or it will die.

        M 1 Reply Last reply
        3
        • aha_1980A aha_1980

          @MrBrightSide8

          IIRC, vectorcan has two simulated (virtual) channels. If no other CAN hardware is present, can0 will be the first of them. In Qt 5.9, the ConnectDialog shows you the available devices and should have printed "virtual" for can0 already.

          M Offline
          M Offline
          MrBrightSide8
          wrote on last edited by
          #4

          @aha_1980
          So how would we know if the hardware connection is successful or not if it always show it's connected?

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

            @MrBrightSide8 said in bool QCanBusDevice::connectDevice and QCanBus's createDevice always return true?:

            So how would we know if the hardware connection is successful or not if it always show it's connected?

            The connection is successful. You're just connected to a virtual (simulated) channel (provided by the Vector Informatik drivers) that indeed works without hardware.

            Quoting https://doc.qt.io/qt-5/qtserialbus-vectorcan-overview.html :

            The VectorCAN plugin provides 64 channels (defined by XL_CONFIG_MAX_CHANNELS in the Vector API) from can0 to can63. Some of these channels can be virtual, and therefore can be used without actual CAN hardware. To find out the virtual channels, the program "Vector Hardware Config" (vcanconf.exe) can be used, which is included in Vector's driver package.

            So, if you connect your Vector CAN hardware to your computer, does it appear in the vcanconf.exe? Which device number does it get assigned?

            Qt has to stay free or it will die.

            M 1 Reply Last reply
            4
            • aha_1980A aha_1980

              @MrBrightSide8 said in bool QCanBusDevice::connectDevice and QCanBus's createDevice always return true?:

              So how would we know if the hardware connection is successful or not if it always show it's connected?

              The connection is successful. You're just connected to a virtual (simulated) channel (provided by the Vector Informatik drivers) that indeed works without hardware.

              Quoting https://doc.qt.io/qt-5/qtserialbus-vectorcan-overview.html :

              The VectorCAN plugin provides 64 channels (defined by XL_CONFIG_MAX_CHANNELS in the Vector API) from can0 to can63. Some of these channels can be virtual, and therefore can be used without actual CAN hardware. To find out the virtual channels, the program "Vector Hardware Config" (vcanconf.exe) can be used, which is included in Vector's driver package.

              So, if you connect your Vector CAN hardware to your computer, does it appear in the vcanconf.exe? Which device number does it get assigned?

              M Offline
              M Offline
              MrBrightSide8
              wrote on last edited by
              #6

              @aha_1980
              Yes, I can see it in vcanconf.exe in channel 1 and 2 of the CAN device.
              Is there anyway to determine the actual hardware connection in code?

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

                @MrBrightSide8 said in bool QCanBusDevice::connectDevice and QCanBus's createDevice always return true?:

                Yes, I can see it in vcanconf.exe in channel 1 and 2 of the CAN device.

                So you mean, channel 1 and 2 are the real hardware channels, right? Do you see virtual channels there also? (You could also post a screenshot of vcanconf.exe).

                If the channels 1 and 2 are the hardware CAN channels, you should be able to connect to "can0" or "can1". Unfortunately I don't have Vector CAN hardware at hand so I could always test using the virtual channels only.

                Is there anyway to determine the actual hardware connection in code?

                There is currently none, except using availableDevices() first.

                Qt has to stay free or it will die.

                1 Reply Last reply
                1

                • Login

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