Wrong data when reading from serial port
-
ok I use qSort similar The sort algorithm is efficient on large data sets. It operates in linear-logarithmic time, O(n log n).
But I have one more question when I fast read serial port I get
"042GGHHIIJJ\r86D8102730DF38AEDDFD1"
it's correct data buffer:
"86D8102730DF38AEDDFD1042GGHHIIJJ\r"
I use this function
data = serialPort->read(33); //read buffer
[Edit: forked as this is a whole new topic ~~ @Wieland]
-
Hi,
From the looks of it, you are receiving the same frame several times one after the other. You are reading the serial port as if it was a file but it's not. You'll be getting data when they arrive, your application might not receive a frame when it starts listening to the serial port so it's up to you to devise a way to know when you did in fact get a full frame e.g. size of data and
\r
being the last character.
-
I know but how I'm supposed to know when data frame is ready?
-
You know the device and the protocol. From what you wrote it looks like you need to have retrieved a frame once you have at least 33 chars which last one is
\r
.