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. PeakCAN receives unrecognized packages
Forum Updated to NodeBB v4.3 + New Features

PeakCAN receives unrecognized packages

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 464 Views 1 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.
  • C Offline
    C Offline
    ChristophFroe
    wrote on last edited by ChristophFroe
    #1

    Dear all,

    I tried to use the QtSerialBus with the peakcan plugin and a PCAN USB interface.

    Qt creator 4.9.0, based on Qt 5.12.2 (MSVC2017, 32bit)
    Compiler Mingw32
    Windows 10
    PCAN driver 4.1.4.16279
    PCANBasic.dll 4.3.3.239 (installed with the driver into Windows/System32) or 4.3.4.246 copied into the executable folder

    Using the software of Peak (PCAN-View or the sample shipped with the API) I can clearly read the packages on the CAN-Bus: 250kbit, base frame format, 8byte payload

    Using Qt with the plugin: following the instructions in the manual it connects successfully and I can read the messages with the valid CAN ID, but frame.isValid() returns false, frameType is UnknownFrame, hasExtendedFrameFormat is true, hasFlexibleDataRateFOrmat is true (which is, in fact, everything not correct) while frame.error() is No error and errorString is empty.
    Reading the payload().size() gives me some rather big number, toString() gives a segmentation fault.

    if (QCanBus::instance()->plugins().contains(QStringLiteral("peakcan"))) {
        // plugin available
        QString errorString;
        QCanBusDevice *device = QCanBus::instance()->createDevice(
            QStringLiteral("peakcan"), QStringLiteral("usb0"), &errorString);
        if (!device) {
            // Error handling goes here
            qDebug << errorString;
        } else {
            device->setConfigurationParameter(QCanBusDevice::BitRateKey, 250000);
            if(device->connectDevice()) {
                QCanBusFrame frame;
                if (device->waitForFramesReceived(1000) {
                    frame = device->readFrame();
                    /** operating on frame or showing in debugger */
                }
            }
        }
    }
    

    Made I any mistakes using the plugin or is this any incompatibility with the driver and the plugin as older threads in the forum suggest?

    aha_1980A 1 Reply Last reply
    0
    • C ChristophFroe

      Dear all,

      I tried to use the QtSerialBus with the peakcan plugin and a PCAN USB interface.

      Qt creator 4.9.0, based on Qt 5.12.2 (MSVC2017, 32bit)
      Compiler Mingw32
      Windows 10
      PCAN driver 4.1.4.16279
      PCANBasic.dll 4.3.3.239 (installed with the driver into Windows/System32) or 4.3.4.246 copied into the executable folder

      Using the software of Peak (PCAN-View or the sample shipped with the API) I can clearly read the packages on the CAN-Bus: 250kbit, base frame format, 8byte payload

      Using Qt with the plugin: following the instructions in the manual it connects successfully and I can read the messages with the valid CAN ID, but frame.isValid() returns false, frameType is UnknownFrame, hasExtendedFrameFormat is true, hasFlexibleDataRateFOrmat is true (which is, in fact, everything not correct) while frame.error() is No error and errorString is empty.
      Reading the payload().size() gives me some rather big number, toString() gives a segmentation fault.

      if (QCanBus::instance()->plugins().contains(QStringLiteral("peakcan"))) {
          // plugin available
          QString errorString;
          QCanBusDevice *device = QCanBus::instance()->createDevice(
              QStringLiteral("peakcan"), QStringLiteral("usb0"), &errorString);
          if (!device) {
              // Error handling goes here
              qDebug << errorString;
          } else {
              device->setConfigurationParameter(QCanBusDevice::BitRateKey, 250000);
              if(device->connectDevice()) {
                  QCanBusFrame frame;
                  if (device->waitForFramesReceived(1000) {
                      frame = device->readFrame();
                      /** operating on frame or showing in debugger */
                  }
              }
          }
      }
      

      Made I any mistakes using the plugin or is this any incompatibility with the driver and the plugin as older threads in the forum suggest?

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

      Hi @ChristophFroe,

      you should try the CAN example first. You can also find it in QtCreator in the examples section.

      device->waitForFramesReceived(1000)

      This function is not thought to be called from the GUI thread and might give unexpected results there.

      Use the framesReceived signal instead, as shown in the example I mentioned above.

      Regards

      Qt has to stay free or it will die.

      C 1 Reply Last reply
      2
      • aha_1980A aha_1980

        Hi @ChristophFroe,

        you should try the CAN example first. You can also find it in QtCreator in the examples section.

        device->waitForFramesReceived(1000)

        This function is not thought to be called from the GUI thread and might give unexpected results there.

        Use the framesReceived signal instead, as shown in the example I mentioned above.

        Regards

        C Offline
        C Offline
        ChristophFroe
        wrote on last edited by ChristophFroe
        #3

        Thank you for giving me the hint to the example, this one worked immediately.

        After some investigation I found the culprit in my project (an existing project for a test rig): the compiler flag

        -mno-ms-bitfields
        

        influences the can plugin (what makes sense actually).
        I reconfigured the other communication module to avoid the necessity of the compiler option, and both work fine now.

        Pablo J. RoginaP 1 Reply Last reply
        1
        • C ChristophFroe

          Thank you for giving me the hint to the example, this one worked immediately.

          After some investigation I found the culprit in my project (an existing project for a test rig): the compiler flag

          -mno-ms-bitfields
          

          influences the can plugin (what makes sense actually).
          I reconfigured the other communication module to avoid the necessity of the compiler option, and both work fine now.

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @ChristophFroe said in PeakCAN receives unrecognized packages:

          work fine now

          so please don't forget to mark your post as solved! thanks.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          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