forked from GerhardHoffmann/DCLibraries
merge changes from T.Sax
This commit is contained in:
205
src/datIf.cpp
205
src/datIf.cpp
@@ -45,6 +45,8 @@ static uint8_t datif_repeatCtr;
|
||||
static uint8_t datif_kindOfCmd;
|
||||
|
||||
static uint8_t datif_pNextCmd, datif_sendSlowCmd;
|
||||
static char testSerial;
|
||||
static bool autoRequestWasOnBeforePowerDown;
|
||||
|
||||
//#define DATIF_MAXTO_WAIT4RESP 80 //20 erhöht am 17.7 geht viel besser
|
||||
// höchster gemessener Wert (bei 20ms): 6
|
||||
@@ -122,11 +124,11 @@ T_datif::T_datif(QObject *parent) : QObject(parent)
|
||||
datei_clearFile(FILENAME_SHAREDDATA);
|
||||
datei_writeToFile(FILENAME_SHAREDDATA, myBA);
|
||||
*/
|
||||
doRepeat=true;
|
||||
doRepeat=false;
|
||||
datif_pNextCmd=0;
|
||||
datif_sendSlowCmd=0;
|
||||
|
||||
readCount = 0;
|
||||
testSerial=99;
|
||||
autoRequestWasOnBeforePowerDown=false;
|
||||
}
|
||||
|
||||
void T_datif::resetChain(void)
|
||||
@@ -164,22 +166,23 @@ char T_datif::datif_cycleSend()
|
||||
|
||||
// supervise if DC data are valid
|
||||
datif_noResponseCtr++; // inc every 20ms
|
||||
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 20ms x 250 = 5000ms = 5s
|
||||
{
|
||||
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about a sec
|
||||
{ // 10.7.2025: timeout increased 50-->250 (1s-->5s)
|
||||
epi_resetDcDataValid(3); // DC data has not updated for >=5s -> no longer valid!
|
||||
datif_nowNewDyns=0;
|
||||
datif_nowNewStats=0;
|
||||
|
||||
testSerial=0; // New, 11.10.20TS
|
||||
datif_noResponseCtr=0; // New, 11.10.20TS
|
||||
}
|
||||
// 24.7.24 new, data are valid if dynamic machine conditions AND dyn machine states came in
|
||||
if (datif_nowNewDyns && datif_nowNewStats && !epi_areDcDataValid() )
|
||||
epi_setDcDataValid();
|
||||
|
||||
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
|
||||
if (gpi_wantToResetSupervision())
|
||||
{
|
||||
gpi_storeOverallResult(0xFF);
|
||||
}
|
||||
//if (gpi_wantToResetSupervision())
|
||||
//{
|
||||
// gpi_storeOverallResult(0xFF);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -219,16 +222,7 @@ char T_datif::datif_cycleSend()
|
||||
gpi_storeLastResult(8);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Unsinn, wird nie durchlaufen
|
||||
if (cycl_running>=(RESPONSEWAITTIME+6)) // 3.7.24: 101-->110
|
||||
{
|
||||
// Antwort ist gekommen, also nach kurzer Luecke naechstes (datif_cmdWasPerformed==1)
|
||||
// oder nochmal gleiches (datif_cmdWasPerformed==2) Kommando senden
|
||||
//qDebug()<< "datif got any response";
|
||||
cycl_running=0;
|
||||
}
|
||||
*/
|
||||
|
||||
// hier stoppen, weil Antwort des letzten Cmds noch nicht da
|
||||
return 0;
|
||||
}
|
||||
@@ -366,19 +360,53 @@ char T_datif::datif_cycleSend()
|
||||
}
|
||||
|
||||
// if no direct comands need to be sent then send input requests
|
||||
|
||||
// new, 8.10.2024, avoid wrong messages right after wake-up
|
||||
if ( testSerial==1)
|
||||
{
|
||||
myDCIF->setUserWriteData(0, 0,0, data);
|
||||
myDCIF->setUserReadData(CMD2DC_TestSerial);
|
||||
myDCIF->sendUserData(selectedSlaveAddr);
|
||||
// request fixed string from DC and thus wait until DC is ready
|
||||
cycl_running=1; // 1: start transmission
|
||||
datif_kindOfCmd=0;
|
||||
datif_repeatCtr=0;
|
||||
doRepeat=false;
|
||||
} else
|
||||
if ( testSerial==2)
|
||||
{
|
||||
if (autoRequestWasOnBeforePowerDown)
|
||||
epi_startEmmision(true);
|
||||
testSerial++;
|
||||
} else
|
||||
|
||||
if (gpi_isEmmisionOn()) // auto send button is pressed
|
||||
{
|
||||
//qDebug() << "auto request is on";
|
||||
datif_kindOfCmd=0;
|
||||
sendINrequestsAutomatic(); // request all cyclic data sequential
|
||||
}
|
||||
else
|
||||
if (testSerial==0)
|
||||
{
|
||||
// start with test command after wakeup
|
||||
testSerial=1;
|
||||
} else
|
||||
{
|
||||
sendINrequestsAutomatic(); // request all cyclic data sequential
|
||||
autoRequestWasOnBeforePowerDown=true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
// new: after stopping auto-request flush com port ONE time, 6.11.24TS
|
||||
// why? to get boot loader response correct at first request
|
||||
// without flushing we got the response of last cyclic data request in buffer
|
||||
if (autoRequestWasOnBeforePowerDown)
|
||||
myDCIF->flushPort();
|
||||
|
||||
dif_scanStep=0; // always start from beginning
|
||||
epi_resetDcDataValid(4);
|
||||
datif_nowNewDyns=0;
|
||||
datif_nowNewStats=0;
|
||||
|
||||
autoRequestWasOnBeforePowerDown=false;
|
||||
testSerial=0;
|
||||
}
|
||||
|
||||
datif_cmdWasPerformed=0; // 0: no response by now
|
||||
@@ -403,8 +431,11 @@ char T_datif::sendINrequestsAutomatic(void)
|
||||
uint8_t datif_maxNrCommands=35, datif_sendNow;
|
||||
|
||||
// send quicker while transaction is ongoing:
|
||||
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,30,31,32,40,41,42,23,0};
|
||||
uint8_t datif_maxVendingCmds=13;
|
||||
//uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,31,32,40,41,42,23,0,0};
|
||||
//uint8_t datif_maxVendingCmds=13;
|
||||
// 30 muss drin sein um coin attach zu erkennen:
|
||||
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116, 30, 31,32,40,41,42,23,0};
|
||||
uint8_t datif_maxVendingCmds=14;
|
||||
|
||||
// special commands:
|
||||
// 102: get IOs run constantly!!!
|
||||
@@ -620,121 +651,7 @@ char T_datif::loadRecDataFromFrame()
|
||||
|
||||
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
|
||||
|
||||
if (myDCIF && myDCIF->getSerialPort()) {
|
||||
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(reinterpret_cast<char const *>(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<T_moduleCondition const *>(receivedData);
|
||||
|
||||
if(modCond->rtc >= 200) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E002 (modCond->rtc >= 200)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(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<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->printer == 202) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E018 (modCond->printer == 202)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->coinBlocker >= 200) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E025 (modCond->coinBlocker >= 200)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->mdbBus >= 200) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E034 (modCond->mdbBus >= 200)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->intEe >= 200) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (modCond->intEe >= 200)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->voltage >= 200) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E003 (modCond->voltage >= 200)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->changer >= 200) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E026 (modCond->changer >= 200)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->coinSafe == 201) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E007 (modCond->coinSafe == 201)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (modCond->coinSafe == 200) {
|
||||
dump(modCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E009 (modCond->coinSafe == 200)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
}
|
||||
|
||||
if (readSource == 31) {
|
||||
T_dynamicCondition const *dynCond = reinterpret_cast<T_dynamicCondition const *>(receivedData);
|
||||
|
||||
if (dynCond->modeAbrech > 0) {
|
||||
dump(dynCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (dynCond->modeAbrech > 0)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (dynCond->nowCardTest > 0) {
|
||||
dump(dynCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E072 (dynCond->nowCardTest > 0)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
if (dynCond->startupTestIsRunning > 0) {
|
||||
dump(dynCond);
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E073 (dynCond->startupTestIsRunning > 0)"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
} else {
|
||||
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();
|
||||
|
||||
/*
|
||||
if (readSource == 30) {
|
||||
T_moduleCondition const *modCond = reinterpret_cast<T_moduleCondition const *>(receivedData);
|
||||
dump(modCond);
|
||||
}
|
||||
if (readSource == 31) {
|
||||
T_dynamicCondition const *dynCond = reinterpret_cast<T_dynamicCondition const *>(receivedData);
|
||||
dump(dynCond);
|
||||
if (dynCond->coinAttached > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": dynCond->coinAttached"
|
||||
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
readCount = writeCount;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//sub_gerhardsDiagnose();
|
||||
// uint8_t nn;
|
||||
//qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress
|
||||
// << " rdlen:" << RdDleng;
|
||||
@@ -777,8 +694,11 @@ char T_datif::loadRecDataFromFrame()
|
||||
ret=verifyLineTestresponse(RdDleng, receivedData);
|
||||
gpi_storeResult_serialTestOK(ret);
|
||||
if (ret==true)
|
||||
{
|
||||
gpi_setTxt4datifLine("correct");
|
||||
else
|
||||
if ( testSerial==1) testSerial=2; // nach wake kam richtige Antwort
|
||||
|
||||
} else
|
||||
gpi_setTxt4datifLine("false");
|
||||
break;
|
||||
|
||||
@@ -1202,7 +1122,6 @@ char T_datif::loadRecDataFromFrame()
|
||||
uit2=uchar2uint(receivedData[7],receivedData[6]); // value of last coin
|
||||
//if (uitmp>0) // nur 1x bei neuer Münze 6.10.23 aendern:
|
||||
// beim Wechsler hat die kleinste Muenze immer coin type 0!
|
||||
|
||||
if (uitmp>10000 || uit2>10000)
|
||||
{
|
||||
uitmp=0;
|
||||
|
||||
Reference in New Issue
Block a user