Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.9.6
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();