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. Issue in making GUI responsive
Forum Updated to NodeBB v4.3 + New Features

Issue in making GUI responsive

Scheduled Pinned Locked Moved Unsolved General and Desktop
28 Posts 6 Posters 4.4k Views 3 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.
  • KiraK Kira

    @J.Hilk said in Issue in making GUI responsive:

    Seems to me like you're missing a proper queue implementation on your SerialPort communication.

    @J-Hilk : I have tried multiple example also with the sample examples that comes with the qt creator. I was having problem with the microcontroller version which i was using.

    As per what i have understood about signal slot mechanism is that if the slot is not executed at given instance of time it get queued. So their arise a possiblity of the slots getting queue and be the reason of my delay in response creating a bottleneck between the sender and the receiver.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by jsulm
    #16

    @Kira A signal is only queued when communicating between different threads (or setting queued connection type explicitly). In same thread emitting a signal means that all connected slots will be called immediately one after another (in same order as connect() calls), so no queueing.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    KiraK 1 Reply Last reply
    1
    • jsulmJ jsulm

      @Kira A signal is only queued when communicating between different threads (or setting queued connection type explicitly). In same thread emitting a signal means that all connected slots will be called immediately one after another (in same order as connect() calls), so no queueing.

      KiraK Offline
      KiraK Offline
      Kira
      wrote on last edited by
      #17

      @jsulm : @J-Hilk : Guys thanks to you did some sample program regarding implementation of QSerialPort and found an interesting example listed under qt creator.
      https://doc.qt.io/qt-5/qtserialport-blockingmaster-example.html
      Here they have clearly mentioned the example of using serialPort in gui mode.
      Just i have one doubt:
      =>Here every time port is being set, i don't have any such condition in my example so can just set port once in the thread ?
      =>Also does QWaitCondition have any extra overhead ?
      =>Can i implement the similar logic for my camera thread where the thread runs continuously without any sleep?

      jsulmJ aha_1980A 2 Replies Last reply
      0
      • KiraK Kira

        @jsulm : @J-Hilk : Guys thanks to you did some sample program regarding implementation of QSerialPort and found an interesting example listed under qt creator.
        https://doc.qt.io/qt-5/qtserialport-blockingmaster-example.html
        Here they have clearly mentioned the example of using serialPort in gui mode.
        Just i have one doubt:
        =>Here every time port is being set, i don't have any such condition in my example so can just set port once in the thread ?
        =>Also does QWaitCondition have any extra overhead ?
        =>Can i implement the similar logic for my camera thread where the thread runs continuously without any sleep?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #18

        @Kira That example shows how to use SYNCHRONOUS API in GUI thread. But why do you want to use synchronous API instead of the asynchronous? If there is no valid reason to use synchronous API use the asynchronous - this is WAY easier compared to dealing with threads.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        KiraK 1 Reply Last reply
        4
        • KiraK Kira

          @jsulm : @J-Hilk : Guys thanks to you did some sample program regarding implementation of QSerialPort and found an interesting example listed under qt creator.
          https://doc.qt.io/qt-5/qtserialport-blockingmaster-example.html
          Here they have clearly mentioned the example of using serialPort in gui mode.
          Just i have one doubt:
          =>Here every time port is being set, i don't have any such condition in my example so can just set port once in the thread ?
          =>Also does QWaitCondition have any extra overhead ?
          =>Can i implement the similar logic for my camera thread where the thread runs continuously without any sleep?

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #19

          @Kira and just to add to @jsulm:

          I doubt the serial port handling is your problem. Serial ports are slow and handling them with signals and slots is most often no problem.

          I think your problem is handling the data you received through serial port. If that takes a bit longer, you'll block your GUI.

          Regards

          Qt has to stay free or it will die.

          KiraK 1 Reply Last reply
          3
          • jsulmJ jsulm

            @Kira That example shows how to use SYNCHRONOUS API in GUI thread. But why do you want to use synchronous API instead of the asynchronous? If there is no valid reason to use synchronous API use the asynchronous - this is WAY easier compared to dealing with threads.

            KiraK Offline
            KiraK Offline
            Kira
            wrote on last edited by Kira
            #20

            @jsulm said in Issue in making GUI responsive:

            That example shows how to use SYNCHRONOUS API in GUI thread.

            Will this approach cause my GUI to hang if i don't get a timely response??

            Can you please suggest how can i implement the following requirement using asynchronous approch?
            ->Send serial data
            ->Read the data
            ->If data read successfully than allow another serial request.

            jsulmJ 1 Reply Last reply
            0
            • aha_1980A aha_1980

              @Kira and just to add to @jsulm:

              I doubt the serial port handling is your problem. Serial ports are slow and handling them with signals and slots is most often no problem.

              I think your problem is handling the data you received through serial port. If that takes a bit longer, you'll block your GUI.

              Regards

              KiraK Offline
              KiraK Offline
              Kira
              wrote on last edited by
              #21

              @aha_1980 said in Issue in making GUI responsive:

              I think your problem is handling the data you received through serial port. If that takes a bit longer, you'll block your GUI.

              I have used the standard example to get data from the serial port. Still sometimes i don't get response on my serialPort.
              Will look again into the issue and see to it that the data handling is done properly.

              If the above asynchronous approach will cause my GUI to hang i will have to use the second appoach.

              1 Reply Last reply
              0
              • KiraK Kira

                @jsulm said in Issue in making GUI responsive:

                That example shows how to use SYNCHRONOUS API in GUI thread.

                Will this approach cause my GUI to hang if i don't get a timely response??

                Can you please suggest how can i implement the following requirement using asynchronous approch?
                ->Send serial data
                ->Read the data
                ->If data read successfully than allow another serial request.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #22

                @Kira said in Issue in making GUI responsive:

                Will this approach cause my GUI to hang if i don't get a timely response??

                Not in that example. But again: why not simply use asynchronous API? Why do you make things unnecessary complex?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                KiraK 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Kira said in Issue in making GUI responsive:

                  Will this approach cause my GUI to hang if i don't get a timely response??

                  Not in that example. But again: why not simply use asynchronous API? Why do you make things unnecessary complex?

                  KiraK Offline
                  KiraK Offline
                  Kira
                  wrote on last edited by
                  #23

                  @jsulm said in Issue in making GUI responsive:

                  Not in that example. But again: why not simply use asynchronous API? Why do you make things unnecessary complex?

                  @jsulm : Actually i am writing program for system which is completely based on feedback mechanism.
                  As an example: If i give the my device command to move 15 steps in an axis i will have wait for feedback from my controller device after than i can allow user to give next command.
                  Feedback is generated by after the device have moved. It is also observed that if i continuously request the device without getting the feedback, serial port hangs most of the time.

                  For different command there are different feedback. I will have to analyse the feedback generated
                  and allow for controller to move.

                  If the feedback mechanism can be implemented in asynchronous approch i would be happy to implement.Can you please help with an example if already available?
                  I have checked the terminal example in qt creator but it does not have feedback mechanism

                  jsulmJ 1 Reply Last reply
                  0
                  • KiraK Kira

                    @jsulm said in Issue in making GUI responsive:

                    Not in that example. But again: why not simply use asynchronous API? Why do you make things unnecessary complex?

                    @jsulm : Actually i am writing program for system which is completely based on feedback mechanism.
                    As an example: If i give the my device command to move 15 steps in an axis i will have wait for feedback from my controller device after than i can allow user to give next command.
                    Feedback is generated by after the device have moved. It is also observed that if i continuously request the device without getting the feedback, serial port hangs most of the time.

                    For different command there are different feedback. I will have to analyse the feedback generated
                    and allow for controller to move.

                    If the feedback mechanism can be implemented in asynchronous approch i would be happy to implement.Can you please help with an example if already available?
                    I have checked the terminal example in qt creator but it does not have feedback mechanism

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #24

                    @Kira You can take a look at this: https://doc.qt.io/qt-5/qstatemachine.html

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    KiraK 1 Reply Last reply
                    3
                    • jsulmJ jsulm

                      @Kira You can take a look at this: https://doc.qt.io/qt-5/qstatemachine.html

                      KiraK Offline
                      KiraK Offline
                      Kira
                      wrote on last edited by
                      #25

                      @jsulm said in Issue in making GUI responsive:

                      You can take a look at this: https://doc.qt.io/qt-5/qstatemachine.html

                      @jsulm : Hi, just a last clarfication. I went through the documentation of statemachine.
                      And i have following signal and slots:
                      connect(serial, &QSerialPort::readyRead, this, &MainWindow::readData);

                      connect(console, &Console::getData, this, &MainWindow::writeData);
                      How can i apply the state machine logic to this
                      Thanks and regards

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #26

                        The idea would be that you will drive the state machine based on the feedback your receive from the device.

                        One controller object that will send command and parse answers and will emit something that will allow the state machine to go to the next state.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        KiraK 1 Reply Last reply
                        2
                        • SGaistS SGaist

                          The idea would be that you will drive the state machine based on the feedback your receive from the device.

                          One controller object that will send command and parse answers and will emit something that will allow the state machine to go to the next state.

                          KiraK Offline
                          KiraK Offline
                          Kira
                          wrote on last edited by
                          #27

                          @SGaist : Thanks for the reply just one thing i need to clarify.
                          Just couple of doubts .
                          How can i handle the situation if there is no response for the serial input?

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #28

                            In what case would that happen ?
                            Do you have some times guarantees with regard to answer from the device ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            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