Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57658

QCanBusDevice::framesToWrite() doesn't work as I would expect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.7.1
    • SerialBus: CAN Bus
    • CM-FX6 (EVK) from Compulab.
      Linux-compulab-imx_4.1.15_1.0.0_ga.
      Qt cross-compiled using Yocto Project.

    Description

      Using QtSerialBus (5.7.0 at first, then I tried 5.7.1 too) and taking the CAN-bus example from Qt I have modified sendMessage() method simulating a heavy-download. I send the same frame i times consecutively (being i >1000 per example). I tried this:

      for(int i=0; i<m_ui->loopBox->currentData().toInt(); i++){
          while(m_canDevice->framesToWrite() > 0){/*do nothing*/}
          m_canDevice->writeFrame(frame);
      }
      

      But I still getting "No buffer space available" errors, resulting on packets loss.
      If I print framesToWrite() it always returns me 0.
      The workaround I do:

      while(!m_canDevice->writeFrame(frame)){}
      

      Which isn't the best way as I'm forcing the error to occur ("No buffer space available") but I send as fast as possible without loosing packets.

      The documentation specifies:

      qint64 QCanBusDevice::framesToWrite() const
      Returns the number of frames waiting to be written.

      So why it doesn't work as I'm expecting?

      My configuration:

      Socketcan backend, 1MB/s bitrate, 4B data frame

      Attachments

        Issue Links

          Activity

            People

              aha_1980 André Hartmann
              anatoli-io Anatoli Veselinov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: