QSerialPort open flips RTS and DTR despite I don't want it
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?
Re: QSerialPort open flips RTS and DTR despite I don't want it
I am having the same problem (Mac OS X), did you find a solution?
Re: QSerialPort open flips RTS and DTR despite I don't want it
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?
Re: QSerialPort open flips RTS and DTR despite I don't want it
This is the code:
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);
qDebug() << "setDataTerminalReady" << serial->setDataTerminalReady(false);
...
If I run it then both debug outputs are TRUE.
Re: QSerialPort open flips RTS and DTR despite I don't want it
And setRequestToSend()? Have you measured the actual DTR and RTS signal lines?
Re: QSerialPort open flips RTS and DTR despite I don't want it
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.
Re: QSerialPort open flips RTS and DTR despite I don't want it
What version of Qt / QtSerialPort?
Re: QSerialPort open flips RTS and DTR despite I don't want it
I am using Qt 5.3 on OS X 10.9
Re: QSerialPort open flips RTS and DTR despite I don't want it
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/Di...rialConnection
Re: QSerialPort open flips RTS and DTR despite I don't want it
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!
Re: QSerialPort open flips RTS and DTR despite I don't want it
I can confirm the same behavior on Windows 8.1 Qt 5.6. FYI pinoutSignals returns QFlags<QSerialPort::PinoutSignal>(NoSignal).