Show real code especially the place where you notice that you have received only 4 bytes.
Show real code especially the place where you notice that you have received only 4 bytes.
Maybe just use QIODevice::readAll()?
It will allocate the buffer as needed, so its length will be exactly the size of its content.
Cheers,
_
I mean the data stored in arr_cReadbuffer is ^MK1 instead of the nBytesReceived is 9
How did you determine that your code snippet doesn't show.
Again, using readAll() will give you both the check and the data in one go
Qt Code:
// check if there was data available if (data.count() > 0){ // do something with the data qDebug() << "received" << data.count() << "bytes"; }To copy to clipboard, switch view to plain text mode
Cheers,
_
Sure, if there is no data available, then nothing can be read.
The is like your bytesAvailable() check.
My suggestion was addressing the case when data is available.
Anyway, it might be helpful to see how you determine that you got less data than you expected.
All your snippet has so far is a log output that treats the data as an array of text characters.
Cheers,
_
But still while I use read data I am getting it as 9 bytes received
Show all of the code (method) performing the reading. Remember that the serial port does not know anything about the logic of your data (eg. That the package is 10 bytes).
P.S.
Read this thread.
Bookmarks