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. QCanBus on Qt5.8
Forum Updated to NodeBB v4.3 + New Features

QCanBus on Qt5.8

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.5k Views 2 Watching
  • 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.
  • D Offline
    D Offline
    duarna
    wrote on last edited by
    #1

    Hi!

    When visiting the main page of Qt5.8, we can read "Fast & easy integration and communication with devices and peripherals using Qt Serial Bus API".

    My problem is quite simple: my CAN connection works well with Qt5.7, but fails with Qt5.8.
    I'm using a PEAK device, and I follow this example. It's a little bit different from the Qt5.7 version. e.g QCanBus::instance()->plugins() returns a QStringList in Qt5.8 while it returned a QByteArray in Qt5.7 but anyway, I modified my code to match with these new prototypes.

    Here is a sample of my code:

     if(QCanBus::instance()->plugins().contains(QStringLiteral("peakcan")))
        {
            foreach (QString bus, listBus) //listBus contains usbbus0, usbbus1, usbbus2,...
            {
                device = QCanBus::instance()->createDevice("peakcan", bus);
    
                if(device!=nullptr)
                {
                    // apply filters
                    device->setConfigurationParameter(QCanBusDevice::BitRateKey, 500000);//500kbits/s
                    device->setConfigurationParameter(QCanBusDevice::ReceiveOwnKey, false); //readonly
                    device->setConfigurationParameter(QCanBusDevice::RawFilterKey, QVariant::fromValue(filterList));
    
                    if(device->connectDevice()) /******returns false******/
                    {
                        //blablabla
                    }
                }
    

    connectDevice() always returns false, and I really don't get why.
    Any help would be appreciated, thank you in advance!

    Arnaud

    1 Reply Last reply
    0
    • D Offline
      D Offline
      duarna
      wrote on last edited by
      #4

      Ok, I finally used the peak lib instead of QCanBus, where it is possible to use the filters and much more options.

      Thank you all!

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

        Hi,

        I haven't used that module yet but did you try to print the value returned by QCanBusDevice::errorString ?

        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
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on last edited by
          #3

          said in QCanBus on Qt5.8:

          connectDevice() always returns false, and I really don't get why.

          Did you read documentation? The PeakCAN still supports only one property as QCanBusDevice::BitRateKey!

          1 Reply Last reply
          0
          • D Offline
            D Offline
            duarna
            wrote on last edited by
            #4

            Ok, I finally used the peak lib instead of QCanBus, where it is possible to use the filters and much more options.

            Thank you all!

            1 Reply Last reply
            0

            • Login

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