Solved Serial Port setRts(true) returns zero.
-
Hi everyone!
I am rewriting the old windows application which works with serial port for old research setup, but i have some problem with QSerialPort. After creating a new QSerialPort and performing initial setting i get a false returned value when i'm trying to setRts(true)
QSerialPort *port = new QSerialPort(QString("ttyS0")); port->setBaudRate(QSerialPort::Baud9600); port->setDataBits(QSerialPort::Data8); port->setStopBits(QSerialPort::TwoStop); port->setParity(QSerialPort::NoParity); port->setFlowControl(QSerialPort::HardwareControl); port->setReadBufferSize(256); port->open(QIODevice::ReadWrite) // returns true port->clear(); port->setRts(true) // returns false
I had launched the old program and its works well so problem is not in connected device. When i set QSerialPort::SoftwareControl the port->setRts(true) returns true (that is strange) but after some time device freezes and no data arrive in buffer. That can be a reason why i cant setRts(true) when the hardware control is used? I thought that rts signal is used only with hardware control, am i wrong?
-
When the HW flow control is set, then the RTS changing is prohibited manually. It does automatically by the driver (because it is HARDWARE FLOW CONTROL). The previous implementation of QSP had bugs which allow to change RTS in HW flow control.
-
UPD: You allowed to change RTS only with NoFlowControl or SoftwareFlowControl.
-
wow, didn't know that in hw control it sets automatically, thx @kuzulis!