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. why serial data write on one line on console in terminal example is in package of 3 or 4 characters with qDebug?
Forum Updated to NodeBB v4.3 + New Features

why serial data write on one line on console in terminal example is in package of 3 or 4 characters with qDebug?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 904 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.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by aha_1980
    #1

    hello, I want use serial data but when I write received data in file or qDebug with starting project example of Qt: terminal

        m_console->putData(data);
        QString DataAsString =QString(data);
        qDebug()<<DataAsString;
    

    I get result:

    ":T"
    "empe"
    "ratu"
    "re: "
    "18.8"
    "0:Hu"
    "midi"
    "ty: "
    "59.0"
    "0;\r"
    "\n"

    but on console I have
    :Temperature: 18.80:Humidity:59.00;

    thank you for your help

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

      Hi,

      How are you getting these data ?
      What console are you referring to ?

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

      F 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        How are you getting these data ?
        What console are you referring to ?

        F Offline
        F Offline
        filipdns
        wrote on last edited by
        #3

        @SGaist Hello, data is from arduino and console is from terminal sample of Qt

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

          qDebug() adds an carriage return when it's done while the terminal example might just concatenate all the data received.

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

          F 1 Reply Last reply
          3
          • SGaistS SGaist

            qDebug() adds an carriage return when it's done while the terminal example might just concatenate all the data received.

            F Offline
            F Offline
            filipdns
            wrote on last edited by
            #5

            @SGaist may be but when I when to add date and time to the data and save it to text file with QTextStream, I have date/time between package.. like example:

            :T05/05/19 23h55empe05/05/19 23h55ratu05/05/19 23h55re: 05/05/19 23h55:18.805/05/19 23h550:Hu05/05/19 23h55midi05/05/19 23h55ty:05/05/19 23h5559.005/05/19 23h550;

            it's that like the data is not send in one time but by package...

            aha_1980A 1 Reply Last reply
            0
            • F filipdns

              @SGaist may be but when I when to add date and time to the data and save it to text file with QTextStream, I have date/time between package.. like example:

              :T05/05/19 23h55empe05/05/19 23h55ratu05/05/19 23h55re: 05/05/19 23h55:18.805/05/19 23h550:Hu05/05/19 23h55midi05/05/19 23h55ty:05/05/19 23h5559.005/05/19 23h550;

              it's that like the data is not send in one time but by package...

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

              @filipdns

              it's that like the data is not send in one time but by package...

              Thats how serial lines work. As your data is line-based, you should use canReadLine() and readLine() from QSerialPort

              Regards

              Qt has to stay free or it will die.

              F 1 Reply Last reply
              7
              • aha_1980A aha_1980

                @filipdns

                it's that like the data is not send in one time but by package...

                Thats how serial lines work. As your data is line-based, you should use canReadLine() and readLine() from QSerialPort

                Regards

                F Offline
                F Offline
                filipdns
                wrote on last edited by
                #7

                @aha_1980 to solve to issue, I switch from 9600 bauds to 115200 and problem fixed...

                JonBJ 1 Reply Last reply
                0
                • F filipdns

                  @aha_1980 to solve to issue, I switch from 9600 bauds to 115200 and problem fixed...

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by
                  #8

                  @filipdns
                  It's up to you if you decide that marks your problem as Solved. However, switching to a faster speed can hardly address whatever your issue is, which is presumably a timing one. Beware that you do not find the problem arises again, as presumably it will if the data does not arrive fast enough even though you've upped the speed. As @aha_1980 said, I would have thought you need to correctly address when you read how much.....

                  F 1 Reply Last reply
                  2
                  • JonBJ JonB

                    @filipdns
                    It's up to you if you decide that marks your problem as Solved. However, switching to a faster speed can hardly address whatever your issue is, which is presumably a timing one. Beware that you do not find the problem arises again, as presumably it will if the data does not arrive fast enough even though you've upped the speed. As @aha_1980 said, I would have thought you need to correctly address when you read how much.....

                    F Offline
                    F Offline
                    filipdns
                    wrote on last edited by
                    #9

                    @JonB Hi Jon, you are right, I jumped over the solution of @aha_1980 while(m_serial->canReadLine()) {} and this one work at 9600, then, I think that can solve really the problem

                    1 Reply Last reply
                    2

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved