Results 1 to 11 of 11

Thread: QSerialPort open flips RTS and DTR despite I don't want it

  1. #1
    Join Date
    Apr 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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?

  2. #2
    Join Date
    Feb 2010
    Location
    Los Angeles
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,543
    Thanks
    13
    Thanked 1,577 Times in 1,506 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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?

  4. #4
    Join Date
    Feb 2010
    Location
    Los Angeles
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSerialPort open flips RTS and DTR despite I don't want it

    This is the code:

    Qt Code:
    1. ...
    2. serial->setPortName(ui->port->currentText());
    3. serial->setBaudRate(QSerialPort::Baud115200);
    4. serial->setDataBits(QSerialPort::Data8);
    5. serial->setParity(QSerialPort::NoParity);
    6. serial->setStopBits(QSerialPort::OneStop);
    7. qDebug() << "setFlowControl" << serial->setFlowControl(QSerialPort::NoFlowControl);
    8. if (serial->open(QIODevice::ReadWrite)) {
    9. qDebug() << "setDataTerminalReady" << serial->setDataTerminalReady(false);
    10. ...
    To copy to clipboard, switch view to plain text mode 

    If I run it then both debug outputs are TRUE.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,543
    Thanks
    13
    Thanked 1,577 Times in 1,506 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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?

  6. #6
    Join Date
    Feb 2010
    Location
    Los Angeles
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.
    Last edited by Markus; 14th February 2015 at 03:40.

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,543
    Thanks
    13
    Thanked 1,577 Times in 1,506 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSerialPort open flips RTS and DTR despite I don't want it

    What version of Qt / QtSerialPort?

  8. #8
    Join Date
    Feb 2010
    Location
    Los Angeles
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSerialPort open flips RTS and DTR despite I don't want it

    I am using Qt 5.3 on OS X 10.9

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,543
    Thanks
    13
    Thanked 1,577 Times in 1,506 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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

  10. The following user says thank you to ChrisW67 for this useful post:

    Markus (16th February 2015)

  11. #10
    Join Date
    Feb 2010
    Location
    Los Angeles
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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!

  12. #11
    Join Date
    Dec 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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).

Similar Threads

  1. Replies: 3
    Last Post: 7th April 2014, 10:46
  2. Qserialport issue in QT4
    By coss_cat in forum Qt Programming
    Replies: 3
    Last Post: 11th December 2013, 18:11
  3. QSerialport in multithread
    By snow_starzz in forum Newbie
    Replies: 3
    Last Post: 3rd December 2013, 10:18
  4. Qt5 cmake and QSerialPort
    By Chris.Burner in forum Newbie
    Replies: 1
    Last Post: 21st April 2013, 16:13
  5. Replies: 1
    Last Post: 15th April 2009, 09:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.