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":http://code.google.com/p/qextserialport/
    and "QtSerialPort ":http://qt-project.org/wiki/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.


  • Moderators

    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.



  • 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:
    [code]
    textEdit->append(port->readAll);
    [/code]

    do:

    [code]
    QByteArray data = port->readAll();
    data = data;
    [/code]

    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;
    p.name = "COM4";

    serial->setPort(p.name);
    if(serial->isOpen())serial->close();
    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 {
            serial->close();
    
            QMessageBox::critical(this, tr("Error"),
                                  tr("Can't configure the serial port: %1,\n"
                                     "error code: %2")
                                  .arg(p.name).arg(serial->error()));
    
        }
    } else {
        QMessageBox::critical(this, tr("Error"),
                              tr("Can't opened the serial port: %1,\n"
                                 "error code: %2")
                              .arg(p.name).arg(serial->error()));
    
    }
    

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

    data read action:
    @void RegisterForm::readData()
    {
    readBytes.append(serial->readAll());
    //some action...
    }@



  • 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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.