Serial Data "reading" disorder
-
@mrjj Thank you.
I used differents letters as separator because i wanted to reconize each data. Indeed I can just use one separator but it means that I have to gather all the data in the good order.
".append" seams like a good way but my problem is that I can't know the size of my expected bytes. Each potentiometer can send 1 to 4 digits. I assume there are already solutions for that, but I don't know what ... -
@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 ? -
@ftsm
but how does the potentiometer send its data ?
you have no control over the format? -
@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
-
Mix both techniques: an ID to know what kind of data you have and the "special" char to know where to split.
-
@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 ? -
You can use a while loop and take the first element at each iteration so no need for a particular check.
-
@ftsm
also QstringList has a size() that tells the number of elements. (strings)
That also gives hints to valid index. -
@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()" ? -
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
-
@ftsm
Congratulations with the baby ;)
14/16