Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SerialPort Test
Qt 6.12 LTS is out! See what's new in the release blog

SerialPort Test

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 5.8k 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.
  • hskoglundH Offline
    hskoglundH Offline
    hskoglund
    wrote on last edited by
    #2

    Just guessing: but maybe try reducing the speed of your serial port.

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

      Hi,

      Depending on your Qt version, there was a problem with the blocking implementation. The usual way of using QSerialPort is the asynchronous mode.

      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
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #4

        My Qt version is 5.2.0, I will try asynchronous mode today. Wish it could solve this problem.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #5

          Hi, I had another problem now. When I use the asynchronous method like this
          @
          connect(cSerialPort,SIGNAL(readyRead()),this,SLOT(ReadData()));
          @
          Firstly, nothing happened in my program, there is no data received. Next I add
          a line like following
          @
          serialPort->waitForReadyRead(0);
          @
          My program can receive data. Is this usage appropriate?.

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

            Are you still using a loop anywhere in your code ?

            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
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

              Yes, I have a loop in "Read data" Slot function. They are like this
              @
              void worker::ReadData()
              {
              while(!serialPort->atEnd())
              DataReceive += serialPort->read(serialPort->bytesAvailable());
              }
              @
              The result still as same as synchronous mode. Byte and byte sometimes would delay a random time(0~15ms).

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

                Don't do it like that. Just call readAll and you'll get all what is currently available

                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
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #9

                  Hi, I modified it and tested again. This problem still was existing.... By the way, I used another language(C#) to implement function like I wrote by Qt. I never found this problem occurred. Is it a potential bug in using QSerialPort?

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

                    Can you show your complete test code ?

                    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
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #11

                      Sure, but it's a little big. Do you have e-mail? I can mail the project to you.

                      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