Add collected changes from T.Sax

This commit is contained in:
2024-07-04 14:01:43 +02:00
parent ab5a343ab2
commit b0e55d8ea4
16 changed files with 2623 additions and 338 deletions

148
src/datIf.cpp Normal file → Executable file
View File

@@ -88,7 +88,7 @@ T_datif::T_datif(QObject *parent) : QObject(parent)
dif_scanStep=0;
selectedSlaveAddr=FIX_SLAVE_ADDR;
cycl_running=0;
epi_resetDcDataValid(); // data are not yet valid, no response from DC by now
epi_resetDcDataValid(1); // data are not yet valid, no response from DC by now
datif_noResponseCtr=0;
@@ -129,6 +129,11 @@ void T_datif::resetChain(void)
dif_scanStep=0;
}
#define RESPONSEWAITTIME 10
// ab 5 keine timeouts mehr
#define GOTRESP_SENDGAP 20
// Wert egal, muss nur > RESPONSEWAITTIME und <255 sein
char T_datif::datif_cycleSend()
{
// cyclic transmission of INPUT-Requests
@@ -145,14 +150,14 @@ char T_datif::datif_cycleSend()
if ( !myDCIF->isPortOpen())
{
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
epi_resetDcDataValid(); // DC data not valid
epi_resetDcDataValid(2); // DC data not valid
return 0;
}
// supervise if DC data are valid
datif_noResponseCtr++; // inc every 20ms
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s
epi_resetDcDataValid(); // DC data has not updated for >=5s -> no longer valid!
epi_resetDcDataValid(3); // DC data has not updated for >=5s -> no longer valid!
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
if (gpi_wantToResetSupervision())
@@ -171,8 +176,7 @@ char T_datif::datif_cycleSend()
// c) gar keine Antwort, Timeout nach 100ms -> 2x wiederholen (nach einer Luecke von 10ms )
// cycl_running=0: nichts zu tun 1: Mitteilung: Kommando wurde soeben abgesendet, 2,3,4 = Wiederholung
if (cycl_running) // 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL)
// if (cycl_running && doRepeat)
if (cycl_running)
{
// request is still running, wait for response before next sending
//qDebug()<< "datif wait for response";
@@ -180,28 +184,35 @@ char T_datif::datif_cycleSend()
datif_trigger->start(20); // ruft "this" (datif_cycleSend) erneut in 20ms auf
// mit 10 kein Unterscheid weil Zykluszeit grösser
cycl_running++; // inc every 20...30ms // warte max 100ms auf Antwort
if (cycl_running >80 && cycl_running <95) // neu 13.9.23 mind. 40 damit Templates
// in Folge gedruckt werden koennen
// 95: muss nur kleiner sein als die 100 fuer die Luecke
// 17.10.23: 50--> 80
cycl_running++; // inc every 20ms, warte auf Antwort
if (cycl_running >= GOTRESP_SENDGAP)
{
// 100ms vergangen, bisher keine Antwort, also Kommando wiederholen
qDebug()<< "datif timeout no response for wr/rd cmd "<< keepLastWrCmd << " " << keepLastRdCmd;
// got response, wait just one (this) cycle before next sending
cycl_running=0;
return 0;
}
if (cycl_running >=RESPONSEWAITTIME )
{
// bisher keine Antwort, also Kommando wiederholen
qDebug()<< "datif timeout no response for wr/rd cmd "<< keepLastWrCmd << " " << keepLastRdCmd;
cycl_running = 0; // gleich wiederholen weil ja schon ewig nichts mehr reinkam
datif_cmdWasPerformed=2; // NO :((
gpi_storeLastResult(8);
return 0;
}
if (cycl_running>=101) // 100 + 1
/*
* 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;
}
@@ -223,6 +234,7 @@ char T_datif::datif_cycleSend()
datif_kindOfCmd=0;
cycl_running=0;
gpi_storeOverallResult(2);
qCritical()<<"datif, error no response to wr/rd "<<keepLastWrCmd<<" "<<keepLastRdCmd;
return 0;
}
@@ -249,7 +261,7 @@ char T_datif::datif_cycleSend()
datif_cmdWasPerformed=0;
} else
{
qDebug() << "datif: unknown cmd, stop repeating wr/rd:" << keepLastWrCmd << " " << keepLastRdCmd;
qCritical() << "datif: unknown cmd, stop repeating wr/rd:" << keepLastWrCmd << " " << keepLastRdCmd;
datif_cmdWasPerformed=0;
cycl_running=0;
datif_kindOfCmd=0;
@@ -280,8 +292,10 @@ char T_datif::datif_cycleSend()
myDCIF->setUserReadData(nextRdCmd);
myDCIF->sendUserData(selectedSlaveAddr);
//qDebug()<<"Datif send long FD cmd (wr/rd): "<<nextWrCmd<< " / " << nextRdCmd
// << " " << data[0]<< " " << data[1]<< " " << data[2]<< " " << data[3];
qDebug()<<"Datif send long FD cmd (wr/rd): "<<nextWrCmd<< " / " << nextRdCmd << "Dlen:" << length;
// << " data:" << data[0]<< " " << data[1]<< " " << data[2]<< " " << data[3]
// << " " << data[4]<< " " << data[5]<< " " << data[6]<< " " << data[7]
// << " " << data[8]<< " " << data[9]<< " " << data[10]<< " " << data[11];
cycl_running=1; // 1: start transmission
datif_kindOfCmd=2;
@@ -308,8 +322,8 @@ char T_datif::datif_cycleSend()
myDCIF->setUserReadData(nextRdCmd);
myDCIF->sendUserData(selectedSlaveAddr);
//qDebug()<<"Datif send short FD cmd (wr/rd): "<<nextWrCmd<< " / " << nextRdCmd << " "
// << blockNum << " " << dat1 << " " << dat2<< " " << dat3<< " " << dat4;
qDebug()<<"Datif send short FD cmd (wr/rd): "<<nextWrCmd<< " / " << nextRdCmd << " ";
// << blockNum << " " << dat1 << " " << dat2<< " " << dat3<< " " << dat4;
cycl_running=1; // 1: start transmission
datif_kindOfCmd=1;
@@ -345,7 +359,7 @@ char T_datif::datif_cycleSend()
else
{
dif_scanStep=0; // always start from beginning
epi_resetDcDataValid();
epi_resetDcDataValid(4);
}
datif_cmdWasPerformed=0; // 0: no response by now
@@ -363,10 +377,10 @@ char T_datif::sendINrequestsAutomatic(void)
// 114,0,0,0,0,0,0,0,0,0};
// extension 6.12.23, complete list:
uint8_t datif_autoRequCommandList[40]={11, 12, 13, 14, 17, 18, 19, 21, 22, 23,
24, 25, 27, 30, 31, 32, 33, 35, 39, 40,
uint8_t datif_autoRequCommandList[40]={11, 12, 14, 17, 18, 19, 21, 22, 23, 24,
25, 27, 30, 31, 32, 33, 34, 35, 39, 40,
41, 42, 102,103,104,106,107,108,109,110,
112,113,114,115,116,0, 0, 0, 0, 0};
112,113,114,115,116,0, 0, 0, 0, 0};
uint8_t datif_maxNrCommands=35, datif_sendNow;
// send quicker while transaction is ongoing:
@@ -380,7 +394,8 @@ char T_datif::sendINrequestsAutomatic(void)
// 19: get time and date and Extra values. poll occasionally and if needed
// 107, 22: MDB: poll if needed
doRepeat=true; // 20.9.23 15uhr (after release)
//doRepeat=true; // 20.9.23 15uhr (after release)
doRepeat=false; // 3.7.24 off, is repeated cyclic anyway
if (gpi_getNowCoinPay())
{
@@ -478,7 +493,7 @@ char T_datif::loadRecDataFromFrame()
if (gpi_getNowIsBootload())
{
datif_cmdWasPerformed=1;
cycl_running=100; // stop waiting for response and wait 1cycle till next sending
cycl_running=GOTRESP_SENDGAP; // stop waiting for response and wait 1cycle till next sending
return 0;
}
@@ -504,11 +519,11 @@ char T_datif::loadRecDataFromFrame()
receivedData[12], receivedData[13], receivedData[14], receivedData[15]);
*/
datif_cmdWasPerformed=2; // NO :((
cycl_running=100; // stop waiting for response and wait 1cycle till next sending
cycl_running=GOTRESP_SENDGAP; // stop waiting for response and wait 1cycle till next sending
return 0;
}
datif_cmdWasPerformed=1; // YES :), stop repeating
cycl_running=100; // stop waiting for response
cycl_running=GOTRESP_SENDGAP; // stop waiting for response
//qDebug() << "datif: got valid response ";
@@ -546,6 +561,9 @@ char T_datif::loadRecDataFromFrame()
localStr.append(ctmp);
}
if (readSource==0)
return 0; // done
//qDebug() << "got HW version: " << localStr;
switch (readSource) // = request command
{
@@ -924,22 +942,6 @@ char T_datif::loadRecDataFromFrame()
break;
// ab hier neu: 12.4.23
case CMD2DC_RDBK_DEV_PARA: //14
/*
buf66[0]=devPara.kindOfPrinter;
@@ -990,8 +992,8 @@ char T_datif::loadRecDataFromFrame()
case 112: // get inserted amount in cent in sum
// byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value
newInsertedAmount=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
uitmp=uchar2uint(receivedData[5],receivedData[4]); // last coin type
uit2=uchar2uint(receivedData[7],receivedData[6]); // last coin value
uitmp=uchar2uint(receivedData[5],receivedData[4]); // type of last coin
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)
@@ -999,7 +1001,7 @@ char T_datif::loadRecDataFromFrame()
uitmp=0;
uit2=0;
}
if ((newInsertedAmount != lastInsertedAmount) || uit2>0) // 22.5.2024
if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )
{
gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
emit datif_gotNewCoin(); // OR BILL if (uitmp & 0x8000)>0
@@ -1037,7 +1039,9 @@ char T_datif::loadRecDataFromFrame()
break;
case 31: // Get dynamic machine conditions (doors, voltage, alarm….)
if (RdDleng>50)
// first 64 bytes, rest comes with cmd 34
if (RdDleng>60)
{
epi_setDcDataValid(); // DC-Data are valid as DC responded.
// Could be set to every response but this (31)
@@ -1046,23 +1050,8 @@ char T_datif::loadRecDataFromFrame()
gpi_storeDI_CoinAttach(receivedData[6]); // new, 14.2.24 needed for direct coin insertion
}
/* funktioniert, ist aber nicht nötig. Signal wird nach dem shared memory erzeugt
prnResult=receivedData[52];
if (prnResult != lastResult)
{
// new result
if (prnResult==1)
{
emit datif_templatePrintFinished_OK();
} else
if (prnResult==2)
{
emit datif_templatePrintFinished_Err();
}
lastResult=prnResult;
}*/
} else
qDebug()<<"datif received cmd31 with "<<RdDleng<<" bytes only";
break;
@@ -1078,24 +1067,22 @@ char T_datif::loadRecDataFromFrame()
gpi_storeDCbackupAccNr(RdDleng, receivedData);
break;
case 34: // Get dynamic machine conditions part 2
if (RdDleng>5)
{
gpi_storeDynMachCond2(RdDleng, receivedData);
//qDebug()<<"datif rec. cmd34: ";
//for (int nn=0; nn<64; nn++)
// qDebug() << nn << " : " << receivedData[nn] << " ";
}
break;
case 35:
gpi_storeMifCardType(RdDleng, receivedData);
break;
case 38: // Get stored account record backup
// readAddress, &RdDleng, receivedData
//if (RdDleng>50) // 1.8.23 nach Verlängerung des Datensatzes um 20byte falsch!!!
//{
gpi_storeVaultRecord(readAddress, receivedData ); // always/max 64byte
/*
qDebug()<<"datif cmd38 got vault data. blockNr: "<<readAddress;
if (readAddress==0)
for (nn=0; nn<64; nn+=8)
{
qDebug()<<receivedData[nn]<<" "<<receivedData[nn+1]<<" "<<receivedData[nn+2]<<" "<<receivedData[nn+3]<<" "
<<receivedData[nn+4]<<" "<<receivedData[nn+5]<<" "<<receivedData[nn+6]<<" "<<receivedData[nn+7];
}
*/
//}
break;
case 39:
@@ -1141,6 +1128,9 @@ char T_datif::loadRecDataFromFrame()
}
break;
default:
qCritical()<<"datif, error received unknown cmd "<< readSource;
}
readSource=0; // 17.05.2023: to avoid multiple recording