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. How to wait for ready read for ever on RS232
Qt 6.11 is out! See what's new in the release blog

How to wait for ready read for ever on RS232

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.9k Views
  • 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.
  • V Offline
    V Offline
    victor wang
    wrote on last edited by
    #1

    Hi All,
    I'm using qt5.5 on my computer and Linux+QT for my OS system.
    I'm using QSerialport to get the information from my MCU via RS232.
    And I want to detect is there any information I have to read.

    After some googling I'm using waitforreadyread() to do it.
    But I do not know how can I wait until the data is coming.

    How can I wait for the data without limited time?

    Thanks in Advanced!

    L 1 Reply Last reply
    0
    • V victor wang

      Hi All,
      I'm using qt5.5 on my computer and Linux+QT for my OS system.
      I'm using QSerialport to get the information from my MCU via RS232.
      And I want to detect is there any information I have to read.

      After some googling I'm using waitforreadyread() to do it.
      But I do not know how can I wait until the data is coming.

      How can I wait for the data without limited time?

      Thanks in Advanced!

      L Offline
      L Offline
      Lolo67
      wrote on last edited by
      #2

      @victor-wang said in How to wait for ready read for ever on RS232:

      QSerialpor

      Have to you tried to connect to the readyRead() signal ?

      1 Reply Last reply
      2
      • aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @victor-wang said in How to wait for ready read for ever on RS232:

        After some googling I'm using waitforreadyread() to do it.
        But I do not know how can I wait until the data is coming.
        How can I wait for the data without limited time?

        Hi Victor,

        Hmm, it seems the documentation is missing a piece here, but it's documented in http://doc.qt.io/qt-5/qiodevice.html#waitForReadyRead:

        If msecs is -1, this function will not time out.

        I've checked in the Win and Unix implementations of QSerialPort, that passing -1 as timeout should never time out.

        You can check yourself:

        http://code.qt.io/cgit/qt/qtserialport.git/tree/src/serialport/qserialport_win.cpp#n371

        http://code.qt.io/cgit/qt/qtserialport.git/tree/src/serialport/qserialport_unix.cpp#n521

        Qt has to stay free or it will die.

        1 Reply Last reply
        1
        • aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I've added a note to the QSerialPort documentation for waitForReadyRead():

          https://codereview.qt-project.org/207213

          Qt has to stay free or it will die.

          1 Reply Last reply
          2

          • Login

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