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: problem with waitForReadyRead()
Forum Updated to NodeBB v4.3 + New Features

QSerialPort: problem with waitForReadyRead()

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 6 Posters 6.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.
  • O oBOXPOH

    @kuzulis said in QSerialPort: problem with waitForReadyRead():

    What is OS, and what is Qt version?

    OS: Windows 10
    Qt Version: 5.13.1
    Building: MinGW 32-bit

    J.HilkJ Online
    J.HilkJ Online
    J.Hilk
    Moderators
    wrote on last edited by
    #8

    @oBOXPOH
    I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1

    see this bugreport
    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.

    O D 2 Replies Last reply
    4
    • J.HilkJ J.Hilk

      @oBOXPOH
      I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1

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

      O Offline
      O Offline
      oBOXPOH
      wrote on last edited by oBOXPOH
      #9

      @J-Hilk said in QSerialPort: problem with waitForReadyRead():

      @oBOXPOH
      I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1

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

      Tried Qt 5.9.8.

      In this case waitForReadyRead() always returns false with accepted write command.

      1 Reply Last reply
      0
      • JonBJ JonB

        @oBOXPOH
        Like I & @J-Hilk have said, suggest you at least try it with readyRead signal instead of waits and see if that makes the difference?

        O Offline
        O Offline
        oBOXPOH
        wrote on last edited by oBOXPOH
        #10

        @JonB said in QSerialPort: problem with waitForReadyRead():

        @oBOXPOH
        Like I & @J-Hilk have said, suggest you at least try it with readyRead signal instead of waits and see if that makes the difference?

        I tried next (all is inside the class):

        connect(deviceControl_SerialPort, &QSerialPort::readyRead, this, &Class::readData_slot);
        
        void Class::readData_slot()
        {
            qDebug() << "Ready Read" << endl;
            deviceControl_readData.append(deviceControl_SerialPort->readAll());
        }
        

        In this case I can't reach readData_slot() method.

        Then I tried next:

        connect(deviceControl_SerialPort, &QSerialPort::errorOccurred, this, &Class::serialPortError_slot);
        
        void Class::serialPortError_slot(QSerialPort::SerialPortError error)
        {
            qDebug() << error << endl;
        }
        
        

        and got some error (see log below):

        WRITTEN  1 
        
        READING... 
        
        QSerialPort::TimeoutError 
        
        WRITTEN  2 
        
        READING... 
        
        QSerialPort::TimeoutError 
        
        WRITTEN  3 
        
        QSerialPort::TimeoutError 
        
        I AM NOT READY! 
        
        Ready Read 
        
        Ready Read 
        

        and, by the way, message for readyRead signal. Strangely, that I got it only after 2 real readings...

        aha_1980A 1 Reply Last reply
        0
        • O oBOXPOH

          @JonB said in QSerialPort: problem with waitForReadyRead():

          @oBOXPOH
          Like I & @J-Hilk have said, suggest you at least try it with readyRead signal instead of waits and see if that makes the difference?

          I tried next (all is inside the class):

          connect(deviceControl_SerialPort, &QSerialPort::readyRead, this, &Class::readData_slot);
          
          void Class::readData_slot()
          {
              qDebug() << "Ready Read" << endl;
              deviceControl_readData.append(deviceControl_SerialPort->readAll());
          }
          

          In this case I can't reach readData_slot() method.

          Then I tried next:

          connect(deviceControl_SerialPort, &QSerialPort::errorOccurred, this, &Class::serialPortError_slot);
          
          void Class::serialPortError_slot(QSerialPort::SerialPortError error)
          {
              qDebug() << error << endl;
          }
          
          

          and got some error (see log below):

          WRITTEN  1 
          
          READING... 
          
          QSerialPort::TimeoutError 
          
          WRITTEN  2 
          
          READING... 
          
          QSerialPort::TimeoutError 
          
          WRITTEN  3 
          
          QSerialPort::TimeoutError 
          
          I AM NOT READY! 
          
          Ready Read 
          
          Ready Read 
          

          and, by the way, message for readyRead signal. Strangely, that I got it only after 2 real readings...

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

          Hi @oBOXPOH,

          Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.

          You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html

          Regards

          Qt has to stay free or it will die.

          O 1 Reply Last reply
          5
          • aha_1980A aha_1980

            Hi @oBOXPOH,

            Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.

            You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html

            Regards

            O Offline
            O Offline
            oBOXPOH
            wrote on last edited by
            #12

            @aha_1980 said in QSerialPort: problem with waitForReadyRead():

            Hi @oBOXPOH,

            Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.

            You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html

            Regards

            Terminal Example also works badly -> https://forum.qt.io/topic/108848/terminal-example-for-qserialport-doesn-t-work-correctly

            O 1 Reply Last reply
            0
            • O oBOXPOH

              @aha_1980 said in QSerialPort: problem with waitForReadyRead():

              Hi @oBOXPOH,

              Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.

              You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html

              Regards

              Terminal Example also works badly -> https://forum.qt.io/topic/108848/terminal-example-for-qserialport-doesn-t-work-correctly

              O Offline
              O Offline
              oBOXPOH
              wrote on last edited by
              #13

              @oBOXPOH said in QSerialPort: problem with waitForReadyRead():

              @aha_1980 said in QSerialPort: problem with waitForReadyRead():

              Hi @oBOXPOH,

              Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.

              You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html

              Regards

              Terminal Example also works badly -> https://forum.qt.io/topic/108848/terminal-example-for-qserialport-doesn-t-work-correctly

              Solution is to install 5.13.2 or more version of Qt.

              1 Reply Last reply
              2
              • D Offline
                D Offline
                DiaaQTdev
                wrote on last edited by
                #14

                @oBOXPOH Hello i am having the same exact problem with QT, i don't receive any output by triggering the readyread signal or by using the return value of waitForReadyRead(), is it really issue related to QT version??
                => I do have 5.12 version of QT, i want to make sure that that is the problem before deciding to do an upgrade..

                Thank you in advance for your reply!

                1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @oBOXPOH
                  I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1

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

                  D Offline
                  D Offline
                  DiaaQTdev
                  wrote on last edited by
                  #15

                  @J-Hilk Hello, is it really a QT bug for versions under 5.13?

                  J.HilkJ 1 Reply Last reply
                  0
                  • D DiaaQTdev

                    @J-Hilk Hello, is it really a QT bug for versions under 5.13?

                    J.HilkJ Online
                    J.HilkJ Online
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #16

                    @DiaaQTdev

                    iirc 5.12 should work fine, only 5.13 had the issues


                    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.

                    1 Reply Last reply
                    1
                    • D Offline
                      D Offline
                      DiaaQTdev
                      wrote on last edited by
                      #17

                      @J-Hilk Thank you for your reply, i had upgraded my QT and i still had the same issue, when i send one byte i don't receive any feedback from my device(readyRead is not triggered), it has to be more than one byte in order to receive something. do you please have any idea why is this happening?

                      J.HilkJ 1 Reply Last reply
                      0
                      • D DiaaQTdev

                        @J-Hilk Thank you for your reply, i had upgraded my QT and i still had the same issue, when i send one byte i don't receive any feedback from my device(readyRead is not triggered), it has to be more than one byte in order to receive something. do you please have any idea why is this happening?

                        J.HilkJ Online
                        J.HilkJ Online
                        J.Hilk
                        Moderators
                        wrote on last edited by
                        #18

                        @DiaaQTdev
                        Can you show your code?


                        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.

                        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