Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Avoid any changes on serial handshaking lines
Forum Updated to NodeBB v4.3 + New Features

Avoid any changes on serial handshaking lines

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 210 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by Mark81
    #1

    Here my functions to open and close a serial port:

    QSerialPort _serial;
    
    bool MySerial::open(QString port, quint32 baudrate)
    {
        _serial.setPortName(port);
        _serial.setFlowControl(QSerialPort::NoFlowControl);
        if (_serial.open(QIODevice::ReadWrite))
        {
            _serial.setRequestToSend(false);
            _serial.setDataTerminalReady(false);
            _serial.setBaudRate(baudrate);
            _serial.flush();
            return true;
        }
        else return false;
    }
    
    void MySerial::close()
    {
        _serial.close();
    }
    

    The serial port is actually an FT232RL USB/TTL converter. The remote device is a board with an ESP32. The handshaking signals (RTS, DTR) are use to reset the board and to put the MCU in bootloader mode.

    Under Linux (Qt 6.6.0) no problem, the code above just opens and closes the port without changing the handshaking lines (even without explicitly setting their state).

    Instead, under Windows 7 (Qt 5.15) when the port closes those signals change for a while causing a reset of my board and often put it in bootloader mode.

    How can I avoid this behavior?

    Christian EhrlicherC 1 Reply Last reply
    0
    • M Mark81

      Here my functions to open and close a serial port:

      QSerialPort _serial;
      
      bool MySerial::open(QString port, quint32 baudrate)
      {
          _serial.setPortName(port);
          _serial.setFlowControl(QSerialPort::NoFlowControl);
          if (_serial.open(QIODevice::ReadWrite))
          {
              _serial.setRequestToSend(false);
              _serial.setDataTerminalReady(false);
              _serial.setBaudRate(baudrate);
              _serial.flush();
              return true;
          }
          else return false;
      }
      
      void MySerial::close()
      {
          _serial.close();
      }
      

      The serial port is actually an FT232RL USB/TTL converter. The remote device is a board with an ESP32. The handshaking signals (RTS, DTR) are use to reset the board and to put the MCU in bootloader mode.

      Under Linux (Qt 6.6.0) no problem, the code above just opens and closes the port without changing the handshaking lines (even without explicitly setting their state).

      Instead, under Windows 7 (Qt 5.15) when the port closes those signals change for a while causing a reset of my board and often put it in bootloader mode.

      How can I avoid this behavior?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Mark81 said in Avoid any changes on serial handshaking lines:

      How can I avoid this behavior?

      Ask the vendor of the hardware to fix their windows drivers. When you look around you will find a lot of such strange issues with serial ports on windows. There is nothing what Qt can do here since it's an underlying problem of the serial to usb driver.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      M 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @Mark81 said in Avoid any changes on serial handshaking lines:

        How can I avoid this behavior?

        Ask the vendor of the hardware to fix their windows drivers. When you look around you will find a lot of such strange issues with serial ports on windows. There is nothing what Qt can do here since it's an underlying problem of the serial to usb driver.

        M Offline
        M Offline
        Mark81
        wrote on last edited by Mark81
        #3

        @Christian-Ehrlicher I accept this, but I also notice that other softwares, like RealTerm, are able to open/close the port with no issues. If it is a driver problem, shouldn't it have the same problem?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved