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 Offline
    C Offline
    Crawl.W
    wrote on 15 Jan 2020, 01:28 last edited by aha_1980
    #1

    I simply connect readyRead() with handle function. My USB monitor detect the received data,but the readyRead() did not trigger. And when I write serial port again, I receive the last respone at once.I know which is the last response, because I will receive a response later. I just record log after handle funcation. My Qt version is 5.11.1.

    Application output as following:

    11:22:12.001 GetAxisZPosition
    11:22:13.490 GetAxisZPosition again
    11:22:13.490 ReceiveAxisZPosition
    11:22:13.491 SetAxisZMoveSpeed
    11:22:13.494 ReceiveAxisZPosition

    The second log show that I query X axis pos again because I estimate data lost.However, my USB monitor dectect the respone.
    76FAC816-5231-46c1-8C09-7F3E9D74F1B8.png

    J 1 Reply Last reply 15 Jan 2020, 05:47
    0
    • C Crawl.W
      15 Jan 2020, 01:28

      I simply connect readyRead() with handle function. My USB monitor detect the received data,but the readyRead() did not trigger. And when I write serial port again, I receive the last respone at once.I know which is the last response, because I will receive a response later. I just record log after handle funcation. My Qt version is 5.11.1.

      Application output as following:

      11:22:12.001 GetAxisZPosition
      11:22:13.490 GetAxisZPosition again
      11:22:13.490 ReceiveAxisZPosition
      11:22:13.491 SetAxisZMoveSpeed
      11:22:13.494 ReceiveAxisZPosition

      The second log show that I query X axis pos again because I estimate data lost.However, my USB monitor dectect the respone.
      76FAC816-5231-46c1-8C09-7F3E9D74F1B8.png

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 15 Jan 2020, 05:47 last edited by
      #2

      @Crawl-W
      please update your Qt version, in 5.12.4 & 5.12.5 and (I think) 5.13.0 & 1. QSerialport is broken, as in it emits not ready read signal

      see
      https://bugreports.qt.io/browse/QTBUG-78086


      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 16 Jan 2020, 03:54
      3
      • J J.Hilk
        15 Jan 2020, 05:47

        @Crawl-W
        please update your Qt version, in 5.12.4 & 5.12.5 and (I think) 5.13.0 & 1. QSerialport is broken, as in it emits not ready read signal

        see
        https://bugreports.qt.io/browse/QTBUG-78086

        C Offline
        C Offline
        Crawl.W
        wrote on 16 Jan 2020, 03:54 last edited by Crawl.W
        #3

        @J-Hilk My version is 5.11.1 and trigger the problem occasionally .

        J 1 Reply Last reply 16 Jan 2020, 05:51
        0
        • C Crawl.W
          16 Jan 2020, 03:54

          @J-Hilk My version is 5.11.1 and trigger the problem occasionally .

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 16 Jan 2020, 05:51 last edited by
          #4

          @Crawl-W
          well, have you tried/can you try with 5.12.6 ?


          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 16 Jan 2020, 06:18
          0
          • J J.Hilk
            16 Jan 2020, 05:51

            @Crawl-W
            well, have you tried/can you try with 5.12.6 ?

            C Offline
            C Offline
            Crawl.W
            wrote on 16 Jan 2020, 06:18 last edited by
            #5

            @J-Hilk thks, I try it soon.What's more painful is that it was an accidental event.

            A 1 Reply Last reply 16 Jan 2020, 08:00
            0
            • C Crawl.W
              16 Jan 2020, 06:18

              @J-Hilk thks, I try it soon.What's more painful is that it was an accidental event.

              A Offline
              A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on 16 Jan 2020, 08:00 last edited by
              #6

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

              @J-Hilk thks, I try it soon.What's more painful is that it was an accidental event.

              Well, it might still be a problem in your code. Can you show it?

              Regards

              Qt has to stay free or it will die.

              C 1 Reply Last reply 17 Jan 2020, 01:17
              0
              • A aha_1980
                16 Jan 2020, 08:00

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

                @J-Hilk thks, I try it soon.What's more painful is that it was an accidental event.

                Well, it might still be a problem in your code. Can you show it?

                Regards

                C Offline
                C Offline
                Crawl.W
                wrote on 17 Jan 2020, 01:17 last edited by Crawl.W
                #7

                @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 1 Reply Last reply 17 Jan 2020, 06:05
                0
                • 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