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. QSerialport receive delay
Forum Updated to NodeBB v4.3 + New Features

QSerialport receive delay

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 327 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.
  • IPlayGenji6I Offline
    IPlayGenji6I Offline
    IPlayGenji6
    wrote on last edited by
    #1

    I found an issue with the serial port assistant written in Qt. When receiving high-speed data, the data cannot be read in real-time and it always reads multiple data packets at once within a short period of time. This issue exists not only in my own Qt program, but also in other serial port programs written in Qt that I downloaded from Github.

    For example, I am receiving data sent every 10ms, with each data packet containing 60 bytes of data. In my own program, Serial Studio, and other serial port assistants written in Qt, I receive 66 data packets once every 660ms.

    Here is the code:

    connect(serialPort, &QSerialPort::readyRead, this, &SerialPort::readserialPort);
    
    void SerialPort::readIMUPort()
    {
        QByteArray readData = imuPort->readAll();
        buffer.append(readData);
        qDebug()<<readData .size() / PACKET_LENGTH;    //len = 60 bytes
    }
    
    Kent-DorfmanK C 2 Replies Last reply
    0
    • IPlayGenji6I IPlayGenji6

      I found an issue with the serial port assistant written in Qt. When receiving high-speed data, the data cannot be read in real-time and it always reads multiple data packets at once within a short period of time. This issue exists not only in my own Qt program, but also in other serial port programs written in Qt that I downloaded from Github.

      For example, I am receiving data sent every 10ms, with each data packet containing 60 bytes of data. In my own program, Serial Studio, and other serial port assistants written in Qt, I receive 66 data packets once every 660ms.

      Here is the code:

      connect(serialPort, &QSerialPort::readyRead, this, &SerialPort::readserialPort);
      
      void SerialPort::readIMUPort()
      {
          QByteArray readData = imuPort->readAll();
          buffer.append(readData);
          qDebug()<<readData .size() / PACKET_LENGTH;    //len = 60 bytes
      }
      
      Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      @IPlayGenji6

      If you require ms precise serial data transmission then you need to use a hard RTOS or bare-metal programming on microcontroller.

      Just because "a lot" of folks do it, doesn't make it correct. The pros know better.

      I light my way forward with the fires of all the bridges I've burned behind me.

      1 Reply Last reply
      2
      • IPlayGenji6I IPlayGenji6

        I found an issue with the serial port assistant written in Qt. When receiving high-speed data, the data cannot be read in real-time and it always reads multiple data packets at once within a short period of time. This issue exists not only in my own Qt program, but also in other serial port programs written in Qt that I downloaded from Github.

        For example, I am receiving data sent every 10ms, with each data packet containing 60 bytes of data. In my own program, Serial Studio, and other serial port assistants written in Qt, I receive 66 data packets once every 660ms.

        Here is the code:

        connect(serialPort, &QSerialPort::readyRead, this, &SerialPort::readserialPort);
        
        void SerialPort::readIMUPort()
        {
            QByteArray readData = imuPort->readAll();
            buffer.append(readData);
            qDebug()<<readData .size() / PACKET_LENGTH;    //len = 60 bytes
        }
        
        C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        @IPlayGenji6 The connect() call and the slot code you posted do not seem to be related.

        As for the time between slot invocations, this will depend very much on what else is happening in your program and on your system. Qt cannot respond to data received if your operating system serial driver does not announce it. Qt cannot dispatch a signal to your slot if it is busy doing something else e.g., updating a display overly often or processing something long running in another slot.

        1 Reply Last reply
        2
        • IPlayGenji6I IPlayGenji6 has marked this topic as solved on

        • Login

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