removed waitForBytesWritten()

This commit is contained in:
Gerhard Hoffmann 2024-10-15 12:44:56 +02:00
parent 209132054f
commit 4c770349bf

View File

@ -47,7 +47,7 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength)
int bytesToWrite = buffer.size(); int bytesToWrite = buffer.size();
while (bytesToWrite > 0 && !buffer.isEmpty()) { while (bytesToWrite > 0 && !buffer.isEmpty()) {
int bytesWritten = CatSerial->write(buffer); int bytesWritten = CatSerial->write(buffer);
if (bytesWritten != -1 && CatSerial->waitForBytesWritten(1000)) { if (bytesWritten != -1) {
bytesToWrite -= bytesWritten; bytesToWrite -= bytesWritten;
buffer = buffer.right(bytesWritten); buffer = buffer.right(bytesWritten);
} else { } else {
@ -67,13 +67,14 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength)
<< "ERROR sending" << data.toHex(':') << "port is not open"; << "ERROR sending" << data.toHex(':') << "port is not open";
} }
} else { } else {
qCritical() << __func__ << "" << __LINE__ << "ERROR detected active read cmd" << readCmds[0]; qCritical() << __func__ << "" << __LINE__ << errorCnt << "ERROR about to send cmd" << QString("0x%1").arg((unsigned char)data.constData()[2], 0, 16);
qCritical() << __func__ << "" << __LINE__ << errorCnt << "ERROR detected active read cmds" << readCmds;
if (CatSerial->isOpen()) { if (CatSerial->isOpen()) {
int availableBytes = CatSerial->bytesAvailable(); int availableBytes = CatSerial->bytesAvailable();
qCritical() << __func__ << "" << __LINE__ << "ERROR available bytes" << availableBytes; qCritical() << __func__ << "" << __LINE__ << "ERROR available bytes" << availableBytes;
if (availableBytes == 0) { if (availableBytes == 0) {
errorCnt += 1; errorCnt += 1;
if (errorCnt > 100) { if (errorCnt > 20) {
readCmds.clear(); readCmds.clear();
errorCnt = 0; errorCnt = 0;
} }