Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Read data RS232 without pooling
Qt 6.12 LTS is out! See what's new in the release blog

Read data RS232 without pooling

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 3.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    i read data from RS232 in a for loop.this has no good performance.i want don't have a for loop instead of that there was a thing like event that when data is receiving it fire. is this possible? for example when data is receiving from COM16 event firing.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      You give absolutely no info what API you are currently using to read from COM port.

      Anyway, if that API has a blocking call, that will not return before new data is available, you can simply use that one, in a loop, and put that loop into a background thread. Then send a signal as soon as new data is available.

      Like:
      @MyThread::run()
      {
      forever
      {
      readDataFromComPort_blocking();
      emit newDataAvailable();
      }
      }@

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        thanks for your reply. how can i have blocking call for that? i can't implement
        @
        readDataFromComPort_blocking();
        @
        function.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          Tell us what API you are using to read from the COM port, if you expect an answer on this ;-)

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DerManu
            wrote on last edited by
            #5

            I'm using QExtSerialPort very successfully in an application that doesn't poll, either.
            http://code.google.com/p/qextserialport/

            It makes this possible by emitting a readyRead signal, as soon as data is available.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kuzulis
              Qt Champions 2020
              wrote on last edited by
              #6

              You can also use official "QtSerialPort":http://qt-project.org/wiki/QtSerialPort addon.

              See documentation about API and examples "here":http://doc-snapshot.qt-project.org/qt5-stable/qtserialport/qtserialport-index.html.

              Therefore there is no need of use of your custom code.

              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
              • Unsolved