Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QSerialPort passing received data to GUI [solved]
Qt 6.11 is out! See what's new in the release blog

QSerialPort passing received data to GUI [solved]

Scheduled Pinned Locked Moved 3rd Party Software
15 Posts 5 Posters 7.4k 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.
  • J Offline
    J Offline
    jarosda
    wrote on last edited by
    #6

    Hi,
    current baudrate is 9600 bps, I receive upto 8 B every 10 ms. Baudrate has to be so slow because it requires the target device (low power embedded board with MSP430). One part of qt application should frequently (100 Hz) handle received data and the second part should show data to the user in GUI (here could be refresh rate about 2 Hz as I wrote above). At this moment this proccess (just showing data in GUI) spent 10% of CPU power (AMD Phenom II X4 965, 3,4GHz).
    By target device I mean second side of serial line :-).

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #7

      Ok, then what about firing the QTimer in the slot that handles the "frequent" data (on_readyRead()), so that the GUI gets a call less often?

      (Z(:^

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

        One other thing: is the data to be appended ? Or does it just replace the current values ?

        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
        • J Offline
          J Offline
          jarosda
          wrote on last edited by
          #9

          To SGaist: The data are prepended in QString (newest data on the first line in multiline string).
          To sierdzio: I think so, yes it could be the easiest way. I will try it

          I have one another question related to QSerialPort. Does it possible to handle any QSerialPort exception (framing error, buffer overflow.. etc) ? I am asking becouse sometimes when I debugging app the exception is invoked and I think that is caused by serial port.

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

            2 jarosda,

            You can try do connect to SerialPortError signal to catch some errors.

            But detecting for FramingError, ParityError or BreakConditionError still is not fully implemented. Because it is very difficult (and sometimes impossible) to make a same behavior for different operating systems to detect these errors.

            So, at least catching for this errors should be work on Windows, although it is not a fact, please try it and let me know. :)

            In general, the overall approach to catch such errors is not yet implemented in the design. Developers can not agree among themselves. Also it is so hard implement on *nix platforms...

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #11

              You can also try to use the serial device in the UI thread directly. The API is asynchronous anyway and communicating between threads requires locking, etc. This overhead can severely slow down your application.

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

                Then, you might be interested in using a "QListView":http://qt-project.org/doc/qt-4.8/qlistview.html with a "QStringListModel":http://qt-project.org/doc/qt-4.8/qstringlistmodel.html

                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
                • J Offline
                  J Offline
                  jarosda
                  wrote on last edited by
                  #13

                  Guys thank you for posts, the problem wasn't in qserialdevice at all. The cpu looad was caused by offten accessing qtextedit and related operations with qstring. Thanks again, David.

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

                    Good to see it works !

                    If you're problem is solved, can you update the thread title so other people may know that you found a solution ?

                    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
                    • J Offline
                      J Offline
                      jarosda
                      wrote on last edited by
                      #15

                      Ok, I'll do it. I didn't know how to close this thread.

                      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