Remove unnecessary initial read and reduce timeout

This commit is contained in:
BlackMark 2020-07-04 22:39:37 +02:00
parent dad6f0835f
commit 6c50eb6f84

View File

@ -109,15 +109,12 @@ bool SensorDriver::getSensorCommandResponse(const QString& serialPortName, QByte
.arg(serialPort.errorString()));
return false;
}
else if(!serialPort.waitForBytesWritten(1000)) {
else if(!serialPort.waitForBytesWritten(500)) {
qCritical(ltr("Writing operation timed out for serial port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()));
return false;
}
response = serialPort.readAll();
qDebug(ltr("Read %1 bytes from serial port %2").arg(response.size()).arg(serialPortName));
while(serialPort.waitForReadyRead(1000)) {
while(serialPort.waitForReadyRead(500)) {
const auto newData = serialPort.readAll();
qDebug(ltr("Read additional %1 bytes from serial port %2").arg(newData.size()).arg(serialPortName));
response.append(newData);