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. QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem

QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
qserialport
17 Posts 3 Posters 3.3k 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.
  • C Crawl.W
    17 Jan 2020, 01:17

    @aha_1980 @J-Hilk yeah,really, there was a problem still.Now, I start to suspect a problem with my code because I use QSerialPort in the GUI thread.
    I found that if there is a slightly longer time interval(more than 3min), the probability of problems is relatively high.But not necessarily.

    A Offline
    A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on 17 Jan 2020, 06:05 last edited by
    #8

    @Crawl-W said in QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem:

    Now, I start to suspect a problem with my code because I use QSerialPort in the GUI thread

    There is nothing wrong with that. I do this all the time.

    There is one problem on Windows though: when you click and hold the mouse button on the window's title bar, the window does not receive events anymore. So if the serial port is in the GUI thread, it will stuck until the mouse is released.

    Regards

    Qt has to stay free or it will die.

    C 1 Reply Last reply 19 Feb 2020, 05:34
    4
    • A aha_1980
      17 Jan 2020, 06:05

      @Crawl-W said in QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem:

      Now, I start to suspect a problem with my code because I use QSerialPort in the GUI thread

      There is nothing wrong with that. I do this all the time.

      There is one problem on Windows though: when you click and hold the mouse button on the window's title bar, the window does not receive events anymore. So if the serial port is in the GUI thread, it will stuck until the mouse is released.

      Regards

      C Offline
      C Offline
      Crawl.W
      wrote on 19 Feb 2020, 05:34 last edited by
      #9

      @aha_1980 Okay, I will do some checks based on your reminder.Thks!

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Crawl.W
        wrote on 25 Feb 2020, 10:01 last edited by aha_1980
        #10

        @aha_1980 I see another question you answered https://forum.qt.io/topic/94537/qserialport-troubles-on-windows-10/3. My client slowed down also and cpu has been running. My countdown is running normally in the gui thread and highlight effect of minimize button a bit stuck. Just a word, I use QSerialPort in the GUI thread and the program, program always has only one thread, although it has been said before, it is too long. I will go to debug source code further, but if you know what's going on it would be great. The number of threads in this case is 21 which is show in Win10's task mannager.
        OS : Windows 10 Pro
        Kit : Qt 5.12.6 msvc2017 64bit
        Cpu:7700k
        cpustatus.jpg

        A 1 Reply Last reply 25 Feb 2020, 10:42
        0
        • C Crawl.W
          25 Feb 2020, 10:01

          @aha_1980 I see another question you answered https://forum.qt.io/topic/94537/qserialport-troubles-on-windows-10/3. My client slowed down also and cpu has been running. My countdown is running normally in the gui thread and highlight effect of minimize button a bit stuck. Just a word, I use QSerialPort in the GUI thread and the program, program always has only one thread, although it has been said before, it is too long. I will go to debug source code further, but if you know what's going on it would be great. The number of threads in this case is 21 which is show in Win10's task mannager.
          OS : Windows 10 Pro
          Kit : Qt 5.12.6 msvc2017 64bit
          Cpu:7700k
          cpustatus.jpg

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 25 Feb 2020, 10:42 last edited by
          #11

          Hi @Crawl-W,

          no unfortunately I don't know what's going on.

          And as you cannot share your code, it's just guessing from my side.

          So the best tip I can give you: Minimize your program. Generate reproduciable test cases. Use tools like profilers or timestamp logging to find the places that eat your CPU.

          Good luck, regards

          Qt has to stay free or it will die.

          1 Reply Last reply
          1
          • C Offline
            C Offline
            Crawl.W
            wrote on 27 Feb 2020, 09:07 last edited by
            #12

            @aha_1980 I found QIODevice::readyRead eat my cpu, but I am still not know why. This usually happens in a pop-up dialog to let the user confirm an action and the user waits for a while to do it. The serial port was not actively disconnected during the period, and of course it was not reconnected, just continue to send command to the equipment. From the cpu curve, I suspect the effect of the timer.
            bug.jpg

            J 1 Reply Last reply 27 Feb 2020, 09:18
            0
            • C Crawl.W
              27 Feb 2020, 09:07

              @aha_1980 I found QIODevice::readyRead eat my cpu, but I am still not know why. This usually happens in a pop-up dialog to let the user confirm an action and the user waits for a while to do it. The serial port was not actively disconnected during the period, and of course it was not reconnected, just continue to send command to the equipment. From the cpu curve, I suspect the effect of the timer.
              bug.jpg

              J Offline
              J Offline
              J.Hilk
              Moderators
              wrote on 27 Feb 2020, 09:18 last edited by
              #13

              @Crawl-W said in QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem:

              I found QIODevice::readyRead eat my cpu, but I am still not know why. This usually happens in a pop-up dialog to let the user confirm an action and the user waits for a while to do it.

              No. Popup dialogs do not consume cpu. If your (Qt)program does, then you're doing something wrong. Most likely blocking while loops and manual event loop spinning or QEventLoop uses.
              Stuff like that, and one isn't supposed to do...


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              C 1 Reply Last reply 6 Mar 2020, 03:26
              1
              • J J.Hilk
                27 Feb 2020, 09:18

                @Crawl-W said in QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem:

                I found QIODevice::readyRead eat my cpu, but I am still not know why. This usually happens in a pop-up dialog to let the user confirm an action and the user waits for a while to do it.

                No. Popup dialogs do not consume cpu. If your (Qt)program does, then you're doing something wrong. Most likely blocking while loops and manual event loop spinning or QEventLoop uses.
                Stuff like that, and one isn't supposed to do...

                C Offline
                C Offline
                Crawl.W
                wrote on 6 Mar 2020, 03:26 last edited by
                #14

                @aha_1980 @J-Hilk First of all, I need to clarify that the software I maintain now is really suck. I most likely have solved this problem and now the program runs well.

                I need to describe the process of this problem:
                1.QTextEdit becomes stuck slowly because of appending so many messages
                2.a dialog pops up(exec()), after confirmation then update tableview viewport with QTableView::viewport()->update()
                3.click a button continue to R/W serial port.

                I originally suspected it was due to QTableView::viewport()->update(), which schedules a paint event for processing when Qt returns to the main event loop. However, my experiment found QTextEdit's stuck lead the QSerialport did not emit readyRead () signal.

                Why?
                thanks you guys for patience all the time.

                A J 2 Replies Last reply 6 Mar 2020, 04:39
                2
                • C Crawl.W
                  6 Mar 2020, 03:26

                  @aha_1980 @J-Hilk First of all, I need to clarify that the software I maintain now is really suck. I most likely have solved this problem and now the program runs well.

                  I need to describe the process of this problem:
                  1.QTextEdit becomes stuck slowly because of appending so many messages
                  2.a dialog pops up(exec()), after confirmation then update tableview viewport with QTableView::viewport()->update()
                  3.click a button continue to R/W serial port.

                  I originally suspected it was due to QTableView::viewport()->update(), which schedules a paint event for processing when Qt returns to the main event loop. However, my experiment found QTextEdit's stuck lead the QSerialport did not emit readyRead () signal.

                  Why?
                  thanks you guys for patience all the time.

                  A Offline
                  A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 6 Mar 2020, 04:39 last edited by
                  #15

                  @Crawl-W

                  However, my experiment found QTextEdit's stuck lead the QSerialport did not emit readyRead () signal.

                  I can only think of problems if both are in the same thread, and maybe the event loop does not run anymore when you edit gets too slow.

                  Anyway, glad you solved it!

                  Regards

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  0
                  • C Crawl.W
                    6 Mar 2020, 03:26

                    @aha_1980 @J-Hilk First of all, I need to clarify that the software I maintain now is really suck. I most likely have solved this problem and now the program runs well.

                    I need to describe the process of this problem:
                    1.QTextEdit becomes stuck slowly because of appending so many messages
                    2.a dialog pops up(exec()), after confirmation then update tableview viewport with QTableView::viewport()->update()
                    3.click a button continue to R/W serial port.

                    I originally suspected it was due to QTableView::viewport()->update(), which schedules a paint event for processing when Qt returns to the main event loop. However, my experiment found QTextEdit's stuck lead the QSerialport did not emit readyRead () signal.

                    Why?
                    thanks you guys for patience all the time.

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 6 Mar 2020, 06:23 last edited by
                    #16

                    @Crawl-W said in QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem:

                    QTextEdit's

                    have you tried setting the undoRedo property to false ? That's usually a high performance eater when one appends (a lot) to the textedit

                    setUndoRedoEnabled(false);

                    the default is true


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    C 1 Reply Last reply 6 Mar 2020, 07:28
                    1
                    • J J.Hilk
                      6 Mar 2020, 06:23

                      @Crawl-W said in QSerialport did not emit readyRead () signal,but USB monitor data received.Only occasionally problem:

                      QTextEdit's

                      have you tried setting the undoRedo property to false ? That's usually a high performance eater when one appends (a lot) to the textedit

                      setUndoRedoEnabled(false);

                      the default is true

                      C Offline
                      C Offline
                      Crawl.W
                      wrote on 6 Mar 2020, 07:28 last edited by
                      #17

                      @J-Hilk Tks, I will do a test. Btw, I want to know more the root cause of QSerialport did not emit readyRead () signal.

                      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