QSerialPort - readAll stops after CR
-
Dear all
If I read from serial port using readAll it stops after receiving a CR (\r). Device Monitoring Studio reads the following string:
24 30 37 37 0D 24 30 37 37 0D $077.$077.
requestData.append(cormet->readLine()); cormet->clear(); qDebug() << "All " << requestData;The qDebug() output is as follows:
All "$077\r"
All "$077\r"What can I do that the whole buffer is read without taking notice CR or LF since also data in binary (Modbus) format are transferred here (I have afterwards to determine the data format).
Thanks in advance.
Hans
-
Dear all
If I read from serial port using readAll it stops after receiving a CR (\r). Device Monitoring Studio reads the following string:
24 30 37 37 0D 24 30 37 37 0D $077.$077.
requestData.append(cormet->readLine()); cormet->clear(); qDebug() << "All " << requestData;The qDebug() output is as follows:
All "$077\r"
All "$077\r"What can I do that the whole buffer is read without taking notice CR or LF since also data in binary (Modbus) format are transferred here (I have afterwards to determine the data format).
Thanks in advance.
Hans
@hkottmann You are calling "readLine()" that just stops reading when find a CR.
-
I've just tried this too. But this here does the same:
requestData.append(cormet->readAll()); cormet->clear(); qDebug() << "All " << requestData;All "$077\r"
All "$077\r"Kind regards,
Hans
@hkottmann
readAll()does not "stop" after reading a\ror anything else. Review where you are calling this from (i.e. needs to bereadyRead()signal/slot). You must allow for received data arriving in multiple "chunks", regardless of how they might have been sent. -
I've just tried this too. But this here does the same:
requestData.append(cormet->readAll()); cormet->clear(); qDebug() << "All " << requestData;All "$077\r"
All "$077\r"Kind regards,
Hans