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();