From 9daa5e17cbc59784a3f4c9fafa3af154c031bbc1 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 09:54:09 +0200 Subject: [PATCH 01/19] Introduce a vector of commands currently sent to device controller. --- include/com.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/com.h b/include/com.h index 0cee78d..379d739 100644 --- a/include/com.h +++ b/include/com.h @@ -7,6 +7,7 @@ //#include #include #include +#include #include "tslib.h" #include "controlBus.h" #include "interfaces.h" @@ -32,6 +33,10 @@ class T_com : public QObject //, public QPlainTextEdit // QSerialPort *CatSerial = nullptr; QSerialPort *CatSerial; + QVector readCmds; // list of active commands sent to DC + + + //char oeffneSerialPort(); char open_Serial_Port(); void closeSerialPort(); @@ -61,6 +66,9 @@ public: bool readFromSerial(QByteArray &data, uint16_t &sendLength); // retval: true: data available + QVector &getReadCmds() { return readCmds; } + QVector const &getReadCmds() const { return readCmds; } + /* uint8_t getAllPortPins(void); // rs232pins: all signals bitwise coded in one byte: From 6321f9068fb1bc7f05fcb4e0e1330d70a8514b8b Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 09:57:49 +0200 Subject: [PATCH 02/19] Add helpers getReadSource() getSerialPort(). --- include/prot.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/prot.h b/include/prot.h index 36ca14c..fa059d3 100644 --- a/include/prot.h +++ b/include/prot.h @@ -122,6 +122,9 @@ public: uint8_t *RdDlen, uint8_t *receivedData); // retval: data valid, only one time true + uint16_t getReadSource() { return readSource; } // readSource contains last command sent to device controller + T_com *getSerialPort() { return mySerialPort; } // utility function + signals: void framerecieved(); //bool gotINdata); From 26a11e6c56f97a2dae0bb1cbb730f2c2bd27da9d Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 10:00:34 +0200 Subject: [PATCH 03/19] writeToSerial(): Only write to serial interface if no current command has been sent to DC already. --- src/com.cpp | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/src/com.cpp b/src/com.cpp index b89119d..d77c303 100644 --- a/src/com.cpp +++ b/src/com.cpp @@ -20,13 +20,48 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) { sendBuffer=data; sendLen=sendLength; - if (CatSerial->isOpen()) - { - //qDebug() << "sending..." << sendBuffer; - CatSerial->write(sendBuffer); - } else - qDebug() << "error sending, port is not open"; + if (readCmds.size() == 0) { // no other read command active + if (CatSerial->isOpen()) + { + if (CatSerial->error() != QSerialPort::NoError) { + qCritical() << __func__ << "" << __LINE__ << "ERROR on serial line" << CatSerial->errorString(); + CatSerial->clearError(); + qCritical() << __func__ << "" << __LINE__ << "cleared error on serial line"; + } + + if (!CatSerial->atEnd()) { + qCritical() << QString("ERROR %1 bytes available on serial line before write").arg(CatSerial->bytesAvailable()); + qCritical() << CatSerial->readAll().toHex(':'); + CatSerial->clear(); + qCritical() << __func__ << "" << __LINE__ << "read all data from serial line"; + } + + QByteArray buffer(data); + + int bytesToWrite = buffer.size(); + while (bytesToWrite > 0 && !buffer.isEmpty()) { + int bytesWritten = CatSerial->write(buffer); + if (bytesWritten != -1 && CatSerial->waitForBytesWritten(1000)) { + bytesToWrite -= bytesWritten; + buffer = buffer.right(bytesWritten); + } else { + qCritical() << __func__ << ":" << __LINE__ + << QString("ERROR %1 for sending %2").arg(CatSerial->errorString()).arg(data.toHex(':').constData()); + CatSerial->clearError(); + qCritical() << __func__ << ":" << __LINE__ << "cleared error on serial line. returning ..."; + return; + } + } + readCmds.append(data.constData()[2]); + } else { + qCritical() << __func__ << ":" << __LINE__ + << "ERROR sending" << data.toHex(':') << "port is not open"; + } + } else { + qCritical() << __func__ << "" << __LINE__ << "ERROR detected active read cmd" << readCmds[0]; + readCmds.clear(); + } } From 900b0ef952d0fc6100aefd1a8f12f9775217f00b Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 10:04:40 +0200 Subject: [PATCH 04/19] loadRecDataFromFrame(): Read last message if only one command to device controller is active. Otherwise assume that the data is obsolete. Trigger the sending of a known test-response to find new valid data-stream. --- src/datIf.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/datIf.cpp b/src/datIf.cpp index 25e4365..ea18f4e 100755 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -6,6 +6,7 @@ History: */ #include "datIf.h" +#include "hwapi.h" #include "sendWRcmd.h" #include "controlBus.h" #include "storeINdata.h" @@ -513,6 +514,8 @@ char T_datif::loadRecDataFromFrame() return 0; } + memset(receivedData, 0x00, sizeof(receivedData)); + ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData); // nur true wenn CommandState OK und readState OK @@ -545,6 +548,37 @@ char T_datif::loadRecDataFromFrame() gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi) + if (myDCIF && myDCIF->getSerialPort()) { + QVector &readCmds = myDCIF->getSerialPort()->getReadCmds(); + + if (readCmds.size() == 1) { + if (readSource == myDCIF->getReadSource() && readSource == readCmds[0]) { + if (waitForTestResponse) { + if (readCmds[0] == CMD2DC_TestSerial) { + if (QString(QByteArray((char const *)receivedData, RdDleng)) == "< SlaveResponse") { + waitForTestResponse = false; + ((hwapi *)parent())->dc_autoRequest(true); + } + } + } + readCmds.clear(); + } else { + qCritical() << __func__ << ":" << __LINE__ << ":" << readSource << myDCIF->getReadSource() << readCmds[0]; + qCritical() << __func__ << ":" << __LINE__ << ":" << QByteArray((char const *)receivedData, RdDleng).toHex(':'); + readCmds.clear(); + return 0; + } + } else { + readCmds.clear(); + if (parent()) { + waitForTestResponse = true; + ((hwapi *)parent())->dc_autoRequest(false); + ((hwapi *)parent())->dc_requTestResponse(); + } + return 0; + } + } + // uint8_t nn; //qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress // << " rdlen:" << RdDleng; From 36a8f07069c08dccadaf10f6d5b63f9dbe52a0a5 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 10:07:29 +0200 Subject: [PATCH 05/19] Pass "this" as parent --- src/hwapi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hwapi.cpp b/src/hwapi.cpp index 69d561a..ee32e98 100755 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -56,7 +56,7 @@ hwapi::hwapi(QObject *parent) : QObject(parent) #error "SLAVE LIB COMPILED INTO MASTER" #endif - myDatif = new T_datif(); // für die CAslave-Lib auskommentieren! + myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren! #endif From 08bb513c7b3eaa6db00b85998c62a5c89582d871 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 10:08:11 +0200 Subject: [PATCH 06/19] Minor: set recBuf to a definite value --- src/prot.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/prot.cpp b/src/prot.cpp index ca1e397..e242690 100755 --- a/src/prot.cpp +++ b/src/prot.cpp @@ -368,6 +368,9 @@ uint8_t recBuffer[FRAME_MAXLEN]; // read from "VCP": mySerialPort->readFromSerial(Indata, recLength); //qDebug()<<"prot: got data " << recLength; + + memset(recBuffer, 0x00, sizeof(recBuffer)); + if (recLength>FRAME_MAXLEN) recLength=FRAME_MAXLEN; for (int nn=0; nn Date: Tue, 15 Oct 2024 10:08:49 +0200 Subject: [PATCH 07/19] Minor: add waitForTestResponse --- include/datIf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/datIf.h b/include/datIf.h index 566f068..c030f71 100644 --- a/include/datIf.h +++ b/include/datIf.h @@ -168,6 +168,8 @@ class T_datif : public QObject QTimer *datif_trigger; uint8_t selectedSlaveAddr; + bool waitForTestResponse = false; + private slots: char datif_cycleSend(); void StoredRecData(); From 0f7ab3c71ca525c8b1d4bc9d22bd4886f2a9c4da Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 10:49:30 +0200 Subject: [PATCH 08/19] Minor: adding comments --- src/datIf.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/datIf.cpp b/src/datIf.cpp index ea18f4e..8a5b675 100755 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -551,26 +551,40 @@ char T_datif::loadRecDataFromFrame() if (myDCIF && myDCIF->getSerialPort()) { QVector &readCmds = myDCIF->getSerialPort()->getReadCmds(); - if (readCmds.size() == 1) { + if (readCmds.size() == 1) { // there can be only one command been sent to the DC + // the command number active at the moment must be the same as the saved one if (readSource == myDCIF->getReadSource() && readSource == readCmds[0]) { + // maybe we have sent a explicit request for a test-response if (waitForTestResponse) { if (readCmds[0] == CMD2DC_TestSerial) { if (QString(QByteArray((char const *)receivedData, RdDleng)) == "< SlaveResponse") { waitForTestResponse = false; - ((hwapi *)parent())->dc_autoRequest(true); + qCritical() << __func__ << ":" << __LINE__ << "turn on auto-request"; + ((hwapi *)parent())->dc_autoRequest(true); // return autorequest to true + } else { + qCritical() << __func__ << ":" << __LINE__ << "received wrong test-response" + << QString(QByteArray((char const *)receivedData, RdDleng)); } } + } else { + // usual handling of response } readCmds.clear(); - } else { + } else { // error qCritical() << __func__ << ":" << __LINE__ << ":" << readSource << myDCIF->getReadSource() << readCmds[0]; qCritical() << __func__ << ":" << __LINE__ << ":" << QByteArray((char const *)receivedData, RdDleng).toHex(':'); readCmds.clear(); return 0; } } else { + // error: read commands has not size 1 as it should be: turn off + // auto requests and send explicit request for test-response: + // once this response has been received, turn on the autmatic requests + // again. readCmds.clear(); if (parent()) { + qCritical() << __func__ << ":" << __LINE__ << "turn off auto-request"; + qCritical() << __func__ << ":" << __LINE__ << "send request for test-response"; waitForTestResponse = true; ((hwapi *)parent())->dc_autoRequest(false); ((hwapi *)parent())->dc_requTestResponse(); From 209132054f94d56b9521b620a38b42036cd6863e Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 10:51:20 +0200 Subject: [PATCH 09/19] Added sanity check if there is a command active but no data can be read on the serial line --- src/com.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/com.cpp b/src/com.cpp index d77c303..91f2982 100644 --- a/src/com.cpp +++ b/src/com.cpp @@ -21,7 +21,12 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) sendBuffer=data; sendLen=sendLength; - if (readCmds.size() == 0) { // no other read command active + // logic: exactly one command is sent to DC. no other command can be sent + // until the respond has been read from the serial line. + + static int errorCnt = 0; + + if (readCmds.size() == 0) { // no other read command active: ok if (CatSerial->isOpen()) { if (CatSerial->error() != QSerialPort::NoError) { @@ -53,14 +58,32 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) return; } } - readCmds.append(data.constData()[2]); + + // save last command sent. + readCmds.append(data.constData()[2]); // 2: index of the last command + } else { qCritical() << __func__ << ":" << __LINE__ << "ERROR sending" << data.toHex(':') << "port is not open"; } } else { - qCritical() << __func__ << "" << __LINE__ << "ERROR detected active read cmd" << readCmds[0]; - readCmds.clear(); + qCritical() << __func__ << "" << __LINE__ << "ERROR detected active read cmd" << readCmds[0]; + if (CatSerial->isOpen()) { + int availableBytes = CatSerial->bytesAvailable(); + qCritical() << __func__ << "" << __LINE__ << "ERROR available bytes" << availableBytes; + if (availableBytes == 0) { + errorCnt += 1; + if (errorCnt > 100) { + readCmds.clear(); + errorCnt = 0; + } + } else { + errorCnt = 0; + } + } else { + qCritical() << __func__ << ":" << __LINE__ + << "ERROR sending" << data.toHex(':') << "port is not open"; + } } } From 4c770349bf75a3ea6f32e9ef208eb538953ddd7b Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 12:44:56 +0200 Subject: [PATCH 10/19] removed waitForBytesWritten() --- src/com.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com.cpp b/src/com.cpp index 91f2982..859717a 100644 --- a/src/com.cpp +++ b/src/com.cpp @@ -47,7 +47,7 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) int bytesToWrite = buffer.size(); while (bytesToWrite > 0 && !buffer.isEmpty()) { int bytesWritten = CatSerial->write(buffer); - if (bytesWritten != -1 && CatSerial->waitForBytesWritten(1000)) { + if (bytesWritten != -1) { bytesToWrite -= bytesWritten; buffer = buffer.right(bytesWritten); } else { @@ -67,13 +67,14 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) << "ERROR sending" << data.toHex(':') << "port is not open"; } } 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()) { int availableBytes = CatSerial->bytesAvailable(); qCritical() << __func__ << "" << __LINE__ << "ERROR available bytes" << availableBytes; if (availableBytes == 0) { errorCnt += 1; - if (errorCnt > 100) { + if (errorCnt > 20) { readCmds.clear(); errorCnt = 0; } From ca2d9e1b5a1623d68ce651eb3261d5fcf1a402a9 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 15 Oct 2024 12:45:38 +0200 Subject: [PATCH 11/19] Minor: added debug output in error case --- src/datIf.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/datIf.cpp b/src/datIf.cpp index 8a5b675..9ef3efa 100755 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -556,23 +556,27 @@ char T_datif::loadRecDataFromFrame() if (readSource == myDCIF->getReadSource() && readSource == readCmds[0]) { // maybe we have sent a explicit request for a test-response if (waitForTestResponse) { + qCritical() << __func__ << ":" << __LINE__ << "turn on auto-request"; if (readCmds[0] == CMD2DC_TestSerial) { if (QString(QByteArray((char const *)receivedData, RdDleng)) == "< SlaveResponse") { waitForTestResponse = false; qCritical() << __func__ << ":" << __LINE__ << "turn on auto-request"; ((hwapi *)parent())->dc_autoRequest(true); // return autorequest to true } else { - qCritical() << __func__ << ":" << __LINE__ << "received wrong test-response" + qCritical() << __func__ << ":" << __LINE__ << "ERROR received wrong test-response" << QString(QByteArray((char const *)receivedData, RdDleng)); } } } else { // usual handling of response + // qCritical() << __func__ << ":" << __LINE__ << ":" << readSource << myDCIF->getReadSource() << readCmds[0]; + // qCritical() << __func__ << ":" << __LINE__ << ":" << QByteArray((char const *)receivedData, RdDleng).toHex(':'); } readCmds.clear(); } else { // error - qCritical() << __func__ << ":" << __LINE__ << ":" << readSource << myDCIF->getReadSource() << readCmds[0]; - qCritical() << __func__ << ":" << __LINE__ << ":" << QByteArray((char const *)receivedData, RdDleng).toHex(':'); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR " << readSource << myDCIF->getReadSource() << readCmds[0]; + qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << QString(", ignore data for cmd 0x%1").arg(readCmds[0], 0, 16) + << QByteArray((char const *)receivedData, RdDleng).toHex(':'); readCmds.clear(); return 0; } @@ -583,8 +587,8 @@ char T_datif::loadRecDataFromFrame() // again. readCmds.clear(); if (parent()) { - qCritical() << __func__ << ":" << __LINE__ << "turn off auto-request"; - qCritical() << __func__ << ":" << __LINE__ << "send request for test-response"; + qCritical() << __func__ << ":" << __LINE__ << "ERROR turn off auto-request"; + qCritical() << __func__ << ":" << __LINE__ << "ERROR send request for test-response"; waitForTestResponse = true; ((hwapi *)parent())->dc_autoRequest(false); ((hwapi *)parent())->dc_requTestResponse(); From d540f1b467064af143b1cadd6bac810d66ba136f Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 16 Oct 2024 13:01:41 +0200 Subject: [PATCH 12/19] Use writeCount instaed of readCmds. --- include/com.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/com.h b/include/com.h index 379d739..1684b80 100644 --- a/include/com.h +++ b/include/com.h @@ -33,9 +33,7 @@ class T_com : public QObject //, public QPlainTextEdit // QSerialPort *CatSerial = nullptr; QSerialPort *CatSerial; - QVector readCmds; // list of active commands sent to DC - - + uint32_t writeCount = 0; //char oeffneSerialPort(); char open_Serial_Port(); @@ -66,8 +64,7 @@ public: bool readFromSerial(QByteArray &data, uint16_t &sendLength); // retval: true: data available - QVector &getReadCmds() { return readCmds; } - QVector const &getReadCmds() const { return readCmds; } + uint32_t getWriteCount() { return writeCount; } /* uint8_t getAllPortPins(void); From ff746a45bc2bde25982dd62888107ffc400af165 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 16 Oct 2024 13:02:27 +0200 Subject: [PATCH 13/19] Use readCount to track number of read messages. --- include/datIf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/datIf.h b/include/datIf.h index c030f71..ede2918 100644 --- a/include/datIf.h +++ b/include/datIf.h @@ -169,6 +169,7 @@ class T_datif : public QObject uint8_t selectedSlaveAddr; bool waitForTestResponse = false; + uint32_t readCount = 0; private slots: char datif_cycleSend(); From 87bc5b5c1e6558bd011f28690651a2f907010e1e Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 16 Oct 2024 13:03:20 +0200 Subject: [PATCH 14/19] writeToSerial(): Always write next message. Set writeCount. Clear() serial line before sending. Flush() serial line after sending. --- src/com.cpp | 97 ++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 57 deletions(-) diff --git a/src/com.cpp b/src/com.cpp index 859717a..4be8ae7 100644 --- a/src/com.cpp +++ b/src/com.cpp @@ -1,5 +1,6 @@ #include "com.h" #include +#include //#include "controlBus.h" ////////////////////////////////////////////////////////////////////////////////// @@ -24,67 +25,48 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) // logic: exactly one command is sent to DC. no other command can be sent // until the respond has been read from the serial line. - static int errorCnt = 0; - - if (readCmds.size() == 0) { // no other read command active: ok - if (CatSerial->isOpen()) - { - if (CatSerial->error() != QSerialPort::NoError) { - qCritical() << __func__ << "" << __LINE__ << "ERROR on serial line" << CatSerial->errorString(); - CatSerial->clearError(); - qCritical() << __func__ << "" << __LINE__ << "cleared error on serial line"; - } - - if (!CatSerial->atEnd()) { - qCritical() << QString("ERROR %1 bytes available on serial line before write").arg(CatSerial->bytesAvailable()); - qCritical() << CatSerial->readAll().toHex(':'); - CatSerial->clear(); - qCritical() << __func__ << "" << __LINE__ << "read all data from serial line"; - } - - QByteArray buffer(data); - - int bytesToWrite = buffer.size(); - while (bytesToWrite > 0 && !buffer.isEmpty()) { - int bytesWritten = CatSerial->write(buffer); - if (bytesWritten != -1) { - bytesToWrite -= bytesWritten; - buffer = buffer.right(bytesWritten); - } else { - qCritical() << __func__ << ":" << __LINE__ - << QString("ERROR %1 for sending %2").arg(CatSerial->errorString()).arg(data.toHex(':').constData()); - CatSerial->clearError(); - qCritical() << __func__ << ":" << __LINE__ << "cleared error on serial line. returning ..."; - return; - } - } - - // save last command sent. - readCmds.append(data.constData()[2]); // 2: index of the last command - - } else { - qCritical() << __func__ << ":" << __LINE__ - << "ERROR sending" << data.toHex(':') << "port is not open"; + if (CatSerial->isOpen()) { + if (CatSerial->error() != QSerialPort::NoError) { + qCritical() << __func__ << "" << __LINE__ << "ERROR on serial line" << CatSerial->errorString(); + CatSerial->clearError(); + qCritical() << __func__ << "" << __LINE__ << "cleared error on serial line"; } - } else { - 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()) { - int availableBytes = CatSerial->bytesAvailable(); - qCritical() << __func__ << "" << __LINE__ << "ERROR available bytes" << availableBytes; - if (availableBytes == 0) { - errorCnt += 1; - if (errorCnt > 20) { - readCmds.clear(); - errorCnt = 0; - } + + if (!CatSerial->atEnd()) { + qCritical() << QString("ERROR %1 bytes available on serial line before write").arg(CatSerial->bytesAvailable()); + qCritical() << CatSerial->readAll().toHex(':'); + CatSerial->clear(); + qCritical() << __func__ << "" << __LINE__ << "read all data from serial line"; + } + + CatSerial->clear(); + + QByteArray buffer(data); + int bytesToWrite = buffer.size(); + while (bytesToWrite > 0 && !buffer.isEmpty()) { + int bytesWritten = CatSerial->write(buffer); + if (bytesWritten != -1) { + bytesToWrite -= bytesWritten; + buffer = buffer.right(bytesWritten); } else { - errorCnt = 0; + qCritical() << __func__ << ":" << __LINE__ + << QString("ERROR %1 for sending %2").arg(CatSerial->errorString()).arg(data.toHex(':').constData()); + CatSerial->clearError(); + qCritical() << __func__ << ":" << __LINE__ << "cleared error on serial line. returning ..."; + return; } - } else { - qCritical() << __func__ << ":" << __LINE__ - << "ERROR sending" << data.toHex(':') << "port is not open"; } + + CatSerial->flush(); + writeCount += 1; + + // only for debugging + // qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) + // << "write cmd" << (unsigned int)data.constData()[2]; + + } else { + qCritical() << __func__ << ":" << __LINE__ + << "ERROR sending" << data.toHex(':') << "port is not open"; } } @@ -141,6 +123,7 @@ T_com::T_com(QObject *parent) : QObject(parent) ChkConnectTimer->setSingleShot(false); ChkConnectTimer->start(100); // in ms com_want2read=0; + writeCount = 0; } From 8714071a30f0f224d3282e8b118647b933c95fbd Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 16 Oct 2024 13:06:07 +0200 Subject: [PATCH 15/19] loadRecDataFromFrame(): When reading next message, check readCount + 1 == writeCount. If not, there must be something wrong: ignore this message and set readCount <- writeCount. --- src/datIf.cpp | 57 +++++++++++++++------------------------------------ 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/src/datIf.cpp b/src/datIf.cpp index 9ef3efa..0b470da 100755 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -11,6 +11,7 @@ History: #include "controlBus.h" #include "storeINdata.h" #include +#include #include #include @@ -125,6 +126,7 @@ T_datif::T_datif(QObject *parent) : QObject(parent) datif_pNextCmd=0; datif_sendSlowCmd=0; + readCount = 0; } void T_datif::resetChain(void) @@ -549,50 +551,25 @@ char T_datif::loadRecDataFromFrame() gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi) if (myDCIF && myDCIF->getSerialPort()) { - QVector &readCmds = myDCIF->getSerialPort()->getReadCmds(); - - if (readCmds.size() == 1) { // there can be only one command been sent to the DC - // the command number active at the moment must be the same as the saved one - if (readSource == myDCIF->getReadSource() && readSource == readCmds[0]) { - // maybe we have sent a explicit request for a test-response - if (waitForTestResponse) { - qCritical() << __func__ << ":" << __LINE__ << "turn on auto-request"; - if (readCmds[0] == CMD2DC_TestSerial) { - if (QString(QByteArray((char const *)receivedData, RdDleng)) == "< SlaveResponse") { - waitForTestResponse = false; - qCritical() << __func__ << ":" << __LINE__ << "turn on auto-request"; - ((hwapi *)parent())->dc_autoRequest(true); // return autorequest to true - } else { - qCritical() << __func__ << ":" << __LINE__ << "ERROR received wrong test-response" - << QString(QByteArray((char const *)receivedData, RdDleng)); - } - } - } else { - // usual handling of response - // qCritical() << __func__ << ":" << __LINE__ << ":" << readSource << myDCIF->getReadSource() << readCmds[0]; - // qCritical() << __func__ << ":" << __LINE__ << ":" << QByteArray((char const *)receivedData, RdDleng).toHex(':'); - } - readCmds.clear(); - } else { // error - qCritical() << __func__ << ":" << __LINE__ << ": ERROR " << readSource << myDCIF->getReadSource() << readCmds[0]; - qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << QString(", ignore data for cmd 0x%1").arg(readCmds[0], 0, 16) + uint32_t writeCount = myDCIF->getSerialPort()->getWriteCount(); + if ((readCount + 1) == writeCount) { // there can be only one command sent to the DC + readCount = writeCount; + if (readSource != myDCIF->getReadSource()) { + qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << ", ignore data" << QByteArray((char const *)receivedData, RdDleng).toHex(':'); - readCmds.clear(); + qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource(); return 0; + } else { + // only for debugging + // qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << readSource << myDCIF->getReadSource(); } } else { - // error: read commands has not size 1 as it should be: turn off - // auto requests and send explicit request for test-response: - // once this response has been received, turn on the autmatic requests - // again. - readCmds.clear(); - if (parent()) { - qCritical() << __func__ << ":" << __LINE__ << "ERROR turn off auto-request"; - qCritical() << __func__ << ":" << __LINE__ << "ERROR send request for test-response"; - waitForTestResponse = true; - ((hwapi *)parent())->dc_autoRequest(false); - ((hwapi *)parent())->dc_requTestResponse(); - } + qCritical() << __func__ << ":" << __LINE__ << QString(": ERROR readCount + 1 != writeCount: %1 != %2").arg(readCount + 1).arg(writeCount); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << ", ignore data" + << QByteArray((char const *)receivedData, RdDleng).toHex(':'); + qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource(); + + readCount = writeCount; return 0; } } From b024e34b82c75a41ec0a5911e4ea8ea0e65fed2c Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 16 Oct 2024 13:21:33 +0200 Subject: [PATCH 16/19] writeToSerial(): Write to serial line in one call as before. --- src/com.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/com.cpp b/src/com.cpp index 4be8ae7..51163bc 100644 --- a/src/com.cpp +++ b/src/com.cpp @@ -42,19 +42,13 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) CatSerial->clear(); QByteArray buffer(data); - int bytesToWrite = buffer.size(); - while (bytesToWrite > 0 && !buffer.isEmpty()) { - int bytesWritten = CatSerial->write(buffer); - if (bytesWritten != -1) { - bytesToWrite -= bytesWritten; - buffer = buffer.right(bytesWritten); - } else { - qCritical() << __func__ << ":" << __LINE__ - << QString("ERROR %1 for sending %2").arg(CatSerial->errorString()).arg(data.toHex(':').constData()); - CatSerial->clearError(); - qCritical() << __func__ << ":" << __LINE__ << "cleared error on serial line. returning ..."; - return; - } + int bytesWritten = CatSerial->write(buffer); + if (bytesWritten == -1) { + qCritical() << __func__ << ":" << __LINE__ + << QString("ERROR %1 for sending %2").arg(CatSerial->errorString()).arg(data.toHex(':').constData()); + CatSerial->clearError(); + qCritical() << __func__ << ":" << __LINE__ << "cleared error on serial line. returning ..."; + return; } CatSerial->flush(); From 5c9578ebefdabd9c437a7eb04f49dd8dcebee9f2 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 17 Oct 2024 12:40:37 +0200 Subject: [PATCH 17/19] Minor: debug output (commented out) --- src/com.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com.cpp b/src/com.cpp index 51163bc..a72ee4f 100644 --- a/src/com.cpp +++ b/src/com.cpp @@ -55,9 +55,10 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) writeCount += 1; // only for debugging - // qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) - // << "write cmd" << (unsigned int)data.constData()[2]; - + // if ((unsigned int)data.constData()[2] == 31) { // request dynamic data + // qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) + // << "write cmd" << (unsigned int)data.constData()[2]; + //} } else { qCritical() << __func__ << ":" << __LINE__ << "ERROR sending" << data.toHex(':') << "port is not open"; From 1cc14e9a4c1116465224ed826e9c1dc8d4592b2e Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 17 Oct 2024 12:41:31 +0200 Subject: [PATCH 18/19] Add some debug out-put (in error case). --- src/datIf.cpp | 155 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 1 deletion(-) diff --git a/src/datIf.cpp b/src/datIf.cpp index 0b470da..a9f0b29 100755 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -483,6 +483,76 @@ void T_datif::StoredRecData() gpi_storeLastResult(res); } +static void dump(T_moduleCondition const *modCond) { + qCritical() << QString("modCond->ram %1 (%2)").arg(modCond->ram).arg(modCond->ram, 0, 16); + qCritical() << QString("modCond->intEe %1 (%2)").arg(modCond->intEe).arg(modCond->intEe, 0, 16); + qCritical() << QString("modCond->extEe %1 (%2)").arg(modCond->extEe).arg(modCond->extEe, 0, 16); + qCritical() << QString("modCond->rtc %1 (%2)").arg(modCond->rtc).arg(modCond->rtc, 0, 16); + qCritical() << QString("modCond->boardHw %1 (%2)").arg(modCond->boardHw).arg(modCond->boardHw, 0, 16); + qCritical() << QString("modCond->printer %1 (%2)").arg(modCond->printer).arg(modCond->printer, 0, 16); + qCritical() << QString("modCond->modem %1 (%2)").arg(modCond->modem).arg(modCond->modem, 0, 16); + qCritical() << QString("modCond->signal %1 (%2)").arg(modCond->signal).arg(modCond->signal, 0, 16); + + qCritical() << QString("modCond->regist %1 (%2)").arg(modCond->regist).arg(modCond->regist, 0, 16); + qCritical() << QString("modCond->mdbBus %1 (%2)").arg(modCond->mdbBus).arg(modCond->mdbBus, 0, 16); + qCritical() << QString("modCond->coinChecker %1 (%2)").arg(modCond->coinChecker).arg(modCond->coinChecker, 0, 16); + qCritical() << QString("modCond->coinEscrow %1 (%2)").arg(modCond->coinEscrow).arg(modCond->coinEscrow, 0, 16); + + qCritical() << QString("modCond->mifareReader %1 (%2)").arg(modCond->mifareReader).arg(modCond->mifareReader, 0, 16); + qCritical() << QString("modCond->creditTerm %1 (%2)").arg(modCond->creditTerm).arg(modCond->creditTerm, 0, 16); + qCritical() << QString("modCond->coinReject %1 (%2)").arg(modCond->coinReject).arg(modCond->coinReject, 0, 16); + qCritical() << QString("modCond->coinSafe %1 (%2)").arg(modCond->coinSafe).arg(modCond->coinSafe, 0, 16); + + qCritical() << QString("modCond->billSafe %1 (%2)").arg(modCond->billSafe).arg(modCond->billSafe, 0, 16); + qCritical() << QString("modCond->voltage %1 (%2)").arg(modCond->voltage).arg(modCond->voltage, 0, 16); + qCritical() << QString("modCond->temper %1 (%2)").arg(modCond->temper).arg(modCond->temper, 0, 16); + qCritical() << QString("modCond->poweronTest %1 (%2)").arg(modCond->poweronTest).arg(modCond->poweronTest, 0, 16); + + qCritical() << QString("modCond->doorState %1 (%2)").arg(modCond->doorState).arg(modCond->doorState, 0, 16); + qCritical() << QString("modCond->doorWasOpened %1 (%2)").arg(modCond->doorWasOpened).arg(modCond->doorWasOpened, 0, 16); + qCritical() << QString("modCond->changer %1 (%2)").arg(modCond->changer).arg(modCond->changer, 0, 16); + qCritical() << QString("modCond->coinBlocker %1 (%2)").arg(modCond->coinBlocker).arg(modCond->coinBlocker, 0, 16); + + qCritical() << QString("modCond->billReader %1 (%2)").arg(modCond->billReader).arg(modCond->billReader, 0, 16); + qCritical() << QString("modCond->ResetReason %1 (%2)").arg(modCond->ResetReason).arg(modCond->ResetReason, 0, 16); + qCritical() << QString("modCond->allModulesChecked %1 (%2)").arg(modCond->allModulesChecked).arg(modCond->allModulesChecked, 0, 16); + qCritical() << QString("modCond->alarmState %1 (%2)").arg(modCond->alarmState).arg(modCond->alarmState, 0, 16); + qCritical() << QString("modCond->fuses %1 (%2)").arg(modCond->fuses).arg(modCond->fuses, 0, 16); +} + +static void dump(T_dynamicCondition const *dynCond) { + qCritical() << QString("dynCond->allDoorsDebounced %1 (%2)").arg((unsigned char)dynCond->allDoorsDebounced).arg((unsigned char)dynCond->allDoorsDebounced, 0, 16); + qCritical() << QString("dynCond->openedAuthorized %1 (%2)").arg((unsigned char)dynCond->openedAuthorized).arg((unsigned char)dynCond->openedAuthorized, 0, 16); + qCritical() << QString("dynCond->CBinDebounced %1 (%2)").arg((unsigned char)dynCond->CBinDebounced).arg((unsigned char)dynCond->CBinDebounced, 0, 16); + qCritical() << QString("dynCond->upperDoor %1 (%2)").arg((unsigned char)dynCond->upperDoor).arg((unsigned char)dynCond->upperDoor, 0, 16); + qCritical() << QString("dynCond->middleDoor %1 (%2)").arg((unsigned char)dynCond->middleDoor).arg((unsigned char)dynCond->middleDoor, 0, 16); + qCritical() << QString("dynCond->lowerDoor %1 (%2)").arg((unsigned char)dynCond->lowerDoor).arg((unsigned char)dynCond->lowerDoor, 0, 16); + qCritical() << QString("dynCond->middleDoor %1 (%2)").arg((unsigned char)dynCond->middleDoor).arg((unsigned char)dynCond->middleDoor, 0, 16); + qCritical() << QString("dynCond->coinAttached %1 (%2)").arg((unsigned char)dynCond->coinAttached).arg((unsigned char)dynCond->coinAttached, 0, 16); + qCritical() << QString("dynCond->billBox %1 (%2)").arg((unsigned char)dynCond->billBox).arg((unsigned char)dynCond->billBox, 0, 16); + qCritical() << QString("dynCond->modeAbrech %1 (%2)").arg((unsigned char)dynCond->modeAbrech).arg((unsigned char)dynCond->modeAbrech, 0, 16); + qCritical() << QString("dynCond->onAlarm %1 (%2)").arg((unsigned char)dynCond->onAlarm).arg((unsigned char)dynCond->onAlarm, 0, 16); + qCritical() << QString("dynCond->nowCardTest %1 (%2)").arg((unsigned char)dynCond->nowCardTest).arg((unsigned char)dynCond->nowCardTest, 0, 16); + qCritical() << QString("dynCond->nowPayment %1 (%2)").arg((unsigned char)dynCond->nowPayment).arg((unsigned char)dynCond->nowPayment, 0, 16); + qCritical() << QString("dynCond->lastMifCardType %1 (%2)").arg((unsigned char)dynCond->lastMifCardType).arg((unsigned char)dynCond->lastMifCardType, 0, 16); + qCritical() << QString("dynCond->lastSDoorState %1 (%2)").arg(dynCond->lastSDoorState).arg(dynCond->lastSDoorState, 0, 16); + qCritical() << QString("dynCond->lastVDoorState %1 (%2)").arg(dynCond->lastVDoorState).arg(dynCond->lastVDoorState, 0, 16); + qCritical() << QString("dynCond->lastCBstate %1 (%2)").arg(dynCond->lastCBstate).arg(dynCond->lastCBstate, 0, 16); + qCritical() << QString("dynCond->paymentInProgress %1 (%2)").arg((unsigned char)dynCond->paymentInProgress).arg((unsigned char)dynCond->paymentInProgress, 0, 16); + qCritical() << QString("dynCond->U_Batt %1 (%2)").arg(dynCond->U_Batt).arg(dynCond->U_Batt, 0, 16); + qCritical() << QString("dynCond->nrCoinsInBox %1 (%2)").arg(dynCond->nrCoinsInBox).arg(dynCond->nrCoinsInBox, 0, 16); + qCritical() << QString("dynCond->amountInBox %1 (%2)").arg(dynCond->amountInBox).arg(dynCond->amountInBox, 0, 16); + qCritical() << QString("dynCond->totalTransVolume %1 (%2)").arg(dynCond->totalTransVolume).arg(dynCond->totalTransVolume, 0, 16); + qCritical() << QString("dynCond->totalNrOfVends %1 (%2)").arg(dynCond->totalNrOfVends).arg(dynCond->totalNrOfVends, 0, 16); + qCritical() << QString("dynCond->resultOfLastTemplPrint %1 (%2)").arg((unsigned char)dynCond->resultOfLastTemplPrint).arg((unsigned char)dynCond->resultOfLastTemplPrint, 0, 16); + qCritical() << QString("dynCond->lastPrinterStatus %1 (%2)").arg(dynCond->lastPrinterStatus).arg(dynCond->lastPrinterStatus, 0, 16); + qCritical() << QString("dynCond->startupTestIsRunning %1 (%2)").arg(dynCond->startupTestIsRunning).arg(dynCond->startupTestIsRunning, 0, 16); + qCritical() << QString("dynCond->totalNrOfCuts %1 (%2)").arg(dynCond->totalNrOfCuts).arg(dynCond->totalNrOfCuts, 0, 16); + qCritical() << QString("dynCond->nextAccountNumber %1 (%2)").arg(dynCond->nextAccountNumber).arg(dynCond->nextAccountNumber, 0, 16); + qCritical() << QString("dynCond->nrOfBillsInBox %1 (%2)").arg(dynCond->nrOfBillsInBox).arg(dynCond->nrOfBillsInBox, 0, 16); + qCritical() << QString("dynCond->UbatAtLastPrint %1 (%2)").arg(dynCond->UbatAtLastPrint).arg(dynCond->UbatAtLastPrint, 0, 16); +} + char T_datif::loadRecDataFromFrame() { // is called even with wrong received data in order to speed up the process (stop waiting for response) @@ -556,12 +626,86 @@ char T_datif::loadRecDataFromFrame() readCount = writeCount; if (readSource != myDCIF->getReadSource()) { qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << ", ignore data" - << QByteArray((char const *)receivedData, RdDleng).toHex(':'); + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource(); return 0; } else { // only for debugging // qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << readSource << myDCIF->getReadSource(); + if (readSource == 30) { + T_moduleCondition const *modCond = reinterpret_cast(receivedData); + + if(modCond->rtc >= 200) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E002 (modCond->rtc >= 200)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->printer == 200 || modCond->printer == 201) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E020 (modCond->printer == 200 || modCond->printer == 201)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->printer == 202) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E018 (modCond->printer == 202)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->coinBlocker >= 200) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E025 (modCond->coinBlocker >= 200)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->mdbBus >= 200) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E034 (modCond->mdbBus >= 200)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->intEe >= 200) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (modCond->intEe >= 200)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->voltage >= 200) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E003 (modCond->voltage >= 200)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->changer >= 200) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E026 (modCond->changer >= 200)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->coinSafe == 201) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E007 (modCond->coinSafe == 201)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (modCond->coinSafe == 200) { + dump(modCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E009 (modCond->coinSafe == 200)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + } + + if (readSource == 31) { + T_dynamicCondition const *dynCond = reinterpret_cast(receivedData); + + if (dynCond->modeAbrech > 0) { + dump(dynCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (dynCond->modeAbrech > 0)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (dynCond->nowCardTest > 0) { + dump(dynCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E072 (dynCond->nowCardTest > 0)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + if (dynCond->startupTestIsRunning > 0) { + dump(dynCond); + qCritical() << __func__ << ":" << __LINE__ << ": ERROR E073 (dynCond->startupTestIsRunning > 0)" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } + } } } else { qCritical() << __func__ << ":" << __LINE__ << QString(": ERROR readCount + 1 != writeCount: %1 != %2").arg(readCount + 1).arg(writeCount); @@ -569,6 +713,15 @@ char T_datif::loadRecDataFromFrame() << QByteArray((char const *)receivedData, RdDleng).toHex(':'); qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource(); + if (readSource == 30) { + T_moduleCondition const *modCond = reinterpret_cast(receivedData); + dump(modCond); + } + if (readSource == 31) { + T_dynamicCondition const *dynCond = reinterpret_cast(receivedData); + dump(dynCond); + } + readCount = writeCount; return 0; } From 3e7f71899c7553f01a965d7a70fe3e982d70b0ad Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 21 Oct 2024 16:16:26 +0200 Subject: [PATCH 19/19] loadRecDataFromFrame(): Move coinAttached from error-state to normal debug output. --- src/datIf.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/datIf.cpp b/src/datIf.cpp index a9f0b29..0d70b65 100755 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -720,6 +720,10 @@ char T_datif::loadRecDataFromFrame() if (readSource == 31) { T_dynamicCondition const *dynCond = reinterpret_cast(receivedData); dump(dynCond); + if (dynCond->coinAttached > 0) { + qCritical() << __func__ << ":" << __LINE__ << ": dynCond->coinAttached" + << QByteArray(reinterpret_cast(receivedData), RdDleng).toHex(':'); + } } readCount = writeCount;