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. Using Socketcan Plugin in Qt
QtWS25 Last Chance

Using Socketcan Plugin in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 2.0k 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.
  • S Offline
    S Offline
    safiye
    wrote on last edited by
    #1

    Hi, I'm doing a work on can bus in qt creator. In this work, I need to use the socketcan plugin in qt. However, when I make a test as follows, I get an error "No such plugin: socketcan". I can see can0 when I write "ifconfig" on the Raspberry Pi terminal screen. But I can't use it in qt. How do you think I can fix this error and I can use socketcan in qt?

    Qt code:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QtSerialBus>
    #include <QCanBusDevice>
    #include <QCanBus>
    #include <QString>
    #include <QDebug>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    }

    MainWindow::~MainWindow()
    {
    delete ui;

    }

    void MainWindow::on_pushButton_clicked()
    {
    QString errorString;
    QCanBusDevice *device = QCanBus::instance()->createDevice(
    QStringLiteral("socketcan"), QStringLiteral("can0"), &errorString);
    if (!device)
    qDebug() << errorString;
    else
    device->connectDevice();
    }

    The Error:

    8999211f-e1e5-45b0-ac09-bca948c7db55-image.png

    aha_1980A 1 Reply Last reply
    0
    • S safiye

      Hi, I'm doing a work on can bus in qt creator. In this work, I need to use the socketcan plugin in qt. However, when I make a test as follows, I get an error "No such plugin: socketcan". I can see can0 when I write "ifconfig" on the Raspberry Pi terminal screen. But I can't use it in qt. How do you think I can fix this error and I can use socketcan in qt?

      Qt code:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <QtSerialBus>
      #include <QCanBusDevice>
      #include <QCanBus>
      #include <QString>
      #include <QDebug>

      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);

      }

      MainWindow::~MainWindow()
      {
      delete ui;

      }

      void MainWindow::on_pushButton_clicked()
      {
      QString errorString;
      QCanBusDevice *device = QCanBus::instance()->createDevice(
      QStringLiteral("socketcan"), QStringLiteral("can0"), &errorString);
      if (!device)
      qDebug() << errorString;
      else
      device->connectDevice();
      }

      The Error:

      8999211f-e1e5-45b0-ac09-bca948c7db55-image.png

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

      Hi @safiye,

      you need the plugin libqtsocketcanbus.so on your target.

      How did you install or deploy Qt there?

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        safiye
        wrote on last edited by
        #3

        Thank you @aha_1980 ,

        I have not installed plugin libqtsocketcanbus.so. I installed Qt on Raspberry Pi with "sudo apt-get install qtcreator". I did not do anything different for Socketcan. How can I install the plugin libqtsocketcanbus.so ?

        jsulmJ 1 Reply Last reply
        0
        • S safiye

          Thank you @aha_1980 ,

          I have not installed plugin libqtsocketcanbus.so. I installed Qt on Raspberry Pi with "sudo apt-get install qtcreator". I did not do anything different for Socketcan. How can I install the plugin libqtsocketcanbus.so ?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @safiye said in Using Socketcan Plugin in Qt:

          sudo apt-get install qtcreator

          This installs QtCreator and only some basic Qt stuff. If you want to install Qt search for Qt packages.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • S Offline
            S Offline
            safiye
            wrote on last edited by safiye
            #5

            Hi @jsulm,

            To install Qt, I just did the following in order:

            sudo apt-get update
            sudo apt-get upgrade
            sudo apt-get install qt5-default
            sudo apt-get install qtcreator

            1 Reply Last reply
            0
            • S Offline
              S Offline
              safiye
              wrote on last edited by
              #6

              @aha_1980,

              I installed sudo apt-get install libqt5serialbus5-dev and sudo apt-get install libqt5serialbus5 on Raspberry Pi. However, it gives the same error.

              jsulmJ 1 Reply Last reply
              0
              • S safiye

                @aha_1980,

                I installed sudo apt-get install libqt5serialbus5-dev and sudo apt-get install libqt5serialbus5 on Raspberry Pi. However, it gives the same error.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @safiye Do you build on RaspberryPi or do you do cross compiling?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @safiye Do you build on RaspberryPi or do you do cross compiling?

                  S Offline
                  S Offline
                  safiye
                  wrote on last edited by
                  #8

                  @jsulm said in Using Socketcan Plugin in Qt:

                  @safiye Do you build on RaspberryPi or do you do cross compiling?

                  I'm building on a Raspberry Pi.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    safiye
                    wrote on last edited by safiye
                    #9

                    @jsulm,
                    I proceeded by following all the steps here in order to use the socketcan plugin.

                    jsulmJ 1 Reply Last reply
                    0
                    • S safiye

                      @jsulm,
                      I proceeded by following all the steps here in order to use the socketcan plugin.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @safiye That will not work as long as you do not have libqtsocketcanbus.so plug-in. I don't know which package you have to install to get it. I'm not even sure the Linux distribution you're running on your device provides that at all (my Ubuntu 18.04 seems not to provide it). You could try to build it from source though.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      S 1 Reply Last reply
                      2
                      • jsulmJ jsulm

                        @safiye That will not work as long as you do not have libqtsocketcanbus.so plug-in. I don't know which package you have to install to get it. I'm not even sure the Linux distribution you're running on your device provides that at all (my Ubuntu 18.04 seems not to provide it). You could try to build it from source though.

                        S Offline
                        S Offline
                        safiye
                        wrote on last edited by
                        #11

                        Thank you @jsulm .

                        1 Reply Last reply
                        0
                        • Y Offline
                          Y Offline
                          Yenii
                          wrote on last edited by
                          #12

                          Hello, it is an old topic but someone can use it there, I had the same problem and nothing worked, but I solved it by adding the serialbus plugins because they will not be added they are libqt5serialbus5, it has to be installed:

                          sudo apt-get install libqt5serialbus5-plugins

                          Regards.

                          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