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. Serial Data "reading" disorder
Forum Update on Monday, May 27th 2025

Serial Data "reading" disorder

Scheduled Pinned Locked Moved General and Desktop
arduinoseriesbuffer
16 Posts 3 Posters 6.5k 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.
  • M mrjj
    24 Nov 2015, 20:52

    @ftsm
    Ah ok, yes if they can come out of order then same separator is not a option.

    -Each potentiometer can send 1 to 4 digits
    so maybe there comes 1 byte or maybe 4 ?

    F Offline
    F Offline
    ftsm
    wrote on 24 Nov 2015, 21:49 last edited by
    #7

    @mrjj Indeed. And so if I try ".append" I will have a huge disorder in datas ...
    I'm still trying to figure out a way to get everything in order but nothing work fine yet

    M 1 Reply Last reply 24 Nov 2015, 21:52
    0
    • F ftsm
      24 Nov 2015, 21:49

      @mrjj Indeed. And so if I try ".append" I will have a huge disorder in datas ...
      I'm still trying to figure out a way to get everything in order but nothing work fine yet

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 24 Nov 2015, 21:52 last edited by
      #8

      @ftsm
      but how does the potentiometer send its data ?
      you have no control over the format?

      F 1 Reply Last reply 24 Nov 2015, 22:03
      1
      • M mrjj
        24 Nov 2015, 21:52

        @ftsm
        but how does the potentiometer send its data ?
        you have no control over the format?

        F Offline
        F Offline
        ftsm
        wrote on 24 Nov 2015, 22:03 last edited by
        #9

        @mrjj The potentiometer send its data via Arduino. I can write how I want to send it. First I tried with "," to separate, but I could'nt reconize wich data was what. So I tried with a specific letter before and after each potentiometer value. In this case it is really hard for me to extract the potentiometer value from the line (from serial) because I only know the "split" technic

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 24 Nov 2015, 22:07 last edited by
          #10

          Mix both techniques: an ID to know what kind of data you have and the "special" char to know where to split.

          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 24 Nov 2015, 22:12
          1
          • S SGaist
            24 Nov 2015, 22:07

            Mix both techniques: an ID to know what kind of data you have and the "special" char to know where to split.

            F Offline
            F Offline
            ftsm
            wrote on 24 Nov 2015, 22:12 last edited by
            #11

            @SGaist Yes I think that is my best move, that's what I'm currently trying to do.
            But I have a last problem: how can I try the existence of a string from QstringList ? For example I need to know if after spliting "buffer_split[1]" exist ?

            M 1 Reply Last reply 24 Nov 2015, 22:18
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 24 Nov 2015, 22:15 last edited by
              #12

              You can use a while loop and take the first element at each iteration so no need for a particular check.

              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 25 Nov 2015, 00:17
              1
              • F ftsm
                24 Nov 2015, 22:12

                @SGaist Yes I think that is my best move, that's what I'm currently trying to do.
                But I have a last problem: how can I try the existence of a string from QstringList ? For example I need to know if after spliting "buffer_split[1]" exist ?

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 24 Nov 2015, 22:18 last edited by
                #13

                @ftsm
                also QstringList has a size() that tells the number of elements. (strings)
                That also gives hints to valid index.

                1 Reply Last reply
                1
                • S SGaist
                  24 Nov 2015, 22:15

                  You can use a while loop and take the first element at each iteration so no need for a particular check.

                  F Offline
                  F Offline
                  ftsm
                  wrote on 25 Nov 2015, 00:17 last edited by
                  #14

                  @SGaist @mrjj Thank you for that, I managed to split correctly and find the right data.
                  But I am still able to do that only on debug mode, when I try to run the program it's like i'm going too fast and my "->ReadAll()" don't gather enought data. (I saw that with some qDebug()).
                  So I go back to my first problem, if I use a while loop with "append" I will mix the data.
                  Can't I use "waitForReadyRead()" ?

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    ftsm
                    wrote on 25 Nov 2015, 00:25 last edited by
                    #15

                    OH MY GOD that was the solution since the begining !! It's 1:30am and it's perfectly working !!

                    THank you guys I love you so much !!

                    YAAaaaaaayyy my first beautiful program on Qt and it rules !! THANK YOU

                    M 1 Reply Last reply 25 Nov 2015, 05:13
                    0
                    • F ftsm
                      25 Nov 2015, 00:25

                      OH MY GOD that was the solution since the begining !! It's 1:30am and it's perfectly working !!

                      THank you guys I love you so much !!

                      YAAaaaaaayyy my first beautiful program on Qt and it rules !! THANK YOU

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 25 Nov 2015, 05:13 last edited by
                      #16

                      @ftsm
                      Congratulations with the baby ;)

                      1 Reply Last reply
                      0

                      16/16

                      25 Nov 2015, 05:13

                      • Login

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