From d0445949d248f8ce1f7d365e6c5a3fc73277c44d Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 19 May 2023 13:57:17 +0200 Subject: [PATCH 1/9] Merge changes from T.Sax DC_plugin 18.5.23 --- include/datIf.h | 2 + include/hwapi.h | 63 +++++++++- include/interfaces.h | 19 ++- include/shared_mem_buffer.h | 2 +- src/datIf.cpp | 36 +++++- src/hwapi.cpp | 230 ++++++++++++++++++++++++++++++++++-- src/storeINdata.cpp | 44 ++++++- 7 files changed, 374 insertions(+), 22 deletions(-) diff --git a/include/datIf.h b/include/datIf.h index 0b173e2..465691f 100644 --- a/include/datIf.h +++ b/include/datIf.h @@ -308,6 +308,8 @@ class T_datif : public QMainWindow QTimer *datif_trigger; uint8_t selectedSlaveAddr; + int datif_noResponseCtr; + private slots: char datif_cycleSend(); void StoredRecData(); diff --git a/include/hwapi.h b/include/hwapi.h index 9489e08..8be320c 100644 --- a/include/hwapi.h +++ b/include/hwapi.h @@ -1,8 +1,30 @@ +/* +matching interfaces.h: + +// History +// 11.10.2021: V1.0 222 functions +// 23.12.2021: V1.1 added block-parameter to function "read mifare data" +// 30.12.2021: V1.2 added function: mif_clearDataBuffer(), mif_isBlockAvailable(uint8_t blkNr) and mif_getAvailableDataBlocks() +// 1.1.2022: V1.3 Mifare extended. ( background: read 16 x 48byte from card to DC, read 12 x 64byte from DC to CA) +// new: read full card with 768bytes from HWapi without block borders +// added: mif_getNrOfAvailableDataBytes mif_getCardData768byteDec(uint8_t *buf, uint16_t bufferSize) +// mif_getCardDataDec(uint16_t fromAddr, uint16_t toAddr, uint8_t *buf, uint16_t bufferSize) +// mif_getCardDataStr(bool useHexFormat, char seperator) +// 29.03.2023: V3.1 some extensions for PSA1256_ptu5, +// V3.2 Bootloader improvement +// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging + +//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.1" +#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3" +*/ + #ifndef hwapi_H #define hwapi_H #include +#include #include #include "interfaces.h" #include "datIf.h" @@ -15,6 +37,7 @@ class hwapi : public QObject, Q_INTERFACES(hwinf) private: void sub_storeSendingText(QByteArray *buf) const; + QTimer *hwapi_TimerPayment; DownloadResult sendNextAddress(int bNum) const; DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const; @@ -161,6 +184,13 @@ public: uint8_t bl_exitBL(uint8_t *sendData) const override; // minimum size of sendData-buffer: 5byte retval: length + + + + + + + // ------------------------------------------------------------------------------ // Level 2 DC2-onboard devices // WR: set time @@ -963,6 +993,17 @@ public: bool cash_startPayment(uint32_t amount) const override; // 17.4.23TS: extended to 32bit + uint8_t cash_paymentProcessing(void) const override; + // run this function periodically while coin payment process to generate necessary signals + // return value: + // 0: stopped 1: starting up 2: coin collection + // 3: finished by User (Push button) 4: finished, Max-Value collected + // 5: finished by escrow + // 10,11: error cannot start + // 12: timeout while payment, coins returned + // 13: stopped by unexpected error + + bool cash_cancelPayment(void) const override; // and return coins @@ -1032,6 +1073,7 @@ public: void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const override; + bool sys_areDCdataValid(void) const override; /* --------------------------------------------------------------------------------------------- // ------------ supervise all hardware components @@ -1076,14 +1118,31 @@ public: signals: void hwapi_templatePrintFinished_OK(void) const override; void hwapi_templatePrintFinished_Err(void) const override; + + void hwapi_coinCollectionJustStarted(void) const override; + void hwapi_coinCollectionAborted(void) const override; + void hwapi_gotNewCoin(void) const override; - void hwapi_vendStopByMax(void) const override; - void hwapi_vendStopByPushbutton(void) const override; + void hwapi_payStopByMax(void) const override; + void hwapi_payStopByPushbutton(void) const override; + + void hwapi_payStopByEscrow(void) const override; + void hwapi_payStopByError(void) const override; + void hwapi_payStopByTimeout(void) const override; + void hwapi_payCancelled(void) const override; + + void hwapi_coinProcessJustStopped(void) const override; + + + + + private slots: void hwapi_slotPrintFinished_OK(void); void hwapi_slotPrintFinished_Err(void); void hwapi_slotGotCoin(void); + void hwapi_slotPayProc(void); }; diff --git a/include/interfaces.h b/include/interfaces.h index 31856ce..43c683d 100644 --- a/include/interfaces.h +++ b/include/interfaces.h @@ -1452,6 +1452,8 @@ public: virtual bool cash_startPayment(uint32_t amount) const=0; // 17.4.23TS: extended to 32bit + virtual uint8_t cash_paymentProcessing(void) const=0; + virtual uint32_t getInsertedAmount(void) const=0; virtual uint16_t getLastInsertedCoin(void) const=0; @@ -1616,6 +1618,8 @@ public: virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const=0; + virtual bool sys_areDCdataValid(void) const=0; + /* --------------------------------------------------------------------------------------------- // ------------ supervise all hardware components // ------------ assess the machine state @@ -1669,9 +1673,20 @@ public: signals: virtual void hwapi_templatePrintFinished_OK(void) const=0; virtual void hwapi_templatePrintFinished_Err(void) const=0; + + virtual void hwapi_coinCollectionJustStarted(void) const=0; + virtual void hwapi_coinCollectionAborted(void) const=0; + virtual void hwapi_gotNewCoin(void) const=0; - virtual void hwapi_vendStopByMax(void) const=0; - virtual void hwapi_vendStopByPushbutton(void) const=0; + virtual void hwapi_payStopByMax(void) const=0; + virtual void hwapi_payStopByPushbutton(void) const=0; + + virtual void hwapi_payStopByEscrow(void) const=0; + virtual void hwapi_payStopByError(void) const=0; + virtual void hwapi_payStopByTimeout(void) const=0; + virtual void hwapi_payCancelled(void) const=0; + + virtual void hwapi_coinProcessJustStopped(void) const=0; }; diff --git a/include/shared_mem_buffer.h b/include/shared_mem_buffer.h index 07cc2b8..d45841f 100644 --- a/include/shared_mem_buffer.h +++ b/include/shared_mem_buffer.h @@ -227,7 +227,7 @@ struct SharedMemBuffer { uint16_t nrOfCoins; bool dcDataValid; uint8_t wakeReason; - + char curPayNewCoin; } store; struct T_globTime { diff --git a/src/datIf.cpp b/src/datIf.cpp index ddc9bc1..14709de 100644 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -50,6 +50,7 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent) cycl_running=0; //datif_DCdataValid=0; gpi_storeDcDataValid(0); + datif_noResponseCtr=0; } void T_datif::resetChain(void) @@ -69,6 +70,11 @@ char T_datif::datif_cycleSend() uint8_t length, data[66]; bool b_ret; + datif_noResponseCtr++; // inc every 10ms fehlt noch in SysCont + if (datif_noResponseCtr>500) // seit 5s kein Lebenszeichen von DC2 + gpi_storeDcDataValid(0); // fehlt in SysCont + + if (cycl_running) { // request is still running, wait for response before next sending @@ -214,7 +220,10 @@ char T_datif::datif_cycleSend() sendINrequestsAutomatic(); // sendCyclicCmd(); // request all cyclic data sequential } else + { dif_scanStep=0; // always start from beginning + gpi_storeDcDataValid(0); // fehlt in SysCont + } } #ifdef USEHANDSHAKES else @@ -225,6 +234,7 @@ char T_datif::datif_cycleSend() } else { //qDebug() << "com port not available"; // wird ununterbrochen ausgegeben + gpi_storeDcDataValid(0); // fehlt in SysCont } return 0; @@ -842,6 +852,7 @@ char T_datif::isPortOpen(void) void T_datif::StoredRecData() { + datif_noResponseCtr=0; //qDebug() << "StoreRecData called"; // call automatically by T_prot //if (myDCIF->ifDataReceived()) @@ -1210,6 +1221,15 @@ char T_datif::loadRecDataFromFrame() // DB1: last coin signal (value / scale) // DB2,3: last coin value // DB4: lastError from Emp + + // 0: nr of stored coins + // 1: got 2:type 3:err 4=valL 5=valH + +// qDebug() << "got emp coin "<< " " << receivedData[0] <<" " << receivedData[1] +// << " " << receivedData[2]<< " " << receivedData[3] +// << " " << receivedData[4]<< " " << receivedData[5] +// << " " << receivedData[6]<< " " << receivedData[7]; + gpi_storeEmpCoinSignal(receivedData[0], &receivedData[1]); break; @@ -1365,11 +1385,18 @@ char T_datif::loadRecDataFromFrame() newInsertedAmount=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]); uitmp=uchar2uint(receivedData[5],receivedData[4]); uit2=uchar2uint(receivedData[7],receivedData[6]); - gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2); - if (newInsertedAmount != lastInsertedAmount) + if (uitmp>0) // nur 1x bei neuer Münze { - emit datif_gotNewCoin(); - lastInsertedAmount=newInsertedAmount; + gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2); + //void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue) + if (newInsertedAmount != lastInsertedAmount) + { + emit datif_gotNewCoin(); +//qDebug()<<"emit new coin"; + + lastInsertedAmount=newInsertedAmount; + } +qDebug()<<" store new coin"< baudrateMap = { {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, @@ -51,6 +53,18 @@ hwapi::hwapi(QObject *parent) : QObject(parent) { connect(myDatif, SIGNAL(datif_templatePrintFinished_OK()), this, SLOT(hwapi_slotPrintFinished_OK())); connect(myDatif, SIGNAL(datif_templatePrintFinished_Err()), this, SLOT(hwapi_slotPrintFinished_Err())); connect(myDatif, SIGNAL(datif_gotNewCoin()), this, SLOT(hwapi_slotGotCoin())); + + hwapi_TimerPayment = new QTimer(); + hwapi_TimerPayment->setSingleShot(true); + + QTimer *hwapi_callPayProc = new QTimer(); + connect(hwapi_callPayProc, SIGNAL(timeout()), this, SLOT(hwapi_slotPayProc())); + hwapi_callPayProc->setSingleShot(false); + hwapi_callPayProc->start(100); // in ms + + hwapi_lastStartAmount=0; + hwapi_cash_lastCollectionState=0; + hwapi_paymentStarted=0; } hwapi::~hwapi() { @@ -59,6 +73,12 @@ hwapi::~hwapi() { } } + +void hwapi::hwapi_slotPayProc(void) +{ + cash_paymentProcessing(); +} + void hwapi::hwapi_slotPrintFinished_OK(void) { emit hwapi_templatePrintFinished_OK(); } @@ -74,7 +94,7 @@ void hwapi::hwapi_slotGotCoin(void) { uint32_t newSum=epi_CurrentPaymentGetAmount(); if (newSum>=hwapi_lastStartAmount) - emit hwapi_vendStopByMax(); + emit hwapi_payStopByMax(); } @@ -1636,6 +1656,20 @@ uint8_t hwapi::coin_escrowFlapOpened(void) const + + + + + +// ------------------------------------------------------------------------------ +// Level4 devices are operated by DC +// processes with more then one devices +// timer controlled or long term processes +// ------------------------------------------------------------------------------ + + + + void hwapi::sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, uint8_t kindOfMifareReader, uint8_t suppressSleep, uint8_t kindOfModem, uint8_t kindOfCredit) const @@ -3507,11 +3541,7 @@ bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const // nr = 1..32 { // return true if sending, false if cmd-stack is full - - // 3.5.23: die dynVals und alle templates sollen am stück gesendet - uint8_t data[64]; - data[0]=nrOftemplate; - return longFDcmd_set(152, 0,0, 1, data); + return sendFDcmd_set(152, 0,0, nrOftemplate,0,0,0); } void hwapi::log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const @@ -3608,11 +3638,190 @@ bool hwapi::cash_startPayment(uint32_t amount) const dat2=ulong2uchar(amount, 1); dat3=ulong2uchar(amount, 2); dat4=ulong2uchar(amount, 3); + hwapi_cash_lastCollectionState=0; + sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4); - return sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4); + hwapi_paymentStarted=1; + hwapi_TimerPayment->start(5000); // in ms + + return true; } + +uint8_t hwapi::cash_paymentProcessing(void) const +{ + // run this function periodically while coin payment process to generate necessary signals: + // virtual void hwapi_coinCollectionJustStarted(void) const=0; + // virtual void hwapi_coinCollectionAborted(void) const=0; + // virtual void hwapi_gotNewCoin(void) const=0; // comes from: hwapi_slotGotCoin() + // virtual void hwapi_payStopByMax(void) const=0; // comes from: hwapi_slotGotCoin() + // virtual void hwapi_payStopByPushbutton(void) const=0; // comes from cash_stopPayment() + // virtual void hwapi_payStopByEscrow(void) const=0; + // virtual void hwapi_payStopByError(void) const=0; + // virtual void hwapi_payStopByTimeout(void) const=0; + // virtual void hwapi_payCancelled(void) const=0; + + // virtual void hwapi_coinProcessJustStopped(void) const=0; + + // return value: + // 0: stopped 1: starting up 2: coin collection + // 3: finished by User (Push button) 4: finished, Max-Value collected + // 5: finished by escrow + // 6: money encashed + // 7: cancelled + // 10,11: error cannot start + // 12: timeout while payment, coins returned + // 13: stopped by unexpected error + + + + struct T_emp empStat; + struct T_dynamicCondition myDynMachCond; + uint8_t collActiv=0, payInProg, empState; + + if (hwapi_paymentStarted<1) + return 0; // off + + collActiv=1; // starting up payment + emp_getAllParameters(&empStat); + //collActiv=empStat.paymentRunning; + + empState=empStat.state; + // 0=start command + // 1=powered, do emp ini, send reset + // 2=delay + // 3=wait for response, requesting status after response + // 4,5 through, startup + // 6: wait for status + // 7: through, startup + // 8: IDLE state. EMP is up and ready, polling is running + // 9: polling on, payment not yet on + // 10: payment, check coins + // 11: through + // 12: wait 1s for last coin + // 90: stop all, 1s delay + // 99: off, all stopped + + sys_getDynMachineConditions(&myDynMachCond); + payInProg= myDynMachCond.paymentInProgress; + // 0: stopped by timeout + // 1: running 2: wait4lastCoin + // 3: payment stopped manually, coins in Escrow + // 4: payment stopped autom, amount collected, coins in Escrow + // 5: payment stopped, escrow full, coins in Escrow + // 6: coins encashed 7:coins returned + // 8: CoinChecker or MDB on Error + + + if (payInProg==8) + { + // coin checker faulty, cannot start + if (hwapi_paymentStarted==1) + { + hwapi_paymentStarted=90; // stop due to error + emit hwapi_coinCollectionAborted(); + //sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment + collActiv=10; // error cannot start + } + } else + + if (empState>=10 && empState<=12) + { + // coin acceptance is active now: + hwapi_TimerPayment->stop(); // to avoid error signal + if (hwapi_paymentStarted==1) // 1=wait for coin checker being ready + { + hwapi_paymentStarted=2; // coins can be inserted no + emit hwapi_coinCollectionJustStarted(); + } + } else + { + // EMP not (yet) ready + + if (!hwapi_TimerPayment->isActive()) + { + // 5s after start-payment the coin-checker is still not ready + hwapi_TimerPayment->stop(); + if (hwapi_paymentStarted==1) + { + hwapi_paymentStarted=90; // stop due to error + emit hwapi_coinCollectionAborted(); // error cannot start + //sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment + collActiv=11; // error cannot start + } + } + } + + if (hwapi_paymentStarted==2) + { + collActiv=2; // coin collection active + + // coins can be inserted now, wait for end + if (payInProg==0) // timeout + { + hwapi_paymentStarted++; + collActiv=12; // stop by timeout + emit hwapi_payStopByTimeout(); + } else + if (payInProg==3) // user pressed "Next/Continue" + { + hwapi_paymentStarted++; + collActiv=3; + emit hwapi_payStopByPushbutton(); + } else + if (payInProg==4) // max achieved + { + hwapi_paymentStarted++; + collActiv=4; + emit hwapi_payStopByMax(); + } else + if (payInProg==5) // escrow full + { + hwapi_paymentStarted++; + collActiv=5; + emit hwapi_payStopByEscrow(); + } else + if (payInProg==6) // encashed + { + hwapi_paymentStarted++; + collActiv=6; + + } else + if (payInProg==7) // returned, user pressed Cancel button + { + hwapi_paymentStarted++; + collActiv=7; + emit hwapi_payCancelled(); + } else + + if (empState<9 || payInProg==8) + { + hwapi_paymentStarted++; + collActiv=13; // stopped by unexpected error + emit hwapi_payStopByError(); + } + } + + if (empState<8 || empState>12) + epi_clearCurrentPayment(); // to avoid wrong "got-coin" messages + + + if (hwapi_paymentStarted==90 || hwapi_paymentStarted==3 ) + { + // EMP error, wait till process finished + if (empState==99 && (payInProg==0 || payInProg>5) ) + { + // everything stopped, no more coins in escrow + hwapi_paymentStarted=0; + emit hwapi_coinProcessJustStopped(); + } + } + + return collActiv; +} + + uint32_t hwapi::getInsertedAmount(void) const { return epi_CurrentPaymentGetAmount(); @@ -3643,7 +3852,7 @@ bool hwapi::cash_stopPayment(void) const { // DB1: 1=encash 2=cancel & return coins // 3=stop and keep coins in escrow - emit hwapi_vendStopByPushbutton(); + emit hwapi_payStopByPushbutton(); return sendFDcmd_set(156, 0,0, 3,0,0,0); } @@ -3666,6 +3875,11 @@ bool hwapi::vend_failed(void) const } + + + + + uint8_t hwapi::mif_getCardType(QString *cardholder) const // return 1,2,3,4 = upper, lower access card, printer test, coin test // cardholder: 7byte Name-String diff --git a/src/storeINdata.cpp b/src/storeINdata.cpp index 4f4035b..dca481f 100644 --- a/src/storeINdata.cpp +++ b/src/storeINdata.cpp @@ -24,6 +24,7 @@ bool indat_isPrinterOn() { return indat_savePrnPwr; } + static bool indat_saveMifPwr; void indat_storeMifarePower(bool isOn) { @@ -34,6 +35,7 @@ bool indat_isMifareOn() { return indat_saveMifPwr; } + static bool indat_MdbIsOn; void indat_storeMDBisOn(bool isOn) { @@ -44,6 +46,11 @@ bool indat_isMdbOn() { return indat_MdbIsOn; } + +// ////////////////////////////////////////////////////////////////////////// + + + void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits, uint8_t parity, uint8_t NrStopBits) { // store numbers @@ -95,6 +102,7 @@ void gpi_storeGenerals(uint8_t genNr, QString text) { text.toStdString().c_str(), sizeof(SharedMemBuffer::getDataConst()->genStrings[0])); } + } QString epi_loadGenerals(uint8_t genNr) { @@ -108,6 +116,9 @@ QString epi_loadGenerals(uint8_t genNr) { return " "; } + + + // ------------------------------- void gpi_storeUID(uint8_t const *buf8byteUid) { @@ -282,6 +293,7 @@ QString epi_getSlaveTimeDateStr() { } + // /////////////////////////////////////////////////////////////////////////////////// // analog values // /////////////////////////////////////////////////////////////////////////////////// @@ -310,6 +322,7 @@ uint16_t epi_loadAIs(uint8_t aiNr) { // ADC0: temp // 1: voltage // 2: brightness +#define MAXNROF_MEASURE 4 uint32_t epi_loadMeasureValue(uint8_t ValueNr) { // ValueNr 0=ADC0, 1=ADC1 aso... @@ -989,6 +1002,15 @@ void gpi_storePrinterFonts(uint8_t const *buf) { sizeof(SharedMemBuffer::getData()->Sdata.PRN_FONTS)); } +/* + qDebug()<<"printer fonts stored " <store.insertedAmount = 0; p_lastCoin = 0; + memset((char *)&SharedMemBuffer::getData()->store.lastCoinType[0], + 0x00, sizeof(SharedMemBuffer::getData()->store.lastCoinType)); + memset((char *)&SharedMemBuffer::getData()->store.lastCoinValue[0], + 0x00, sizeof(SharedMemBuffer::getData()->store.lastCoinValue)); + SharedMemBuffer::getData()->store.curPayNewCoin = 0; } void gpi_storeCurrentPayment(uint32_t insertedAmount, @@ -1140,7 +1171,9 @@ void gpi_storeCurrentPayment(uint32_t insertedAmount, SharedMemBuffer::getData()->store.insertedAmount = insertedAmount; SharedMemBuffer::getData()->store.lastCoinType[p_lastCoin] = lastCoinType; SharedMemBuffer::getData()->store.lastCoinValue[p_lastCoin] = lastCoinValue; + p_lastCoin++; + SharedMemBuffer::getData()->store.curPayNewCoin++; } uint32_t epi_CurrentPaymentGetAmount(void) { @@ -1225,6 +1258,8 @@ void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data) { *leng); } + + // store dynamic machine conditions void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data) { SharedMemBuffer::getData()->store.machCondLen = leng; @@ -1329,8 +1364,7 @@ bool gpi_areDcDataValid() } - - - - - +bool epi_areDcDataValid() +{ + return SharedMemBuffer::getData()->store.dcDataValid; +} From 3ac91305d40c70151c4755f87828da03124ca7b9 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 19 May 2023 15:33:52 +0200 Subject: [PATCH 2/9] Fix: for load as plugin on target device --- include/storeINdata.h | 1 + src/ATBAPP/ATBDeviceControllerPlugin.cpp | 1 + src/hwapi.cpp | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/storeINdata.h b/include/storeINdata.h index 2a3083c..b28a6ff 100644 --- a/include/storeINdata.h +++ b/include/storeINdata.h @@ -418,6 +418,7 @@ uint8_t epi_mifGetCardType(uint8_t const *holder); void gpi_storeDcDataValid(bool isVal); bool gpi_areDcDataValid(); +bool epi_areDcDataValid(); diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index aa6ae5d..0c81437 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -51,6 +51,7 @@ void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount) qCritical() << "Start Cash vending with amount = " << amount; uint32_t amountInt = static_cast(amount.toUInt()); + hw->cash_startPayment(amountInt); } diff --git a/src/hwapi.cpp b/src/hwapi.cpp index 13815a8..d1d7da3 100644 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -4100,7 +4100,10 @@ void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const } - +bool hwapi::sys_areDCdataValid(void) const +{ + return epi_areDcDataValid(); +} /* --------------------------------------------------------------------------------------------- // ------------ supervise all hardware components From ca5e43e0d78453623a0f9063a51cfd277932d063 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 19 May 2023 15:34:28 +0200 Subject: [PATCH 3/9] Add debug output --- src/com.cpp | 2 +- src/datIf.cpp | 10 ++++++++-- src/hwapi.cpp | 2 ++ src/prot.cpp | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/com.cpp b/src/com.cpp index 01f9292..8c28383 100644 --- a/src/com.cpp +++ b/src/com.cpp @@ -19,7 +19,7 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) sendLen=sendLength; if (CatSerial->isOpen()) { - //qDebug() << "sending..." << sendBuffer; + qCritical() << "sending..." << sendBuffer; CatSerial->write(sendBuffer); } else qDebug() << "error sending, port is not open"; diff --git a/src/datIf.cpp b/src/datIf.cpp index 14709de..2e87c3d 100644 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -887,14 +887,20 @@ char T_datif::loadRecDataFromFrame() ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData); // retval: data valid, only one time true, true if CommandState OK and readState OK gpi_storeResultOfLastRequest(ret); + + + qCritical() << "loadRecDataFromFrame() readSource = " << readSource; + if (ret==false) { - // qDebug() << "datif: rec data not valid"; + qCritical() << "datif: rec data not valid"; return 0; } gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi) + + qCritical() << "loadRecDataFromFrame() readSource = " << readSource; //qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress // << " rdlen:" << RdDleng; // qDebug("datif_recData: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ", @@ -1212,7 +1218,7 @@ char T_datif::loadRecDataFromFrame() break; case CMD2DC_EMP_GET_ALL: //23 - //qDebug() << "got emp parameters "<< receivedData[1]; + qCritical() << "got emp parameters "<< receivedData[1]; gpi_storeEmpSettings(64, receivedData); break; diff --git a/src/hwapi.cpp b/src/hwapi.cpp index d1d7da3..b41c27d 100644 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -3703,6 +3703,8 @@ uint8_t hwapi::cash_paymentProcessing(void) const // 90: stop all, 1s delay // 99: off, all stopped + //qCritical() << "empState = " << empState; + sys_getDynMachineConditions(&myDynMachCond); payInProg= myDynMachCond.paymentInProgress; // 0: stopped by timeout diff --git a/src/prot.cpp b/src/prot.cpp index 95a40aa..a63c092 100644 --- a/src/prot.cpp +++ b/src/prot.cpp @@ -433,7 +433,8 @@ uint8_t recBuffer[FRAME_MAXLEN]; // read from "VCP": mySerialPort->readFromSerial(Indata, recLength); -//qDebug()<<"prot: got data " << recLength; + qCritical()<<"prot: got data " << recLength; + qCritical()<<" Indata: " << Indata; if (recLength>FRAME_MAXLEN) recLength=FRAME_MAXLEN; for (int nn=0; nnhw->getInsertedAmount(); + + QString amountString = QString::number(amountInt); + + emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, + amountString, + "", + ""); +} + +void ATBDeviceControllerPlugin::onCashPayStopByError() +{ + // DEBUG + qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByError()"; + + uint32_t amountInt = this->hw->getInsertedAmount(); + + QString amountString = QString::number(amountInt); + + emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, + amountString, + "", + ""); +} + +void ATBDeviceControllerPlugin::onCashPayStopByTimeout() +{ + // DEBUG + qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByTimeout()"; + + uint32_t amountInt = this->hw->getInsertedAmount(); + + QString amountString = QString::number(amountInt); + + emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, + amountString, + "", + ""); +} + + + + + /************************************************************************************************ * Mandatory plugin methods * diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.h b/src/ATBAPP/ATBDeviceControllerPlugin.h index 6e8285b..d7e833d 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.h +++ b/src/ATBAPP/ATBDeviceControllerPlugin.h @@ -119,7 +119,10 @@ private slots: // cash payment void onCashGotCoin(); - void onCashVendStopByMax(); + void onCashPayStopByMax(); + void onCashPayStopByEscrow(); + void onCashPayStopByError(); + void onCashPayStopByTimeout(); }; #endif // ATBDEVICECONTROLLERPLUGIN_H From a97ef4ea0418a65dafcee4af9d67e74e443eabf9 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 22 May 2023 11:21:08 +0200 Subject: [PATCH 5/9] SwitchOn dc feature autorequest This is necessary for receiving coint input events --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 0219fb5..c116156 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -34,6 +34,7 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceive QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1(); + hw->dc_autoRequest(true); // open serial port hw->dc_openSerial(5, "115200", serialPort, 1); From 2ac0f5b275a538b65442646e0c76d078cfc41e31 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 22 May 2023 11:23:28 +0200 Subject: [PATCH 6/9] Delay printing ... ... printing day tickets need this delay --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index c116156..66c6b90 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -134,6 +134,8 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHashhw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) { this->errorCode = "hwapi::prn_sendDynamicPrnValues"; @@ -152,7 +154,7 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHashcurrentTemplate++; - QTimer::singleShot(1000, this, SLOT(onPrinterPrintNextTemplate())); + QTimer::singleShot(2000, this, SLOT(onPrinterPrintNextTemplate())); } } From 584e3af035e5dd0c60819b609070ca98b6428036 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Tue, 23 May 2023 10:21:00 +0200 Subject: [PATCH 7/9] Start CashInput with UINT_MAX (PayUp) --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 66c6b90..3adc414 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -58,6 +58,8 @@ void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount) uint32_t amountInt = static_cast(amount.toUInt()); + if (amountInt == 0) amountInt = UINT_MAX; + hw->cash_startPayment(amountInt); } From 1f9cc3b8c064fa7ea87a780ee034ce3522eb3c84 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Tue, 23 May 2023 10:23:04 +0200 Subject: [PATCH 8/9] Add debug output --- src/datIf.cpp | 13 ++++++++----- src/prot.cpp | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/datIf.cpp b/src/datIf.cpp index 2e87c3d..9075f82 100644 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -888,9 +888,6 @@ char T_datif::loadRecDataFromFrame() // retval: data valid, only one time true, true if CommandState OK and readState OK gpi_storeResultOfLastRequest(ret); - - qCritical() << "loadRecDataFromFrame() readSource = " << readSource; - if (ret==false) { qCritical() << "datif: rec data not valid"; @@ -900,7 +897,7 @@ char T_datif::loadRecDataFromFrame() gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi) - qCritical() << "loadRecDataFromFrame() readSource = " << readSource; + //qCritical() << "loadRecDataFromFrame() readSource = " << readSource; //qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress // << " rdlen:" << RdDleng; // qDebug("datif_recData: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ", @@ -1218,11 +1215,14 @@ char T_datif::loadRecDataFromFrame() break; case CMD2DC_EMP_GET_ALL: //23 - qCritical() << "got emp parameters "<< receivedData[1]; + //qCritical() << "got emp parameters "<< receivedData[1]; gpi_storeEmpSettings(64, receivedData); break; case CMD2DC_EMP_GOTCOIN: //108 + + //qCritical() << "loadRecDataFromFrame() readSource = " << readSource; + // DB0: 1=coin 0xFF=error 0=got nothing // DB1: last coin signal (value / scale) // DB2,3: last coin value @@ -1387,6 +1387,9 @@ char T_datif::loadRecDataFromFrame() break; case 112: // get inserted amount in cent in sum + + //qCritical() << "loadRecDataFromFrame() readSource = " << readSource; + // 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]); diff --git a/src/prot.cpp b/src/prot.cpp index a63c092..8c13052 100644 --- a/src/prot.cpp +++ b/src/prot.cpp @@ -433,8 +433,8 @@ uint8_t recBuffer[FRAME_MAXLEN]; // read from "VCP": mySerialPort->readFromSerial(Indata, recLength); - qCritical()<<"prot: got data " << recLength; - qCritical()<<" Indata: " << Indata; + //qCritical()<<"prot: got data " << recLength; + //qCritical()<<" Indata: " << Indata; if (recLength>FRAME_MAXLEN) recLength=FRAME_MAXLEN; for (int nn=0; nn