Important: Please read the Qt Code of Conduct -

Experience with serial interface

  • Hi everyone!
    At the moment I am working with a project-intensive uses a serial interface. The data flow is three request-response pairs per second.
    I tried to use the "qextserialport":
    and "QtSerialPort ":
    for Qt4. As it turned out QtSerialPort easier and more convenient to use, but there is one problem.Sometimes, after receiving some data, the software freezes, and not only software but also the entire operating system. Only hard reset helps.Has anyone encountered this problem?
    If not, can some body show me a right way how to work with a serial interface in Qt, for intensive data transferring.
    Example from QtSerialPort "terminal" also freezes.

  • Thanks for sharing your experience when using the alternative implementations of serial interfaces.
    However, it would be good to add also some additional information on OS, compilers and RS settings.

  • Version of QtSDK: 1.2
    OS: Windows7
    Compiler: MinGW from QtSDK
    RS: 9600bps, 8bit, 1 stop, no parity

  • Right now i downloaded last version of qextserialport. I'll try it soon, and will write here about results.

  • Qt Champions 2020

    2 qxoz,

    Give a detailed description of the test with a QtSerialPort, but rather himself a test project (source code).

    Try do read/write to port without displaying the results to the GUI.

    For example, instead of:


    QByteArray data = port->readAll();
    data = data;

    Maybe it's GUI does not have time to handle request/response,
    the idea understand?

  • 2 kuzulis
    Yes i try that. Without GUI result is same.
    Open port code:
    @void RegisterForm::openSerialPort()
    SettingsDialog::Settings p;
    p.rate = 9600;
    p.parity = SerialPort::NoParity;
    p.flowControl = SerialPort::NoFlowControl;
    p.dataBits = SerialPort::Data8;
    p.stopBits = SerialPort::OneStop; = "COM4";

    if (serial->open(QIODevice::ReadWrite)) {
        if (serial->setRate(p.rate)
                && serial->setDataBits(p.dataBits)
                && serial->setParity(p.parity)
                && serial->setStopBits(p.stopBits)
                && serial->setFlowControl(p.flowControl)) {
        } else {
            QMessageBox::critical(this, tr("Error"),
                                  tr("Can't configure the serial port: %1,\n"
                                     "error code: %2")
    } else {
        QMessageBox::critical(this, tr("Error"),
                              tr("Can't opened the serial port: %1,\n"
                                 "error code: %2")

    Signal connection:
    @connect(serial, SIGNAL(readyRead()), this, SLOT(readData()));@

    data read action:
    @void RegisterForm::readData()
    //some action...

  • Qt Champions 2020

    Ok. Try now the new QtSerialPort snapshot.
    There is something that has been fixed in terms of CPU usage and operations of I / O.

  • Hi kuzulis!
    I try the last snapshot of QtSerialPort, and for now not detect any freezing.

Log in to reply