Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSerialPort
Qt 6.12 LTS is out! See what's new in the release blog

QSerialPort

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 6 Posters 3.1k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #3

    Hi,

    Is it expected that you read only one line ?
    You should rather get everything from the serial port, accumulate in a buffer and then process the data once you have a full frame (or more).

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

    T 1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      Is it expected that you read only one line ?
      You should rather get everything from the serial port, accumulate in a buffer and then process the data once you have a full frame (or more).

      T Offline
      T Offline
      Tomaz
      wrote on last edited by
      #4

      @SGaist Hi SGaist. Everytime is good to read your replies. Yes. I control what is being red and it is one line from arduino loop (simple sensor data). Thomas

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

        Can you share also the thread related code ?

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

        T 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @Tomaz

          What do you expect from emitting a signal in a while(1) loop?!
          It will never get processed

          Edit:
          Ah havent seen your comment. You only emit once when the loop has ended.

          Have a look at the synchronous and asynchronous QSerialPort examples here:

          • https://doc.qt.io/qt-6/qtserialport-blockingreceiver-example.html
          • https://doc.qt.io/qt-6/qtserialport-terminal-example.html
          T Offline
          T Offline
          Tomaz
          wrote on last edited by Tomaz
          #6

          @Pl45m4 Hi.
          I am sorry but the code is correct on syntax, semantic and semiotic/pragmatic level. The creation of and object has to happen inside the working loop I concluded; (in run loop). I think it has to do with usb port access on low level (QSerialPort c/c++ Qt code). I think. The error is gone now.

          I got it from one of SGaist comments/replies.

          Perhaps SGaist could give us more enlightenment why it has to be inside run loop (or custom loop like I have)? Perhaps because it is made on heap?

          regards, Thomas

          T 1 Reply Last reply
          0
          • T Tomaz

            @Pl45m4 Hi.
            I am sorry but the code is correct on syntax, semantic and semiotic/pragmatic level. The creation of and object has to happen inside the working loop I concluded; (in run loop). I think it has to do with usb port access on low level (QSerialPort c/c++ Qt code). I think. The error is gone now.

            I got it from one of SGaist comments/replies.

            Perhaps SGaist could give us more enlightenment why it has to be inside run loop (or custom loop like I have)? Perhaps because it is made on heap?

            regards, Thomas

            T Offline
            T Offline
            Tomaz
            wrote on last edited by
            #7

            @Tomaz No it is not the heap problem. Perhaps of the scope object is living in?

            K 1 Reply Last reply
            0
            • T Tomaz

              @Tomaz No it is not the heap problem. Perhaps of the scope object is living in?

              K Offline
              K Offline
              kuzulis
              Qt Champions 2020
              wrote on last edited by
              #8

              @Tomaz

              Right now everything is wrong in your code.

              Christian EhrlicherC 1 Reply Last reply
              0
              • K kuzulis

                @Tomaz

                Right now everything is wrong in your code.

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #9

                Where is readttyUSB0 instantiated / is it moved to a thread somewhere? If yes then you forgot to move sPort (btw: very strange name for a member var) as it has no parent.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                T 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  Where is readttyUSB0 instantiated / is it moved to a thread somewhere? If yes then you forgot to move sPort (btw: very strange name for a member var) as it has no parent.

                  T Offline
                  T Offline
                  Tomaz
                  wrote on last edited by Tomaz
                  #10

                  @Christian-Ehrlicher Hi. Sorry for my late reply. Well it is in mainwindow constructor. This is in constructor.

                  rttyUSB0->moveToThread(threadttyUSB0);
                  connect(threadttyUSB0,SIGNAL(started()),rttyUSB0,SLOT(doWork()));
                  connect(rttyUSB0,SIGNAL(usb0Data(QString)),this,SLOT(readSerialCom(QString)));
                  threadttyUSB0->start();```
                  

                  Declared in .h file in private part.

                  What I do in readSerialCom(QString) is not important.

                  I let this loop to run for a week with no problem. No compile error. Should be ok.

                  Thomas

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Can you share also the thread related code ?

                    T Offline
                    T Offline
                    Tomaz
                    wrote on last edited by
                    #11

                    @SGaist Hi. SGaist. One question. What is the best way (board?) to boot Linux into Qt graphic App (I need access to /dev- USB) in max 2 to 3 seconds? But to be on open source non commercial side. I tried raspberry Pi and eglfs but it needs 10 seconds. regards Thomas

                    Ronel_qtmasterR SGaistS 2 Replies Last reply
                    0
                    • T Tomaz

                      @SGaist Hi. SGaist. One question. What is the best way (board?) to boot Linux into Qt graphic App (I need access to /dev- USB) in max 2 to 3 seconds? But to be on open source non commercial side. I tried raspberry Pi and eglfs but it needs 10 seconds. regards Thomas

                      Ronel_qtmasterR Offline
                      Ronel_qtmasterR Offline
                      Ronel_qtmaster
                      wrote on last edited by
                      #12

                      @Tomaz if you are using yocto, you can disable certain services at start or change the boot order by prioritising your app

                      1 Reply Last reply
                      0
                      • T Tomaz

                        @SGaist Hi. SGaist. One question. What is the best way (board?) to boot Linux into Qt graphic App (I need access to /dev- USB) in max 2 to 3 seconds? But to be on open source non commercial side. I tried raspberry Pi and eglfs but it needs 10 seconds. regards Thomas

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @Tomaz hi,

                        It depends on what your device has to do, which services are required, etc.

                        Based on that you can optimize some things to reduce boot time.

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