Important: Please read the Qt Code of Conduct -

QtSerialPort -> Terminal Example -> Only reads 8-bytes at a time

  • Hello,

    I am very new to C++ and Qt framework and I have two questions. I have been programming under CentOS using Qt 4 framework.

    1. When using the "Terminal Example": I have noticed that it seems to only be reading in a maximum 8 bytes of data at a time. _Is there a way I can increase this? _ I have checked the "QSerialPort Class": and the only item that seems to stand out is:

    qint64 QSerialPort::readBufferSize() const

    Which seems to be set to the default value of 0, meaning no size limit.

    1. I would like some input from experienced programmers on whether or not longterm its worth to switch to Qt5 from Qt4?


  • Qt Champions 2020


    1. The class reads automatically all available data when triggered Rx event, which are at present in the FIFO buffer of the driver and caches them at itself inside in RingBuffer. Value of 8 bytes not the constant. It depends on the driver of port, the current speed, CPU loading, etc. Simply, between two read() operations in driver FIFO is accumulated in time ~8-10 byte.

    It shan't disturb you.

  • Hi kuzulis,

    Thank you for your reply. The reason I was asking is because I was using this example to receive packets that could vary in the number of bytes. I ended up receiving a maximum of 8 bytes while the packet could be 16 bytes or more. My approach now will be to reconstruct the packets based on the packet framing.

  • Hi kuzulis,

    The issue doesn't occure when using "QextSerialPort": to access the same serial port on the same platform.

    Would you have any feedback on why this difference exists? It seems like a difference in implementation rather than a FIFO limit on the serial port.

Log in to reply