Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-70364

Setting parity checking mode on serial port doesn't take effect if done after writing data

    XMLWordPrintable

Details

    • Linux/X11

    Description

      The problem was seen when communicating to RS-485 with 9bit data packets. Here the address and actual data need different parity checking. Therefore, first, the parity is set to QSerialPort::MarkParity, and the address is written. Then the parity is set to QSerialPort::SpaceParity, and the data is written. QtSerialPort::setParity() returns 'true' i.e. success and QSerialPort::error() returns QSerialPort::SerialPortError(NoError), but measuring from the serial port, the parity has not changed.

      There is a workaround: adding delay before setting the parity. The needed delay depends on the system. With 32bit Ubuntu the needed delay is 50 usec while with 64bit Debian it needs 150 usec.

      Following code is used to test this (and can be used in Qt Terminal Example):

      m_serial->setParity(QSerialPort::MarkParity);
      m_serial->write(address);
      m_serial->flush();
      //QThread::currentThread()->usleep(50); // workaround
      m_serial->setParity(QSerialPort::SpaceParity);
      m_serial->write(data);
      m_serial->flush();
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kuzulis Denis Shienkov
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes