PDA

View Full Version : QSerialPort open flips RTS and DTR despite I don't want it



LaminateFloor
20th May 2014, 17:14
Running on Linux, when I do an open with QSerialPort I've noticed that QSerialPort sets RTS (requestToSend) and DTR (dataTerminalReady) to true despite I don't want it. This has the effect that the Arduino board that I'm using is resetted. The Arduino board is using the RTS and DTS signals to reset the board. What I want to do is to open the serial port without the Arduino board being resetted.

On Windows this case works. Here you have to explicitly use setDataTerminalReady(true) and setRequestToSend(true) instead in order to reset the board. It is this behaviour I was rather expected. Why the difference between Linux and Windows?

Is there a way to come around this problem on Linux using the QSerialPort library?

Markus
11th February 2015, 23:08
I am having the same problem (Mac OS X), did you find a solution?

ChrisW67
12th February 2015, 21:21
Does your code turn hardware flow control off?
Do you set RTS and DTR off after you open the port? Are you checking the return value of those calls?

Markus
13th February 2015, 19:31
This is the code:



...
serial->setPortName(ui->port->currentText());
serial->setBaudRate(QSerialPort::Baud115200);
serial->setDataBits(QSerialPort::Data8);
serial->setParity(QSerialPort::NoParity);
serial->setStopBits(QSerialPort::OneStop);
qDebug() << "setFlowControl" << serial->setFlowControl(QSerialPort::NoFlowControl);
if (serial->open(QIODevice::ReadWrite)) {
qDebug() << "setDataTerminalReady" << serial->setDataTerminalReady(false);
...


If I run it then both debug outputs are TRUE.

ChrisW67
13th February 2015, 21:56
And setRequestToSend()? Have you measured the actual DTR and RTS signal lines?

Markus
14th February 2015, 00:26
RTS does not matter, reset is wired to DTR on the Arduinos. I have not measured the levels but I have a counter that resets on a 'reset' so I know it does a reset.

ChrisW67
14th February 2015, 06:26
What version of Qt / QtSerialPort?

Markus
16th February 2015, 17:08
I am using Qt 5.3 on OS X 10.9

ChrisW67
16th February 2015, 21:29
My guess is that DTR is off by default before your program starts and returns to off when your program closes the port: both conditions hold the Arduino in reset. This is hangup-on-close behaviour can be turned off on Linux with "stty -F /dev/usbTTY0 -hupcl" on the relevant port. The same command is likely to work on OSX.

The reset behaviour of Arduino is a perennial problem it seems
http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection

Markus
16th February 2015, 23:49
I had seen the the Arduino playground link but I wanted to avoid modifying the hardware. It looks like this is now the only option. Thanks for confirming!

krizajb
17th April 2016, 20:39
I can confirm the same behavior on Windows 8.1 Qt 5.6. FYI pinoutSignals returns QFlags<QSerialPort::PinoutSignal>(NoSignal).