Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Experience with serial interface
Forum Updated to NodeBB v4.3 + New Features

Experience with serial interface

Scheduled Pinned Locked Moved 3rd Party Software
8 Posts 3 Posters 7.0k 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.
  • Q Offline
    Q Offline
    qxoz
    wrote on 5 May 2012, 12:24 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on 5 May 2012, 12:40 last edited by
      #2

      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.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on 5 May 2012, 13:02 last edited by
        #3

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

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on 5 May 2012, 13:07 last edited by
          #4

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

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kuzulis
            Qt Champions 2020
            wrote on 5 May 2012, 16:43 last edited by
            #5

            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?

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qxoz
              wrote on 5 May 2012, 17:30 last edited by
              #6

              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...
              }@

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kuzulis
                Qt Champions 2020
                wrote on 10 May 2012, 14:17 last edited by
                #7

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

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qxoz
                  wrote on 22 May 2012, 12:15 last edited by
                  #8

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

                  1 Reply Last reply
                  0

                  • Login

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