From de1dc88e518ab311d5b809ac8546adc405bb7bab Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 5 Jun 2023 12:49:20 +0200 Subject: [PATCH 1/4] Use CashAgentLib --- DCPlugin.pri | 25 - DCPlugin.pro | 2 +- include/com.h | 105 - include/controlBus.h | 194 - include/datIf.h | 343 -- include/dcBL.h | 102 - include/hwChk.h | 35 - include/hwapi.h | 1290 ------- include/prot.h | 129 - include/sendWRcmd.h | 250 -- include/shared_mem_buffer.h | 296 -- include/storeINdata.h | 428 --- include/tslib.h | 90 - src/ATBAPP/ATBDeviceControllerPlugin.cpp | 51 +- src/ATBAPP/ATBDeviceControllerPlugin.h | 4 +- src/com.cpp | 448 --- src/controlBus.cpp | 326 -- src/datIf.cpp | 1853 ---------- src/dcBL.cpp | 1461 -------- src/hwChk.cpp | 25 - src/hwapi.cpp | 4278 ---------------------- src/prot.cpp | 768 ---- src/sendWRcmd.cpp | 704 ---- src/shared_mem_buffer.cpp | 39 - src/storeINdata.cpp | 1370 ------- src/tslib.cpp | 598 --- 26 files changed, 54 insertions(+), 15160 deletions(-) delete mode 100644 DCPlugin.pri delete mode 100644 include/com.h delete mode 100644 include/controlBus.h delete mode 100644 include/datIf.h delete mode 100644 include/dcBL.h delete mode 100755 include/hwChk.h delete mode 100644 include/hwapi.h delete mode 100644 include/prot.h delete mode 100644 include/sendWRcmd.h delete mode 100644 include/shared_mem_buffer.h delete mode 100644 include/storeINdata.h delete mode 100644 include/tslib.h delete mode 100644 src/com.cpp delete mode 100644 src/controlBus.cpp delete mode 100644 src/datIf.cpp delete mode 100644 src/dcBL.cpp delete mode 100755 src/hwChk.cpp delete mode 100644 src/hwapi.cpp delete mode 100644 src/prot.cpp delete mode 100644 src/sendWRcmd.cpp delete mode 100644 src/shared_mem_buffer.cpp delete mode 100644 src/storeINdata.cpp delete mode 100644 src/tslib.cpp diff --git a/DCPlugin.pri b/DCPlugin.pri deleted file mode 100644 index 1f6add0..0000000 --- a/DCPlugin.pri +++ /dev/null @@ -1,25 +0,0 @@ -INCLUDEPATH += $${PWD}/include -DEPENDPATH += $${PWD} - -HEADERS += $${PWD}/include/com.h \ - $${PWD}/include/controlBus.h \ - $${PWD}/include/datIf.h \ - $${PWD}/include/dcBL.h \ - $${PWD}/include/hwapi.h \ - $${PWD}/include/interfaces.h \ - $${PWD}/include/prot.h \ - $${PWD}/include/sendWRcmd.h \ - $${PWD}/include/storeINdata.h \ - $${PWD}/include/tslib.h \ - $${PWD}/include/shared_mem_buffer.h - -SOURCES += $${PWD}/src/com.cpp \ - $${PWD}/src/controlBus.cpp \ - $${PWD}/src/datIf.cpp \ - $${PWD}/src/dcBL.cpp \ - $${PWD}/src/hwapi.cpp \ - $${PWD}/src/prot.cpp \ - $${PWD}/src/sendWRcmd.cpp \ - $${PWD}/src/storeINdata.cpp \ - $${PWD}/src/tslib.cpp \ - $${PWD}/src/shared_mem_buffer.cpp diff --git a/DCPlugin.pro b/DCPlugin.pro index 817abf8..eeead9b 100644 --- a/DCPlugin.pro +++ b/DCPlugin.pro @@ -14,7 +14,6 @@ QMAKE_CXXFLAGS += -Wno-deprecated-copy # default ARCH = PTU5 -include(DCPlugin.pri) contains( CONFIG, DesktopLinux ) { QMAKE_CC = ccache $$QMAKE_CC @@ -70,6 +69,7 @@ DEFINES += QT_DEPRECATED_WARNINGS # ATBAPP interface HEADERS += \ + include/interfaces.h \ src/ATBAPP/ATBAPPplugin.h \ src/ATBAPP/DeviceControllerInterface.h \ src/ATBAPP/ATBHealthEvent.h \ diff --git a/include/com.h b/include/com.h deleted file mode 100644 index 44b0021..0000000 --- a/include/com.h +++ /dev/null @@ -1,105 +0,0 @@ -//CAT is always master, no receive before request - -#ifndef SER_H -#define SER_H -#include -#include -#include -#include -#include -#include "tslib.h" -#include "controlBus.h" - -#define MAXTELEGRAMLEN 90 - -// display all inputs and outputs in output window: -//#define PRINTALLDEBUGS 1 - -class T_com : public QObject //, public QPlainTextEdit -{ - Q_OBJECT - - // complete send message (protocol frame) - QByteArray sendBuffer; //[MAXTELEGRAMLEN]; - uint16_t sendLen; // >0: Daten Sendebereit, nach senden wieder auf 0 setzen - - // right after reception: - QByteArray rawInput; //[MAXTELEGRAMLEN]; - uint16_t rawInLen; // 0: keine neuen Daten erhalten - -// QSerialPort *CatSerial = nullptr; - QSerialPort *CatSerial; - - //char oeffneSerialPort(); - char open_Serial_Port(); - void closeSerialPort(); - void receiveByLength(void); - -private slots: - void readSomeBytes(void); - void serialSendComplete(void); - //void incomingWake(void); //bool LevelOfTheBit); - void receiveTO(void); - void ser_ISR100ms(); - - - -public: - T_com(QObject *parent = nullptr); - ~T_com(); - - QTimer *serRecTime; - - bool isPortOpen(void); - - void writeToSerial(const QByteArray &data, uint16_t sendLength); - - void receiveFixLen(int64_t nrOfbytesToReceive); - - bool readFromSerial(QByteArray &data, uint16_t &sendLength); - // retval: true: data available - -/* - uint8_t getAllPortPins(void); - // rs232pins: all signals bitwise coded in one byte: - // readback output: bit 0=TxD(=output) bit2=DTR (=output) bit 6=RTS (=output) - // unused inputs: bit1=RxD bit 3=DCD bit 5 = RING - // handshake inputs: bit 4=DSR (0x10) bit 7=CTS (0x80) - - bool getHSin_CTS(void); - // return the CTS Handshake input): true= high level (+8V) - - bool getHSin_DSR(void); - // return the DSR Handshake input): true= high level (+8V) - - bool setHSout_RTS(bool hsout); - // hsout true=positiv voltage +12V false= -12V - // retval: true=setting OK - - bool setHSout_DTR(bool hsout); - // hsout true=positiv voltage +12V false= -12V - // retval: true=setting OK -*/ - -signals: - void receivingFinished(); - void sendingFinished(); - //void wasWokenBySerialHandshake(); - -}; - - - -#endif // SER_H - - - - - - - - - - - - diff --git a/include/controlBus.h b/include/controlBus.h deleted file mode 100644 index 3dc8b11..0000000 --- a/include/controlBus.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef CONTROLBUS_H -#define CONTROLBUS_H - - -#include -#include "tslib.h" -#include - - -// /////////////////////////////////////////////////////////////////////////////////// -// control serial interface gui <--> serial -// /////////////////////////////////////////////////////////////////////////////////// - - -void epi_setSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect); - // Actions: open serial port with parameters - -void epi_closeSerial(void); -// Actions: close serial port - -// Actions, GUI Buttons -> API, start cyclic transmission -void epi_startEmmision(char start); // 1: start sending activated - -//void epi_setPeriodicSendTimeVal(uint16_t val); - - -// Port -> API -void gpi_serialChanged(void); - // serial confirms that port was closed or opened - -// Actions, API -> serialPort -uint8_t gpi_getSerialConn(void); // connect if 1, disconnect if 0 - -int gpi_getBaudNr(void); - -QString gpi_getComPortName(void); - - -void gpi_serialIsOpen(bool offen); - -bool epi_isSerialPortOpen(); - // true: port is open false: port is closed - - - - - -// Meldung von TabCom an Datif: starte zyklische Sendung: -bool gpi_isEmmisionOn(void); - -//uint16_t gpi_getPeriodicSendTimeVal(); - -//bool gpi_PeriodicSendTimeHasChanged(); - -//void epi_setCurrSlavAddr(int slavAd); - -//int gpi_getCurrSlavAddr(void); - - - - -// /////////////////////////////////////////////////////////////////////////////////// -// Status Display gui <--> serial -// /////////////////////////////////////////////////////////////////////////////////// - -//--------------------- - // Statuszeile COM Port (serial Port) (open, closed) -// Display in tab_com -QString epi_getTxt4comStateLine(void); -void epi_clrTxt4comStateLine(); - // GUI: get Text for serial Comport-State Line - -//--------------------- -// Statuszeile Handshakes (serial Control) flow.cpp -// geht überhaupt was raus? kommt überhaupt was zurück? -// I -QString epi_getTxt4HsStateLine(void); -void epi_clrTxt4HsStateLine(); - // GUI: get Text - -// II Master receive state (empfangenes Telgramm OK? crc? length? ) -// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp) -QString epi_getTxt4masterStateLine(void); -void epi_clrTxt4masterStateLine(); - -// III Slave receive (from Master) OK? if then show results, if not then show errors -// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR -// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch -// nicht verwenden und nichts ausgeben oder einlesen -QString epi_getTxt4resultStateLine(void); -void epi_clrTxt4resultStateLine(); - -// IV Statuszeile Sende- und Empfangsdaten (Datif) -// Display in tab_com -QString epi_getTxt4dataStateLine(void); -void epi_clrTxt4dataStateLine(); -// GUI: get Text for serial Comport-State Line - -// V, unten, Datif -QString epi_getTxt4datifLine(void); -void epi_clrTxt4datifLine(); - -//--------------------- - - // sende-empfangs-Rohdaten-Fenster -// Display in tab_com -QString epi_getTxt4RsDiagWin(void); -void epi_clrTxt4RsDiagWin(); - -QString epi_get2ndTxt4RsDiagWin(void); -void epi_clr2ndTxt4RsDiagWin(); - - -// Statuszeile COM Port (serial Port) (open, closed) -// Display in tab_com -void gpi_setTxt4comStateLine(QString txtline); - // serial: write Text to be displayed in serial Comport-State line (like "connected") - // used in vcp.cpp, links in tabCom - - -// Statuszeile Handshakes (serial Control) -// I obere Zeile -void gpi_setTxt4HsStateLine(QString txtline); - // used in flow.cc - -// II -void gpi_setTxt4masterStateLine(QString txtline); - -// III -void gpi_setTxt4resultStateLine(QString txtline); - -// IV -void gpi_setTxt4dataStateLine(QString txtline); - // serial: write Text to be displayed in serial Comport-State line (like "connected") - // used in prot.cpp - -// V unten: -void gpi_setTxt4datifLine(QString txtline); - - -// sende-empfangs-Rohdaten-Fenster -// Display in tab_com -void gpi_setTxt4RsDiagWin(QString txtline); -void gpi_set2ndTxt4RsDiagWin(QString txtline); - -// /////////////////////////////////////////////////////////////////////////////////// -// Memory for Slave responses, common data -// /////////////////////////////////////////////////////////////////////////////////// - -bool epi_getResult_serialTestOK(); -// retval: true: test was successful, got right response - - -// result of serial line test, slave sent fixed string -void gpi_storeResult_serialTestOK(bool wasOn); - - -// /////////////////////////////////////////////////////////////////////////////////// -// restore just received data -// /////////////////////////////////////////////////////////////////////////////////// - - -uint8_t gpi_startNewRequest(); - // called by Datif - -uint8_t gpi_storeResultOfLastRequest(bool answisok); - // written by Datif - -uint8_t epi_getResultOfLastRequest(); - // retval: 0: in progress 1: OK 2: error - - -void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData); - // stored by Datif - -uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad); - // get data back in *pl, max 64 byte - // retval = nr of bytes received. If host buffer too small then - // only plBufSíz bytes are copied to pl - // plBufSíz=size of host buffer - - - -#endif - - - - - - - - - - diff --git a/include/datIf.h b/include/datIf.h deleted file mode 100644 index f1f2c07..0000000 --- a/include/datIf.h +++ /dev/null @@ -1,343 +0,0 @@ -// Data Interface between slave (DC) and pi buffer -// determines sending and receiving order of data -// cares for storing input data and restoring output data - - - -#ifndef DIF_H -#define DIF_H -#include -#include "tslib.h" -#include "prot.h" -#include "dcBL.h" - - -#include -#include -#include -#include -#include -#include -#include - - - -#define CMD2DC_sendTime 20 -#define CMD2DC_setWakeFrequ 112 -#define CMD2DC_MOV_UPLOCK 113 -#define CMD2DC_MOV_DNLOCK 114 -#define CMD2DC_UPPER_DOOR 115 -#define CMD2DC_LOWER_DOOR 116 -#define CMD2DC_VAULT_DOOR 117 -#define CMD2DC_REJMOT_ON 118 -#define CMD2DC_REJMOT_RUN 119 -#define CMD2DC_LED_COIN 100 -#define CMD2DC_LED_ILLU 101 -#define CMD2DC_LED_TICKET 102 -#define CMD2DC_LED_START 104 -#define CMD2DC_LED_PIN 103 -#define CMD2DC_LED_IN 105 -#define CMD2DC_FAN 106 -#define CMD2DC_SIREN 107 -#define CMD2DC_BARRIER 108 -#define CMD2DC_WAKEPTU 109 -#define CMD2DC_SWITCHAUXPWR 110 -#define CMD2DC_SWITCHAUXDDR 18 -#define CMD2DC_SWITCHAUXOUT 19 -#define CMD2DC_UCONTACTON 111 -#define CMD2DC_DEVICE_PARAM 23 -#define CMD2DC_SEND_MACH_ID 11 -#define CMD2DC_RDBK_DEV_PARA 14 - -#define CMD2DC_RDBK_MACH_ID 15 - -#define CMD2DC_MDB_ON 120 -#define CMD2DC_MDB_GET_STATE 107 // REQ -#define CMD2DC_MDB_DORESET 121 -#define CMD2DC_MDB_SETWAK 122 -//#define CMD2DC_MDB_GETWAK 0x2812 // REQ not nec. -#define CMD2DC_MDB_SENDCMD 123 -#define CMD2DC_MDB_SENDMSG 12 -#define CMD2DC_MDB_GETRESP 22 // REQ - -#define CMD2DC_EMP_SET 24 -#define CMD2DC_EMP_GET_ALL 23 // REQ -#define CMD2DC_EMP_STARTPOLL 124 -#define CMD2DC_EMP_STARTPAY 125 -#define CMD2DC_EMP_STOPPAY 126 -#define CMD2DC_EMP_GOTCOIN 108 // REQ -#define CMD2DC_SHUTTER_OPEN 129 -#define CMD2DC_ESCR_OPEN 132 -#define CMD2DC_ESCR_TAKE 133 -#define CMD2DC_ESCR_RETURN 134 -#define CMD2DC_MOD_ON 135 -#define CMD2DC_MOD_WAK 136 -#define CMD2DC_CRED_ON 137 -#define CMD2DC_CRED_WAK 138 - -// READ Commands ((e.g. get input) -#define CMD2DC_TestSerial 10 -#define CMD2DC_GetSerialConfig 105 -#define CMD2DC_RdBkHWversion 11 -#define CMD2DC_RdBkSWversion 12 -#define CMD2DC_RdBkDCstate 101 -#define CMD2DC_RdBkUID 18 -#define CMD2DC_RdBkTime 104 -#define CMD2DC_RdBkAnalog 106 -#define CMD2DC_GetAllInputs 102 -#define CMD2DC_RdBkAllOutputs 103 -#define CMD2DC_MIFREADERON 127 -#define CMD2DC_ATB_CREATE 128 - - - - -// Mif read data: -#define CMD2DC_RdBk_MifState 109 -#define CMD2DC_RdBk_MifData 24 - - - - -#define CMD2DC_RdBk_AtbCardType 25 -#define CMD2DC_SHUTTER_COIN 131 -#define CMD2DC_SHUTTER_OPEN3S 130 -#define CMD2DC_SEND_SHUT_TIME 0x2915 -#define CMD2DC_ESCR_TAKE 133 -#define CMD2DC_ESCR_RETURN 134 -#define CMD2DC_PRINTERON 139 -#define CMD2DC_RdBk_PrnState 110 -#define CMD2DC_RdBk_PrnFonts 26 -#define CMD2DC_RdBk_AllPrnData 27 - // nr of params: -#define CMD2DC_PRI_SYS_CMD 25 // 3 -#define CMD2DC_PRI_ESC_CMD 26 // 4 -#define CMD2DC_PRI_SETUP 27 // 5 -#define CMD2DC_PRI_MOVE 140 // 2 -#define CMD2DC_PRI_SETFONT 141 // 4 -#define CMD2DC_PRI_SETLETTER 142 // 3 -#define CMD2DC_PRI_CUT 143 // 1 -#define CMD2DC_PRI_PRINT_TXT 13 // 64 -#define CMD2DC_PRI_LF 144 // 1 -#define CMD2DC_PRI_PRIFONTTABLE 145 -#define CMD2DC_PRI_BARCODE 14 // ca 15...25 -#define CMD2DC_STOR_QR_DATA 15 // 150 -#define CMD2DC_PRI_QR_CODE 146 // 0 -#define CMD2DC_PRI_LOGOFROMFLASH 147 // 2 -#define CMD2DC_PRI_STORE_DOC 16 // 1 -#define CMD2DC_PRI_DOCUMENT_NR 17 // 1 + 64 -#define CMD2DC_PRI_CLEAR_DOC 148 // 1 - - -/* -// WRITE Commands (e.g. switch relay) -#define CMD2DC_sendTime 0x1310 -#define CMD2DC_setWakeFrequ 0x1320 - -#define CMD2DC_MOV_UPLOCK 0x1801 -#define CMD2DC_MOV_DNLOCK 0x1802 -#define CMD2DC_UPPER_DOOR 0x1810 -#define CMD2DC_LOWER_DOOR 0x1811 -#define CMD2DC_VAULT_DOOR 0x1812 - -// neu 7.10.21: -#define CMD2DC_REJMOT_ON 0x1813 -#define CMD2DC_REJMOT_RUN 0x1814 - - -#define CMD2DC_LED_COIN 0x1204 -#define CMD2DC_LED_ILLU 0x1205 -#define CMD2DC_LED_TICKET 0x1206 -#define CMD2DC_LED_START 0x1208 -#define CMD2DC_LED_PIN 0x1207 -#define CMD2DC_LED_IN 0x1209 -#define CMD2DC_FAN 0x1210 -#define CMD2DC_SIREN 0x1211 -#define CMD2DC_BARRIER 0x1212 -#define CMD2DC_WAKEPTU 0x1218 -#define CMD2DC_SWITCHAUXPWR 0x1220 -#define CMD2DC_SWITCHAUXDDR 0x1222 -#define CMD2DC_SWITCHAUXOUT 0x1224 -#define CMD2DC_UCONTACTON 0x1226 - -#define CMD2DC_DEVICE_PARAM 0x2000 -#define CMD2DC_SEND_MACH_ID 0x2002 -#define CMD2DC_RDBK_DEV_PARA 0x2001 -#define CMD2DC_RDBK_MACH_ID 0x2003 - - - -// --------------------------- MDB -------------- -#define CMD2DC_MDB_ON 0x2800 -#define CMD2DC_MDB_GET_STATE 0x2801 // REQ -#define CMD2DC_MDB_DORESET 0x2802 -#define CMD2DC_MDB_SETWAK 0x2811 -//#define CMD2DC_MDB_GETWAK 0x2812 // REQ not nec. -#define CMD2DC_MDB_SENDCMD 0x2820 -#define CMD2DC_MDB_SENDMSG 0x2821 -#define CMD2DC_MDB_GETRESP 0x2822 // REQ - -// --------------------------- EMP -------------- -#define CMD2DC_EMP_SET 0x2830 -#define CMD2DC_EMP_GET_ALL 0x2831 // REQ -#define CMD2DC_EMP_STARTPOLL 0x2832 -#define CMD2DC_EMP_STARTPAY 0x2834 -#define CMD2DC_EMP_STOPPAY 0x2836 -#define CMD2DC_EMP_GOTCOIN 0x2837 // REQ - - - - - - - - -#define CMD2DC_SHUTTER_OPEN 0x2911 -#define CMD2DC_ESCR_OPEN 0x2920 -#define CMD2DC_ESCR_TAKE 0x2921 -#define CMD2DC_ESCR_RETURN 0x2922 -#define CMD2DC_MOD_ON 0x2940 -#define CMD2DC_MOD_WAK 0x2941 -#define CMD2DC_CRED_ON 0x2960 -#define CMD2DC_CRED_WAK 0x2961 - - -// READ Commands ((e.g. get input) -#define CMD2DC_TestSerial 0x1101 -#define CMD2DC_GetSerialConfig 0x1107 -#define CMD2DC_RdBkHWversion 0x110A -#define CMD2DC_RdBkSWversion 0x110B -#define CMD2DC_RdBkDCstate 0x110C - -#define CMD2DC_RdBkUID 0x1305 -#define CMD2DC_RdBkTime 0x1313 -#define CMD2DC_RdBkAnalog 0x1550 -#define CMD2DC_GetAllInputs 0x1201 -#define CMD2DC_RdBkAllOutputs 0x1202 - - -#define CMD2DC_MIFREADERON 0x2900 -#define CMD2DC_ATB_CREATE 0x2907 -// Mif read data: -#define CMD2DC_RdBk_MifState 0x2902 -#define CMD2DC_RdBk_MifData 0x2903 -#define CMD2DC_RdBk_AtbCardType 0x2905 -//#define CMD2DC_RdBk_CardData 0x2906 - - - - -// higher Level operation commands -//#define CMD2DC_SHUTTER_ONE 0x2912 -#define CMD2DC_SHUTTER_COIN 0x2913 -#define CMD2DC_SHUTTER_OPEN3S 0x2912 -#define CMD2DC_SEND_SHUT_TIME 0x2915 - -#define CMD2DC_ESCR_TAKE 0x2921 -#define CMD2DC_ESCR_RETURN 0x2922 - - -#define CMD2DC_PRINTERON 0x2A01 -#define CMD2DC_RdBk_PrnState 0x2A02 -#define CMD2DC_RdBk_PrnFonts 0x2A12 -#define CMD2DC_RdBk_AllPrnData 0x2A40 - - // nr of params: -#define CMD2DC_PRI_SYS_CMD 0x2A03 // 3 -#define CMD2DC_PRI_ESC_CMD 0x2A04 // 4 -#define CMD2DC_PRI_SETUP 0x2A05 // 5 -#define CMD2DC_PRI_MOVE 0x2A06 // 2 -#define CMD2DC_PRI_SETFONT 0x2A10 // 4 -#define CMD2DC_PRI_SETLETTER 0x2A11 // 3 -#define CMD2DC_PRI_CUT 0x2A13 // 1 - -#define CMD2DC_PRI_PRINT_TXT 0x2A14 // 64 - -#define CMD2DC_PRI_LF 0x2A15 // 1 -#define CMD2DC_PRI_PRIFONTTABLE 0x2A16 -#define CMD2DC_PRI_BARCODE 0x2A17 // ca 15...25 - -#define CMD2DC_STOR_QR_DATA 0x2A18 // 150 -#define CMD2DC_PRI_QR_CODE 0x2A19 // 0 - -#define CMD2DC_PRI_LOGOFROMFLASH 0x2A1A // 2 - -#define CMD2DC_PRI_STORE_DOC 0x2A41 // 1 -#define CMD2DC_PRI_DOCUMENT_NR 0x2A42 // 1 + 64 -#define CMD2DC_PRI_CLEAR_DOC 0x2A43 // 1 - -*/ - - - - -#define FIX_SLAVE_ADDR 0 -#define SEND_ATONCE 1 -#define SENDCOMBINED 0 - - - - -class T_datif : public QObject -{ - Q_OBJECT - - char sendINrequestsAutomatic(void); - // sende alle Befehle um die Eingangsdaten abzufragen der Reihe nach - char loadRecDataFromFrame(); - void datif_startSending(void); - void datif_sendIOrequest(uint16_t WRcmd, uint16_t RDcmd, uint8_t nrOfWrData); - - void datif_send8byteOutCmd(uint16_t WRcmd, uint16_t RDcmd); - - bool verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData); - void datif_OUT_setTime(void); - uint8_t datif_OUT_SendRandomData(uint8_t *buf, uint8_t Length); - - void datif_send64byteOutCmd(uint16_t WRcmd, uint16_t addr, uint16_t RDcmd); - - void datif_sendToMemory(uint16_t WRcmd, uint16_t docNr, uint16_t blockNr, uint8_t *data64); - // send printer documents to DC2 memory - // docNr: 0...15(31) with 1280 byte each (20 blocks a 64byte) - // blockNr=0...19 with 64byte each - // docNr =transmitted in WRITEADDRESS high byte - // blockNr=transmitted in WRITEADDRESS low byte - - - T_prot *myDCIF; - QTimer *datif_trigger; - uint8_t selectedSlaveAddr; - - int datif_noResponseCtr; - -private slots: - char datif_cycleSend(); - void StoredRecData(); - -public: - T_datif(QObject *parent = nullptr); - - T_prot *getProt() { return myDCIF; } - T_prot const *getProt() const { return myDCIF; } - - void resetChain(void); - char isPortOpen(void); - void sendWRcommand(uint16_t nxtAsCmd); - // Sende Schreibbefehle die bereits vorher asynchron gespeichert wurden - void send_requests(uint16_t nextWrCmd); - void sendHighLevel(uint16_t nxtHLCmd); - bool areDataValid(void); - -signals: - void ResponseRecieved(); - //the requested data are stored in peripheral image - // can be loaded with epi - - void datif_templatePrintFinished_OK(); - void datif_templatePrintFinished_Err(); - - void datif_gotNewCoin(); - -}; - -#endif // CI_H diff --git a/include/dcBL.h b/include/dcBL.h deleted file mode 100644 index f605270..0000000 --- a/include/dcBL.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef DCBL_H -#define DCBL_H -#include -#include "qbytearray.h" -#include "qstring.h" -#include - -uint8_t dcBL_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf); -// make BL protocol, retval = outbuf length (5...133) -// bring data in correct form: start always with 0x02 finish with 0x03 and append checksum -// 0x02 Cmd < ...sendData ..> CRC CRC 0x03 -// Data length = 0...64 -// special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 -// so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 - -uint8_t dcBL_readBLversion(uint8_t *sendData); - // minimum size of sendData-buffer: 5byte retval: length - -uint8_t dcBL_readFWversion(uint8_t *sendData); - // minimum size of sendData-buffer: 5byte retval: length - -uint8_t dcBL_exitBL(uint8_t *sendData); - // minimum size of sendData-buffer: 5byte retval: length - -uint8_t dcBL_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData); - // minimum size of sendData-buffer: 13byte retval: length (9...13) - -uint8_t dcBL_writeLastPage(uint8_t *sendData); - // minimum size of sendData-buffer: 5byte retval: length - -uint8_t dcBL_restartDC(uint8_t *sendData); - // minimum size of sendData-buffer: 20 byte retval: length - -uint8_t dcBL_activatBootloader(uint8_t *sendData); - // minimum size of sendData-buffer: 20 byte retval: length - -uint8_t dcBL_getResponse(uint8_t *respBuff); - // retval: nr of received bytes - -bool dcBL_responseOK(); - // retval: 0: response OK (cmd |0x80) 1: response error (cmd or "0xe0") - -bool dcBL_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl); - - - -bool dcBL_isTextMemFree(void); - -void dcBL_writeText(QString newTxt); - -bool dcBL_checkForText(void); - // if pointer at 0 then no more content - -QString dcBL_readText(void); - // read from 0...9 (oldest first) - - - -void dcBL_iniChain(void); - -uint8_t dcBL_startChain(void); - -uint8_t dcBL_runChain(void); - -void dcBL_iniLoading(void); - -void dcBL_startLoading(void); - -uint8_t dcBL_sendHexfile(void); - - -uint8_t dcBL_getResult(void); -// call after every step to what's going on.... -// 1: connected to BL -// 2: transmission started -// 3: transmission successful - - - -#define RAW_BL_DATALEN 150 -void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData); - -uint8_t epi_getRawReceivedData(uint8_t *receivedData); - // retval=length, will be zeroed after first reading - -uint8_t epi_getRawRecLength(void); - // retval=length - -QString epi_getRawReceivedString(); - -void epi_clrRawReceivedString(); - - -uint8_t dcBL_sendSuccess(uint8_t lastCommand); - // return val: 0: no response by now 1:error 10: OK - // lastCommand=0x21 for sendAddr or 0x22 for send data - -char dcBL_loadBinary(char withDisplay); - - - -#endif // DCBL_H diff --git a/include/hwChk.h b/include/hwChk.h deleted file mode 100755 index 7163675..0000000 --- a/include/hwChk.h +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef hwchk_H -#define hwchk_H - -#include -#include -#include -#include "interfaces.h" -//#include "datIf.h" -#include -#include -#include "hwapi.h" - -//class QSharedMemory; -class hwChk : public QObject, - public hwinf -{ - Q_OBJECT -// Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" ) //FILE "HWapi.json") -// Q_INTERFACES(hwinf) -//private: -// QSharedMemory *m_sharedMem; - -public: - explicit hwChk(QWidget *parent = nullptr); - virtual ~hwChk(); - - -public: - hwinf *HWaccess; - - -}; - -#endif diff --git a/include/hwapi.h b/include/hwapi.h deleted file mode 100644 index 8be320c..0000000 --- a/include/hwapi.h +++ /dev/null @@ -1,1290 +0,0 @@ -/* -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" - -class QSharedMemory; -class hwapi : public QObject, - public hwinf -{ - Q_OBJECT - 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; - DownloadResult sendStatus(int ret) const; - DownloadResult dc_downloadBinary(QByteArray const &binary) const; - - bool startBootloader() const; - bool stopBootloader() const; - bool openSerial(int br, QString baudrate, QString comPort) const; - bool closeSerial(QString comport) const; - bool resetDeviceController() const; - QByteArray loadBinaryDCFile(QString filename) const; - bool downloadBinaryToDC(QString const &bFile) const; - - QSharedMemory *m_sharedMem; -public: - explicit hwapi(QObject *parent = nullptr); - virtual ~hwapi(); - - T_datif *myDatif; - - - virtual QStringList dc_getStatus() const override; - - // ------------------------------------------------------------------------------ - // Level 0 commands, interface - // open, close, change serial interface - // actually not neccessary as it is opened automatically on program start - // start automatic READ requests - // ------------------------------------------------------------------------------ - - bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const override; - // BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200 - // BaudStr: for exapmle "19200" - // ComName: for example "COM48" - // connect: 0, 1 - - bool dc_closeSerial(void) const override; - - bool dc_isPortOpen(void) const override ; - - void dc_autoRequest(bool on) const override ; - // select if READ-Requests are sent manually one by one or automatically - // automatically request ALL digital and analog sensors, get time/date, get status information - - bool dc_updateDC(QString binFileName, QString baudrate, - QString comPort) const override; - - bool dc_updatePrinterTemplate(enum FileTypeJson type, - QVector templateIdx, - QVector fnames, - QString br, - QString serial = QString()) const override; - - bool dc_printTemplate(enum FileTypeJson type, - QVector templateIdx, - QString br, - QString serial = QString()) const override; - // ------------------------------------------------------------------------------ - // Level 1, control device-controller (functions of µC) - // check serial connection to deviceController - // read response from DC2 (input data) - // some test function for serial communication - // also Bootloader is here - // ------------------------------------------------------------------------------ - - void dc_requTestResponse() const override; - // tell DC2 to return his TestString in order - // to test the serial and the baudrate - // must always be triggered manually, is never sent automatically - - bool dc_readAnswTestResponse() const override; - // retval: true: test was successful, got right response - - uint8_t dc_isRequestDone(void) const override; - // retval: 0: request is still in progress - // 1: answer from DC2 was OK - // 2: wrong answer from DC2 - - uint16_t dc_getCompletePayLoad(uint16_t plBufSiz, uint8_t *payLoad) const override; - // get data back in *pl, max 64 byte, can be used for diagnosis - // retval = nr of bytes received. If host buffer too small then - // only plBufSíz bytes are copied to pl - // plBufSíz=size of host buffer - - void dc_setWakeFrequency(uint8_t period) const override; - // RTC wakes DC2 (and PTU) by hardware signal every 32seconds - // change wake signal period to 1...64s - - void dc_OrderToReset(void) const override; - // want DC2 to reset (in order to start Bootloader) - - QString dc_getSerialState(void) const override; - void dc_clrSerialStateText(void) const override; - - void bl_sendDataDirectly(uint8_t length, uint8_t *buf) const override; - // send without protocol frame, needed for the DC bootloader - - uint8_t getRawRecLength(void) const override; - - uint8_t getRawReceivedData(uint8_t *receivedData) const override; - - QString dc_getSerialParams(void) const override; - - QString dc_getHWversion(void) const override; - - QString dc_getSWversion(void) const override; - - QString dc_getState(void) const override; - - QString dc_getTxt4RsDiagWin(void) const override; - void dc_clrTxt4RsDiagWin(void) const override; - QString dc_get2ndTxt4RsDiagWin(void) const override; - void dc_clr2ndTxt4RsDiagWin(void) const override; - QString dc_getTxt4HsStateLine(void) const override; - void dc_clrTxt4HsStateLine(void) const override; - QString dc_getTxt4masterStateLine(void) const override; - void dc_clrTxt4masterStateLine(void) const override; - QString dc_getTxt4resultStateLine(void) const override; - void dc_clrTxt4resultStateLine(void) const override; - QString dc_getdataStateLine(void) const override; - void dc_clrTxt4dataStateLine(void) const override; - QString dc_getdatifLine(void) const override; - void dc_clrTxt4datifLine(void) const override; - - // using DC2 Bootloader - void bl_iniChain(void) const override; - bool bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const override; - uint8_t bl_activatBootloader(uint8_t *sendData) const override; - uint8_t bl_startChain(void) const override; - uint8_t bl_readBLversion(uint8_t *sendData) const override; - // minimum size of sendData-buffer: 5byte retval: length - uint8_t bl_readFWversion(uint8_t *sendData) const override; - // minimum size of sendData-buffer: 5byte retval: length - - uint8_t bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const override; - // make BL protocol, retval = outbuf length (5...133) - // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum - // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 - // Data length = 0...64 - // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 - // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 - - 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 - // RD. get time, get measure, get test results - // ------------------------------------------------------------------------------ - - // get UID, get time/date test results memory, RTC analog values -/* - struct Trtc_DateTime - { - uint8_t rtc_hour; - uint8_t rtc_min; - uint8_t rtc_sec; - uint8_t rtc_dayOfMonth; - uint8_t rtc_month; - uint8_t rtc_year; - uint8_t rtc_dayOfWeek; - }; -*/ - uint8_t rtc_getDateTime(struct Trtc_DateTime *rtc_DateTime) const override; - - uint8_t rtc_setDateTime(void) const override; - // synch DC2 with PC or PTU system time and date - - void rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const override; - // get time directly - - void rtc_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) const override; - // get date directly - - uint8_t rtc_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) const override; - // dow=day of week, 1=monday...7 - // minOfToday: 0=midnight...1439= 23:59 - // secOfToday: 0=midnight...86399= 23:59:59 - - bool rtc_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) const override; - // retval true: this year is leap year - - bool rtc_isLeapYear() const override; - - void rtc_getWeek(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) const override; - // DayOfWeek: 1=monday...7 - // HoursOfWeek: 0=Monday 0:00 o'clock...167=Sunday 23:00 - // MinutesOfWeek: 0=Monday 0:00 o'clock...10079=Sunday 23:59 - - void rtc_getMonth(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) const override; - // DayOfMonth: 1...31 - // HoursOfMonth: 0 = 0:00o'clock of 1.day in month up to 743 - // MinutesOfMonth:0 = 0:00o'clock of 1.day in month up to 44639 - - void rtc_getYear(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) const override; - // DayOfYear: 1...366 1= 1.Jan of this current year - // HoursOfYear: 0=1.Jan 0:00o'clock ...8783=31.12 23 o'clock - // MinutesOfYear: 0=1.Jan 0:00o'clock ...527039=31.12 23:59 o'clock - - QString rtc_getTimStr(void) const override; - QString rtc_getDatStr(void) const override; - QString rtc_getTimDatStr(void) const override; - - // UID - void dc_getUID8byte(uint8_t *buf8byteUid) const override; - QString dc_getUIDstr() const override; - uint64_t dc_getUIDnumber(void) const override; - - - // Analog inputs: - uint32_t dc_getTemperature(void) const override; // in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C) - QString dc_getTemperaturStr(void) const override; - - uint32_t dc_getVoltage(void) const override; // in mV, 0...65,535V - QString dc_getVoltagStr(void) const override; - - bool dc_mainFuseIsOk(void) const override; - - // ------------------------------------------------------------------------------ - // Level 3: digital outputs and simple switching of connected devices - // simple processes like flashing a led or open flap for 1s - // ------------------------------------------------------------------------------ - - void lock_switchContactPower(bool on) const override; - - // Locks move until stop cmd (0) - uint8_t lock_switchUpperLock(uint8_t dir) const override; - // dir 0=off 1=up 2=down - uint8_t lock_switchLowerLock(uint8_t dir) const override; - // dir 0=off 1=up 2=down - void lock_switchVaultDoor(void) const override; - - void coin_switchRejectMotor(uint8_t dir) const override; - - void coin_rejectCoins(void) const override; - - // LEDs - void led_switchLedIllumination(uint8_t on) const override; - void led_switchLedService(uint8_t on) const override; - void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const override; - void led_switchLedPinPad(uint8_t on, uint8_t ton, uint8_t tof) const override; - void led_switchLedStart(uint8_t on, uint8_t ton, uint8_t tof) const override; - void led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const override; - - void fan_switchFan(bool on) const override; - void alarm_switchSiren(bool on) const override; - void bar_OpenBarrier(bool open) const override; - void ptu_switchWake(bool WAKEACTIVE) const override; - - void prn_switchPower(bool on) const override; - - void mif_readerOn(bool on) const override; - void shut_move(bool open) const override; - void esc_moveFlaps(uint8_t flap ) const override; - // 0: close both 1: open take-flap 2: open return - - void mdb_switchPower(bool on) const override; - void mdb_switchWake(bool WAKEACTIVE) const override; - - void mod_switchPower(bool on) const override; - void credit_switchPower(bool on) const override; - - void aux_power(bool on) const override; - void aux_setUsage(uint8_t PinDirection) const override; - void aux_setOutputs(uint8_t PinIsHigh) const override; - - - void mod_switchWake(bool WAKEACTIVE) const override; - - void credit_switchWake(bool WAKEACTIVE) const override; - - - - - // ------------------------------------------------------------------------------ - // Level 3: digital inputs of connected devices - // ------------------------------------------------------------------------------ - - bool door_isContactPowerOn(void) const override; - - uint8_t door_getSwitches(void) const override; - // retval: bit0: upper door 1: low door 2:vault door - - bool door_isUpperDoorOpen(void) const override; - - bool door_isLowerDoorOpen(void) const override; - - bool vault_isVaultDoorOpen(void) const override; - - uint8_t vault_getSwitches(void) const override; - // retval bit0: cash box, bit 1: bill box - - bool vault_isCoinVaultIn(void) const override; - - bool vault_isBillVaultIn(void) const override; - - uint8_t door_getLocks(void) const override; - // retval bit0: upper lever is up - // bit1: upper lever is down - // bit2: lower lever is up - // bit3: lower lever is down - - bool door_upperDoorIsLocked(void) const override; - - bool door_upperDoorIsUnlocked(void) const override; - - bool door_lowerDoorIsLocked(void) const override; - - bool door_lowerDoorIsUnlocked(void) const override; - - bool bar_optoIn1isOn(void) const override; - - bool bar_optoIn2isOn(void) const override; - - bool ptu_WakeINisActive(void) const override; - - bool prn_isPrinterPowerOn(void) const override; - uint8_t prn_PrnFuseIsOk(void) const override; - //retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off - - bool prn_readyINisActive(void) const override; - - bool mif_cardIsAttached(void) const override; - bool mif_isMifarePowerOn(void) const override; - - bool mdb_WakeINisActive(void) const override; - bool mdb_testIsmdbTxDon(void) const override; - bool mdb_isMdbPowerOn(void) const override; - - bool coid_isAttached(void) const override; - bool coin_escrowIsOpen(void) const override; - - bool aux_isAuxPowerOn(void) const override; - - uint8_t aux_getAuxInputs(void) const override; - - bool mod_isGsmPowerOn(void) const override; - - bool cred_isCreditPowerOn(void) const override; - - bool cash_getRejectMotorHomePos(void) const override; - - uint8_t cash_getLowPaperSensor(void) const override; - // 0: Sensor sees paper 1: no paper 99: off - - - // ------------------------------------------------------------------------------ - // Level1,2,3 RD request commands - // ------------------------------------------------------------------------------ - - // all read-requests can be sent manually by the following functions - // or automatically in background by: void hwapi::dc_autoRequest(bool on) - // in other words: - // if automatic-reading is on, then there's no need to send any of these commands, - // but it's allowed to send them in order to speed up the refreshing of the inputs - - void request_DC2serialConfig() const override; - void request_DC2_HWversion() const override; - void request_DC2_SWversion() const override; - void request_DC2_condition() const override; - void request_DC2_UID() const override; - void request_DC2_TimeAndDate() const override; - void request_DC2_analogues() const override; - void request_DC2_digitalInputs() const override; - void request_DC2_digitalOutputs() const override; - - // ------------------------------------------------------------------------------ - // the folowing device state requests are deploed only if device is powered up: - void request_PrinterHwState() const override; - void request_PrinterCurrentFonts() const override; - void request_PrinterStateComplete() const override; - - void request_MifareReaderState() const override; - void request_MifareCardType() const override; - void request_MifareAtbType() const override; - void request_MifareID() const override; - void request_MifareData(uint8_t dataBlockNumber) const override; - // dataBlockNumber must be 0....11, returns 64byte of data - - void request_MDB_Status() const override; - void request_MDB_lastResponse() const override; - void request_EMP_allParameters() const override; - void request_EMP_lastCoin() const override; - - - - // ------------------------------------------------------------------------------ - // Level 3: readback digital outputs of connected devices - // these functions are not needed for normal operation - // but can be used to test and verify conditions - - // There are two options: - // 1) the important things like power-outputs and wake lines are - // measured at DC2-terminals (after transistors) and come as input to DC-board - // 2) others like Leds are read from µC-pins by DC-board - // ------------------------------------------------------------------------------ - - bool test_getDO_mdbRXtst(void) const override; - - uint8_t lock_getDO_motors(void) const override; - // bit0: upper lock forward bit 1 backward - // bit2: lower lock forward bit 3 backward - - uint8_t test_serialState(void) const override; - // test on-board signals for the serials - // serial drv on/off, Serial mux1, Serial mux2 - bool test_serialIsOn(void) const override; - bool test_serialMux1isSetToPrinter(void) const override; - bool test_serialMux1isSetToModem(void) const override; - bool test_serialMux2isSetToCredit(void) const override; - bool test_serialMux2isSetToMifare(void) const override; - - bool led_coinIsOn(void) const override; - bool led_frontIsOn(void) const override; - bool led_ticketIsOn(void) const override; - bool led_pinIsOn(void) const override; - bool led_StartIsOn(void) const override; - bool led_insideIsOn(void) const override; - - bool fan_isOn(void) const override; - bool siren_isOn(void) const override; - bool bar_relayIsOn(void) const override; - bool ptu_WakeOutIsOn(void) const override; - - bool aux_powerIsOn(void) const override; - - bool coin_shutterIsOpen(void) const override; - bool coin_shutterTestOutput(void) const override; - - uint8_t coin_escrowFlapOpened(void) const override; - // retval: 1:return flap is open 2:take flap is open 0:closed - - - - // ------------------------------------------------------------------------------ - // Level4 ( Timer processes, device supervision by DC, processes with more then one devices - // WRITE - // ------------------------------------------------------------------------------ - - - void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, - uint8_t kindOfMifareReader, uint8_t suppressSleep, - uint8_t kindOfModem, uint8_t kindOfCredit ) const override; - // enable hardware in device controller: - // kindOfPrinter: 0:off 1: GPT4672 (only this one implemented) - // kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer - // kindOfMifareReader: 0:off 1: SL025 (only this one implemented) - // suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason - // kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented) - // kindOfCredit: 0:off 1: cVendTopp 2:cVendPin (not yet implemented) - - void request_ReadbackDeviceSettings() const override; - - void readback_DeviceSettings(uint8_t *length, uint8_t *data) const override; - // refer to DC2 manual for exact content - // state 5.5.21: byte[0]=kindOfPrinter byte[1]=kindOfCoinChecker - // byte[2]=kindOfMifarereadr byte[3]=suppress sleep mode - // byte[4]=kindOfModem byte[5]=kind of cc terminal - - uint8_t emp_returnLastCoin(uint16_t *value, uint8_t *signal) const override; - // use for changer - - void sendMachineID(uint16_t customerNr, uint16_t machineNr, - uint16_t borough, uint16_t zone, - uint16_t alias, char *location) const override; - - void request_ReadbackMachineID() const override; - - void readback_machineIDdata(uint8_t *length, uint8_t *data) const override; - // state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number - // byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name - // byte[10...41]=location - - - // Locks stops automatically at end switch or by timeout - uint8_t lock_openUpperDoor(void) const override; - uint8_t lock_closeUpperDoor(void) const override; - - uint8_t lock_openLowerDoor(void) const override; - uint8_t lock_closeLowerDoor(void) const override; - - - void shut_openOnce(void) const override; - // and close automatic after shutter time - - void shut_openForCoin(bool start) const override; - // open flap if coin is attached - // once process is started it runs until stop command - - void shut_sendOpeningTime(uint16_t timeIn_ms ) const override; - // after this time without retrigger the flap is closed - - void esc_takeMoney(void) const override; - // and close automatically after escrow time (1s) - - void esc_returnMoney(void) const override; - // and close automatically after escrow time (1s) - - void mif_creatAtbCard(uint8_t cardType) const override; - - - // ------------------------------------------------------------------------------ - // read response from DC2 (input data) - // ------------------------------------------------------------------------------ - - uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const override; - // retval 0=OK 1=error host buffer too small - /* data description, new fast version: - byte 0= still the same: current read state: - 0=power off 1=reader-fault 2=ready - 3=just reading 4=read complete - 5=read partial, removed too early - 6=state unknown - - byte 1: reader state 1=ok 0=nok - byte 2: card preent (0,1) - byte 3: card selected (0) - byte 4: card type: 0...5 - byte 5: card allowed (0=no 1=MifareClassic 1k or 4k) - byte 6: CardSize: 1 or 4 (kB) - byte 7: length of UID 4 or 7 (byte) - */ - - bool mif_readerIsOK(void) const override; - - bool mif_cardAttached(void) const override; - - uint8_t mif_readResult(void) const override; - // result: 0: unknown or still in progress - // 1: card read successful - // 2: reading error - - QString mif_cardUID(void) const override; - - uint8_t mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const override; - - QString mif_getCardDataStr(uint8_t blockNumber) const override; - // with blockNumber=0...11 - - - - - // ---------------------------------------------------------------------------------------------------------- - // --------------------------------------------- PRINTER ---------------------------------------------------- - // ---------------------------------------------------------------------------------------------------------- - - // read printer condition and settings - - uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const override; - // retval: status byte - // byte 0 = 0: prnter OK, >0: error - // bit0: paper low 1: no paper 2: temperature error - // 3: head open 4: paper jam in cutter - // 6: no response 7: bad response from printer - // and return struct "Tprn_hw_state" - - bool prn_isUpAndReady(void) const override; - // true: printer is powered, serial is ok, no error, printer is connected and resonding - - void prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const override; - - - // send Commands to printer: - - void prn_sendText(QByteArray *buf) const override; - // up to 1280 bytes - - void prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) const override; - // send three byte through to printer, see printers manual - - void prn_sendPrnEscCmd(uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4) const override; - // send four byte through to printer, see printers manual - - - void prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) const override; - // send 5 byte: byte 0,1: speed 5...250 mm/s - // byte2: density 0....(25)....50 - // byte3: alignment 'l', 'c', 'r' = left, center, right - // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) - // not batched! don't use twice within 100ms - - void prn_movePaper(uint8_t wayInMm, uint8_t direction) const override; - //direction: 1=forward 2=backward - // - void prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const override; - // font = kind of font 5...11 (0..22) - // size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge - // width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) - // heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense - - void prn_setLetters(uint8_t bold, uint8_t invers, uint8_t underlined) const override; - // bold: 0/1 - // invers: 0/1 - // underlined: 0/1 - - void prn_cut(uint8_t kindof) const override; - // kindof: 1=full cut 2=partial cut 3=eject (5xLF + full cut) - - void prn_newLine(uint8_t nrOfLines) const override; - - void prn_printCompleteFontTable(void) const override; - - - void prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) const override; - // kind of barcode: 0=Code39 1=Code128 2=EAN13 3= 2/5interleaved 4=UPC-A 5=EAN8 - // withText: print readable text below - // offset: move by pixel from left border - // rotation - // dataLeng in byte - - void prn_sendQRdata(QByteArray *buf) const override; - // maximal 150 alphanummeric bytes - - void prn_printQRcode(void) const override; - // QRcode may have 1...150 alphanummeric data, must be transfered in advance - - - void prn_printLogo(uint8_t nrOfLogo, uint8_t offset ) const override; - // nrOfLogo: 1..4 in flash 5...8 in Ram - // offset: in mm form left border - - - - // ......................................................... - // Parking Ticket (print-out document) designer TD - // ......................................................... - - // Predefine document Layout (e.g. parking ticket) in advance and stroe it for quick and easy use - // in opposite to the above "single" commands you need only one or a few commands at vending time. - // Stored text is just send to printer once the printing command is issued - // stored commands within the text are interpreted and executed right at the place (in ticket) they are - // example: start bold, , stop bold - // Predefinition of up to 16 ticket Layouts is possible, 0...1280 byte each - // Number 0..15, al keept non-volatile - // up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command - // example: print current time at this point (the time of printing not the storage time!!) - - void pri_startTicketDesign(void) const override; - // start for every new printer document, reseting collecting buffer - - // all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed - // return val of the appending functions: true=ok false=too long, buffer full - - int pri_TD_getCurrentSize(void) const override; - // retval: 0...1278 - - bool pri_TD_addText(QByteArray text) const override; - // example: pri_TD_addText("Hello") const override; - // example: pri_TD_addText(tempStr) const override; - // retval: true=ok false=too long, buffer full - - bool pri_TD_addValue(int val) const override; - // +/- 0...2^(31) - - bool pri_TD_addNewLine(void) const override; - - bool pri_TD_addSign(char sign) const override; - // example: '.' ' ' 0x20 'W' '$' - - bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const override; - // always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5 - /* complete list of possible commands: - group 50 : paper - attribute 10 : move forward - p1: wayInMm p2: direction - attribute 11 : cut - p1: kind of, 1=full 2=partial, 3=eject - attribute 12 : new line(s) - p1: nr of lines 1...100 - - group 51 : fonts - attribute 10 : kind of font see description above - p1: 0...8 - attribute 11 : font size - p1: 6...20 - attribute 12 : font width - p1: 0...4 - attribute 13 : font heigth - p1: 0...7 - attribute 14 : switch bold print on/off - p1: 0=off 1=on - attribute 15 : switch invers print on/off - p1: 0=off 1=on - attribute 16 : switch underlined print on/off - p1: 0=off 1=on - - group 52 : print graphics - attribute 10 : print barcode with dynamic data 6 and 7 - p1...p5 = kindOf, withText, offset, rotation, dataLeng, see description above - attribute 11 : print QRcode with preset data - - attribute 12 : print Logo - p1=nrOfLogo, p2=offset - - group 53 : print dynamics - attribute 10 : - p1: 1...8 = print dynData 0..7 at this place - - */ - - char prn_clearDocument(uint8_t documentNumber) const override; - // clear memory buffer for ONE document - // function takes a second! don't send right before "store doc" - - bool prn_store_Document(uint8_t documentNumber ) const override; - - // send the predefined Layout (generated with above TD functions) to DeviceController to save - // documentNumber=0...15 - // maximal 1280 bytes each - // allowed: 0x20...0xFF, 0x0A, 0x0C, 0x1B (LF, CR, Esc) - // 0x1B=start of embedded command (next 7bytes = command) - - // with a print command a set of 8 dynamic strings can be sent - // the place in the ticket layout is predefined (already in DC memory) - // the dynamics are first calculated at printing time - - bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const override; - - - - - - // ---------------------------------------------------------------------------------------------------------- - // --------------------------------------------- MDB Bus ---------------------------------------------------- - // ---------------------------------------------------------------------------------------------------------- - - //void mdb_switchPower(bool on) const override; defined above - //void mdb_switchWake(bool WAKEACTIVE) const override; defined above -// bool mdb_WakeINisActive(void) const override; -// bool mdb_testIsmdbTxDon(void) const override; -// bool mdb_isMdbPowerOn(void) const override; -// void request_MDB_Status() const override; -// void request_MDB_lastResponse() const override; - - - void mdb_sendBusReset(void) const override; - - void mdb_sendCommand(uint8_t toMdbDevice, uint8_t mdbCommand) const override; - // send one bus command directly over mdb bus, refer to mdb manual for commands - // this command is not needed in normal operation, just for new or special things - - void mdb_sendMessage(uint8_t toMdbDevice, uint8_t mdbCommand, uint8_t nrOfData, uint8_t *dataBuffer) const override; - // nrOfData = sizeOf(dataBuffer) maximal 34 byte according mdb specs - // same as mdb_sendCommand, just with data - - bool mdb_busIsReadyToWork() const override; - - bool mdb_deviceVoltageOK() const override; - - bool mdb_busVoltageOk() const override; - - uint8_t mdb_getLastDeviceResponse(uint8_t *fromDevice, uint8_t *lastRequest, - uint8_t *responseLength, uint8_t *responseBuffer) const override; - // fromDevice: device nr from which data was requested 0,1,2,3 - // lastRequest: sent mdb command - // responseLength: nr of payload data (after mdb-ack) 0...34 - // responseBuffer holds payload data (answer from mdb device) - // return val: mdb result of this request: 1=got ACK 2=got 3xNAK 3=no or bad response 4:got Data (after ACK) - - - - - - // ---------------------------------------------------------------------------------------------------------- - // ---------------------------------- Electronic Coin Validator EMP ----------------------------------------- - // ---------------------------------------------------------------------------------------------------------- - - - void emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const override; - // coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation) - // tokenChannel 0...31: if this signal comes from emp then a token was inserted - // coinDenomination = array of 16 coin values (e.g. 5, 10, 20...) - - void emp_pollingOnOff(uint8_t on) const override; - - void emp_startCoinAcceptance(void) const override; - - void emp_stopCoinAcceptance(void) const override; - - void emp_getAllParameters(struct T_emp *emp) const override; - // see struct in hwapi.h - // usage example: - // hwapi *HWaccess const override; - // HWaccess = new hwapi() const override; - // struct T_emp myEmp const override; - // HWaccess->emp_getAllParameters(&myEmp) const override; - // readval=myEmp.pollingRunning const override; - - uint8_t emp_chkIfCoinInserted(void) const override; - // retval: 0...16 coins left in FIFO - - void emp_getNewCoinRecord(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) const override; - // with every call ONE coin is taken out of FIFO and pointer decremented - // valid: should be 1 - // signal: comes right from coin checker, 0...15 (0=first programmed coin type) 0xFF=no signal - // error: was reported from EMP as dynamic signal right after coin insertion (instead of - // coin signal), example: 3=unknown coin 4=coin is blocked by host. 0xFF=no error - // value: of the coin. Depends on parameter "coinDenomination" in function "emp_sendSettings" - // if coinDenomination[coin 0..15] = 0 then the value programmed in coin checker is taken - // if coinDenomination > 0 then this value is taken. - // Useful in case of two currencies (adapt to local currency) or for token. - - // function gives more details as "emp getLastCoin()" but "emp getLastCoin()" is easier to use - - // alternativ to emp_getNewCoinRecord( ): - uint8_t emp_giveLastCoin(uint16_t *value, uint8_t *signal) const override; - // retval: 0: NO coin stored 1: valid coin 2: got wrong coin or coin denied - // value: if retval1: value of the coin if reval=2: error number - // 0xFF means NO error or NO signal (as 0 is a valid error/signal) - // signal: channel nr reported from checker 0...15 - - - - - -// neu, 25.3.23 - - void bl_rebootDC(void) const override; - - void bl_startBL(void) const override; - bool bl_checkBL(void) const override; - bool bl_isUp(void) const override; - // return true is bl is up and running - // also initializes "sendFile" - - void bl_sendAddress(uint16_t blockNumber) const override; - // send start address, nr of 64byte-block, start with 0 - // will be sent only for folling block-numbers: - // 0, 1024, 2048, 3072 and 4096, so basically every 64kByte - - uint8_t bl_wasSendingAddOK(void) const override; - // return val: 0: no response by now 1:error 10: OK - - void bl_openBinary(void) const override; - - void bl_sendDataBlock(uint8_t length, uint8_t *buffer) const override; - // send 64 byte from bin file - - void bl_sendLastBlock(void) const override; - - uint8_t bl_wasSendingDataOK(void) const override; - // return val: 0: no response by now 1:error 10: OK - - void bl_stopBL(void) const override; - - - // Bootlader, not used or obsolete - //bool bl_isDiagAvailable(void) const override; - //QString dc_getDiagText(void) const override; - //void bl_startSending(void) const override; - //void bl_sendFile(void) const override; - - - -// neu, ab 6.4.23 -// bereits vorhanden, nochmal getestet/verbessert: - // void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const override; - // void alarm_switchSiren(bool on) const override; - - // void mif_readerOn(bool on) const override; - // bool mif_cardIsAttached(void) const override; - - // void shut_move(bool open) const override; - // void esc_moveFlaps(uint8_t flap ) const override; - // 0: close both 1: open take-flap 2: open return - // void shut_openOnce(void) const override; - // and close automatic after shutter time - // void shut_openForCoin(bool start) const override; - // open flap if coin is attached - // once process is started it runs until stop command - // void shut_sendOpeningTime(uint16_t timeIn_ms ) const override; - // after this time without retrigger the flap is closed - // void esc_takeMoney(void) const override; - // and close automatically after escrow time (1s) - // void esc_returnMoney(void) const override; - // and close automatically after escrow time (1s) - - // void prn_switchPower(bool on) const override; - // void prn_sendText(QByteArray *buf) const override; - // up to 1280 bytes - - // uint8_t rtc_setDateTime(void) const override; - // send system time - - //void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, - // uint8_t kindOfMifareReader, uint8_t suppressSleep, - // uint8_t kindOfModem, uint8_t kindOfCredit ) const override; - - //void sendMachineID(uint16_t customerNr, uint16_t machineNr, - // uint16_t borough, uint16_t zone, - // uint16_t alias, char *location) const override; - - - bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const override; - // return true if successful. could fail if more the 8 commands are waiting - - bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const override; - bool rtc_getExtendedTime(struct T_extTime *exTime) const override; - - bool sys_runCompleteTest(void) const override; - // warning: lasts 20s in one pace - - bool sys_ready4sending(void) const override; - // return true if a Json-file can be sent - - bool sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8_t *content ) const override; - // kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer - // nrOfTemplate=1...32 if kindOfFile==6 - // content = content of the Json file, max 800byte ascii signs - // file is 0-terminated! - // return false if sending is not possible, wait a second - - bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const override; - // dynPrnVal = array of 8 Variables with 8 byte each, come as ascii string - // like: char prn_dynPrnVal[8][8]; - // return true if sending, false if cmd-stack is full - - bool prn_printTemplate(uint8_t nrOftemplate) const override; - // print one of the templates loaded by Json prior - // nr = 1..32 - // return true if sending, false if cmd-stack is full - - void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const override; - // returns all acc nrs of the backuped vault records - // use: uint16_t backupedAccNumbers[8] - - bool log_selectVaultRecord(uint16_t accountNr ) const override; - // return true if sending, false if cmd-stack is full - // and trigger transfer - - bool log_chkIfVaultRecordAvailable(void) const override; - // return true if completly received - - bool log_getVaultRecord(struct T_vaultRecord *retVR) const override; - // which was selected by: log_selectVaultRecord() - // to be forwarded to Ismas - - bool prn_printAccountReceipt(void) const override; - // return true if sending to DC OK, false if cmd-stack is full - - bool prn_printTestTicket(void) const override; - // return true if sending to DC OK, false if cmd-stack is full - - 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 - - bool cash_stopPayment(void) const override; - // and keep coins in escrow - - uint32_t getInsertedAmount(void) const override; - - uint16_t getLastInsertedCoin(void) const override; - - bool getAllInsertedCoins(uint16_t *types, uint16_t *values) const override; - // alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert, max 64 - - - // after ticket/goods issue: - bool vend_success(void) const override; - // conclude payment process, encash all inserted coins to vault. Printing was successful - // if possible return change - - bool vend_failed(void) const override; - // conclude payment process and return all inserted coins - - - - - - uint8_t mif_getCardType(QString *cardholder) const override; - // return 1,2,3,4 = upper, lower access card, printer test, coin test - // cardholder: 7byte Name-String - - uint64_t sys_getWakeSource(void) const override; - // retval: 6 bytes, bit coded, 1=event keeps DC awake - - uint8_t sys_getWakeReason(void) const override; - // Master was woken by following reason: - // 1: MDB Event - // 2: Coin Event - // ( 3: Master Event) - will not set the wake line - // ( 4: 32s pulse) - will not set the wake line - // 5: Door Event - // ( 6: Diag Event) - will not set the wake line - // 7: 30min-Pulse for HB - - void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const override; - - void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override; - - void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override; - void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override; - - - uint32_t cash_getAmountInVault(void) const override; - - uint16_t cash_getNrCoinsInVault(void) const override; - - uint8_t prn_getPrintResult() const override; - - uint8_t prn_getCurrentPrinterState() const override; - // 0: printer OK - // bit0: near paper end bit1: no paper - // bit2: temperature error bit3: error head open - // bit4: paper jam in cutter - // bit6: no response bit7: serial rec. error - // bit5: printer not ready - - void sys_sendDeviceParameter(struct T_devices *deviceSettings) const override; - - void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const override; - - bool sys_areDCdataValid(void) const override; - - /* --------------------------------------------------------------------------------------------- - // ------------ supervise all hardware components - // ------------ assess the machine state - - 1. check if DC startup test is through, retrigger if not - 2. get results and find errors - 3. in case of error check if component is used (e.g. billreader is seldom used) - 4: check doors - 5. return value: 0: no response from DC - 1: no Test results and Test not running. need retrigger! - 2: state not clear by now, test ongoing, wait - 3: Service or battery door is open, goto INTRUSION MODE - from here: after valid ID-card goto SERVICE MODE - 4: vault door is open, goto INTRUSION MODE - from here: after valid ID-card and vault door closed goto TEST MODE - in TEST MODE: complete system check decides if vending mode allowed - 5: All doors are closed but errors found, - goto OOO MODE (out-of-order) - from here: run system test until problem is fixed - 6: All doors are closed, no error, maybe warnings, - goto VENDING MODE (normal operation) - (priority sinks from 0 to 6) - - --------------------------------------------------------------------------------------------- */ - - uint8_t sys_componentAssessment(void) const override; - // this function decides if vending mode is possible, independant from door - // return >0 in case of error - // is inncluded in sys_superviseSystem - - uint8_t sys_superviseSystem(void) const override; - // this function proofs if vending is possible depending of doors state - - - uint8_t sys_getSystemErrors(void) const override; - - // --------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------- - -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_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); - -}; - - -#endif - - - -/* - // Coin checker and changer mdb4.2 / section 5 - // Level 2 Commands (predefined device msg acc. mdb manual and auto-poll) - uint8_t mdb_coin_startPolling(bool on) const override; // send ether one command (from list below) - // or a poll command in the proper polling grid (e.g. every 100ms) - uint8_t mdb_coin_reset() const override; - uint8_t mdb_coin_setup() const override; - uint8_t mdb_coin_tubestatus() const override; - uint8_t mdb_coin_pollManually(void) const override; - uint8_t mdb_coin_type(uint16_t coinEnable, uint16_t dispenseEnable) const override; - uint8_t mdb_coin_dispense(uint8_t disp) const override; - uint8_t mdb_coin_expansion(uint8_t subCmd, uint8_t send[32]) const override; - uint8_t mdb_coin_getResponse(void) const override; - // 0: no response 1: got ACK 2: got NAK 3 got ACK with additional data - uint8_t mdb_coin_getDataLen(void) const override; - // return nr of byte received from any mdb device - uint8_t mdb_coin_getData(uint8_t *mdb_data, uint8_t maxBufferSize) const override; - - - - // Bill validator // section 6 - uint8_t mdb_bill_startPolling(bool on) const override; - uint8_t mdb_bill_reset() const override; - uint8_t mdb_bill_setup() const override; - uint8_t mdb_bill_security(uint16_t secLevel) const override; - uint8_t mdb_bill_pollManually(void) const override; - uint8_t mdb_bill_billType(uint16_t billEnable, uint16_t escrowEnable) const override; - uint8_t mdb_bill_escrow(uint8_t action) const override; - uint16_t mdb_bill_stacker(void) const override; - uint8_t mdb_bill_expansion(uint8_t subCmd, uint8_t send[32]) const override; - uint8_t mdb_bill_gotPollResponse(void) const override; - // 0: no response 1: got ACK 2: got NAK 3 got ACK with additional data - uint8_t mdb_bill_getDataLen(void) const override; - uint8_t mdb_bill_getPollData(uint8_t *mdb_data, uint8_t maxBufferSize) const override; - - - - // Level 3 Commands - all cash devices are used together and automatically - // -->easiest way to use - - // setting up payment: - uint8_t cash_getAcceptance(struct Tcash_state *cash_state) const override; - // return device specific parameters, (e.g. which tubes are installed) - // to be requested before/after payment - uint8_t cash_setMaxReturn(uint32_t amount) const override; // Security Limit - uint8_t cash_setMaxAcceptance(uint32_t amount) const override; // can pay up to this amount - // example: set to 12€ (=max price step), then the 3rd 5€ bill would be kept in escrow - // or with coins: max. insertable = 13,95€ (11,95€ is still <12€, plus a 2€-coin) - uint8_t cash_setCoinsToBeAccepted(uint16_t coinVal[2][16]) const override; - // up to 16 coins per currency in one or two currencies - // [0]=first currency, e.g. Huf [1]=2nd, like euros - uint8_t cash_setBillsToBeAccepted(uint32_t billVal[2][16]) const override; - uint8_t cash_setOpeningTime(uint16_t opentime_100ms) const override; // coin slot is opening/closing automatically - uint8_t cash_setWaitForLastCoinTime(uint16_t lastCoinTime_100ms) const override; - // while this time coin/bill aceptance is still active after "disable payment" command - uint8_t cash_getAllsettings(struct TcashSettings cashSettings) const override; - // return all above set own parameters - - // starting payment - uint8_t cash_powerUp(bool on) const override; // power up/down devices (bill takes up to 3s) - uint8_t cash_enablePayment(bool start) const override; // start/stop accepting bills and coins - - // running payment - bool gotNewCoinBill(void) const override; // true on every insertion, only once - uint8_t cash_getInserted(struct Tcash_pay *payment_state) const override; - - // finishing payment - uint8_t cash_coinEscrowTake(void) const override; - uint8_t cash_coinEscrowReturn(void) const override; - uint8_t cash_return(uint32_t amount) const override; -*/ - - -/* - uint8_t cc_setCondition(uint16_t chgCmd) const override; // e.g. change to state registered, sleep, open, off.... - uint16_t cc_getCondition(void) const override; // e.g. now socket open - bool cc_sendBufferFree(void) const override; // sending allowed (before writing) and sending finished (after writing) - uint8_t cc_sendDataBlk(uint16_t len, uint8_t *buf) const override; - void cc_wantReadData(uint16_t nrOfData) const override; // start reading - uint16_t cc_gotData(void) const override; // return nr of received bytes - uint8_t cc_loadDataBlk(uint16_t len, uint8_t *buf) const override; - uint8_t cc_getWorkFlow(void) const override; - // off, activated, gotStart_wait4card, wait4pin, gotPin, callingBank, CardAccepted..... - uint8_t cc_setupSerial(struct TserialParams serialParameter) const override; - uint8_t cc_getCurrentSerialSettings(struct TserialParams *serialParameter) const override; -*/ - - -/* - -struct TcashSettings -{ - uint32_t MaxReturnAmount const override; - uint32_t MaxAcceptAmount const override; - uint32_t CoinsAcceptedCur[2][16] const override; - uint32_t BillsAcceptedCur[2][16] const override; - uint32_t availableReturnAmount const override; - -} const override; - - -struct Tcc_hw_state -{ - bool powerRdBk const override; // prn pwr is on - bool rsSwOk const override; // serial switch (printer or modem) is set to CreditCard (iUC) - bool rsDrvOk const override; // RS232 converter for PTU, Printer and Modem in on - uint8_t HwState const override; // idle, off, on, ready - bool gotAnswer const override; // cable OK? - uint8_t moduleType const override; - uint8_t protocolType const override; - -} const override; - - -*/ - - -/* - // not yet implemented - uint8_t mod_power(bool on) const override; - uint8_t mod_getHwState(struct Tmod_hw_state *mod_hw_state) const override; - uint8_t mod_setCondition(uint16_t chgCmd) const override; // e.g. change to state registered, sleep, open, off.... - uint16_t mod_getCondition(void) const override; // e.g. now socket open - bool mod_sendBufferFree(void) const override; // sending allowed (before writing) and sending finished (after writing) - uint8_t mod_sendDataBlk(uint16_t len, uint8_t *buf) const override; - void mod_wantReadData(uint16_t nrOfData) const override; // start reading - uint16_t mod_gotData(void) const override; // return nr of received bytes - uint8_t mod_loadDataBlk(uint16_t len, uint8_t *buf) const override; - uint8_t mod_setupSerial(struct TserialParams serialParameter) const override; - uint8_t mod_getCurrentSerialSettings(struct TserialParams *serialParameter) const override; - - // Credit Card Terminal: - uint8_t cc_power(bool on) const override; - uint8_t cc_getHwState(struct Tcc_hw_state *cc_hw_state) const override; - -*/ - diff --git a/include/prot.h b/include/prot.h deleted file mode 100644 index 33a9845..0000000 --- a/include/prot.h +++ /dev/null @@ -1,129 +0,0 @@ - -#ifndef SERIAL_FRAME_H -#define SERIAL_FRAME_H - -#include -#include -#include -#include -#include "tslib.h" -#include "com.h" - -/* - get's OUT-data from datif, - get's IN-data from datif - get's send command from datif - makes frame and calls: isSerialFree(), setSendData(), - if not free retrigger datif sending period (normally 500ms or 50ms for direct cmds) - - with control-signal: gotReceiveData(): - getRecData(); - send results to diag window/line - send IN-data to datif -*/ - -#define FRAME_DATALEN 64 -#define FRAME_MAXLEN FRAME_DATALEN+20 -#define BL_DATA_LEN 150 - -#define DATALEN_SEND_FAST 4 -#define DATALEN_SEND_LONG 64 -#define HEADERLEN_SEND 4 -#define TELEGRAMLEN_SEND_FAST 12 -#define TELEGRAMLEN_SEND_LONG 70 -#define STARTSIGN_SEND_FAST 0x3F -#define STARTSIGN_SEND_LONG 0x3D - -#define DATALEN_RECEIVE_FAST 8 -#define DATALEN_RECEIVE_LONG 64 -#define HEADERLEN_RECEIVE 2 -#define TELEGRAMLEN_RECEIVE_FAST 12 -#define TELEGRAMLEN_RECEIVE_LONG 68 -#define STARTSIGN_RECEIVE_FAST 0x5F -#define STARTSIGN_RECEIVE_LONG 0x5D - - -class T_prot : public QObject -{ - Q_OBJECT - - // Dateneingang von Datif: - uint8_t SendDataValid; // bit1: WR OK bit 2: RD OK - uint16_t slaveAddr; - - uint16_t WriteCommand; - uint16_t WriteAddr; - uint8_t WrDataLength; - uint8_t ui8OutputData[FRAME_DATALEN]; - char chOut_Data[FRAME_DATALEN]; - uint8_t kindOfData; // 0: binaries, 1:text - - uint16_t ReadCommand; - uint16_t ReadAddr; - uint16_t reserve; - - // Ausgangs-Daten, werden vom Datif geholt: - // nur wenn CommandState und readState OK - uint8_t RecSlaveAddr; - bool INdataValid; // nur true wenn CommandState OK und readState OK - uint16_t readSource; // diese (Eingangs-)Daten stehen im Puffer - uint16_t readAddress; // von dieser Adr wurden die Daten gelesen - //uint8_t lastWakeSrc; // falls der Slave den Master geweckt hat - uint8_t RdDataLength; - uint8_t InputData[FRAME_DATALEN]; - - // 11.11.2020: - uint8_t BLsendDataLength; - uint8_t ui8BLsendData[BL_DATA_LEN]; - - T_com *mySerialPort; - - void startPacking(void); - void startFastPacking(void); - uint8_t FramecheckInData(uint8_t *Inbuf, uint16_t LL); - uint8_t FastCheckInData(uint8_t *Inbuf, uint16_t LL); - - uint8_t CheckInResult(uint8_t *Inbuf); - - uint8_t ShowFastInData(uint8_t *recBuffer); - uint8_t ShowInData(uint8_t *recBuffer); // was CheckInData - void setRecLen(uint16_t WriteCmd); - -private slots: - void analyseRecData(void); - -public: - T_com *getSerialPort() { return mySerialPort; } - T_com const *getSerialPort() const { return mySerialPort; } - - T_prot(); - bool isPortOpen(void); - bool isSerialFree(void); - void setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, uint8_t *data); - void setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr); - void setUserWriteData(uint16_t WriteCmd); - void setUserWriteText(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, char *data); - - void setUserWrite1DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val); - void setUserWrite2DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, uint8_t val1); - - void setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reserv); - void setUserReadData( uint16_t ReadCmd, uint16_t RdAddr); - void setUserReadData( uint16_t ReadCmd); - - void setBLsendData( uint8_t len, uint8_t *buf); - - void receiveFixLen(int64_t nrOfbytesToReceive); - - void sendUserData(uint16_t slaveAdr); - bool ifDataReceived(); - bool getReceivedInData(uint8_t *SlavAddr, uint16_t *readSrc, uint16_t *readAddr, - uint8_t *RdDlen, uint8_t *receivedData); - // retval: data valid, only one time true -signals: - void framerecieved(); //bool gotINdata); - void rawDataRecieved(); - -}; - -#endif // T_prot_H diff --git a/include/sendWRcmd.h b/include/sendWRcmd.h deleted file mode 100644 index 1b12e46..0000000 --- a/include/sendWRcmd.h +++ /dev/null @@ -1,250 +0,0 @@ - -#ifndef SENDWRCMDS_DEFS_H -#define SENDWRCMDS_DEFS_H - -#include -#include "tslib.h" -#include - -// asynch. Commands -// store OUTPUT commands until time to send -// problem: OUT commands are set if a button is pressed or a transaction event happens -// so it's never synchron with sending grid -// but sending must apply the 100ms time grid as we have to wait for the response before sending the next command!!! - -// Level 0 (DC direct) -#define SENDDIRCMD_TestSerial 1 -#define SENDDIRCMD_MakeReset 2 -#define SENDDIRCMD_setTime 3 -#define SENDDIRCMD_setWakeFrequ 4 - -// Level 1 (DC DO's switching connected parts) -#define SENDDIRCMD_MOVEUP_LOCK 5 -#define SENDDIRCMD_MOVEDN_LOCK 6 -#define SENDDIRCMD_OPENUP_DOOR 7 -#define SENDDIRCMD_OPENDN_DOOR 8 -#define SENDDIRCMD_LEDILLU 9 -#define SENDDIRCMD_LEDCOIN 10 -#define SENDDIRCMD_LEDTICKET 11 -#define SENDDIRCMD_LEDPAD 12 -#define SENDDIRCMD_LEDSTART 13 -#define SENDDIRCMD_LEDINSIDE 14 -//#define SENDDIRCMD_LED_ALL 15 -#define SENDDIRCMD_FAN 16 -#define SENDDIRCMD_LAERM 17 -#define SENDDIRCMD_REL1 18 -#define SENDDIRCMD_WAKEPTU 20 -#define SENDDIRCMD_AUXPWR 21 -#define SENDDIRCMD_AUXDDR 22 -#define SENDDIRCMD_AUXOUT 23 - -#define SENDDIRCMD_UCONTACT_ON 30 -#define SENDDIRCMD_PRN2_SWONOFF 31 - -#define SENDDIRCMD_MIF_SWONOFF 32 // 0x2900 -#define SENDDIRCMD_MIF_ATBCREATE 33 // 0x2907 - -#define SENDDIRCMD_MOD_SWONOFF 40 -#define SENDDIRCMD_MOD_WAKE 41 -#define SENDDIRCMD_MDB_POWER 42 -#define SENDDIRCMD_MDB_WAKE 43 -#define SENDDIRCMD_CRED_ON 44 -#define SENDDIRCMD_CRED_WAKE 45 - -#define SENDDIRCMD_SHUT_MOV 50 -#define SENDDIRCMD_ESCRO_MOV 51 -#define SENDDIR_OPENVAULT 52 -#define SENDDIR_REJMOT_ON 53 -#define SENDDIR_REJMOT_RUN 54 - -// Level 2 (serial from DC to devices) -#define SEND_REQU_SERCONF 100 -#define SEND_REQU_HWversion 101 -#define SEND_REQU_SWversion 102 -#define SEND_REQU_CONDITION 103 -#define SEND_REQU_UID 104 -#define SEND_REQU_TIME 105 - // includes wake frequency -#define SEND_REQU_ANALOGS 110 -#define SEND_REQU_DIG_INPUTS 111 -#define SEND_REQU_DIG_OUTPUTS 112 - -#define SEND_REQU_PRN_STATE 120 -#define SEND_REQU_PRN_FONTS 121 -#define SEND_REQU_PRN_ALL 122 - -#define SEND_REQU_MIFSTATE 123 - // Type and state of reader - -#define SEND_REQU_MIFDATA 124 - // Type, UID, Header of card - // read one card sector - // sectors must be addressed by RD_ADD - -#define SEND_REQU_MIF_ATB_TYPE 125 - -#define SEND_REQU_MDB_GETSTAT 126 -//#define SEND_REQU_MDB_GETWAK 127 -#define SEND_REQU_MDB_GETRESP 128 -#define SEND_REQU_EMP_GETALL 129 -#define SEND_REQU_EMP_GETCOIN 130 - - -#define SENDDIRCMD_DEVICE_PARA 131 -#define SENDDIRCMD_MACHINE_ID 132 -#define SEND_REQU_DEVICE_PARA 133 -#define SEND_REQU_MACINE_ID 134 - - -// further: mdb state, coinchecker state, bill state, modem state, credit_state.... - -#define SENDDIRCMD_SHUTOPENBYTIME 60 -#define SENDDIRCMD_SHUTOPENBYCOIN 61 -//#define SENDDIRCMD_SHUT_SENDTIME 62 - -#define SENDDIRCMD_ESCRO_TAKE 63 -#define SENDDIRCMD_ESCRO_GIVE 64 - -#define SENDDIRCMD_PRN_SYS_CMD 70 -#define SENDDIRCMD_PRN_ESC_CMD 71 -#define SENDDIRCMD_PRN_SETUP 72 -#define SENDDIRCMD_PRN_MOVE 73 -#define SENDDIRCMD_PRN_SETFONT 74 -#define SENDDIRCMD_PRN_SETLETT 75 -#define SENDDIRCMD_PRN_CUT 76 -//#define SENDDIRCMD_PRN_TXT // not needed -#define SENDDIRCMD_PRN_LF 78 -#define SENDDIRCMD_PRN_FONTTAB 79 -#define SENDDIRCMD_PRN_BC 80 -#define SENDDIRCMD_PRN_QR 81 -#define SENDDIRCMD_PRN_STOREDQR 82 -#define SENDDIRCMD_PRN_LOGO_FL 83 -//#define SENDDIRCMD_PRN_LOGO_GRAF 84 -//#define SENDDIRCMD_PRN_LOGODAT 85 -//#define SENDDIRCMD_PRN_STORBC 86 -#define SENDDIRCMD_PRN_STORQR 87 -#define SENDDIRCMD_PRN_DOC 88 -#define SENDDIRCMD_PRN_CLEARDOC 89 - -//#define SENDDIRCMD_MDB_POWER 42 -//#define SENDDIRCMD_MDB_WAKE 43 -#define SENDDIRCMD_MDB_RES 90 -#define SENDDIRCMD_MDB_SENDCMD 91 -#define SENDDIRCMD_MDB_SNDMSG 92 -#define SENDDIRCMD_EMP_SETT 93 -#define SENDDIRCMD_EMP_POLL 94 -#define SENDDIRCMD_EMP_STARPPAY 95 -#define SENDDIRCMD_EMP_STOPPAY 96 - - - - -// obsolete: -#define SENDDIRCMD_PRN1_SENDTEXT 54 -#define SENDDIRCMD_PRN1_SENDCMD 55 -#define SENDDIRCMD_PRN1_SERPAR 56 -#define SENDDIRCMD_PRN_LEVEL2_4B 58 -#define SENDDIRCMD_PRN_LEVEL2_64 59 - - -// highest priority -#define CMDSTACKDEPTH 16 -// means: up to 16 cmd can be stored. They are issued one by one every 100ms -void sendWRcmd_clrCmdStack(void); -bool sendWRcmd_setSendCommand0(uint16_t nextCmd); - // GUI or app sends a command to DC transfered by serial - -uint16_t sendWRcmd_getSendCommand0(void); - -// lower priority -#define CMD4STACKDEPTH 8 -void sendWRcmd_clrCmd4Stack(void); -bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4); -uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4); - -#define CMD8STACKDEPTH 4 -void sendWRcmd_clrCmd8Stack(void); -bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint16_t dat3, uint32_t dat4); -uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4); - - - -// lowest priority -// wait for resonse before send next! -bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf); -uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf); - // retval = *leng - -void sendWRcmd_INI(void); - - - -uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf); - // HWapi writes data to be forwarded to DC and further to mdb-device - // not batched! don't use twice within 100ms - -uint8_t gpi_restore64ByteSendData(uint8_t *length, uint8_t *buf); - // datif reads data to forward to dc - - - -// ONE printer doc consists of 20 x 64 byte -#define MAXNROF_PRNBYTES 64 -#define MAXNROF_PRNBLOCKS 20 - -void epi_resetPrinterStack(void); - -uint8_t epi_storePrnText(char *buf, uint8_t leng); - // store text and binary data from Gui in next higher free memory 0....9 - -uint8_t gpi_restorePrnText(uint8_t *retbuf); - // read printer text and send to slave, size of retbuf== 64 - -uint8_t gpi_chk4remainingText(void); - // retval: 0: no more textline left (to send) >0: nr of lines - -void epi_storeUserOfSendingTextBuffer(uint8_t user, uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4 ); - // user=1: Text-Print is using this buffer - // 2: QR-code-Printer is using this buffer - -uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *para3, uint8_t *para4); - // user=1: Text-Print is using this buffer - // 2: QR-code-Printer is using this buffer - -#define FDCMD_STACKDEPTH 16 -void sendFDcmd_clrStack(void); -bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4); - // write Command to memory, wait for transport -bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4); - -uint8_t check4FDshortCmd(void); - // returns number of waiting command, maxFDCMD_STACKDEPTH - -uint8_t check4freeFDshortCmd(void); - // returns number of free places in short-command stack - -#define FDLONG_STACKDEPTH 16 -void longFDcmd_clrStack(void); -bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data); - // write Command to memory, wait for transport - // data buffer size always 64! data[64], padded with 0 -bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data); - -uint8_t check4FDlongCmd(void); - // returns number of waiting command - -uint8_t check4freeFDlongCmd(void); - // returns number of free places in long-command stack - - - -uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf); - // HWapi writes data to be stored - -uint8_t epi_restore64BdevParameter(uint8_t *length, uint8_t *buf); - - - -#endif - - diff --git a/include/shared_mem_buffer.h b/include/shared_mem_buffer.h deleted file mode 100644 index d45841f..0000000 --- a/include/shared_mem_buffer.h +++ /dev/null @@ -1,296 +0,0 @@ -#ifndef SHARED_MEM_BUFFER_INCLUDED_H -#define SHARED_MEM_BUFFER_INCLUDED_H - -#include -#include - -#include - -struct SharedMemBuffer { - struct rs { - char comportName[16]; // z.B. "COM48" - char baudStr[16]; // z.B. "19200" - int baudNr; // 0...5 oder -1 - uint8_t connect; // 0,1 - bool portIsOpen; - } rs; - - char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden - - struct datif { - uint16_t sendingPeriod; - bool sendingPer_changed; - } datif; - -#if 0 - // controlBus.cpp - char txt4comStateLine[32]; - char txt4HsStateLine[32]; - char txt4masterStateLine[32]; - char txt4resultStateLine[32]; - char txt4dataLine[32]; - char txt4datifReceive[32]; - char txt4diagWindow[32]; - char sndTxt4diagWindow[32]; - bool Sdata_serialTestResult[32]; - uint8_t Sdata_pProtResultOk[32]; - uint16_t Sdata_receivedDataLength[32]; - uint8_t Sdata_receivedDataBlock[64]; - - // datif.cpp - uint8_t dif_dataStep; - uint8_t dif_scanStep; - uint8_t RDBLKNR; - uint8_t datif_OutCmdpara1; - uint8_t datif_OutCmdpara2; - uint8_t datif_OutCmdpara3; - uint8_t datif_OutCmdpara4; - - uint16_t datif_OutCmdpara5; - uint32_t datif_OutCmdpara6; - uint8_t cycl_running; - - // dcBL.cpp - uint8_t dcBL_LastBLcmd; // stored the last sent cmd in order to analys response - uint8_t dcBL_AtbBinFile[300000]; - uint32_t dcBL_fileSize; - uint16_t dcBL_nrOfBlocks; - uint16_t dcBL_fileCrc; - uint8_t dcBL_myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise - - char BlResp[50][32]; - uint8_t dcBL_step; - uint8_t dcBL_state; - uint16_t dcBL_BlkCtr; - uint16_t dcBL_cyclCtr; - uint16_t repeatCtr; - uint8_t Sdata_rawData[150]; - uint8_t Sdata_LengthRawData; - - // hwapi.cpp - uint16_t hwapi_shutterTime; - char ticketTemplate[1024]; - - // sendWRcmd.cpp - uint16_t nextAsynchsendCmd0[16]; - uint8_t nrOfCmdsInQueue; - uint16_t nextAsynchsendCmd4[8]; - uint8_t nextCmd4para1[8]; - uint8_t nextCmd4para2[8]; - uint8_t nextCmd4para3[8]; - uint8_t nextCmd4para4[8]; - uint8_t nrOfCmds4InQueue; - uint16_t nextAsynchsendCmd8[4]; - uint8_t nextCmd8para1[4]; - uint8_t nextCmd8para2[4]; - uint16_t nextCmd8para3[4]; - uint32_t nextCmd8para4[4]; - uint8_t nrOfCmds8InQueue; - uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer - uint8_t sendAsyDatLen; - uint8_t Sdata_mdbSendBuffer[64]; - uint8_t Sdata_mdbSendLen; - uint8_t prnDataParameters[4]; - uint8_t prnDataBufferUser; - char Sdata_PRN_TEXT[20][64]; - uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK - uint8_t nextFDwrCmd[16]; - uint8_t nextFDrdCmd[16]; - uint8_t nextFDblkNr[16]; - - uint8_t nextFDpara1[16]; - uint8_t nextFDpara2[16]; - uint8_t nextFDpara3[16]; - uint8_t nextFDpara4[16]; - uint8_t p_nextFDcmdsInQueue; - uint8_t longFDwrCmd[16]; - uint8_t longFDrdCmd[16]; - uint8_t longFDblkNr[16]; - uint8_t longFDlength[16]; - - uint8_t longFDpara[16][64]; - uint8_t p_longFDcmdsInQueue; - - // storeInData.cpp - bool indat_savePrnPwr; - bool indat_saveMifPwr; - bool indat_MdbIsOn; -#endif - - uint8_t ndbs; - uint8_t pari; - uint8_t nsb; - uint8_t br; - -#define MAXNROF_GENSTR 16 - char genStrings[MAXNROF_GENSTR][64]; - -#define MAXNROF_AI 4 - uint16_t AI_val[MAXNROF_AI]; - - struct DigitalInputs { - uint8_t doorSwitch; - uint8_t vaultSwitch; - uint8_t lockSwitch; - uint8_t opto; - uint8_t aux; - bool wakeFromPtu; - bool wakeFromMdb; - bool wakeFromModem; - bool PrnReady; - bool CoinAttach; - bool CoinEscrowOpen; - bool mifCardTap; - bool contactPwrOn; - bool mifarePwrOn; - bool rdbk_mdbTxd; - bool AuxPwrOn; - bool gsmPwrOn; - bool creditPwrOn; - bool printerPwrOn; - bool mdbPwrOn; - bool rejMot_home; - uint8_t npe_sensor; - } din; - - struct DigitalOutputs { - uint8_t mbdRxTst; - uint8_t motorBits; - uint8_t serialSwitch; // serial drv on/off, Serial mux1, Serial mux2 - uint8_t ledsAndFan; - uint8_t laermUndRelay; - uint8_t ptuWake; - uint8_t auxPower; - uint8_t coinShutter; - uint8_t coinEscrow; - uint8_t printerPower; - } dout; - - struct Sdata { -#define NROFMIFSTATEBYTES 40 -#define PRN_STATE_ARRAY_SIZE 20 -#define PRN_STATE_FONT_SIZE 20 - uint8_t MIF_STATE[NROFMIFSTATEBYTES]; - uint8_t MIF_DATA[12][64]; - uint8_t PRN_STATE[PRN_STATE_ARRAY_SIZE]; - uint8_t PRN_FONTS[PRN_STATE_FONT_SIZE]; - bool mdb_busRdy; - bool mdb_V12on; - bool mdb_V5on; - uint8_t mdbNrOfRecData; - uint8_t RecBuff[40]; - uint8_t empNrOfsettings; - uint8_t emp_settingsBuff[66]; - uint8_t NrOfDeviceSetting; - uint8_t DeviceSettingBuff[66]; - uint8_t NrOfMachineIDSetting; - uint8_t NrOfMachineIDBuff[66]; - uint64_t slaveUID; - uint8_t UIDstr[8]; -#define MAXNROF_MEASURE 4 - uint32_t measurement[MAXNROF_MEASURE]; - bool serialTestResult; - uint8_t pProtResultOk; - uint16_t receivedDataLength; - uint8_t receivedDataBlock[64]; - } Sdata; - - uint8_t mif_cardType; - uint8_t mif_cardHolder[8]; - -#define MEMDEPTH_GOTCOINS (16) - struct T_coin { - uint8_t valid; - uint8_t signal; - uint8_t error; - uint8_t pad; - uint16_t value; - } gotCoin[MEMDEPTH_GOTCOINS]; - uint8_t ctr_gotCoin; - - struct store { - uint32_t insertedAmount; - uint16_t lastCoinType[64]; - uint16_t lastCoinValue[64]; - uint64_t wakeSrc; - uint8_t rbDevParamLen; - uint8_t rbDevParams[66]; - uint8_t deviceCondLen; - uint8_t deviceCond[66]; - uint8_t machCondLen; - uint8_t machCond[66]; - uint8_t DcBackupNrOfAccNr; - uint16_t DcBackupAccNr[16]; // z.Z. nur 8 - uint8_t gotNrBlocksOfVaultRec; - uint8_t vaultrecord[360]; - uint32_t amount; - uint16_t nrOfCoins; - bool dcDataValid; - uint8_t wakeReason; - char curPayNewCoin; - } store; - - struct T_globTime { - // Reihenfolge nicht vertauschen!!!!! - uint8_t hour; - uint8_t minute; - uint8_t second; - uint8_t Year; - uint8_t Month; - uint8_t DayOfMonth; - uint8_t DayOfWeek; // 1=monday...7 - uint8_t reserve1; - - uint16_t MinutesOfToday; - uint16_t reserve2; - - uint32_t SecondsOfToday; - - uint8_t IsLeapyear; - uint8_t nextLeap; - uint8_t lastLeap; - uint8_t hoursOfWeek; - - uint16_t minOfWeek; - uint16_t hoursOfMonth; - uint16_t minOfMonth; - uint16_t dayOfYear; - uint16_t hoursOfYear; - uint16_t reserve3; - - uint32_t minOfYear; - - uint8_t squareOutMode; - uint8_t free1; - uint16_t reserve4; - uint32_t minOfMillenium; - // bis hierher 44byts - uint32_t free2; - uint32_t free3; - uint32_t free4; - } getGlobalTime; - - static QSharedMemory *getShm(std::size_t s = 0); - static SharedMemBuffer *getData() { - return (SharedMemBuffer *)getShm()->data(); - } - static SharedMemBuffer const *getDataConst() { - return (SharedMemBuffer const *)getShm()->data(); - } - -#if 0 - static std::atomic __sharedMemLocked; - - static bool sharedMemLocked() { - return __sharedMemLocked; - } - static void setSharedMemLocked() { - __sharedMemLocked = true; - } - static void setSharedMemUnlocked() { - __sharedMemLocked = false; - } -#endif -}; - -#endif // SHARED_MEM_BUFFER_INCLUDED_H diff --git a/include/storeINdata.h b/include/storeINdata.h deleted file mode 100644 index b28a6ff..0000000 --- a/include/storeINdata.h +++ /dev/null @@ -1,428 +0,0 @@ - -#ifndef STOREINDATA_H -#define STOREINDATA_H - -#include -//#include "tslib.h" -#include - - -#define MAXNROF_AO 3 -//#define MAXNROF_GENSTR 16 -#define MAXNROF_CONTR_PORTS 11 -#define MAXNROF_DIports 2 -#define MAXNROF_DOports 2 -#define MAXNROF_CTR 2 -#define MEASCHAN_TEMPERATURE 0 -#define MEASCHAN_VOLTAGE 1 - - -// gpi: DC-driver stores data for graphic peripheral interface -// epi: gui reads values from external peripheral interface - - -// store power on/off condition of the devices to control the data request - -void indat_storePrinterPower(bool isOn); -bool indat_isPrinterOn(); - -void indat_storeMifarePower(bool isOn); -bool indat_isMifareOn(); - -void indat_storeMDBisOn(bool isOn); -bool indat_isMdbOn(); - -void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits, - uint8_t parity, uint8_t NrStopBits); - -void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits, - uint8_t *parity, uint8_t *NrStopBits); - -QString epi_getSlaveParamSTR(); - -void gpi_storeGenerals(uint8_t genNr, QString text); - // 0=HW 1=SW 2=State -QString epi_loadGenerals(uint8_t genNr); -// genNr=0=HW 1=SW 2=State - - -void gpi_storeUID(uint8_t const *buf8byteUid); -// buffer size: 8 byte -void epi_getUIDdec(uint8_t *buf8byteUid); -// buffer size: 8 byte -QString epi_getUIDstr(); - - - - - -// /////////////////////////////////////////////////////////////////////////////////// -// Time and Date -// /////////////////////////////////////////////////////////////////////////////////// - -uint8_t epi_getSquareMode(); -void gpi_backupSquareMode(uint8_t squMode); - -void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng); // 104, <=8byte -void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss); -void epi_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd); -void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday); -bool epi_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear); -bool epi_isLeapYear(); -void epi_getSpecialWeekTimeDate(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek); -void epi_getSpecialMonthTimeDate(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth); -void epi_getSpecialYearTimeDate(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear); - - -// /////////////////////////////////////////////////////////////////////////////////// -// Analog values -// /////////////////////////////////////////////////////////////////////////////////// - - -// #define MAXNROF_AI 4 - -void gpi_storeAIs(uint8_t aiNr, uint16_t val); // rs -> Sdata - -uint8_t gpi_getMaxNrAIs(); - -uint16_t epi_loadAIs(uint8_t aiNr); // Sdata -> gui - // return value of one ADC with channel nr: aiNr 0...15 - -uint32_t epi_loadMeasureValue(uint8_t ValueNr); - // ValueNr 0=ADC0, 1=ADC1 aso... - -void gpi_storeMeasureValue(uint8_t ValueNr, uint32_t val); - // in mV, also bis 65,535V - -QString epi_getSlaveTemperatureStr(); - -QString epi_getSlaveVoltageStr(); - // value in "meas_volt" in mV, also bis 65,535V. Value range [6000...16000] (6V...16V) - -// /////////////////////////////////////////////////////////////////////////////////// -// digital inputs -// /////////////////////////////////////////////////////////////////////////////////// - -void gpi_storeDI_doorSwitches(uint8_t upperDoor, uint8_t lowerDoor, uint8_t vaultDoor); - -uint8_t epi_getDI_doorSwitches(void); - // bit0: upper door 1: low door 2:vault door - -void gpi_storeDI_vaultSwitches(uint8_t CashBoxIn, uint8_t BillBoxIn); - -uint8_t epi_getDI_vaultSwitches(void); - // bit0: cash box 1: bill box in - -void gpi_storeDI_lockSwitches(uint8_t indatUL, uint8_t indatLL); - // D5: bit 0: upper lockbar up bit1:down - // D6: bit 0: lower lockbar up bit1:down - -uint8_t epi_getDI_lockSwitches(void); - // retval: bit 0: upper lockbar up bit1: upper lockbar is down - // bit 2: lower lockbar up bit1: lower lockbar is down - - -void gpi_storeDI_optos(uint8_t indatOpto); - // OptoIn bit 0,1: optoin 1,2 - -uint8_t epi_getDI_optos(void); - // bit0: opto in 1 1: opto in 2 - -uint8_t gpi_storeDI_auxIn(uint8_t indatAuxIn); // Aux0...5 -uint8_t epi_getDI_auxIn(void); // bit0: auxin 1 ... 5: auxin 6 - -bool gpi_storeDI_ptuWake(bool w); -bool epi_getDI_ptuWake(void); - -bool gpi_storeDI_mbdWake(bool w); -bool epi_getDI_mdbWake(void); - -bool gpi_storeDI_prnReady(bool ready); -bool epi_getDI_prnReady(void); - -bool gpi_storeDI_CoinAttach(bool attach); -bool epi_getDI_CoinAttach(void); - -bool gpi_storeDI_CoinEscrow(bool ce); -bool epi_getDI_CoinEscrow(void); - -bool gpi_storeDI_mifareCardTapped(bool tapped); -bool epi_getDI_mifareCardTapped(void); - -bool gpi_storeDI_modemWake(bool w); -bool epi_getDI_modemWake(void); - -bool gpi_storeDI_contactPowerIsOn(bool on); -bool epi_getDI_contactPwr(void); - -bool gpi_storeDI_MifarePowerIsOn(bool on); -bool epi_getDI_mifarePwr(void); - -bool gpi_storeDI_readbackMdbTxD(bool rdbkMdbTxd); -bool epi_getDI_mdbTxd(void); - -bool gpi_storeDI_AuxPowerIsOn(bool on); -bool epi_getDI_auxPwr(void); - -bool gpi_storeDI_GsmPowerIsOn(bool on); -bool epi_getDI_gsmPwr(void); - -bool gpi_storeDI_CreditPowerIsOn(bool on); -bool epi_getDI_creditPwr(void); - -bool gpi_storeDI_PrinterPowerIsOn(bool on); -bool epi_getDI_printerPwr(void); - -bool gpi_storeDI_MdbPowerIsOn(bool on); -bool epi_getDI_mdbPwr(void); - -bool gpi_storeDI_rejMot_home(bool reject); -bool epi_getDI_rejectMotor_homepos(void); - -uint8_t gpi_storeDI_paperLow(uint8_t di); -uint8_t epi_getDI_npe_sensor(void); - // 0: Sensor sees paper 1: no paper 99: off - -// /////////////////////////////////////////////////////////////////////////////////// -// readback digital outputs -// /////////////////////////////////////////////////////////////////////////////////// - -uint8_t gpi_storeDO_mdbRxTst(uint8_t do_mbdRxTst); -bool epi_getDO_mdbRxTestOut(void); - -uint8_t gpi_storeDO_motorOutputs(uint8_t Pwr); -uint8_t epi_getDO_motorOuts(void); - // bit0: upper lock forward bit 1 backward - // bit2: lower lock forward bit 3 backward - -uint8_t gpi_storeDO_serialSwitch(uint8_t state); - // serial drv on/off, Serial mux1, Serial mux2 -uint8_t epi_getDO_serialSwitch(void); - // serial drv on/off, Serial mux1, Serial mux2 - -bool epi_getDO_serialDriverIsOn(void); -bool epi_getDO_serialMux1isSetToPrinter(void); - // mux1 off: serial is switched to printer - -bool epi_getDO_serialMux1isSetToModem(void); - // mux1 on: serial is switched to modem -bool epi_getDO_serialMux2isSetToCredit(void); - // mux2 off: serial is switched to credit card terminal -bool epi_getDO_serialMux2isSetToMifare(void); - // mux2 on: serial is switched to mifare reader - -uint8_t gpi_storeDO_ledsAndFan(uint8_t ledState); -bool epi_getDO_led_coin(void); -bool epi_getDO_led_front(void); -bool epi_getDO_led_ticket(void); -bool epi_getDO_led_pin(void); -bool epi_getDO_led_start(void); -bool epi_getDO_led_inside(void); -bool epi_getDO_fan(void); - -uint8_t gpi_storeDO_sirenAndRelay(uint8_t sirenRelay); -bool epi_getDO_sirene(void); -bool epi_getDO_relay(void); - -uint8_t gpi_storeDO_ptuWake(uint8_t state); -bool epi_getDO_ptuWake(void); - -uint8_t gpi_storeDO_auxPower(uint8_t pwr); -bool epi_getDO_auxPower(void); - -uint8_t gpi_storeDO_coinShutter(uint8_t state); -bool epi_getDO_coinShutterOpen(void); -bool epi_getDO_coinShutterTest(void); - -uint8_t gpi_storeDO_coinEscrow(uint8_t state); -uint8_t epi_getDO_coinEscrow(void); - // retval: 1:return flap is open 2:take flap is open 0:closed - -uint8_t gpi_storeDO_printerPwrOn(uint8_t state); -uint8_t epi_getDO_printerPwr(void); - -// --------------------------------------------------------------------------------------------- -// counterchecks, make sure that DC-outputs are correct - -/* -bool epi_cntchk_wakePtu(void); -bool epi_cntchk_enabDrv01(void); // no communication possible if 0 !!!!! -bool epi_cntchk_swRs1toModem(void); -bool epi_cntchk_modemWake(void); -bool epi_cntchk_enabDrv2(void); -bool epi_cntchk_swRs2toMIF(void); - -bool epi_cntchk_shutterIsOpen(void); - // counter check if shutter is really open, PJ4 must be OUT and HIGH, PB5 must be OUT and HIGH - // retval TRUE: shutter is open FALSE: shutter is closed - -bool epi_cntchk_escrowReturnIsOpen(void); -bool epi_cntchk_escrowTakeIsOpen(void); -bool epi_cntchk_aux1DirOut(uint8_t auxNr); -bool epi_cntchk_aux1OutHigh(uint8_t auxNr); - -bool epi_cntchk_ledPaperOn(void); -bool epi_cntchk_ledPinpadOn(void); -bool epi_cntchk_ledStartOn(void); -bool epi_cntchk_ledServiceOn(void); -bool epi_cntchk_ledCoinOn(void); -bool epi_cntchk_ledIllumOn(void); -bool epi_cntchk_FanOn(void); -bool epi_cntchk_RelaisOn(void); -bool epi_cntchk_LaermOn(void); -bool epi_cntchk_Mot1Ron(void); -bool epi_cntchk_Mot1Fon(void); -bool epi_cntchk_Mot2Ron(void); -bool epi_cntchk_Mot2Fon(void); -*/ - - -// ------------------------------------------------------------------------------------ -// MDB Sendind Data are store here for next transport to DC (Device Controller) -// Transport to Slave runs every 100ms, answer from mdb-slave (e.g. coin changer) comes right -// with next slave answer - -// start with: SENDDIRCMD_EXCHGMDB, - // send crude data from here to DC, DC to mdb slaves, mdb answer, return here within 50ms - -uint8_t gpi_storeMdbRecData(uint8_t length, uint8_t *buf); - // datif store received mdb data -uint8_t epi_getMdbResponse(void); - // 0=no response 1=ACK 2=NAK 3=ACK with data -uint8_t epi_getMdbRecLength(void); - // 0...31 -uint8_t epi_restoreMdbRecData(uint8_t *buf); - // hwapi reads received mdb data from PI - -uint8_t gpi_storeMifReaderStateAndCardType(uint8_t const *buf); - -/* data description: -byte 0: current read state: 0=power off 1=reader-fault 2=ready - 3=just reading 4=read complete - 5=read partial, removed too early - 6=state unknown -byte 1,2: read data length from card -3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader -4...15: reader version, expected "SL025-1.8" -byte16: 1=card is present 0:not -17: 0 -18: card type reported from reader -19: 1=allowed card type 0=not -20: card size: 1 or 4 (dec) = card size -21: LengthOfUID: 4 or 7 (dec) (byte) -22: UID 8 byte in hex -byte 30: sector logged: 0 -byte 31: current sector: 0 -byte 32: result, always 0 -*/ - -uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize); - // retval 0=OK 1=error host buffer too small -bool gpi_storeMifCardData(uint8_t blkNr, uint8_t const *receivedData); - // blkNr=0...11 receivedData[64] -uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize); - // blkNr=0...11 return buf[64] - // retval: 1=error 0=OK - -void epi_restorePrinterState(uint8_t *buf); -void gpi_storePrinterState(uint8_t const *buf); - -void epi_restorePrinterFonts(uint8_t *buf); -void gpi_storePrinterFonts(uint8_t const *buf); - -bool gpi_storeMdbState(bool busReady, bool V12on, bool V5on); -bool epi_restoreMdbBusReady(void); -bool epi_restoreMdbV12Ready(void); -bool epi_restoreMdbV5Ready(void); - -void gpi_storeMdbResponse(uint8_t leng, uint8_t const *data); -void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data); - // last received mdb answer (from mdb device) - // only needed if a special command was sent directly - // DB0: mdb Device-Nr - // DB1: last sent mdb command - // DB2: nr of received (payload) data bytes (apart from ACK, can be 0....34) - // DB3...DB38: rec.data (payload) - -void gpi_storeEmpSettings(uint8_t leng, uint8_t const *data); -void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data); - -/* -void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data); - -void epi_restoreEmpCoinSignal(uint8_t *leng, uint8_t *data); - // return 5 byte: - // data[0]=got coin 0xFF=emp reported an error 0=got nothing - // data[1]=emp-signal of last inserted coin - // data[2,3]=emp-value of last inserted coin - // data[4] = emp-error or warning - -void epi_clearEmpCoinSignal(); -*/ - - -void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t const *data); - -uint8_t epi_isNewCoinLeft(void); - // retval: 0...16 coins left in FIFO -void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value); - -void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t const *data); -void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data); - -void gpi_storeMachineIDsettings(uint8_t leng, uint8_t const *data); -void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data); - -void epi_clearCurrentPayment(void); -void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue); - -uint32_t epi_CurrentPaymentGetAmount(void); -uint16_t epi_CurrentPaymentGetLastCoin(void); - -bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values); - // alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht - -void gpi_storeWakeSources(uint8_t const *receivedData); -uint64_t epi_getWakeSources(void); -uint8_t epi_getWakeReason(void); - -void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data); -void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data); - -void gpi_storeDeviceConditions(uint8_t leng, uint8_t const *data); -void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data); - -void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data); -void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data); - -void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t const *data); -void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs); - // return accNrs[0..7] - -void epi_iniVRstorage(void); -void gpi_storeVaultRecord(uint8_t blkNr, uint8_t const *data); -bool epi_checkIfVaultRecordAvailable(void); -bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf); - // true if completly received - -void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins); - -uint32_t epi_getCashBoxContent(void); -uint16_t epi_getNrOfCoinsInCashBox(void); - -void gpi_storeNewMifareCard(uint8_t typ, uint8_t const *holder); - -uint8_t epi_mifGetCardType(uint8_t const *holder); - //holder[8] = name of card holder - // retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins - -void gpi_storeDcDataValid(bool isVal); -bool gpi_areDcDataValid(); -bool epi_areDcDataValid(); - - - -#endif - - - diff --git a/include/tslib.h b/include/tslib.h deleted file mode 100644 index bc38ade..0000000 --- a/include/tslib.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef TSLIB_H -#define TSLIB_H -#include -#include - - -#define LOWBYTE false -#define HIGHBYTE true - -uint16_t uchar2uint(char Highbyte, char Lowbyte); -uint16_t uchar2uint(uint8_t Highbyte, uint8_t Lowbyte); -uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t Lowbyte); - -uint8_t uint2uchar(uint16_t uival, bool getHighB); - -uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr); - // getBytNr: 0=LSB 3=MSB - - -void delay(uint16_t MilliSec); - -#define MITSEK 1 -#define OHNESEK 0 -#define HourSys12h 1 -#define HourSys24h 0 - -void GetTimeString(uint8_t hours, uint8_t minutes, uint8_t seconds, uint8_t System12h, uint8_t ShowSec, uint8_t *buf); - // generate time as ascii string from integers hours/minutes/seconds - // System12h=0: 24h system =1: 12h System - // ShowSec=0: String has 5 digits (hh:mm) =1: String has 8 digits (hh:mm:ss) - // return String in *buf // 12 byte für buf! - -#define DateFormatDeutsch 0 -#define DateFormatAmerica 1 -#define UsePointSeperator 0 -#define UseSlashSeperator 1 - - -void GetDateString(uint8_t day, uint8_t month, uint8_t yearhigh, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf); - // generate date as ascii string from integers day/month/year - // yearhigh in europe always 20 (not in arabia) - // format= 0: dd.mm.yyyy (deutsch) - // 1: mm.dd.yyyy (amerika) - // 2: yyyy.mm.dd (Iran, Dubai) - // 3: dd.yyyy.mm - // 4: mm.yyyy.dd - // 5: yyyy.dd.mm - // sep: 0: use . as seperator 1: use / as seperator - // return String in *buf // 11 byte für buf! - - -void GetShortDateString(uint8_t day, uint8_t month, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf); - // generate date as ascii string from integers day/month/year - // format= 0: dd.mm.yy (deutsch) - // 1: mm.dd.yy (amerika) - // 2: yy.mm.dd (Iran, Dubai) - // 3: dd.yy.mm - // 4: mm.yy.dd - // 5: yy.dd.mm - // sep: 0: use . as seperator 1: use / as seperator - // return String in *buf // 11byte für buf! - - -uint16_t tslib_strlen(char *buf); -uint16_t tslib_strlen(uint8_t *buf); - -void tslib_strclr(char *buf, char clrsign, uint16_t len); -void tslib_strclr(uint8_t *buf, char clrsign, uint16_t len); - -void tslib_strcpy(char *srcbuf, char *destbuf, uint16_t len); -void tslib_strcpy(char *srcbuf, uint8_t *destbuf, uint16_t len); -void tslib_strcpy(uint8_t *srcbuf, uint8_t *destbuf, uint16_t len); - - -uint16_t tslib_calcCrcCcitt(uint16_t BufLength, uint8_t *buf); - -bool tslib_isDecAsciiNumber(char sign); -bool tslib_isHexAsciiNumber(char sign); - - -int tslib_getMinimum(int val1, int val2); - -void tslib_text2array(QByteArray text, char *aray, uint16_t maxArayLen); - // usage: tslib_text2array("my text", ctmp, 50); - -void biox_CopyBlock(uint8_t *src, uint16_t srcPos, uint8_t *dest, uint16_t destPos, uint16_t len); - // both buffers starting from pos 0 - - -#endif // TSLIB_H diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index d2e36f0..0cbc9f5 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -3,6 +3,10 @@ #include #include +#include + +#include +#include ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(parent), @@ -10,7 +14,12 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject( { this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str()); - this->hw = new hwapi(); + if (!this->private_loadCashAgentLib("")) { + return; + } + + + //connect(dynamic_cast(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK())); //connect(dynamic_cast(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR())); @@ -313,6 +322,46 @@ void ATBDeviceControllerPlugin::onCashPayStopByTimeout() } +bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName) +{ + if (pluginName == "") { + pluginName = "/usr/lib/libCashAgentLib.so"; + } + + if (!QLibrary::isLibrary(pluginName)) { + qCritical() << "ATBDeviceControllerPlugin: can not load CashAgentLib: " << pluginName; + this->errorCode = 5; + this->errorDescription = "ERROR: can not load CashAgentLib: " + pluginName; + return false; + } + + QPluginLoader* pluginLoader = new QPluginLoader(); + pluginLoader->setFileName(pluginName); + + QObject* plugin = pluginLoader->instance(); + if (!pluginLoader->isLoaded()) { + qCritical() << "ATBDeviceControllerPlugin: can not instantiate CashAgentLib: " << pluginName; + this->errorCode = 6; + this->errorDescription = "ERROR: can not instantiate CashAgentLib: " + pluginName; + return false; + } + + if (plugin == nullptr) { + qCritical() << "ATBDeviceControllerPlugin: plugin is NULL"; + } + + qCritical() << "ATBDeviceControllerPlugin: instantiate CashAgentLib: " << pluginName; + + this->hw = qobject_cast(plugin); + + if (this->hw == nullptr) { + qCritical() << "ATBDeviceControllerPlugin: hw is NULL"; + } + + return true; +} + + /************************************************************************************************ * Mandatory plugin methods diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.h b/src/ATBAPP/ATBDeviceControllerPlugin.h index c1c90e6..b8eba92 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.h +++ b/src/ATBAPP/ATBDeviceControllerPlugin.h @@ -9,7 +9,7 @@ -#include "hwapi.h" +#include "interfaces.h" #include #include @@ -114,6 +114,8 @@ private: QTextCodec *codec; + bool private_loadCashAgentLib(QString pluginName); + private slots: // printer diff --git a/src/com.cpp b/src/com.cpp deleted file mode 100644 index 3afec3e..0000000 --- a/src/com.cpp +++ /dev/null @@ -1,448 +0,0 @@ -#include "com.h" -#include -//#include "controlBus.h" - -////////////////////////////////////////////////////////////////////////////////// -/// -/// serial hardware layer -/// -////////////////////////////////////////////////////////////////////////////////// - -static int64_t com_want2read; -// ------------------------------------------------------------------------------------------------------------- -// --------- PUBLIC -------------------------------------------------------------------------------------------- -// ------------------------------------------------------------------------------------------------------------- - -void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) -{ - sendBuffer=data; - sendLen=sendLength; - if (CatSerial->isOpen()) - { - CatSerial->write(sendBuffer); - } else - qDebug() << "error sending, port is not open"; - -} - - -bool T_com::readFromSerial(QByteArray &data, uint16_t &sendLength) -{ - // return one time true if new data (completly) read. - // return new data in &data and &sendLength to other objects - uint16_t ll=rawInLen; - if (!CatSerial->isOpen()) - return false; - data.clear(); - data.append(rawInput); - sendLength=ll; - rawInLen=0; // beim 2. Aufruf 0 zurück weil nichts neues da - if (ll>0) - return true; - return false; -} - - -// ------------------------------------------------------------------------------------------------------------- -// --------- PRIVATES -------------------------------------------------------------------------------------- -// ------------------------------------------------------------------------------------------------------------- - - -T_com::T_com(QObject *parent) : QObject(parent) -{ - // port settings come from tabCom->Sdata->serial - - gpi_serialChanged(); - CatSerial = new QSerialPort(); // PortHW object for Control&Analyse Tool - //CatSerial->clear(); - //CatSerial->clearError(); - - connect(CatSerial, &QSerialPort::readyRead, this, &T_com::readSomeBytes); - // still reading, not sure if complete, undefined number of calls while reading - - connect(CatSerial, &QSerialPort::bytesWritten, this, &T_com::serialSendComplete); - // system confirms sending complete - - //connect(CatSerial, &QSerialPort::dataTerminalReadyChanged, this, &T_com::incomingWake); - //connect(CatSerial, &QSerialPort::requestToSendChanged, this, &T_com::incomingWake); - - // timer detects time gap in input flow - serRecTime = new QTimer(); - connect(serRecTime, SIGNAL(timeout()), this, SLOT(receiveTO())); - serRecTime->setSingleShot(true); // single shot! only one impulse if receive complete - serRecTime->stop(); // on hold - - // check COM-TAB periodic if user wants to connect or disconnect - QTimer *ChkConnectTimer = new QTimer(); - connect(ChkConnectTimer, SIGNAL(timeout()), this, SLOT(ser_ISR100ms())); - ChkConnectTimer->setSingleShot(false); - ChkConnectTimer->start(100); // in ms - com_want2read=0; -} - - - - -T_com::~T_com() -{ - if (CatSerial->isOpen()) - CatSerial->close(); -} - - -void T_com::ser_ISR100ms() -{ - //qDebug() << "~~>LIB" << "ENTER..."; - // call every 100ms to check if user(HMI) wants to connect or disconnect - uint8_t chkConn = gpi_getSerialConn(); // from global GUI buffer (Sdata) - - //qDebug() << "~~>LIB" << "checking connect button... " << chkConn; - - switch (chkConn) - { - case 0: // 0 button "connect" was just released - //qDebug() << "close serial port" << chkConn; - closeSerialPort(); - gpi_serialChanged(); // set chkConn to 2, thus getting edge - break; - case 1: // 1 button "connect" was just pressed - //qDebug() << "open serial port" << chkConn; - open_Serial_Port(); - gpi_serialChanged(); // set chkConn to 2, thus getting edge - break; - } - - - if (CatSerial->isOpen()) { - gpi_serialIsOpen(true); - } else { - gpi_serialIsOpen(false); - } - - //qDebug() << "LEAVE " << chkConn; -} - -// ------------------------------------------------------------------------------------------------------------- -// ------------------------------------------------------------------------------------------------------------- -// ------------------------------------------------------------------------------------------------------------- - -char T_com::open_Serial_Port() -{ - //qDebug() << "ENTER"; - - bool ret; - QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr; - int myBaudNr; - - if (CatSerial->isOpen()) { - qDebug() << "!!!IS OPEN!!!"; - return 0; // opening twice is not allowed - } - - //qDebug() << "connecting..." << myPortName; - myPortName=gpi_getComPortName(); // was selected and stored from GUI - CatSerial->setPortName(myPortName); - myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI - - //qDebug() << "myPortName" << myPortName << ", myBaudNr" << myBaudNr; - - switch (myBaudNr) - { - // 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200 - case 0: CatSerial->setBaudRate(QSerialPort::Baud1200); myBaudStr="1200"; break; - case 1: CatSerial->setBaudRate(QSerialPort::Baud9600); myBaudStr="9600"; break; - case 2: CatSerial->setBaudRate(QSerialPort::Baud19200); myBaudStr="19200"; break; - case 3: CatSerial->setBaudRate(QSerialPort::Baud38400); myBaudStr="38400"; break; - case 4: CatSerial->setBaudRate(QSerialPort::Baud57600); myBaudStr="57600"; break; - case 5: CatSerial->setBaudRate(QSerialPort::Baud115200); myBaudStr="115200"; break; - } - - CatSerial->setDataBits(QSerialPort::Data8); - // alt: QSerialPort::Data5,6,7,8 - - CatSerial->setParity(QSerialPort::NoParity); - // alt: EvenParity, OddParity, NoParity - - CatSerial->setStopBits(QSerialPort::OneStop); - // alternative: OneStop, TwoStop, OneAndHalfStop - - CatSerial->setFlowControl(QSerialPort::NoFlowControl); - // alt: HardwareControl, SoftwareControl, NoFlowControl - - ret=CatSerial->open(QIODevice::ReadWrite); - // alt: QIODevice::ReadWrite QIODevice::ReadOnly QIODevice::WriteOnly - if (!ret) - { - myString.clear(); - myString = "error "; - myString.append(CatSerial->errorString()); - qDebug() << myString; - gpi_setTxt4comStateLine(myString); - - //qDebug() << "LEAVE"; - - return 0; - } else - { - myString.clear(); - myString.append(myPortName); - //lang=myString.size(); - myString.append(" opened with "); - myString.append(myBaudStr); - myString.append(" 8N1"); - qDebug() << myString; - gpi_setTxt4comStateLine(myString); - gpi_setTxt4RsDiagWin(myString+"\n"); - - } - - //qDebug() << "LEAVE"; - return 0; -} - -void T_com::closeSerialPort() -{ - //qDebug() << "ENTER"; - - if (CatSerial->isOpen()) - { - qDebug() << "closing connection"; - CatSerial->close(); - gpi_setTxt4comStateLine("closed"); - gpi_setTxt4RsDiagWin("closed"); - - } - - //qDebug() << "LEAVE"; -} - - -void T_com::readSomeBytes(void) -{ - // called by serial-read-detection - // restart off-time as input flow is ongoing - - // timer for slow receive - // and serves as timeout for fast receive is msg is shorter as expected - serRecTime->stop(); - serRecTime->start(20); // in ms - - //qDebug()<< "com-rec read some bytes"; - - this->receiveByLength(); // since 14.12.21: fast receive -} - -void T_com::receiveFixLen(int64_t nrOfbytesToReceive) -{ - // call this before sending a request to slave - // then we know exactly when reception is complete -> much faster - com_want2read=nrOfbytesToReceive; - // since 14.12.21: FastDevice Protocol has two lengthen: - // fast: 12byte reception long: 68byte -} - -void T_com::receiveByLength(void) -{ - - if (CatSerial->isOpen()) - { - QString myString=nullptr, tmpStr=nullptr; - int64_t nrOfBytesreceived = CatSerial->bytesAvailable(); // nr of received bytes - - //qDebug()<< "com-rec current Len: "<< nrOfBytesreceived; - - if (nrOfBytesreceived >= com_want2read) - { - QByteArray data = CatSerial->readAll(); // erst auslesen wenn alles da! löscht den Empfangspuffer - serRecTime->stop(); // stop timeout to avoid 2nd emit - rawInLen=uint16_t (nrOfBytesreceived); - rawInput.clear(); - rawInput.append(data); - // report "new data received" to other objects - //qDebug()<< "com-recFinished by Len "<< rawInLen; - emit receivingFinished(); - } - } -} - -void T_com::receiveTO(void) -{ - // no new input data for 20ms, --> assuming frame complete - // save data in private "rawInput"-buffer - - if (CatSerial->isOpen()) - { - - QString myString=nullptr, tmpStr=nullptr; - int64_t nrOfBytesreceived = CatSerial->bytesAvailable(); // nr of received bytes - QByteArray data = CatSerial->readAll(); - - rawInLen=uint16_t (nrOfBytesreceived); - rawInput.clear(); - rawInput.append(data); - //rawInput[rawInLen]=0; // Zwangsterminierung bei QByteArray nicht nötig - - // diag display in serial in/out window and debug window - myString.clear(); - myString.setNum(rawInLen); - myString.append(" in: "); - //myString.append(rawInput); - for (int ii=0; ii0x80 dann wird EIN Byte 16 stellig angezeigt - int ll=tmpStr.length(); - if (ll>2) - { - myString.append(tmpStr[ll-2]); - myString.append(tmpStr[ll-1]); - } else - { - myString.append(tmpStr); - } - myString.append(" "); - } - myString.append("\n"); - #ifdef PRINTALLDEBUGS - qDebug() << "VCP:" << myString; // display all inputs and outputs in output window - #endif - gpi_setTxt4RsDiagWin(myString); - //gpi_set2ndTxt4RsDiagWin(myString); - - // report "new data received" to other objects - //qDebug()<< "com-recFinished by TO"; - emit receivingFinished(); - } -} - -void T_com::serialSendComplete(void) -{ - // system confirms sending complete, diag display - QString myString=nullptr, tmpStr=nullptr; - - myString.clear(); - myString.setNum(sendLen); - myString.append(" out: "); - - for (int ii=0; ii0x80 dann 16stellig - int ll=tmpStr.length(); - if (ll>2) - { - //qDebug() << "long_string" << ll << "\n"; - myString.append(tmpStr[ll-2]); - myString.append(tmpStr[ll-1]); - - } else - { - myString.append(tmpStr); - } - myString.append(" "); - } - -#ifdef PRINTALLDEBUGS - myString.append("\n"); - qDebug() << myString; // display all output data in out-window -#endif - - gpi_setTxt4RsDiagWin(myString); - - emit sendingFinished(); // for whom it may interest -} - - -bool T_com::isPortOpen(void) -{ - if (CatSerial->isOpen()) - return true; - return false; -} - - - -// ------------------------------------------------------------------------------------------------------------- -// ------------------------------------------------------------------------------------------------------------- -// ------------------------------------------------------------------------------------------------------------- - -/* -uint8_t T_com::getAllPortPins(void) -{ - uint8_t rs232pins=0; - rs232pins= uint8_t(CatSerial->pinoutSignals()); - // rs232pins: all signals bitwise coded in one byte: - // readback output: bit 0=TxD(=output) bit2=DTR (=output) bit 6=RTS (=output) - // unused inputs: bit1=RxD bit 3=DCD bit 5 = RING - // handshake inputs: bit 4=DSR (0x10) bit 7=CTS (0x80) - //qDebug()<<"serial port pins: " << rs232pins; - return rs232pins; -} - -bool T_com::getHSin_CTS(void) -{ - // return the used Handshake IN (CTS, alt. DSR): true= high level (+8V) - - uint8_t rs232pins=0; - - rs232pins= uint8_t(CatSerial->pinoutSignals()); - // rs232pins: all signals bitwise coded in one byte: - // readback output: bit 0=TxD(=output) bit2=DTR (=output) bit 6=RTS (=output) - // unused inputs: bit1=RxD bit 3=DCD bit 5 = RING - // handshake inputs: bit 4=DSR (0x10) bit 7=CTS (0x80) - - if (rs232pins & 0x80) // CTS - return true; - - return false; -} - - -bool T_com::getHSin_DSR(void) -{ - uint8_t rs232pins=0; - rs232pins= uint8_t(CatSerial->pinoutSignals()); - if (rs232pins & 0x10) // DSR - return true; - return false; -} - -void T_com::incomingWake(void) //(bool LevelOfTheBit) -{ - emit wasWokenBySerialHandshake(); -} - -bool T_com::setHSout_RTS(bool hsout) -{ - // hsout true=positiv voltage +12V false= -12V - // retval: true=setting OK - - bool cc; - // 10.5.19, am Windows-PC nachgemessen, funktioniert gut - // false ergibt -12V true ergibt +12V - - cc=CatSerial->setRequestToSend(hsout); // RTS out - // retval true means "setting was successful" - - // alternative: use DTR as Handshake: - //cc=CatSerial->setDataTerminalReady(false); // DTR out - // retval true means "setting was successful" - //qDebug()<<"RTS " <setDataTerminalReady(hsout); // DTR out - // retval true means "setting was successful" - //qDebug()<<"DTR " < -#include - -#include -#include -#include "tslib.h" -#include "shared_mem_buffer.h" - -// /////////////////////////////////////////////////////////////////////////////////// -// control serial interface gui <--> serial -// /////////////////////////////////////////////////////////////////////////////////// -void epi_setSerial(int BaudNr, - QString BaudStr, - QString ComName, - uint8_t connect) { - memset(&SharedMemBuffer::getData()->rs.comportName[0], 0x00, - sizeof(SharedMemBuffer::getData()->rs.comportName)); - strncpy(SharedMemBuffer::getData()->rs.comportName, - ComName.toStdString().c_str(), - sizeof(SharedMemBuffer::getData()->rs.comportName)-1); - - memset(&SharedMemBuffer::getData()->rs.baudStr[0], 0x00, - sizeof(SharedMemBuffer::getData()->rs.baudStr)); - strncpy(SharedMemBuffer::getData()->rs.baudStr, - BaudStr.toStdString().c_str(), - sizeof(SharedMemBuffer::getData()->rs.baudStr)-1); - - SharedMemBuffer::getData()->rs.baudNr = BaudNr; - SharedMemBuffer::getData()->rs.connect = connect; -} - -void epi_closeSerial(void) { - SharedMemBuffer::getData()->rs.connect = 0; -} - -void gpi_serialChanged(void) { - // serial confirms that port was closed or opened - // rs_connect=2; // Flanke, nur 1x öffnen/schließen - SharedMemBuffer::getData()->rs.connect = 2; -} - -uint8_t gpi_getSerialConn(void) { - return SharedMemBuffer::getDataConst()->rs.connect; -} - -int gpi_getBaudNr(void) { - return SharedMemBuffer::getDataConst()->rs.baudNr; -} - -QString gpi_getComPortName(void) { - return SharedMemBuffer::getDataConst()->rs.comportName; -} - -void gpi_serialIsOpen(bool offen) { - SharedMemBuffer::getData()->rs.portIsOpen = offen; -} - -bool epi_isSerialPortOpen() { - // true: port is open false: port is closed - return SharedMemBuffer::getDataConst()->rs.portIsOpen; -} - -// /////////////////////////////////////////////////////////////////////////////////// -// Control transfer gui <--> serial -// /////////////////////////////////////////////////////////////////////////////////// - -void epi_startEmmision(char start) { - SharedMemBuffer::getData()->AutoEmissionOn = start; -} - -bool gpi_isEmmisionOn(void) { - return SharedMemBuffer::getDataConst()->AutoEmissionOn; -} - -uint16_t gpi_getPeriodicSendTimeVal() { - SharedMemBuffer::getData()->datif.sendingPer_changed = 0; - if ((SharedMemBuffer::getDataConst()->datif.sendingPeriod < 3) || - (SharedMemBuffer::getDataConst()->datif.sendingPeriod > 10000)) { - return 130; // ms, default - } - return SharedMemBuffer::getDataConst()->datif.sendingPeriod; -} - -void epi_setPeriodicSendTimeVal(uint16_t val) { - if (val>=3 && val<10000) { - SharedMemBuffer::getData()->datif.sendingPer_changed = 1; - SharedMemBuffer::getData()->datif.sendingPeriod = val; - } -} - -bool gpi_PeriodicSendTimeHasChanged() { - return SharedMemBuffer::getDataConst()->datif.sendingPer_changed; -} - -// /////////////////////////////////////////////////////////////////////////////////// -// Status Display gui <--> serial -// /////////////////////////////////////////////////////////////////////////////////// - -// linke Spalte, über Connect Button -static QString txt4comStateLine; - -QString epi_getTxt4comStateLine(void) { - // GUI: get Text for serial Comport-State Line - return txt4comStateLine; -} - -void gpi_setTxt4comStateLine(QString txtline) { - // serial: write Text to be displayed in serial Comport-State line (like "connected") - txt4comStateLine.clear(); - if (txtline=="") - txt4comStateLine.clear(); - else - txt4comStateLine=txtline; -} - -void epi_clrTxt4comStateLine() { - txt4comStateLine.clear(); -} - -// rechte Spalte, oberste Statuszeile -// I) "Handshakes" (serial Control) flow.cpp -// geht überhaupt was raus? kommt überhaupt was zurück? -static QString txt4HsStateLine; - -QString epi_getTxt4HsStateLine(void) { - return txt4HsStateLine; -} - -void gpi_setTxt4HsStateLine(QString txtline) { - txt4HsStateLine.clear(); - if (txtline=="") - txt4HsStateLine.clear(); - else - txt4HsStateLine=txtline; -} - -void epi_clrTxt4HsStateLine() { - txt4HsStateLine.clear(); -} - -// II) Master receive state (empfangenes Telgramm OK? crc? length? ) -// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp) -static QString txt4masterStateLine; - -QString epi_getTxt4masterStateLine(void) { - return txt4masterStateLine; -} - -void gpi_setTxt4masterStateLine(QString txtline) { - txt4masterStateLine.clear(); - if (txtline=="") - txt4masterStateLine.clear(); - else - txt4masterStateLine=txtline; -} - -void epi_clrTxt4masterStateLine() { - txt4masterStateLine.clear(); -} - -//--------------------------------------------------------------------------------------------- - -// III Slave receive (from Master) OK? if then show results, if not then show errors -// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR -// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch -// nicht verwenden und nichts ausgeben oder einlesen - -static QString txt4resultStateLine; - -QString epi_getTxt4resultStateLine(void) { - return txt4resultStateLine; -} - -void gpi_setTxt4resultStateLine(QString txtline) { - txt4resultStateLine.clear(); - if (txtline=="") - txt4resultStateLine.clear(); - else - txt4resultStateLine=txtline; -} - -void epi_clrTxt4resultStateLine() { - txt4resultStateLine.clear(); -} - -//--------------------------------------------------------------------------------------------- - -// IV Statuszeile Empfangsdaten -static QString txt4dataLine; - -QString epi_getTxt4dataStateLine(void) { - // GUI: get Text for serial Comport-State Line - return txt4dataLine; - -} - -void gpi_setTxt4dataStateLine(QString txtline) { - // serial: write Text to be displayed in serial Comport-State line (like "connected") - txt4dataLine.clear(); - if (txtline=="") - txt4dataLine.clear(); - else - txt4dataLine=txtline; -} - -void epi_clrTxt4dataStateLine() { - txt4dataLine.clear(); -} - -//--------------------------------------------------------------------------------------------- - -// 5. Zeile: Datif Ergebnis, Daten brauchbar? - -static QString txt4datifReceive; - -QString epi_getTxt4datifLine(void) { - return txt4datifReceive; -} - -void gpi_setTxt4datifLine(QString txtline) { - txt4datifReceive.clear(); - if (txtline=="") - txt4datifReceive.clear(); - else - txt4datifReceive=txtline; -} - -void epi_clrTxt4datifLine() { - txt4datifReceive.clear(); -} - -//--------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------- - -static QString txt4diagWindow; - -QString epi_getTxt4RsDiagWin(void) { - return txt4diagWindow; -} - -void gpi_setTxt4RsDiagWin(QString txtline) { - txt4diagWindow.clear(); - if (txtline=="") - txt4diagWindow.clear(); - else - txt4diagWindow=txtline; -} - -void epi_clrTxt4RsDiagWin() { - txt4diagWindow.clear(); -} - -//--------------------------------------------------------------------------------------------- - -static QString sndTxt4diagWindow; - -QString epi_get2ndTxt4RsDiagWin(void) { - return sndTxt4diagWindow; -} - -void gpi_set2ndTxt4RsDiagWin(QString txtline) { - sndTxt4diagWindow.clear(); - if (txtline=="") - sndTxt4diagWindow.clear(); - else - sndTxt4diagWindow=txtline; -} - -void epi_clr2ndTxt4RsDiagWin() { - sndTxt4diagWindow.clear(); -} - -// /////////////////////////////////////////////////////////////////////////////////// -// Memory for Slave responses, common data -// /////////////////////////////////////////////////////////////////////////////////// -void gpi_storeResult_serialTestOK(bool wasOk) { - SharedMemBuffer::getData()->Sdata.serialTestResult = wasOk; -} - -bool epi_getResult_serialTestOK() { - // retval: true: test was successful, got right response - return SharedMemBuffer::getDataConst()->Sdata.serialTestResult; -} - -// /////////////////////////////////////////////////////////////////////////////////// -// Store received data for hwapi -// /////////////////////////////////////////////////////////////////////////////////// -void gpi_startNewRequest() { - SharedMemBuffer::getData()->Sdata.pProtResultOk = 0; -} - -void gpi_storeResultOfLastRequest(bool answisok) { - SharedMemBuffer::getData()->Sdata.pProtResultOk = answisok ? 1 : 2; -} - -uint8_t epi_getResultOfLastRequest() { - // retval: 0: in progress 1: OK 2: error - return SharedMemBuffer::getDataConst()->Sdata.pProtResultOk; -} - -void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData) { - SharedMemBuffer::getData()->Sdata.receivedDataLength - = std::min(RdDlen, (uint8_t)(64)); - memset((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]), - 0x00, sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock)); - strncpy((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]), - (char const *)receivedData, - sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock)-1); -} - -uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad) { - // get data back in *pl, max 64 byte - // retval = nr of bytes received. If host buffer too small then - // only plBufSíz bytes are copied to pl - // plBufSíz=size of host buffer - - uint16_t ml = std::min(plBufSiz, (uint16_t)(64)); - if (SharedMemBuffer::getDataConst()->Sdata.receivedDataLength < ml) { - ml = SharedMemBuffer::getDataConst()->Sdata.receivedDataLength; - } - strncpy((char *)payLoad, - (char const *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]), - ml); - - return SharedMemBuffer::getDataConst()->Sdata.receivedDataLength; -} diff --git a/src/datIf.cpp b/src/datIf.cpp deleted file mode 100644 index 0299745..0000000 --- a/src/datIf.cpp +++ /dev/null @@ -1,1853 +0,0 @@ -#include "datIf.h" -#include "sendWRcmd.h" -#include "controlBus.h" -#include "storeINdata.h" -#include - -// called from MainWindow() - - -#define DATIF_MAXCMDS 16 -static uint8_t dif_dataStep; -static uint8_t dif_scanStep, RDBLKNR; - - -static uint8_t datif_OutCmdpara1, datif_OutCmdpara2, datif_OutCmdpara3, datif_OutCmdpara4; -static uint16_t datif_OutCmdpara5; -static uint32_t datif_OutCmdpara6; -static uint8_t cycl_running; - -//static bool datif_DCdataValid; - -T_datif::T_datif(QObject *parent) : QObject(parent) -{ - - myDCIF = new T_prot(); - - // valid data was received, storing - connect(myDCIF, SIGNAL(framerecieved()), this, SLOT(StoredRecData())); - - // new, 9.11.20 data for DC-bootloader received not matchind Pprot - //connect(myDCIF, SIGNAL(rawDataRecieved()), this, SLOT(BLdataRecData())); - - // cyclic transmission of INPUT-Requests - datif_trigger = new QTimer(); - connect(datif_trigger, SIGNAL(timeout()), this, SLOT(datif_cycleSend())); - datif_trigger->setSingleShot(false); - datif_trigger->start(10); // in ms, 80 gut, default 100 50....200 - - // passing Signal through - //connect(myDCIF, SIGNAL(framerecieved()), this, SLOT( ResponseRecieved() )); - - datif_OutCmdpara1=0; - datif_OutCmdpara2=0; - datif_OutCmdpara3=0; - datif_OutCmdpara4=0; - dif_dataStep=1; - - dif_scanStep=0; - selectedSlaveAddr=FIX_SLAVE_ADDR; - cycl_running=0; - //datif_DCdataValid=0; - gpi_storeDcDataValid(0); - datif_noResponseCtr=0; -} - -void T_datif::resetChain(void) -{ - dif_scanStep=0; -} - -char T_datif::datif_cycleSend() -{ - // cyclic transmission of INPUT-Requests - // call cyclic to send next request every 100ms, then wait for response before sending again!!! - uint16_t nxtAsCmd; - uint8_t dataSendBuf[160], dataBufLen, dbl, who; - static uint8_t BlockCounter; - - uint8_t nextWrCmd, nextRdCmd, blockNum, dat1, dat2, dat3, dat4; - 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 - datif_trigger->stop(); - datif_trigger->start(10); - cycl_running++; - if (cycl_running>10) - cycl_running=0; - return 0; - } - if (myDCIF->isPortOpen()) - { - #ifdef USEHANDSHAKES - if (myDCIF->isSerialFree()) - #endif - { - // new, from 11.4.23: direkt access to fastDevice Interface - // always use this three functions to send data: - //void myDCIF->setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, uint8_t *data); - //void myDCIF->setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr); - //void myDCIF->setUserWriteData(uint16_t WriteCmd); - //void myDCIF->setUserWrite1DB (uint16_t WriteCmd, uint16_t WrAddr, uint8_t val); - //void myDCIF->setUserWrite2DB (uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, uint8_t val1); - - //void myDCIF->setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reserv); - //void myDCIF->setUserReadData( uint16_t ReadCmd, uint16_t RdAddr); - //void myDCIF->setUserReadData( uint16_t ReadCmd); - - //void myDCIF->sendUserData(uint16_t slaveAdr); - - if (check4FDshortCmd()) - { - cycl_running=1; - b_ret=sendFDcmd_get(&nextWrCmd, &nextRdCmd, &blockNum, &dat1, &dat2, &dat3, &dat4); - if (b_ret) - { - data[0]=dat1; data[1]=dat2; data[2]=dat3; data[3]=dat4; data[4]=0; - myDCIF->setUserWriteData(nextWrCmd, blockNum, 4, data); - myDCIF->setUserReadData(nextRdCmd); - myDCIF->sendUserData(selectedSlaveAddr); - } - return 0; - } - - if (check4FDlongCmd()) - { - cycl_running=1; - b_ret=longFDcmd_get(&nextWrCmd, &nextRdCmd, &blockNum, &length, data); - if (b_ret) - { - myDCIF->setUserWriteData(nextWrCmd, blockNum, length, data); - myDCIF->setUserReadData(nextRdCmd); - myDCIF->sendUserData(selectedSlaveAddr); - } - return 0; - } - - // direct commands have highest prio (setting OUTPUTS) - nxtAsCmd=sendWRcmd_getSendCommand0(); // command was stored by Gui - if (nxtAsCmd>0) - { - cycl_running=1; - // qDebug() << "datif: send next cmd0"; - sendWRcommand(nxtAsCmd); - send_requests(nxtAsCmd); - sendHighLevel(nxtAsCmd); - BlockCounter=0; - return 0; - } - - nxtAsCmd=sendWRcmd_getSendCommand4(&datif_OutCmdpara1, &datif_OutCmdpara2, &datif_OutCmdpara3, &datif_OutCmdpara4); - // command was stored by Gui - if (nxtAsCmd>0) - { - cycl_running=1; - //qDebug() << "datif: send next cmd4"; - sendWRcommand(nxtAsCmd); - send_requests(nxtAsCmd); - sendHighLevel(nxtAsCmd); - BlockCounter=0; - return 0; - } - - nxtAsCmd=sendWRcmd_getSendCommand8(&datif_OutCmdpara1, &datif_OutCmdpara2, &datif_OutCmdpara5, &datif_OutCmdpara6); - // command was stored by Gui - if (nxtAsCmd>0) - { - cycl_running=1; - //qDebug() << "datif: send next cmd8"; - sendWRcommand(nxtAsCmd); - send_requests(nxtAsCmd); - sendHighLevel(nxtAsCmd); - BlockCounter=0; - return 0; - } - - dbl=sendWRcmd_getSendBlock160(&dataBufLen, dataSendBuf); // used for bootloader - if (dbl>0) - { - cycl_running=1; - //qDebug() << "datif: sending 160 byte block, len: " << dataBufLen; - datif_OUT_SendRandomData(dataSendBuf, dataBufLen); - BlockCounter=0; - return 0; - } - - dbl=gpi_chk4remainingText(); - if (dbl>0) - { - cycl_running=1; - //qDebug() << "datif: sending printer text "; - gpi_restorePrnText(&dataSendBuf[0]); - // can hold 1280 byte, get next 64 - //for (uint8_t nn=0; nn<64; nn++) - // qDebug() << dataSendBuf[nn] << " "; - - - who=gpi_getUserOfSendingTextBuffer(&datif_OutCmdpara1, &datif_OutCmdpara2, &datif_OutCmdpara3, &datif_OutCmdpara4); - - if (who==1) - { - epi_store64ByteSendData(64, dataSendBuf); // "dueway", copy this 64 back to pi, used by datif_ send64byteOutCmd - datif_send64byteOutCmd(CMD2DC_PRI_PRINT_TXT, 0, 0); - } else - if (who==2) - { - epi_store64ByteSendData(64, dataSendBuf); // "dueway", copy this 64 back to pi, used by datif_ send64byteOutCmd - datif_send64byteOutCmd(CMD2DC_STOR_QR_DATA, 0, 0); - } else - if (who==3) - { - //qDebug() << "datif: sending printer text, docnr: " <11) - RDBLKNR=0; - datif_OutCmdpara1=RDBLKNR; - - } break; - - case 17: - //datif_sendIOrequest(0, CMD2DC_GetAllInputs, 0); - datif_sendIOrequest(0, 19, 0); - break; - - case 18: - if (indat_isMdbOn()) - datif_sendIOrequest(0, CMD2DC_MDB_GET_STATE, 0); // 107 - //else - // dif_scanStep=24; unsinn - break; - - case 19: - datif_sendIOrequest(0, 30, 0); - break; - - case 20: - //if (indat_isMdbOn()) - datif_sendIOrequest(0, CMD2DC_MDB_GETRESP, 0); // 22 - - break; - - case 21: - datif_sendIOrequest(0, CMD2DC_GetAllInputs, 0); - break; - - case 22: - //if (indat_isMdbOn()) // kein eigener Schalter für EMP - datif_sendIOrequest(0, CMD2DC_EMP_GET_ALL, 0); // 23 - break; - - case 23: - datif_sendIOrequest(0, 31, 0); - break; - - case 24: - //if (indat_isMdbOn()) // kein eigener Schalter für EMP - datif_sendIOrequest(0, CMD2DC_EMP_GOTCOIN, 0); // 108 - break; - - case 25: - datif_sendIOrequest(0, 32, 0); - break; - - case 26: - datif_sendIOrequest(0, 33, 0); - break; - - - } - - dif_scanStep++; - if (dif_scanStep>26) - dif_scanStep=5; - -return 0; - -} - - -char T_datif::isPortOpen(void) -{ - return (myDCIF->isPortOpen()); -} - - -// ############################################################################## -// ############################################################################## -// ############################################################################## -// Empfangsdaten einsortieren -// ---------------------------------------------------------------------------------------------- - - - -void T_datif::StoredRecData() -{ - datif_noResponseCtr=0; - //qDebug() << "StoreRecData called"; - // call automatically by T_prot - //if (myDCIF->ifDataReceived()) - //if (neu) - { - // just a wrapper as we need a retval - // "neu" is the same as "INdataValid" - loadRecDataFromFrame(); - } - cycl_running=0; -} - -char T_datif::loadRecDataFromFrame() -{ - // necessary data in T_prot: - uint16_t readSource, uitmp,uit2; - uint16_t readAddress; - //uint8_t pp; - uint8_t SlaveAdr, RdDleng; - uint8_t receivedData[FRAME_DATALEN]; - QString localStr; - uint32_t ultmp; - //int portNr; - bool ret; - uint8_t uctmp; // maxai - char ctmp; - static uint8_t lastResult; - uint8_t prnResult; - static uint32_t lastInsertedAmount; - uint32_t newInsertedAmount; - - 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); - - if (ret==false) - { - 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 ", -// receivedData[0], receivedData[1], receivedData[2], receivedData[3], -// receivedData[4], receivedData[5], receivedData[6], receivedData[7], -// receivedData[8], receivedData[9], receivedData[10], receivedData[11], -// receivedData[12], receivedData[13], receivedData[14], receivedData[15]); - - // readSource: reflects the READ Command if possible - // readAddress: reflects the requested read/write address if slave could perform - // lastWakeSrc: if Slave wakes master, this ist the reason for it (e.g. button pressed) - // RdDataLength: number of bytes in receivedData - - //firstDB=receivedData[0]; // just shorter, is used very often - //scndDB=receivedData[1]; - //thrdDB=receivedData[2]; - - localStr.clear(); - -// receivedData[0]='a'; -// receivedData[1]='B'; -// receivedData[2]='1'; -// receivedData[3]='-'; - - - for (int ii=0; ii>2)&3)); - uctmp=receivedData[1]; - gpi_storeDI_contactPowerIsOn(uctmp&0x10); - gpi_storeDI_optos((uctmp>>5)&3); - uctmp=receivedData[2]; - gpi_storeDI_auxIn(uctmp); - - uctmp=receivedData[3]; - gpi_storeDI_ptuWake(uctmp&1); - gpi_storeDI_readbackMdbTxD(uctmp&2); - gpi_storeDI_prnReady(uctmp&4); - gpi_storeDI_CoinAttach(uctmp&8); - gpi_storeDI_CoinEscrow(uctmp&16); - gpi_storeDI_mifareCardTapped(uctmp&32); - gpi_storeDI_rejMot_home(uctmp&64); - - uctmp=receivedData[4]; - //gpi_storeDI_modemWake(0); // gibt's gar nicht! - gpi_storeDI_mbdWake(uctmp&1); - gpi_storeDI_MifarePowerIsOn(uctmp&2); - gpi_storeDI_AuxPowerIsOn(uctmp&8); - gpi_storeDI_GsmPowerIsOn(uctmp&16); - gpi_storeDI_CreditPowerIsOn(uctmp&32); - gpi_storeDI_PrinterPowerIsOn(uctmp&64); - - //gpi_storeMdbState(uctmp&4, uctmp&128, uctmp&4); // hat ein eigenes Cmd weiter unten! - gpi_storeDI_MdbPowerIsOn(uctmp&128); - - gpi_storeDI_paperLow(receivedData[5]); - break; - - case CMD2DC_RdBkAllOutputs: //103 - - /* -// alle DO's in einen 8byte Puffer zusammenstellen, werden in einen Rutsch zum Master gesendet - - outBuf[0]: bit 0: TestMdbInput - 1: RS1 drv enabled - 2: RS1switch: 1=GSM 0=printer - 3: RS2switch: H: mifare L: credit - 4: Vbarcode=Vaux is on - - outBuf[1]: bit 0: coin led - 1: 0 - 2: paper led - 3: pinpad led - 4: start led - 5: service led - - outBuf[2]: bit 0: siren - 1: relay - 2: ptu wake - 3: shutter - 4: shutter test - 5: escrowGive - 6: escrowTake - 7: prn power - - outBuf[3]: Motor 1: 0:off 1=vorwärts / öffnen 2=rückw./zu 3: beide ein - outBuf[4]: Motor 2: 0:off 1=vorwärts / öffnen 2=rückw./zu 3: beide ein - */ - - uctmp=receivedData[0]; - gpi_storeDO_mdbRxTst(uctmp&1); - gpi_storeDO_auxPower(uctmp&0x10); - gpi_storeDO_serialSwitch((uctmp>>1)&7); // serial drv 0:on/off, 1:Serial mux1, 2:Serial mux2 - - uctmp=receivedData[1]; - gpi_storeDO_ledsAndFan(uctmp); - // bit0: coinled 1:front_illu 2: paper-led 3:pinpad-led 4:start-led 5:service-led 6:fan - - uctmp=receivedData[2]; - gpi_storeDO_sirenAndRelay(uctmp&3); // bit0: siren 1:relay - gpi_storeDO_ptuWake(uctmp&4); - - - gpi_storeDO_coinShutter(uctmp>>3); // bit0: Coin shutter output, bit1: input-test-output - gpi_storeDO_coinEscrow(uctmp>>5); // retval: 1:return flap is open 2:take flap is open 0:closed - gpi_storeDO_printerPwrOn(uctmp&0x80); - - uctmp=(receivedData[4] & 3); - uctmp<<=2; - if (receivedData[3] & 1) uctmp |=1; - if (receivedData[3] & 2) uctmp |=2; - gpi_storeDO_motorOutputs(uctmp); - // bit0: upper lock forw bit 1 backw bit2: lowLock forw bit3: LL backw - break; - - - case CMD2DC_RdBk_MifState: //109 - // get reader status and card type - - //gpi_storeMifReaderStateAndCardType(receivedData); - gpi_storeNewMifareCard(receivedData[0], &receivedData[1]); - - break; - - case CMD2DC_RdBk_MifData: //24 - // one block of data (64byte) comes in - // blkNr 0...11 in "Addr" - gpi_storeMifCardData(readAddress, receivedData); -//qDebug()<<"datif storing mif data: (adr/data) "<0: error - // bit0: paper low 1: no paper 2: temperature error - // 3: head open 4: paper jam in cutter - // 6: no response 7: bad response from printer - - gpi_storePrinterState(receivedData); // derzeit 10bytes ( 0x2A02) - break; - - case CMD2DC_RdBk_PrnFonts: // 26 - //D0: font table/type - //D1: size - //D2: height - //D3: width - //D4: bold - //D5: invers - //D6: underlined - //D7: density - //D8: speed - //D9: Alignment - gpi_storePrinterFonts(receivedData); // derzeit 10bytes - break; - - case CMD2DC_RdBk_AllPrnData: // 27 - gpi_storePrinterState(receivedData); // derzeit 10bytes ( 0x2A02) - gpi_storePrinterFonts(&receivedData[10]); // derzeit 10bytes - /* - qDebug()<<"printer fonts stored " <40) - //datif_DCdataValid=1; // das hier sind die wichtigsten Daten, deshalb hierrein! - gpi_storeDcDataValid(1); - - gpi_storeDynMachineConditions(RdDleng, receivedData); - - 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; - } - - break; - - case 32: // Get current cash level (in vault) - // bytes 0..3: amount bytes 4,5=Nr.ofCoins in vault - ultmp=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]); - uitmp=uchar2uint(receivedData[5],receivedData[4]); - gpi_storeCBlevel(ultmp, uitmp); - break; - - case 33: // Get all backuped acc. Numbers - // 8 UINTs with acc-nr - gpi_storeDCbackupAccNr(RdDleng, receivedData); - break; - - case 38: // Get stored account record backup -/* - -struct T_vaultRecord -{ - UCHAR startbuffer[4]; // Psa> // never move or change this 1st entry - UINT AccountingNumber; - UINT CUNU; - UINT MANU; - UINT resint1; - //UINT resint2; - - UCHAR label1buffer[4]; // tim> - UCHAR year; - UCHAR month; - UCHAR dom; - UCHAR hour; - UCHAR min; - UCHAR sec; - UCHAR DoW; - UCHAR reschar3; - - UCHAR label2buffer[4]; // abs> - ULONG AbsIncome1; - ULONG AbsReserve; - ULONG AbsNrOfCuts; - -//16 - UCHAR label3buffer[4]; // mw > - - // Verkauf, Tür zu: - ULONG VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen - ULONG VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben -//88 - - // Service, Tür offen: - UINT ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen - UINT ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben - UINT resint3; - UINT resint4; - UINT currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand - UINT resint5; - UINT resint6; -// 56 - - UCHAR label4buffer[4]; // box> - UINT coinsInVault[16]; - UINT billsInStacker[8]; -// 48 - - UCHAR label5buffer[4]; // val> - // actually constant unless exchange rate is changed - UINT coinDenomination[16]; // 5..50000 (z.B. 2€ sind in Ungarn 760Ft) - UINT billDenom[8]; - UINT tubeDenom[6]; - UINT exchangeRate; - UINT resint9; - -// 64 - - UCHAR endofblock[4]; // end> -// 316 byte Block im Speicher -*/ - // readAddress, &RdDleng, receivedData - gpi_storeVaultRecord(readAddress, receivedData ); // always 64byte - break; - - } - readSource=0; // 17.05.2023: to avoid multiple recording - - return 0; -} - -// fehlen: 112, 113,14,17, 19, 30,31,32,33, - -// subs: - -// ---------------------------------------------------------------------------------------------- -// erstelle WRITE Datensätze -// ---------------------------------------------------------------------------------------------- - -// always use this three functions to send data: -//void myDCIF->setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, uint8_t *data); -//void myDCIF->setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr); -//void myDCIF->setUserWriteData(uint16_t WriteCmd); -//void myDCIF->setUserWrite1DB (uint16_t WriteCmd, uint16_t WrAddr, uint8_t val); -//void myDCIF->setUserWrite2DB (uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, uint8_t val1); - -//void myDCIF->setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reserv); -//void myDCIF->setUserReadData( uint16_t ReadCmd, uint16_t RdAddr); -//void myDCIF->setUserReadData( uint16_t ReadCmd); - -//void myDCIF->sendUserData(uint16_t slaveAdr); - -void T_datif::datif_startSending(void) -{ - // egal ob WR und RD Daten gesetzt wurden - myDCIF->sendUserData(selectedSlaveAddr); // starte Sendung - gpi_startNewRequest(); - cycl_running=1; - -} - -// allgemeine Schreib/Lese-Funktion -void T_datif::datif_sendIOrequest(uint16_t WRcmd, uint16_t RDcmd, uint8_t nrOfWrData) -{ - uint8_t data[6]; - - if (nrOfWrData>4) nrOfWrData=0; - tslib_strclr(data,0,6); - - if (nrOfWrData>0) - data[0]=datif_OutCmdpara1; - if (nrOfWrData>1) - data[1]=datif_OutCmdpara2; - if (nrOfWrData>2) - data[2]=datif_OutCmdpara3; - if (nrOfWrData>3) - data[3]=datif_OutCmdpara4; - data[4]=0; data[5]=0; - - myDCIF->setUserWriteData(WRcmd, 0, nrOfWrData, data); - myDCIF->setUserReadData(RDcmd); - myDCIF->sendUserData(selectedSlaveAddr); - cycl_running=1; - -} - -void T_datif::datif_send8byteOutCmd(uint16_t WRcmd, uint16_t RDcmd) -{ - uint8_t data[10]; - uint16_t uitmp; - uint32_t ultmp; - - tslib_strclr(data,0,10); // 8 used - - data[0]=datif_OutCmdpara1; - data[1]=datif_OutCmdpara2; - uitmp=datif_OutCmdpara5; - ultmp=datif_OutCmdpara6; - - data[2]=uint8_t(uitmp); - uitmp>>=8; - data[3]=uint8_t(uitmp); - - data[4]=uint8_t(ultmp); - ultmp>>=8; - data[5]=uint8_t(ultmp); - ultmp>>=8; - data[6]=uint8_t(ultmp); - ultmp>>=8; - data[7]=uint8_t(ultmp); - - data[8]=0; data[9]=0; - - myDCIF->setUserWriteData(WRcmd, 0, 8, data); - myDCIF->setUserReadData(RDcmd); - myDCIF->sendUserData(selectedSlaveAddr); - cycl_running=1; - -} - - -bool T_datif::verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData) -{ - if (RdDlen < 16) - return false; - QString myStr; - char ctmp; - - myStr.clear(); - myStr.append("< Slave Response"); - - for (int nn=0; nn<16; nn++) - { - ctmp=receivedData[nn]; - if (myStr[nn] != ctmp) - { - //qDebug() << " datif cmd 10: got wrong string "; - //qDebug() << myStr; - //qDebug() << receivedData; - //qDebug() << nn; - return false; - } - } - return true; -} - - -// RTC ---------------------------------------------------------------------- - -void T_datif::datif_OUT_setTime(void) -{ - // send PC time/date to slave - //uint8_t hour,min, sec, year, month, day, dayOfWeek, - //uint8_t dayOfYear, isLeap, weekOfYear; - uint8_t buff[15]; - uint16_t uitmp; - - QTime *systTime = new QTime(); - // qDebug() << systTime->currentTime().hour() <<":" - // << systTime->currentTime().minute() <<":" - // << systTime->currentTime().second(); - - buff[0]=uint8_t(systTime->currentTime().hour()); - buff[1]=uint8_t(systTime->currentTime().minute()); - buff[2]=uint8_t(systTime->currentTime().second()); - - - QDate *systDate = new QDate(); - systDate->currentDate(); - - uitmp= uint16_t(systDate->currentDate().year()); - buff[3]=uint8_t(uitmp); - buff[4]=uint8_t(uitmp>>8); - - buff[5]=uint8_t(systDate->currentDate().month()); - buff[6]=uint8_t(systDate->currentDate().day()); - buff[7]=uint8_t(systDate->currentDate().dayOfWeek()); - -// uitmp=systDate->currentDate().dayOfYear(); -// buff[8]=uint8_t(uitmp); -// buff[9]=uint8_t(uitmp>>8); - -// buff[10]=uint8_t(systDate->currentDate().isLeapYear(systDate->currentDate().year())); -// buff[11]=uint8_t(systDate->currentDate().weekNumber()); //weekOfYear -// buff[12]=0; - - //myDCIF->setUserWriteData(0x1310,0,8, buff); - myDCIF->setUserWriteData(CMD2DC_sendTime,0,8, buff); - myDCIF->setUserReadData(0); - myDCIF->sendUserData(selectedSlaveAddr); // jetzt wegsckicken - cycl_running=1; - -} - -// 0x2311: set time to RTC -// 0x2312: set date to RTC - -uint8_t T_datif::datif_OUT_SendRandomData(uint8_t *buf, uint8_t Length) -{ - uint8_t len=Length; - - myDCIF->setBLsendData(len, buf ); - myDCIF->setUserReadData(0); - myDCIF->sendUserData(selectedSlaveAddr); - cycl_running=1; - - return 0; - -} - - - - -void T_datif::datif_send64byteOutCmd(uint16_t WRcmd, uint16_t addr, uint16_t RDcmd) -{ - // sending length is already defined by stored data - // not batched! don't use twice within 100ms - uint8_t LL; - uint8_t data[66]; - - tslib_strclr(data,0,66); // up to 64 used - gpi_restore64ByteSendData(&LL, data); // LL bytes was stored to be sent - myDCIF->setUserWriteData(WRcmd, addr, LL, data); - myDCIF->setUserReadData(RDcmd); - myDCIF->sendUserData(selectedSlaveAddr); - cycl_running=1; - -} - -void T_datif::datif_sendToMemory(uint16_t WRcmd, uint16_t docNr, uint16_t blockNr, uint8_t *data64) -{ - // send printer documents to DC2 memory - // docNr: 0...15(31) with 1280 byte each (20 blocks a 64byte) - // blockNr=0...19 with 64byte each - // docNr =transmitted in WRITEADDRESS high byte - // blockNr=transmitted in WRITEADDRESS low byte - - uint16_t aa=0; - - aa=docNr; - aa<<=8; - aa |=blockNr; - myDCIF->setUserWriteData(WRcmd, aa, 64, data64); - myDCIF->setUserReadData(0); - myDCIF->sendUserData(selectedSlaveAddr); - cycl_running=1; - -} - - - diff --git a/src/dcBL.cpp b/src/dcBL.cpp deleted file mode 100644 index 0d114f7..0000000 --- a/src/dcBL.cpp +++ /dev/null @@ -1,1461 +0,0 @@ -//#include -#include "dcBL.h" -#include -//#include "tabFw.h" -#include "sendWRcmd.h" - - -// File sits "behind" the HWapi and in front of "PI", so all necessary Bootloader functions can be called from HWapi - - - -uint16_t ucharTOuint(uint8_t Highbyte, uint8_t Lowbyte) -{ - uint16_t uitmp; - uitmp=0; - uitmp |= uint8_t(Highbyte); - uitmp<<=8; - uitmp |= uint8_t(Lowbyte); - return uitmp; -} - -#define GETLOWBYTE 0 -#define GETHIGHBYTE 1 - -uint8_t uintTOuchar(uint16_t uival, uint8_t getHighB) -{ - // getHighB: low=GetLowByte - uint16_t uitmp=uival; - if (getHighB==0) - return uint8_t(uitmp); - uitmp>>=8; - return uint8_t(uitmp); - -} - -//#define GETLOWBYTE 0 -//#define GETHIGHBYTE 1 -#define GETMIDLOWBYTE 2 -#define GETMIDHIGHBYTE 3 - -uint8_t ulongTOuchar(uint32_t ulval, uint8_t whichByte) -{ - - uint32_t ultmp=ulval; - if (whichByte==GETLOWBYTE) - return uint8_t(ultmp); - ultmp>>=8; - if (whichByte==GETMIDLOWBYTE) - return uint8_t(ultmp); - ultmp>>=8; - if (whichByte==GETMIDHIGHBYTE) - return uint8_t(ultmp); - ultmp>>=8; - if (whichByte==GETHIGHBYTE) - return uint8_t(ultmp); - return 0; -} - -void strclr(uint8_t *buf, uint8_t clrsign, uint8_t len) -{ - uint16_t nn; - - for (nn=0; nn> (7 - nn)) & 0x01); - if (B15H) - { - crc ^= 0x1021; - } - } - } - - for (nn = 0; nn < 16; nn++) - { - B15H = 0; - if(crc & 0x8000) - B15H = 1; - crc = (crc << 1) | 0x00; - if (B15H) - { - crc ^= 0x1021; - } - } - return crc; - -} - - -#define SEND_STX 2 -#define SEND_ETX 3 -#define SEND_ESC 0x1B - -static uint8_t dcBL_LastBLcmd; // stored the last sent cmd in order to analys response - // cmd echo'ed: error cmd or'ed with 0x80: OK - -uint8_t dcBL_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) -{ - // make BL protocol, retval = outbuf length (5...133) - // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum - // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 - // Data length = 0...64 - // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 - // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 - - // 26.01.2021: noch einen Fehler gefunden: die "special conversion" fehlt bei der angehaengten Checksumme!!! - - uint8_t myBuf[140], pp=0, HB, LB; - uint8_t crcBuf[140], mm=0; - uint8_t nn, uctmp, currLen=0; - uint16_t calcCrc; - - strclr(myBuf, 0, 140); - strclr(crcBuf, 0, 140); // extra Puffer because STX must not be caculated - - myBuf[pp++]=SEND_STX; - myBuf[pp++]=Cmd; - crcBuf[mm++]=Cmd; - dcBL_LastBLcmd=Cmd; - - // append data: - for (nn=0; nn0 && recLen<150) - { - epi_getRawReceivedData(respBuff); - epi_clrRawReceivedString(); - dcBL_writeText("dcBL gotResponse"); - - if (display) - { -/* - // Antwort ins Fenster schreiben: - QString tmpStr="", myStr="~~> "; - - tmpStr.setNum(recLen); - myStr.append(tmpStr); - myStr.append(" bytes received: "); - for (int nn=0; nn block wiederholen. In den anderen Fällen NICHT wiederholen - // sonst ist der block doppelt im Flash!!!!!!!! - if (recLen>0 && recLen<5) - { - dcBL_writeText("error wrong length"); - //exactError=1; -qDebug()<<" DCBL_chkResp wrong length "; - return 10; // OK - } - if (buf[0] !=2) - { - dcBL_writeText("error wrong start"); - //exactError=2; -qDebug()<<" DCBL_chkResp wrong start "; - return 10; // OK - } - if (buf[0]==2 && buf[1]=='e' && buf[2]=='0' ) - { - dcBL_writeText("error wrong crc"); - //exactError=3; // DC reports wrong crc -qDebug()<<" DCBL_chkResp wrong crc"; - return 1; // error - } - if (buf[0]==2 && buf[1]==dcBL_LastBLcmd ) - { - dcBL_writeText("error wrong cmd"); - //exactError=4; // wrong cmd -qDebug()<<" DCBL_chkResp wrong cmd"; - return 10; // OK - } - //tmpStr.clear(); - //tmpStr.setNum(exactError); - //dcBL_writeText(tmpStr); - return 1; // error -} - - - -uint8_t dcBL_sendSuccess(uint8_t lastCommand) -{ - // return val: 0: no response by now 1:error 10: OK - - uint8_t buf[152], recLen; - - recLen=dcBL_getResponse(buf,0); - if (recLen==0) - return 0; // no response by now - - if (buf[0]==2 && buf[1]==(lastCommand | 0x80) ) - return 10; // OK - return 1; -} - -// ----------------------------------------------------------------------------------------------- -// --- ATB Bin-File Handling --------------------------------------------------------------------- -// ----------------------------------------------------------------------------------------------- - -/* example read file from HDD: - uint8_t uit8tmp; - QString stemp=" "; - - QFile file("/own/H2B/dc2.bin"); - //QFile file("/own/H2B/dc2.hex"); // laesst sich genauso oeffnen - - // TODO: use File-Open-Dialog-Box - - if (!file.exists()) - { - qDebug()<<"file not exists"; - } else - { - if (!file.open(QIODevice::ReadOnly) ) - { - qDebug()<<"cannot open"; - } else - { - qDebug()<<"loading...."; - qDebug()<<"size: " << file.size() <<"\n"; - QByteArray myBin = file.readAll(); - - // Kontrolle: - int ii=0; - do - { - uit8tmp=(uint8_t)myBin[ii++]; - //qDebug() << uit8tmp << " "; // Anzeige in dez - stemp.setNum(uit8tmp,16); - qDebug() << stemp << " "; // Anzeige in hex - - } while (ii<100); - } - } - - */ - - -// ------------------------------------------------------------------------- - -char dcBL_loadBinary(char withDisplay) -{ - // same function as in "tabFw" - //uint8_t uit8tmp; - uint32_t ultmp, fileLen; - QString tmpStr="", s2tmp=""; - - qDebug()<<"dcBL loading DC2c binary..."; - QFile file("../dc2c4.bin"); - if (!file.exists()) - { - //qDebug()<<"file _own_H2B_dc2.bin does not exist"; - dcBL_writeText("file _own_H2B_dc2.bin does not exist"); - return 1; - } - if (!file.open(QIODevice::ReadOnly) ) - { - //qDebug()<<"cannot open"; - dcBL_writeText("cannot open"); - return 1; - } - - //qDebug()<<"loading...."; - //qDebug()<<"size: " << file.size() <<"\n"; - if (withDisplay) - { - s2tmp="loading file with "; - tmpStr.setNum(file.size()); - s2tmp.append(tmpStr); - s2tmp.append(" bytes"); - dcBL_writeText(s2tmp); - } - QByteArray myBin = file.readAll(); - fileLen=uint32_t(file.size()); - - // Rest des Blockes mit 0xFF füllen - for (ultmp=fileLen; ultmp<(fileLen+70); ultmp++) - myBin[ultmp]=char(0xFF); - - /* // Kontrolle: - qDebug()<<"dcBL_loadBinary: "; - int ii=59500; - do - { - uit8tmp=uint8_t(myBin[ii++]); - s2tmp.clear(); - //qDebug() << uit8tmp << " "; // Anzeige in dez - s2tmp.setNum(uit8tmp,16); - qDebug() << s2tmp << " "; // Anzeige in hex - - } while (ii<60100); - */ - - dcBL_importBinFile(myBin, fileLen, withDisplay); - return 0; - -} - - -static QByteArray dcBL_AtbBinFile; -static uint32_t dcBL_fileSize; -static uint16_t dcBL_nrOfBlocks; -static uint16_t dcBL_fileCrc; -//static uint8_t dcBL_myBuf[2570000]; // same content like "dcBL_AtbBinFile" but bytewise -static uint8_t dcBL_myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise - -bool dcBL_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) -{ - uint16_t uitmp; - uint32_t ultmp; - uint32_t LL; - QString tmpStr="", s2tmp=""; - - dcBL_AtbBinFile=readBinFile; - dcBL_fileSize=fileSize; - - //if (dcBL_fileSize>258048) // 27.3.23TS woher kommt die Zahl??? - // das hex file hat 278kB - // hex file nicht erlaubt??? - if (dcBL_fileSize>=300000) - return false; // keep last file - ultmp=dcBL_fileSize; - ultmp %=64; - uitmp=uint16_t(ultmp); - ultmp=dcBL_fileSize; - ultmp /=64; - dcBL_nrOfBlocks=uint16_t(ultmp); - if (uitmp>0) - dcBL_nrOfBlocks++; // letzter Block hat !=64 byte - - // type conversion for crc calc - for (LL=0; LLalso sicherstellen dass das Laden des Binfiles 100%ig in Ordnung ist. - QByteArray BINFILECOPY1, BINFILECOPY2, BINFILECOPY3; - uint32_t BinFileCpyLen1, BinFileCpyLen2, BinFileCpyLen3, LL; - uint8_t repeat=0, nn=0, stopp=0; - //char cc; - - do - { - //dcBL_writeText("loading 1st time:"); - //qDebug() <<"loading 1st time:"; - dcBL_loadBinary(0); - // file jetzt in: "QByteArray dcBL_AtbBinFile" mit Laenge "uint32_t dcBL_fileSize" - BINFILECOPY1=dcBL_AtbBinFile; - BinFileCpyLen1=dcBL_fileSize; - - //dcBL_writeText("loading 2nd time:"); - //qDebug() <<"loading 2. time:"; - dcBL_loadBinary(0); - // file jetzt in: "QByteArray dcBL_AtbBinFile" mit Laenge "uint32_t dcBL_fileSize" - BINFILECOPY2=dcBL_AtbBinFile; - BinFileCpyLen2=dcBL_fileSize; - - //dcBL_writeText("loading 3rd time:"); - //qDebug() <<"loading 3. time:"; - dcBL_loadBinary(0); - // file jetzt in: "QByteArray dcBL_AtbBinFile" mit Laenge "uint32_t dcBL_fileSize" - BINFILECOPY3=dcBL_AtbBinFile; - BinFileCpyLen3=dcBL_fileSize; - -//cc=BINFILECOPY2[100]; -//if (cc>0) -// BINFILECOPY2[100]=0; -//else -// BINFILECOPY2[100]=1; - - repeat=0; - if (BinFileCpyLen1 !=BinFileCpyLen2 || BinFileCpyLen1 !=BinFileCpyLen3) - { - dcBL_writeText("file length wrong"); - qDebug() <<"length error"; - - repeat=1; // load both again.... - } - if (repeat==0) - { - LL=0; stopp=0; - //qDebug() <<"1. loop"; - - do - { - if (dcBL_AtbBinFile[LL] != BINFILECOPY1[LL]) - stopp=1; - } while((++LL < dcBL_fileSize) && !stopp); - - if (stopp) - { - dcBL_writeText("file compare1 wrong "); - repeat=1; // load both again.... - } - } - - if (repeat==0) - { - LL=0; stopp=0; - //qDebug() <<"2. loop"; - do - { - if (dcBL_AtbBinFile[LL] != BINFILECOPY2[LL]) - stopp=1; - } while((++LL < dcBL_fileSize) && !stopp); - - if (stopp) - { - dcBL_writeText("file compare2 wrong "); - repeat=1; // load both again.... - } else - dcBL_writeText("file OK"); - } - - } while (++nn<3 && repeat); // 3 trials - - qDebug() << "compare finito " << nn << " " << repeat; - - if (repeat==0) - return true; // file OK - return false; // error, could not load correctly - -} - - - - -uint8_t dcBL_getAtbFileHeader(uint8_t *buf) -{ - // this header is prepended by the pc-direct-loader-tool - // (so the uC-BL expects this!) here it is sent seperately: - uint8_t myBuf[30], pp=0, len; - - myBuf[pp++]='A'; - myBuf[pp++]='T'; - myBuf[pp++]='B'; - myBuf[pp++]='-'; - myBuf[pp++]='D'; - myBuf[pp++]='C'; - myBuf[pp++]='2'; - myBuf[pp++]='-'; - myBuf[pp++]=ulongTOuchar(dcBL_fileSize, GETHIGHBYTE); - myBuf[pp++]=ulongTOuchar(dcBL_fileSize, GETMIDHIGHBYTE); - myBuf[pp++]=ulongTOuchar(dcBL_fileSize, GETMIDLOWBYTE); - myBuf[pp++]=ulongTOuchar(dcBL_fileSize, GETLOWBYTE); - myBuf[pp++]='-'; - myBuf[pp++]=uintTOuchar(dcBL_fileCrc, GETHIGHBYTE); - myBuf[pp++]=uintTOuchar(dcBL_fileCrc, GETLOWBYTE); - myBuf[pp++]='-'; - len=pp; - //tslib_strcpy(myBuf, buf, (len+3)); - len=dcBL_prepareDC_BLcmd(0x32, len, myBuf, buf); - return len; -} - -uint8_t dcBL_getFileBlock(uint16_t blockPointer, uint8_t *buf) -{ - // blockPointer=0....4095 - uint32_t addr, LL; //, BL; - //uint8_t uit8tmp; - //QString stemp=" "; - - addr=uint32_t(blockPointer); - addr<<=6; // *64 =Start address -/* - if ( (addr+63)>dcBL_fileSize) - { - BL=dcBL_fileSize-addr+1; // Block Length - for (LL=0; LL<64; LL++) - buf[LL]=0; - if (BL>64) BL=64; // security limitation - // only BL bytes are left to give - for (LL=0; LL0) - return true; - return false; -} - -QString dcBL_readText(void) -{ - // read from 0...9 (oldest first) - if (pBlResp<=0) // should never be <0 - return ""; - QString locStr=BlResp[1]; // store memory[1] - - // move memories down by one: 2->1 3->2 4>3....9->8. Place 1 is free now - // example: if pBlResp==3 then we have still text 2 and 3 to display. 1 will be transfered now with this call - int nn; - for (nn=1; nn0) pBlResp--; - return locStr; -} - - - -// ------------------------------------------------------------------------- - - -static uint8_t dcBL_step, dcBL_state; -static uint16_t dcBL_BlkCtr, dcBL_cyclCtr, repeatCtr; - -void dcBL_iniChain(void) -{ - int nn; - dcBL_step=0; - dcBL_cyclCtr=0; - dcBL_state=0; - dcBL_BlkCtr=0; - repeatCtr=0; - - // delete output window: - pBlResp=0; - for (nn=0;nn17) - { - dcBL_iniChain(); - dcBL_step=1; - //epi_clrRawReceivedString(); - qDebug()<<"starting chain..."; - //qDebug()<6 && recBuff[0]==2 && recBuff[1]==99 && recBuff[2]==52) - // && recBuff[3]==53 && recBuff[4]==98 && recBuff[5]==51 && recBuff[6]==3 ) - { - dcBL_writeText("BL started"); - dcBL_cyclCtr=0; - dcBL_step++; - return 0; - } - //qDebug()<10) // 50 gibt 6,2s - { - // cancel, report error - dcBL_writeText("cannot start BL, cancel"); - dcBL_state=3; - dcBL_step=0; // stop chain - return 0; - } */ - - dcBL_step++; - repeatCtr=0; - break; - - case 6: // request Version number - len=dcBL_readFWversion(buf); - sendWRcmd_setSendBlock160(len, buf); - dcBL_writeText("request version nr..."); - dcBL_cyclCtr=0; - dcBL_step++; - break; - - case 7: // wait for answer 2 146 45 45 95 176 3 - - if (gotResp==ISOK) - { - dcBL_state=1; // BL started - dcBL_step++; - repeatCtr=0; - return 0; - } else - if (gotResp==ISWRONG) - { - if (++repeatCtr<3) - { - dcBL_step--; - }else - { - dcBL_step=0; // stop chain - } - } - - if (++dcBL_cyclCtr>10) - { - dcBL_writeText("cancel"); - dcBL_step=0; // stop chain - } - break; - - case 8: // send start address - if (dcBL_BlkCtr==0 || dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096) - { - ultmp=uint32_t(dcBL_BlkCtr); - ultmp*=64; - len=dcBL_sendFlashStartAddr2BL(ultmp, buf); - sendWRcmd_setSendBlock160(len, buf); - dcBL_writeText("sending start address"); - dcBL_cyclCtr=0; - dcBL_step++; - return 0; - } else - dcBL_step=12; - break; - - case 9: // wait for answer 2 161 68 59 3 - if (gotResp==ISOK) - { - dcBL_step=12; // Header nicht senden, unnötig - dcBL_BlkCtr=0; // 0 - repeatCtr=0; - return 0; - } else - if (gotResp==ISWRONG) - { - if (++repeatCtr<3) - { - dcBL_step--; - } else - { - dcBL_step=0; // stop chain - } - } - if (++dcBL_cyclCtr>10) - { - dcBL_writeText("cancel"); - dcBL_step=0; // stop chain - } - break; - - - case 12: // send binary 64 byte wise - - len=dcBL_getFileBlock(dcBL_BlkCtr, buf); // read from file, len = 0...64 - //lastBlkLength=len; // recognize last block or end - sendLen=dcBL_prepareDC_BLcmd(0x22, len, buf, sendBuf); // pack into protocol frame - - - // Kontrolle: - qDebug()<<"dcBL sending: "; - ii=0; - do - { - uit8tmp=(uint8_t)sendBuf[ii++]; - //qDebug() << uit8tmp << " "; // Anzeige in dez - stemp.setNum(uit8tmp,16); - qDebug() << stemp << " "; // Anzeige in hex - - } while (ii<100); - - - sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes - delay(100); - //dcBL_writeText("blk nr: "); - tmpStr.setNum(dcBL_BlkCtr); - dcBL_writeText(tmpStr); - delay(100); - //qDebug()<<"sending: " << buf; - dcBL_cyclCtr=0; - dcBL_BlkCtr++; - dcBL_step++; - break; - - case 13: // wait for answer 2 162 116 88 3 - - if (gotResp==ISOK) - { - // check if next address is needed (every 1024Blocks = 65536bytes) - if (dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096) - { - dcBL_step=8; - return 0; - } - - // check for EOF: - if (dcBL_BlkCtr >= dcBL_nrOfBlocks) - { - dcBL_writeText("last block successful sent..."); - dcBL_step++; // stop chain - dcBL_state=3; // transmission SUCCESSFUL - return 0; - } - dcBL_state=2; // transmission started - dcBL_step--; // send next data block - repeatCtr=0; - return 0; - } - if (gotResp==ISWRONG) - { - if (++repeatCtr<3) - { - dcBL_writeText("error"); - dcBL_BlkCtr--; - dcBL_step--; // send same block again - } else - { - dcBL_step=0; // stop chain - } - } - if (++dcBL_cyclCtr>30) // longer TO due to flashing - { - dcBL_writeText("cancel"); - dcBL_step=0; // stop chain - } - break; - - case 14: // - dcBL_writeText("finish writing flash"); - len=dcBL_writeLastPage(buf); // nur zur Sicherheit - sendWRcmd_setSendBlock160(len, buf); - dcBL_step++; - break; - - case 15: // wait for answer - if (gotResp==ISOK) - { - dcBL_step++; - repeatCtr=0; - return 0; - } else - if (gotResp==ISWRONG) - { - if (++repeatCtr>3) - { - dcBL_step--; - } - } - if (++dcBL_cyclCtr>10) - { - dcBL_writeText("cancel"); - dcBL_step=0; // stop chain - } - break; - - - case 16: // - dcBL_writeText("exit BL, bye"); - len=dcBL_exitBL(buf); - sendWRcmd_setSendBlock160(len, buf); - dcBL_step++; - - break; - - case 17: // wait for answer, not sure if it comes! - if (gotResp==ISOK) - { - dcBL_step++; - repeatCtr=0; - return 0; - } else - if (gotResp==ISWRONG) - { - if (++repeatCtr>10) - { - dcBL_step--; - } - } - if (++dcBL_cyclCtr>30) - { - dcBL_writeText("cancel"); - dcBL_step=0; // stop chain - } - break; - - case 18: - dcBL_step=0; - break; - } - - return 0; -} - - - -void dcBL_iniLoading(void) -{ - dcBL_iniChain(); -} - - -// nicht verwendet -void dcBL_startLoading(void) -{ - if (dcBL_step==0 || dcBL_step>17) - { - //dcBL_iniChain(); - dcBL_step=1; - //epi_clrRawReceivedString(); - qDebug()<<"DCBL start sending hexfile..."; - dcBL_writeText("DCBL start sending hexfile..."); - dcBL_BlkCtr=0; - dcBL_cyclCtr=0; - } - -} - - -// nicht verwendet -uint8_t dcBL_sendHexfile(void) -{ - QString tmpStr=""; - uint8_t buf[70], sendBuf[160], len, sendLen, gotResp; //, recLen; recBuff[160], ii, - QString stemp=" "; - uint32_t ultmp; - //uint8_t uit8tmp, ii; - - - gotResp=dcBL_ChkResponse(); - - switch (dcBL_step) - { - case 1: // send start address - if (dcBL_BlkCtr==0 || dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096) - { - ultmp=uint32_t(dcBL_BlkCtr); - ultmp*=64; - len=dcBL_sendFlashStartAddr2BL(ultmp, buf); - sendWRcmd_setSendBlock160(len, buf); - qDebug()<<" DCBL_CYCL_sending HexFile address "; - dcBL_writeText("sending addr"); - dcBL_step++; - return 0; - } else - dcBL_step=12; - break; - - case 2: // wait for answer 2 161 68 59 3 - if (gotResp==ISOK) - { - dcBL_step=12; // Header nicht senden, unnötig - dcBL_BlkCtr=0; // 0 - repeatCtr=0; - return 0; - } else - if (gotResp==ISWRONG) - { - if (++repeatCtr<3) - { - dcBL_step--; - } else - { - dcBL_step=0; // stop chain - qDebug()<<" DCBL_CYCL_got wrong resp to addr"; - dcBL_writeText("wrong resp"); - } - } - if (++dcBL_cyclCtr>100) - { - dcBL_writeText("cancel"); - qDebug()<<" DCBL_CYCL_step 2 got NO resp to addr"; - dcBL_step=0; // stop chain - } - break; - - case 12: // send binary 64 byte wise - - len=dcBL_getFileBlock(dcBL_BlkCtr, buf); // read from file, len = 0...64 - //lastBlkLength=len; // recognize last block or end - sendLen=dcBL_prepareDC_BLcmd(0x22, len, buf, sendBuf); // pack into protocol frame -/* - // Kontrolle: - qDebug()<<"dcBL sending: "; - ii=0; - do - { - uit8tmp=(uint8_t)sendBuf[ii++]; - //qDebug() << uit8tmp << " "; // Anzeige in dez - stemp.setNum(uit8tmp,16); - qDebug() << stemp << " "; // Anzeige in hex - - } while (ii<100); -*/ - sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes - delay(100); - dcBL_writeText("blk nr: "); - tmpStr.setNum(dcBL_BlkCtr); - dcBL_writeText(tmpStr); - delay(100); - qDebug()<<"DCBL sending blk nr: " << dcBL_BlkCtr; - dcBL_cyclCtr=0; - dcBL_BlkCtr++; - dcBL_step++; - break; - - case 13: // wait for answer 2 162 116 88 3 - - if (gotResp==ISOK) - { - // check if next address is needed (every 1024Blocks = 65536bytes) - if (dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096) - { - dcBL_step=8; - return 0; - } - - // check for EOF: - if (dcBL_BlkCtr >= dcBL_nrOfBlocks) - { - dcBL_writeText("last block successful sent..."); - dcBL_step++; // stop chain - dcBL_state=3; // transmission SUCCESSFUL - return 0; - } - dcBL_state=2; // transmission started - dcBL_step--; // send next data block - repeatCtr=0; - return 0; - } - if (gotResp==ISWRONG) - { - if (++repeatCtr<3) - { - dcBL_writeText("error"); - dcBL_BlkCtr--; - dcBL_step--; // send same block again - } else - { - dcBL_step=0; // stop chain - } - } - if (++dcBL_cyclCtr>30) // longer TO due to flashing - { - dcBL_writeText("cancel"); - dcBL_step=0; // stop chain - } - break; - - case 14: // - dcBL_writeText("finish writing flash"); - len=dcBL_writeLastPage(buf); // nur zur Sicherheit - sendWRcmd_setSendBlock160(len, buf); - dcBL_step++; - break; - - case 15: // wait for answer - if (gotResp==ISOK) - { - dcBL_step++; - repeatCtr=0; - return 0; - } else - if (gotResp==ISWRONG) - { - if (++repeatCtr>3) - { - dcBL_step--; - } - } - if (++dcBL_cyclCtr>10) - { - dcBL_writeText("cancel"); - dcBL_step=0; // stop chain - } - break; - - } - return 0; -} - - - - - -uint8_t dcBL_getResult(void) -{ - // call after every step to what's going on.... - // 1: connected to BL - // 2: transmission started - // 3: transmission successful - - return dcBL_state; -} - -// ------------------------------------------------------------------------- -// ------------------------------------------------------------------------- -// ------------------------------------------------------------------------- - - -static uint8_t Sdata_rawData[RAW_BL_DATALEN]; - -static uint8_t Sdata_LengthRawData; - -void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData) -{ - uint8_t nn; - Sdata_LengthRawData=RdDlen; - if (Sdata_LengthRawData>RAW_BL_DATALEN) - Sdata_LengthRawData=RAW_BL_DATALEN; - for (nn=0; nn0x80 dann wird EIN Byte 16 stellig angezeigt - int ll=tmpStr.length(); - if (ll>2) - { - myString.append(tmpStr[ll-2]); - myString.append(tmpStr[ll-1]); - } else - { - myString.append(tmpStr); - } - myString.append(" "); - - } - //ret=Sdata_LengthRawData; - //Sdata_LengthRawData=0; - return myString; -} - -void epi_clrRawReceivedString() -{ - Sdata_LengthRawData=0; -} - - - - - - - - - diff --git a/src/hwChk.cpp b/src/hwChk.cpp deleted file mode 100755 index ddac2ed..0000000 --- a/src/hwChk.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -#include -#include "hwChk.h" - - -hwChk::hwChk(QWidget *parent) : QObject(parent) -{ - -// myDCIF = new T_prot(); -// h: T_prot *myDCIF; - - //myDatif = new T_datif(); - HWaccess = new hwinf(); - - struct T_moduleCondition dcModCond; - sys_getDeviceConditions(dcModCond); - - -} - -hwChk::~hwChk() -{ - -} - diff --git a/src/hwapi.cpp b/src/hwapi.cpp deleted file mode 100644 index 95f55c8..0000000 --- a/src/hwapi.cpp +++ /dev/null @@ -1,4278 +0,0 @@ -/* - * API to the PSA2020 Hardware - * All data come in from device controller via serial interface and will be stored - * PI is updated every 100ms - * This api uses stored data and returns them in the following functions - * created: Q1/2020 TS until Q2/21 - * - */ - -#include -#include -#include -#include - -#include - -#include "tslib.h" -#include "hwapi.h" - -#include "sendWRcmd.h" -#include "controlBus.h" -#include "storeINdata.h" -#include "dcBL.h" -#include "shared_mem_buffer.h" -#include -#include -#include "interfaces.h" - -static uint32_t hwapi_lastStartAmount; -static uint8_t hwapi_cash_lastCollectionState; -static uint8_t hwapi_paymentStarted; - -static const QMap baudrateMap = { - {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, - {"57600" , 4}, {"115200" , 5} -}; - -hwapi::hwapi(QObject *parent) : QObject(parent) { - // create or attach shared memory segment - // !!! The compoment creating the shared memory MUST be ATBQT !!! - m_sharedMem = SharedMemBuffer::getShm(sizeof(SharedMemBuffer)); - if (m_sharedMem) { - if (m_sharedMem->isAttached()) { - qInfo() << "Shared memory (" - << sizeof(SharedMemBuffer) << "bytes) created and attached"; - } - } else { - qCritical() << "Creating/attaching shared memory failed"; - } - sendWRcmd_INI(); - myDatif = new T_datif(); - - 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() { - if (m_sharedMem && m_sharedMem->isAttached()) { - m_sharedMem->detach(); - } -} - - -void hwapi::hwapi_slotPayProc(void) -{ - cash_paymentProcessing(); -} - -void hwapi::hwapi_slotPrintFinished_OK(void) { - emit hwapi_templatePrintFinished_OK(); -} - -void hwapi::hwapi_slotPrintFinished_Err(void) { - emit hwapi_templatePrintFinished_Err(); -} - -void hwapi::hwapi_slotGotCoin(void) { - // new coin was inserted while transaction and new amount reported: - uint32_t newSum=epi_CurrentPaymentGetAmount(); - - // this slot is called sometimes irregularely and providing - // invalid sums! - // TODO: preveent irregular call. Meanwhile, we need this - // limit check: 75000Ft ~200€ - if (newSum > 75000) { - qCritical() << "Fixme: irregular gotNewCoin() signal"; - return; - } - - - emit hwapi_gotNewCoin(); - - if (newSum>=hwapi_lastStartAmount) - emit hwapi_payStopByMax(); - -} - -void hwapi::sub_storeSendingText(QByteArray *buf) const { - - char local[70], copie[1350]; // 64byte more then max buffer size! - int LL, nn, len, maxruns=20; - - epi_resetPrinterStack(); - // make a copy of the incoming byteArray as the byteArray can not be moved (crash!) - tslib_strclr(copie, 0, 1350); - LL=buf->length(); - for (nn=0; nnat(nn); - } - - tslib_strclr(local, 0, 66); - LL=buf->length(); - if (LL>1280) - { - qDebug()<<"reducing text size from " << LL << " to 1280 bytes"; - LL=1280; // Limit size - } else - qDebug()<<"\n printing text with " << LL << " bytes: "; - - do - { - len=tslib_getMinimum(LL, 64); - tslib_strclr(local, 0, 66); - for (nn=0; nn0 && LL>0); - -} - - -// ------------------------------------------------------------------------------ -// Level 0 commands, interface -// open, close, change serial interface -// actually not neccessary as it is opened automatically on program start -// start automatic READ requests -// ------------------------------------------------------------------------------ - -bool hwapi::dc_openSerial(int BaudNr, QString BaudStr, - QString ComName, uint8_t connect) const { - // BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200 - // BaudStr: for exapmle "19200" - // ComName: for example "COM48" - // connect: 0, 1 - //qDebug() << "~~>LIB" << "dc_openSerial called... " ; - - epi_setSerial(BaudNr, BaudStr, ComName, connect); - - // Actions: open serial port with parameters - for (int i = 0; i < 10; ++i) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - if (dc_isPortOpen()) { - return true; - } - } - return false; -} - -QStringList hwapi::dc_getStatus() const { - QStringList status; - - if (m_sharedMem) { - SharedMemBuffer const *shMem = SharedMemBuffer::getDataConst(); - status += QString("comport : %1").arg(shMem->rs.comportName); - status += QString("baudrate : %1").arg(shMem->rs.baudNr); - status += QString("baudNr : %1").arg(shMem->rs.baudStr); - status += QString("connect : %1").arg(shMem->rs.connect); - status += QString("port open: %1").arg(shMem->rs.portIsOpen); - // to be continued - } - - return status; -} - -bool hwapi::dc_closeSerial(void) const { - epi_closeSerial(); - for (int i = 0; i < 10; ++i) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - if (!dc_isPortOpen()) { - return true; - } - } - return false; -} - -bool hwapi::dc_isPortOpen(void) const { - if (myDatif) { - T_prot* prot = myDatif->getProt(); - if (prot) { - T_com *com = prot->getSerialPort(); - if (com) { - return com->isPortOpen(); - } - } - } - return false; - //return epi_isSerialPortOpen(); -} - -void hwapi::dc_autoRequest(bool on) const -{ - // automatically request ALL digital and analog sensors, get time/date, get status information - if (on) - epi_startEmmision(1); - else - epi_startEmmision(0); -} - -/******************************************************************************/ -// -// LEVEL 2: Help-functions for hwapi::dc_updateDC. -// -/******************************************************************************/ -hwapi::DownloadResult hwapi::sendStatus(int ret) const { - switch (ret) { // return values of dc are: - case 0: // 0: no answer by now - return DownloadResult::NOP; // 1: error - case 10: // 10: success - return DownloadResult::OK; - default:; - } - return DownloadResult::ERROR; -} - -hwapi::DownloadResult hwapi::sendNextAddress(int bNum) const { - // sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096 - int noAnswerCount = 0; - int errorCount = 0; - if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) { - qDebug() << "addr-block" << bNum << "..."; - while (noAnswerCount <= 250) { - bl_sendAddress(bNum); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - DownloadResult const res = sendStatus(bl_wasSendingAddOK()); - if (res != DownloadResult::NOP) { - if (res == DownloadResult::ERROR) { - if (++errorCount >= 10) { - qCritical() << "addr-block" << bNum << "...FAILED"; - return res; - } - } else { // res == DownloadResult::OK - qInfo() << "addr-block" << bNum << "...OK"; - return res; - } - } else { - noAnswerCount += 1; // no answer by now - } - } - // wait max. about 3 seconds - return DownloadResult::TIMEOUT; - } - // blockNumber is not one of 0, 1024, 2048, 3072, 4096 -> do nothing - return DownloadResult::NOP; -} - -hwinf::DownloadResult hwapi::sendNextDataBlock(QByteArray const &binary, - int bNum) const { - uint8_t local[66]; - int const bAddr = bNum * 64; - int noAnswerCount = 0; - int errorCount = 0; - - memcpy(local, binary.constData() + bAddr, 64); - local[64] = local[65] = 0x00; - - qDebug() << "data for addr" << bAddr << "..."; - - while (noAnswerCount <= 250) { - bl_sendDataBlock(64, local); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - DownloadResult const res = sendStatus(bl_wasSendingDataOK()); - if (res != DownloadResult::NOP) { - if (res == DownloadResult::ERROR) { - if (++errorCount >= 10) { - qCritical() << "data for addr" << bAddr << "...FAILED"; - return res; - } - } else { - qInfo() << "data for addr" << bAddr << "...OK"; - return res; - } - } else { - noAnswerCount += 1; // no answer by now - } - } - // wait max. about 3 seconds - return DownloadResult::TIMEOUT; -} - -hwinf::DownloadResult hwapi::dc_downloadBinary(QByteArray const &b) const { - int const nBlocks = (((b.size())%64)==0) ? (b.size()/64) : (b.size()/64)+1; - - qInfo() << "total number of bytes to send to dc" << b.size(); - qInfo() << "total number of blocks to send to dc" << nBlocks; - - int bNum = 0; - DownloadResult res = DownloadResult::OK; - while (res != DownloadResult::ERROR && bNum < nBlocks) { - if ((res = sendNextAddress(bNum)) != DownloadResult::ERROR) { - if ((res = sendNextDataBlock(b, bNum)) != DownloadResult::ERROR) { - bNum += 1; - } - } - } - if (res != DownloadResult::ERROR) { - bl_sendLastBlock(); - } - return res; -} - -bool hwapi::startBootloader() const { - qDebug() << "starting bootloader..."; - int nTry = 5; - while (--nTry >= 0) { - bl_startBL(); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - if (bl_isUp()) { - qInfo() << "starting bootloader...OK"; - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - return true; - } - } - qCritical() << "starting bootloader...FAILED"; - return false; -} - -bool hwapi::stopBootloader() const { - qDebug() << "stopping bootloader..."; - int nTry = 5; - while (--nTry >= 0) { - bl_stopBL(); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - if (!bl_isUp()) { - qInfo() << "stopping bootloader...OK"; - return true; - } - } - qCritical() << "stopping bootloader...FAILED"; - return false; -} - -// br is a index into a table, used for historical reasons. -bool hwapi::openSerial(int br, QString baudrate, QString comPort) const { - qDebug() << "opening serial" << br << baudrate << comPort << "..."; - if (dc_openSerial(br, baudrate, comPort, 1)) { // 1 for connect - qInfo() << "opening serial" << br << baudrate << comPort << "...OK"; - return true; - } - qCritical() << "opening serial" << br << baudrate << comPort << "...FAILED"; - return false; -} - -bool hwapi::closeSerial(QString comPort) const { - qDebug() << "closing serial" << comPort << "..."; - if (dc_closeSerial()) { - qInfo() << "closing serial" << comPort << "...OK"; - return true; - } else { - qCritical() << "closing serial" << comPort << "...FAILED"; - } - return false; -} - -bool hwapi::resetDeviceController() const { - qDebug() << "resetting device controller..."; - if (stopBootloader()) { // first stop a (maybe) running bootloader - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - dc_OrderToReset(); - // wait maximally 3 seconds, before starting bootloader - std::this_thread::sleep_for(std::chrono::milliseconds(1500)); - qInfo() << "resetting device controller...OK"; - return true; - } - return false; -} - -QByteArray hwapi::loadBinaryDCFile(QString filename) const { - qDebug() << "loading dc binary" << filename << "..."; - - QFile file(filename); // closed in destructor call - if (!file.exists()) { - qCritical() << file.fileName() << "does not exist"; - return QByteArray(); - } - if (!file.open(QIODevice::ReadOnly)) { - qCritical() << "cannot open file" << file.fileName(); - return QByteArray(); - } - qInfo() << "loading dc binary" << filename << "...OK"; - return file.readAll(); -} - -bool hwapi::downloadBinaryToDC(QString const &bFile) const { - qDebug() << "sending" << bFile << "to dc..."; - QByteArray const dcBinary = loadBinaryDCFile(bFile); - if (dcBinary.size() > 0) { - if (dc_downloadBinary(dcBinary) != DownloadResult::OK) { - qCritical() << "sending" << bFile << "to dc...FAILED"; - return false; - } else { - qInfo() << "sending" << bFile << "to dc...OK"; - } - } else { - qCritical() << "sending" << bFile << "to dc...FAILED"; - qCritical() << "loading binary" << bFile << "FAILED"; - return false; - } - return true; -} - -/******************************************************************************/ -// -// LEVEL 3: hwapi::dc_updateDC. -// -/******************************************************************************/ -bool hwapi::dc_updateDC(QString bFile, QString br, QString serial) const { - if (!baudrateMap.contains(br)) { // sanity check - qCritical() << "passed wrong baudrate" << br; - return false; - } - - qDebug() << "updating dc: " << bFile << br << serial << "..."; - - if (!openSerial(baudrateMap.value(br), br, serial)) { - return false; - } - if (!resetDeviceController()) { - closeSerial(serial); - return false; - } - if (!startBootloader()) { - closeSerial(serial); - return false; - } - if (!downloadBinaryToDC(bFile)) { - stopBootloader(); - closeSerial(serial); - qCritical() << "updating dc: " << bFile << br << serial << "...FAILED"; - return false; - } - - qInfo() << "updating dc: " << bFile << br << serial << "...OK"; - - stopBootloader(); - closeSerial(serial); - return true; -} - -/******************************************************************************/ -// -// LEVEL 3: hwapi::dc_updatePrinterTemplate -// -/******************************************************************************/ -bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type, - QVector templatesIdx, - QVector fnames, - QString br, - QString serial) const { - // sanity checks - if (!baudrateMap.contains(br)) { - qCritical() << "passed wrong baudrate" << br; - return false; - } - if (templatesIdx.size() != fnames.size()) { - qCritical() << "list sizes must be equal" << br; - return false; - } - if (!std::all_of(templatesIdx.cbegin(), templatesIdx.cend(), - [](int i) { return i >= 1 && i <= 32; })) { - qCritical() << "wrong template indices"; - return false; - } - if (type != FileTypeJson::PRINTER) { - qCritical() << "wrong file type" << (uint8_t)type; - return false; - } - - qDebug() << "updating: " << fnames << br << serial << "..."; - - if (!serial.isNull()) { - if (!openSerial(baudrateMap.value(br), br, serial)) { - return false; - } - } - - int nTry = 50; - while (!sys_ready4sending()) { // wait max. 5 seconds - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - if (--nTry <= 0) { - qCritical() << "sys not ready for sending"; - if (!serial.isNull()) { - closeSerial(serial); - } - return false; - } - } - - bool ret = true; - for (int i = 0; i < fnames.size(); ++i) { - QFile file(fnames[i]); - if (file.exists() && file.open(QIODevice::ReadOnly)) { - QByteArray ba = file.readAll(); - if (ba.size() <= 800) { // max. size is 800 bytes - if (sys_sendJsonFileToDc((uint8_t)(type), - templatesIdx[i], - (uint8_t *)ba.data())) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - qInfo() << "sent file" << fnames[i] << "to dc"; - } - } - } else { - qCritical() << fnames[i] << "!!! does not exist!!!"; - ret = false; - continue; - } - } - if (!serial.isNull()) { - closeSerial(serial); - } - return ret; -} - -bool hwapi::dc_printTemplate(enum FileTypeJson type, - QVector templateIdx, - QString br, - QString serial) const { - // sanity checks - if (!baudrateMap.contains(br)) { - qCritical() << "passed wrong baudrate" << br; - return false; - } - if (!std::all_of(templateIdx.cbegin(), templateIdx.cend(), - [](int i) { return i >= 1 && i <= 32; })) { - qCritical() << "wrong template indices"; - return false; - } - if (type != FileTypeJson::PRINTER) { - qCritical() << "wrong file type" << (uint8_t)type; - return false; - } - - qDebug() << "printing: " << templateIdx << br << serial << "..."; - - if (!serial.isNull()) { - if (!openSerial(baudrateMap.value(br), br, serial)) { - return false; - } - } - - int nTry = 50; - while (!sys_ready4sending()) { // wait max. 5 seconds - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - if (--nTry <= 0) { - qCritical() << "sys not ready for sending"; - if (!serial.isNull()) { - closeSerial(serial); - } - return false; - } - } - - bool ret = true; - for (int i = 0; i < templateIdx.size(); ++i) { - if (prn_printTemplate(templateIdx[i])) { - qDebug() << "printing template" << templateIdx[i]; - std::this_thread::sleep_for(std::chrono::seconds(3)); - } else { - ret = false; - continue; - } - } - if (!serial.isNull()) { - closeSerial(serial); - } - return ret; - -} - -// ------------------------------------------------------------------------------ -// Level 1, control device-controller (functions of µC) -// check serial connection to deviceController -// read response from DC2 (input data) -// some test function for serial communication -// also Bootloader is here -// ------------------------------------------------------------------------------ - -void hwapi::dc_requTestResponse() const -{ - sendWRcmd_setSendCommand0(SENDDIRCMD_TestSerial); -} - -bool hwapi::dc_readAnswTestResponse() const -{ - return epi_getResult_serialTestOK(); -} - -uint8_t hwapi::dc_isRequestDone(void) const -{ - // retval: 0: request is still in progress - // 1: answer from DC2 was OK - // 2: wrong answer from DC2 - return epi_getResultOfLastRequest(); -} - -uint16_t hwapi::dc_getCompletePayLoad(uint16_t plBufSiz, uint8_t *payLoad) const -{ - // get data back in *pl, max 64 byte, can be used for diagnosis - // retval = nr of bytes received. If host buffer too small then - // only plBufSíz bytes are copied to pl - // plBufSíz=size of host buffer - - return epi_getLastPayLoad( plBufSiz, payLoad); - -} - -void hwapi::dc_setWakeFrequency(uint8_t period) const -{ - // RTC wakes DC2 (and PTU) by hardware signal every 32seconds - // change wake signal period to 1...64s - sendWRcmd_setSendCommand4(SENDDIRCMD_setWakeFrequ, period,0,0,0); -} - -void hwapi::dc_OrderToReset(void) const -{ - uint8_t len, buf[160]; - - len=dcBL_restartDC(buf); - sendWRcmd_setSendBlock160(len, buf); - //sendWRcmd_setSendCommand0(SENDDIRCMD_MakeReset); - // not needed, sendWRcmd_setSendBlock160() starts sending as well... -} - -QString hwapi::dc_getSerialState(void) const -{ -// geht - return epi_getTxt4comStateLine(); -} - -void hwapi::dc_clrSerialStateText(void) const -{ - epi_clrTxt4comStateLine(); -} - - - -void hwapi::bl_sendDataDirectly(uint8_t length, uint8_t *buf) const -{ - // send without protocol frame, needed for the DC bootloader - sendWRcmd_setSendBlock160(length, buf); - -} - -uint8_t hwapi::getRawRecLength(void) const -{ - return epi_getRawRecLength(); -} - -uint8_t hwapi::getRawReceivedData(uint8_t *receivedData) const -{ - return epi_getRawReceivedData(receivedData); -} - - - - -QString hwapi::dc_getSerialParams(void) const -{ - return epi_getSlaveParamSTR(); -} - -QString hwapi::dc_getHWversion(void) const -{ - return epi_loadGenerals(0); -} - -QString hwapi::dc_getSWversion(void) const -{ - return epi_loadGenerals(1); -} - -QString hwapi::dc_getState(void) const -{ - return epi_loadGenerals(2); -} - - -// ------------------------------------------------------------------------------ -// Level 2 DC2-onboard devices -// WR: set time -// RD. get time, get measure, get test results -// ------------------------------------------------------------------------------ - -// get UID, get time/date test results memory, RTC analog values - -// ---------------------------------------------------------------------------------------------------------- -// Date and Time -// ---------------------------------------------------------------------------------------------------------- - -uint8_t hwapi::rtc_getDateTime(struct Trtc_DateTime *rtc_DateTime) const -{ -// void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss); -// void epi_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd); -// void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday); - uint8_t H, M, S; - uint16_t unused16; - uint32_t unused32; - - epi_getTime(&H, &M, &S); - rtc_DateTime->rtc_hour=H; - rtc_DateTime->rtc_min=M; - rtc_DateTime->rtc_sec=S; - - epi_getDate(&H, &M, &S); - rtc_DateTime->rtc_year=H; - rtc_DateTime->rtc_month=M; - rtc_DateTime->rtc_dayOfMonth=S; - - epi_getToday(&H, &unused16, &unused32); - rtc_DateTime->rtc_dayOfWeek=H; - return 0; -} - -uint8_t hwapi::rtc_setDateTime(void) const -{ - sendWRcmd_setSendCommand0(SENDDIRCMD_setTime); - return 0; -} - - -void hwapi::rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const -{ - epi_getTime(hh, mm, ss); -} - -void hwapi::rtc_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) const -{ - epi_getDate(yy, mm, dd); -} - -uint8_t hwapi::rtc_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) const -{ - // dow=day of week, 1=monday...7 - // minOfToday: 0=midnight...1439= 23:59 - // secOfToday: 0=midnight...86399= 23:59:59 - - epi_getToday(dow, minOfToday, secOfToday); - return 0; -} - -bool hwapi::rtc_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) const -{ - return epi_isLeapYear(lastLeapYear, NextLeapYear); -} - - -bool hwapi::rtc_isLeapYear(void) const -{ - return epi_isLeapYear(); -} - -void hwapi::rtc_getWeek(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) const -{ - epi_getSpecialWeekTimeDate(DayOfWeek, HoursOfWeek, MinutesOfWeek); -} - -void hwapi::rtc_getMonth(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) const -{ - epi_getSpecialMonthTimeDate(DayOfMonth, HoursOfMonth, MinutesOfMonth); -} - -void hwapi::rtc_getYear(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) const -{ - epi_getSpecialYearTimeDate(DayOfYear, HoursOfYear, MinutesOfYear); -} - - -QString hwapi::rtc_getTimStr() const -{ - uint8_t hh, mm, ss, buf[20], nn; - QString qbuf; - char ctmp; - qbuf.clear(); - for (nn=0; nn<20; nn++) buf[nn]=0; - epi_getTime(&hh, &mm, &ss); - GetTimeString(hh, mm, ss, HourSys24h, MITSEK, buf); // about 12byte long - for (nn=0; nn<20; nn++) - { - ctmp=buf[nn]; - qbuf[nn]=ctmp; - } - return qbuf; -} - -QString hwapi::rtc_getDatStr() const -{ - uint8_t day, month, year, buf[20], nn; - QString qbuf; - char ctmp; - - qbuf.clear(); - for (nn=0; nn<20; nn++) buf[nn]=0; - epi_getDate(&year, &month, &day); - GetDateString(day, month, 0x20, year, DateFormatDeutsch, 0, buf); - for (nn=0; nn<20; nn++) - { - ctmp= buf[nn]; - qbuf[nn]=ctmp; - } - return qbuf; -} - -QString hwapi::rtc_getTimDatStr() const -{ - // style: 0: hh:mm 1: hh:mm:ss - QString qbuf; - - qbuf.clear(); - qbuf.append(rtc_getTimStr()); - qbuf.append(" "); - qbuf.append(rtc_getDatStr()); - return qbuf; -} - - - - - -// UID -void hwapi::dc_getUID8byte(uint8_t *buf8byteUid) const -{ - epi_getUIDdec(buf8byteUid); -} - -QString hwapi::dc_getUIDstr() const -{ - return epi_getUIDstr(); -} - -uint64_t hwapi::dc_getUIDnumber(void) const -{ - uint64_t retval=0; - uint8_t buf8byteUid[12], nn; - - epi_getUIDdec(buf8byteUid); - for (nn=8; nn>0; nn--) - { - retval+=buf8byteUid[nn-1]; - retval<<=8; // *256 - } - return retval; -} - - - -uint32_t hwapi::dc_getTemperature(void) const -{ - // - return epi_loadMeasureValue(MEASCHAN_TEMPERATURE); -} - -QString hwapi::dc_getTemperaturStr(void) const -{ - return epi_getSlaveTemperatureStr(); -} - - -uint32_t hwapi::dc_getVoltage(void) const -{ - // in mV, e.g. 12300 = 12,3V - return epi_loadMeasureValue(MEASCHAN_VOLTAGE); -} - -QString hwapi::dc_getVoltagStr(void) const -{ - return epi_getSlaveVoltageStr(); -} - -bool hwapi::dc_mainFuseIsOk(void) const -{ - uint32_t ulong=epi_loadMeasureValue(MEASCHAN_VOLTAGE); // in mV, e.g. 12300 = 12,3V - if (ulong>3000) - return true; - return false; -} - -// ------------------------------------------------------------------------------ -// Level 3: digital outputs and simple switching of connected devices -// simple processes like flashing a led or open flap for 1s -// ------------------------------------------------------------------------------ - -// Locks: -uint8_t hwapi::lock_switchUpperLock(uint8_t dir) const -{ - // dir 0=off 1=up 2=down - sendWRcmd_setSendCommand4(SENDDIRCMD_MOVEUP_LOCK ,dir,0,0,0); - return 0; -} - -uint8_t hwapi::lock_switchLowerLock(uint8_t dir) const -{ - // dir 0=off 1=up 2=down - sendWRcmd_setSendCommand4(SENDDIRCMD_MOVEDN_LOCK ,dir,0,0,0); - return 0; -} - -void hwapi::lock_switchVaultDoor(void) const -{ - - sendWRcmd_setSendCommand0(SENDDIR_OPENVAULT); -} - -void hwapi::coin_switchRejectMotor(uint8_t dir) const -{ - - sendWRcmd_setSendCommand4(SENDDIR_REJMOT_ON, dir, 0,0,0); -} - -void hwapi::coin_rejectCoins(void) const -{ - - sendWRcmd_setSendCommand0(SENDDIR_REJMOT_RUN); -} - - -void hwapi::led_switchLedService(uint8_t on) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_LEDINSIDE, on, 0, 0, 0); -} - -void hwapi::led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_LEDTICKET, on, ton, tof, 0); -} - -void hwapi::led_switchLedPinPad(uint8_t on, uint8_t ton, uint8_t tof) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_LEDPAD, on, ton, tof, 0); -} - -void hwapi::led_switchLedStart(uint8_t on, uint8_t ton, uint8_t tof) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_LEDSTART, on, ton, tof, 0); -} - -void hwapi::led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_LEDCOIN, on, ton, tof, 0); -} - -void hwapi::fan_switchFan(bool on) const -{ - //return epi_storeDOsToSend(DOBYTE3, FAN_ON, on); - sendWRcmd_setSendCommand4(SENDDIRCMD_FAN, on, 0, 0, 0); -} - -void hwapi::alarm_switchSiren(bool on) const -{ - //return epi_storeDOsToSend(DOBYTE4, LAERM, on); - sendWRcmd_setSendCommand4(SENDDIRCMD_LAERM, on, 0, 0, 0); -} - -void hwapi::bar_OpenBarrier(bool open) const -{ - //return epi_storeDOsToSend(DOBYTE4, REL1, open); - sendWRcmd_setSendCommand4(SENDDIRCMD_REL1, open, 0, 0, 0); -} - -void hwapi::ptu_switchWake(bool WAKEACTIVE) const -{ - //return epi_storeDOsToSend(DOBYTE1, CTS_PTU, WAKEACTIVE); - sendWRcmd_setSendCommand4(SENDDIRCMD_WAKEPTU, WAKEACTIVE,0,0,0); -} - -// AUX-IO's or barcode reader -void hwapi::aux_power(bool on) const -{ -// return epi_storeDOsToSend(DOBYTE2, BARC_POW_ON, on); - sendWRcmd_setSendCommand4(SENDDIRCMD_AUXPWR, on,0,0,0); -} - -void hwapi::aux_setUsage(uint8_t PinDirection) const -{ - // bit 0= Aux1 bit5=Aux6 1=output 0=input with pullup - - // return epi_storeDOsToSend(DOBYTE6, nr, PinDirection); - sendWRcmd_setSendCommand4(SENDDIRCMD_AUXDDR, PinDirection,0,0,0); -} - -void hwapi::aux_setOutputs(uint8_t PinIsHigh) const -{ - // PinIsHigh bit 0..5 =Aux1...6 1=output high 0=set output low - - //return epi_storeDOsToSend(DOBYTE5, nr, PinIsHigh); - sendWRcmd_setSendCommand4(SENDDIRCMD_AUXOUT, PinIsHigh,0,0,0); -} - -void hwapi::lock_switchContactPower(bool on) const -{ - //epi_storeDOsToSend(DOBYTE2, U_SW_ON, on); - sendWRcmd_setSendCommand4(SENDDIRCMD_UCONTACT_ON, on, 0,0,0); -} - -void hwapi::prn_switchPower(bool on) const -{ - // also switches and enables serial driver - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN2_SWONOFF, on,0,0,0); - indat_storePrinterPower(on); - // PRINTER-ON/OFF zusätzlich statisch abspeichern - // Status-request soll nur gesendet werden wenn der Drucker ein ist - // Status-Abfrage (hier in HWapi) gibt 0 zurück wenn power-off - // dito mit allen anderen Geräten! - - // pi ---> storeINdata.cpp speichert diese statische Info (printer on/off) UND - // auch alles rückgelesene - -} - - -void hwapi::mif_readerOn(bool on) const -{ - // DC2 also switches and enables serial driver - sendWRcmd_setSendCommand4(SENDDIRCMD_MIF_SWONOFF, on,0,0,0); -} - -void hwapi::mif_creatAtbCard(uint8_t cardType) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MIF_SWONOFF, cardType, 0,0,0); -} - - -void hwapi::mod_switchPower(bool on) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MOD_SWONOFF, on,0,0,0); -} - -void hwapi::mod_switchWake(bool WAKEACTIVE) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MOD_WAKE, WAKEACTIVE,0,0,0); -} - -void hwapi::mdb_switchPower(bool on) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_POWER, on,0,0,0); -} - -void hwapi::mdb_switchWake(bool WAKEACTIVE) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_WAKE, WAKEACTIVE,0,0,0); -} - -void hwapi::credit_switchPower(bool on) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_CRED_ON, on,0,0,0); -} - -void hwapi::credit_switchWake(bool WAKEACTIVE) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_CRED_WAKE, WAKEACTIVE,0,0,0); -} - -void hwapi::shut_move(bool open) const -{ - // true:open false:close - sendWRcmd_setSendCommand4(SENDDIRCMD_SHUT_MOV, open, 0,0,0); -} - -void hwapi::esc_moveFlaps(uint8_t flap ) const -{ - // 0: close both 1: open take-flap 2: open return - sendWRcmd_setSendCommand4(SENDDIRCMD_ESCRO_MOV, flap, 0,0,0); -} - - -// ------------------------------------------------------------------------------ -// Level 3: digital inputs of connected devices -// ------------------------------------------------------------------------------ - - - -uint8_t hwapi::door_getSwitches(void) const -{ - // retval // bit0: upper door 1: low door 2:vault door - uint8_t ret; - - ret= epi_getDI_doorSwitches(); - // bit0: upper door 1: low door 2:vault door - ret &= 0x08; - return ret; -} - -bool hwapi::door_isUpperDoorOpen(void) const -{ - uint8_t ret; - - ret= epi_getDI_doorSwitches(); - // bit0: upper door 1: low door 2:vault door - if (ret & 1) - return true; - return false; -} - -bool hwapi::door_isLowerDoorOpen(void) const -{ - uint8_t ret; - - ret= epi_getDI_doorSwitches(); - // bit0: upper door 1: low door 2:vault door - if (ret & 2) - return true; - return false; -} - -bool hwapi::vault_isVaultDoorOpen(void) const -{ - uint8_t ret; - - ret= epi_getDI_doorSwitches(); - // bit0: upper door 1: low door 2:vault door - if (ret & 4) - return true; - return false; -} - - -uint8_t hwapi::vault_getSwitches(void) const -{ - // retval bit0: cash box, bit 1: bill box - uint8_t ret; - - ret=epi_getDI_vaultSwitches(); // bit0: cash box 1: bill box in - ret&=0x03; - return ret; -} - -bool hwapi::vault_isCoinVaultIn(void) const -{ - uint8_t ret; - - ret=epi_getDI_vaultSwitches(); // bit0: cash box 1: bill box in - if (ret & 1) - return true; - return false; -} - -bool hwapi::vault_isBillVaultIn(void) const -{ - uint8_t ret; - - ret=epi_getDI_vaultSwitches(); // bit0: cash box 1: bill box in - if (ret & 2) - return true; - return false; -} - - - -uint8_t hwapi::door_getLocks(void) const -{ - // retval bit0: upper lever is up - // bit1: upper lever is down - // bit2: lower lever is up - // bit3: lower lever is down - - uint8_t ret; - - ret= epi_getDI_lockSwitches(); - // retval: bit 0: upper lockbar up bit1: upper lockbar is down - // bit 2: lower lockbar up bit1: lower lockbar is down - ret&=0x0F; - return ret; -} - -bool hwapi::door_upperDoorIsLocked(void) const -{ - uint8_t ret; - - ret= epi_getDI_lockSwitches(); - if (ret & 2) - return true; - return false; -} - -bool hwapi::door_upperDoorIsUnlocked(void) const -{ - uint8_t ret; - - ret= epi_getDI_lockSwitches(); - if (ret & 1) - return true; - return false; -} - -bool hwapi::door_lowerDoorIsLocked(void) const -{ - uint8_t ret; - - ret= epi_getDI_lockSwitches(); - if (ret & 8) - return true; - return false; -} - -bool hwapi::door_lowerDoorIsUnlocked(void) const -{ - uint8_t ret; - - ret= epi_getDI_lockSwitches(); - if (ret & 4) - return true; - return false; -} - - - -bool hwapi::bar_optoIn1isOn(void) const -{ - uint8_t ret=epi_getDI_optos(); - // bit0: opto in 1 1: opto in 2 - if (ret & 1) - return true; - return false; -} - -bool hwapi::bar_optoIn2isOn(void) const -{ - uint8_t ret=epi_getDI_optos(); - // bit0: opto in 1 1: opto in 2 - if (ret & 2) - return true; - return false; -} - - -uint8_t hwapi::aux_getAuxInputs(void) const -{ - // retval: bit0=Aux1....Bit5=Aux6 - // 0: input low 1:input high - - uint8_t ret=epi_getDI_auxIn(); - // bit0: auxin 1 ... 5: auxin 6 - ret &=0x3F; - return ret; -} - -bool hwapi::ptu_WakeINisActive(void) const -{ - return epi_getDI_ptuWake(); -} - -bool hwapi::mdb_WakeINisActive(void) const -{ - return epi_getDI_mdbWake(); -} - -bool hwapi::prn_readyINisActive(void) const -{ - return epi_getDI_prnReady(); -} - -bool hwapi::coid_isAttached(void) const -{ - return epi_getDI_CoinAttach(); -} - -bool hwapi::coin_escrowIsOpen(void) const -{ - return epi_getDI_CoinEscrow(); -} - -bool hwapi::mif_cardIsAttached(void) const -{ - return epi_getDI_mifareCardTapped(); -} - -//bool hwapi::mod_WakeINisActive(void) -//{ -// return epi_getDI_modemWake(); -//} - - - -bool hwapi::door_isContactPowerOn(void) const -{ - return epi_getDI_contactPwr(); -} - -bool hwapi::mif_isMifarePowerOn(void) const -{ - bool mo=indat_isMifareOn(); - bool mi=epi_getDI_mifarePwr(); - if (mo && mi) - return true; - return false; -} - -bool hwapi::mdb_testIsmdbTxDon(void) const -{ - return epi_getDI_mdbTxd(); -} - -bool hwapi::aux_isAuxPowerOn(void) const -{ - return epi_getDI_auxPwr(); -} - -bool hwapi::mod_isGsmPowerOn(void) const -{ - return epi_getDI_gsmPwr(); -} - -bool hwapi::cred_isCreditPowerOn(void) const -{ - return epi_getDI_creditPwr(); -} - -bool hwapi::prn_isPrinterPowerOn(void) const -{ - return epi_getDI_printerPwr(); -} - -uint8_t hwapi::prn_PrnFuseIsOk(void) const -{ - //retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off - if (!epi_getDO_printerPwr()) - return 2; // unknown as printer power is off - if (epi_getDI_printerPwr()) - return 1; // printer voltage is OK - return 0; // fuse blown -} - -bool hwapi::mdb_isMdbPowerOn(void) const -{ - return epi_getDI_mdbPwr(); -} - - -bool hwapi::cash_getRejectMotorHomePos(void) const -{ - return epi_getDI_rejectMotor_homepos(); -} - -uint8_t hwapi::cash_getLowPaperSensor(void) const -{ - // 0: Sensor sees paper 1: no paper 99: off - return epi_getDI_npe_sensor(); - -} - -// ------------------------------------------------------------------------------ -// Level1,2,3 RD request commands -// ------------------------------------------------------------------------------ - -// the following requests can be sent manually -// or automatically in background by: void hwapi::dc_autoRequest(bool on) -// in other words: -// if automatic-reading is on then there's no need to send any of these commands! - - -void hwapi::request_DC2serialConfig() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_SERCONF); -} - -void hwapi::request_DC2_HWversion() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_HWversion); -} - -void hwapi::request_DC2_SWversion() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_SWversion); -} - -void hwapi::request_DC2_condition() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_CONDITION); -} - -void hwapi::request_DC2_UID() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_UID); -} - -void hwapi::request_DC2_TimeAndDate() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_TIME); -} - -void hwapi::request_DC2_analogues() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_ANALOGS); -} - -void hwapi::request_DC2_digitalInputs() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_DIG_INPUTS); -} - -void hwapi::request_DC2_digitalOutputs() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_DIG_OUTPUTS); -} - -// ------------------------------------------------------------------------------ -// the folowing device state requests are deployed only if device is powered up: - -void hwapi::request_PrinterHwState() const -{ - - sendWRcmd_setSendCommand0(SEND_REQU_PRN_STATE); -} - -void hwapi::request_PrinterCurrentFonts() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_PRN_FONTS); -} - -void hwapi::request_PrinterStateComplete() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_PRN_ALL); -} - - - - - -void hwapi::request_MifareReaderState() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_MIFSTATE); -} - -void hwapi::request_MifareCardType() const -{ - //uint8_t blkAdr=0; - //sendWRcmd_setSendCommand4(SEND_REQU_MIFDATA, blkAdr,0,0,0); - sendWRcmd_setSendCommand0(SEND_REQU_MIFSTATE); -} - -void hwapi::request_MifareAtbType() const -{ - //sendWRcmd_setSendCommand0(SEND_REQU_MIF_ATB_TYPE); - sendWRcmd_setSendCommand0(SEND_REQU_MIFSTATE); - -} - -void hwapi::request_MifareID() const -{ - uint8_t sequenceNumber=0; - sendWRcmd_setSendCommand4(SEND_REQU_MIFDATA, sequenceNumber,0,0,0); // 1st data = card sequence =blk nr (0...15) -} - -void hwapi::request_MifareData(uint8_t dataBlockNumber) const -{ - if (dataBlockNumber<12) // 1k cards return 12 data blocks, 4k cards would return 54 data blocks (not implemented) - sendWRcmd_setSendCommand4(SEND_REQU_MIFDATA, dataBlockNumber,0,0,0); // 1st data = card sequence =blk nr (0...15) -} - - - -void hwapi::request_MDB_Status() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_MDB_GETSTAT); -} - -//void hwapi::request_MDB_wakeInLine() const -//{ -// sendWRcmd_setSendCommand0(SEND_REQU_MDB_GETWAK); -//} - -void hwapi::request_MDB_lastResponse() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_MDB_GETRESP); -} - -void hwapi::request_EMP_allParameters() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_EMP_GETALL); -} - -void hwapi::request_EMP_lastCoin() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_EMP_GETCOIN); - -} - - - -// ------------------------------------------------------------------------------ -// Level 3: readback digital outputs of connected devices -// these functions are not needed for normal operation -// but can be used to test and verify conditions - -// There are two options: -// 1) the important things like power-outputs and wake lines are -// measured at DC2-terminals (after transistors) and come as input to DC-board -// 2) others like Leds are read from µC-pins by DC-board -// ------------------------------------------------------------------------------ - -bool hwapi::test_getDO_mdbRXtst(void) const -{ - return epi_getDO_mdbRxTestOut(); -} - -uint8_t hwapi::lock_getDO_motors(void) const -{ - // bit0: upper lock forward bit 1 backward - // bit2: lower lock forward bit 3 backward - - return epi_getDO_motorOuts(); -} - -uint8_t hwapi::test_serialState(void) const -{ - // test on-board signals for the serials - // serial drv on/off, Serial mux1, Serial mux2 - - uint8_t ret=epi_getDO_serialSwitch(); - // serial drv on/off, Serial mux1, Serial mux2 - ret &=0x07; - return ret; -} - -bool hwapi::test_serialIsOn(void) const -{ - return epi_getDO_serialDriverIsOn(); -} - -bool hwapi::test_serialMux1isSetToPrinter(void) const -{ - return epi_getDO_serialMux1isSetToPrinter(); - // mux1 off: serial is switched to printer -} - -bool hwapi::test_serialMux1isSetToModem(void) const -{ - return epi_getDO_serialMux1isSetToModem(); - // mux1 on: serial is switched to modem -} - -bool hwapi::test_serialMux2isSetToCredit(void) const -{ - return epi_getDO_serialMux2isSetToCredit(); - // mux2 off: serial is switched to credit card terminal -} - -bool hwapi::test_serialMux2isSetToMifare(void) const -{ - return epi_getDO_serialMux2isSetToMifare(); - // mux2 on: serial is switched to mifare reader -} - -bool hwapi::led_coinIsOn(void) const -{ - return epi_getDO_led_coin(); -} - -bool hwapi::led_frontIsOn(void) const -{ - return epi_getDO_led_front(); -} - -bool hwapi::led_ticketIsOn(void) const -{ - return epi_getDO_led_ticket(); -} - -bool hwapi::led_pinIsOn(void) const -{ - return epi_getDO_led_pin(); -} - -bool hwapi::led_StartIsOn(void) const -{ - return epi_getDO_led_start(); -} - -bool hwapi::led_insideIsOn(void) const -{ - return epi_getDO_led_inside(); -} - -bool hwapi::fan_isOn(void) const -{ - return epi_getDO_fan(); -} - -bool hwapi::siren_isOn(void) const -{ - return epi_getDO_sirene(); -} - -bool hwapi::bar_relayIsOn(void) const -{ - return epi_getDO_relay(); -} - -bool hwapi::ptu_WakeOutIsOn(void) const -{ - return epi_getDO_ptuWake(); -} - -bool hwapi::aux_powerIsOn(void) const -{ - return epi_getDO_auxPower(); -} - - -bool hwapi::coin_shutterIsOpen(void) const -{ - return epi_getDO_coinShutterOpen(); -} - -bool hwapi::coin_shutterTestOutput(void) const -{ - return epi_getDO_coinShutterTest(); -} - -uint8_t hwapi::coin_escrowFlapOpened(void) const -{ - // retval: 1:return flap is open 2:take flap is open 0:closed - - return epi_getDO_coinEscrow(); -} - - - - - - - - -// ------------------------------------------------------------------------------ -// 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 -{ - uint8_t buf[64]; - - tslib_strclr(buf,0,64); - buf[0]=kindOfPrinter; - buf[1]=kindOfCoinChecker; - buf[2]=kindOfMifareReader; - buf[3]=suppressSleep; - buf[4]=kindOfModem; - buf[5]=kindOfCredit; - - epi_store64ByteSendData(6, buf); - sendWRcmd_setSendCommand0(SENDDIRCMD_DEVICE_PARA); - - -} - -void hwapi::request_ReadbackDeviceSettings() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_DEVICE_PARA); -} - - -void hwapi::readback_DeviceSettings(uint8_t *length, uint8_t *data) const -{ - - epi_restoreRbDeviceSettings(length, data); -/* - buf66[0]=devPara.kindOfPrinter; - buf66[1]=devPara.kindOfCoinChecker; - buf66[2]=devPara.kindOfMifareReader; - buf66[3]=devPara.suppressSleepMode; - buf66[4]=devPara.kindOfModem; - buf66[5]=devPara.kindOfCreditcard; - buf66[6]=devPara.CoinEscrow; - buf66[7]=devPara.CoinRejectUnit; - buf66[8]=devPara.CoinShutter; - buf66[9]=devPara.BillAcceptor; - buf66[10]=devPara.usevaultLock; - buf66[11]=devPara.autoAlarm; - buf66[12]=devPara.autoOpen; - buf66[13]=devPara.printAccReceipt; - buf66[14]=devPara.printDoorReceipt; - buf66[15]=devPara.printTokenTicket; - uitmp=devPara.VaultFullWarnLevel; - buf66[16]=swl_getOneByteFromUint(uitmp, GETLOWBYT); - buf66[17]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); - uitmp=devPara.VaultFullErrorLevel; - buf66[18]=swl_getOneByteFromUint(uitmp, GETLOWBYT); - buf66[19]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); - -*/ -} - -// .................................................................................... - -void hwapi::sendMachineID(uint16_t customerNr, uint16_t machineNr, - uint16_t borough, uint16_t zone, - uint16_t alias, char *location) const -{ - uint8_t buf[64]; - - tslib_strclr(buf,0,64); - buf[0]=uint2uchar(customerNr, LOWBYTE); - buf[1]=uint2uchar(customerNr, HIGHBYTE); - buf[2]=uint2uchar(machineNr, LOWBYTE); - buf[3]=uint2uchar(machineNr, HIGHBYTE); - buf[4]=uint2uchar(borough, LOWBYTE); - buf[5]=uint2uchar(borough, HIGHBYTE); - buf[6]=uint2uchar(zone, LOWBYTE); - buf[7]=uint2uchar(zone, HIGHBYTE); - buf[8]=uint2uchar(alias, LOWBYTE); - buf[9]=uint2uchar(alias, HIGHBYTE); - tslib_strcpy(location, &buf[10], 32); - - epi_store64ByteSendData(42, buf); - sendWRcmd_setSendCommand0(SENDDIRCMD_MACHINE_ID); - - -} - -void hwapi::request_ReadbackMachineID() const -{ - sendWRcmd_setSendCommand0(SEND_REQU_MACINE_ID); -} - - -void hwapi::readback_machineIDdata(uint8_t *length, uint8_t *data) const -{ - epi_restoreMachineIDsettings(length, data); -/* - buf66[0]=swl_getOneByteFromUint(machPara.customerNumber, GETLOWBYT); - buf66[1]=swl_getOneByteFromUint(machPara.customerNumber, GETHIGHBYT); - buf66[2]=swl_getOneByteFromUint(machPara.machineNumber, GETLOWBYT); - buf66[3]=swl_getOneByteFromUint(machPara.machineNumber, GETHIGHBYT); - buf66[4]=swl_getOneByteFromUint(machPara.borough, GETLOWBYT); - buf66[5]=swl_getOneByteFromUint(machPara.borough, GETHIGHBYT); - buf66[6]=swl_getOneByteFromUint(machPara.zone, GETLOWBYT); - buf66[7]=swl_getOneByteFromUint(machPara.zone, GETHIGHBYT); - buf66[8]=swl_getOneByteFromUint(machPara.alias, GETLOWBYT); - buf66[9]=swl_getOneByteFromUint(machPara.alias, GETHIGHBYT); - for (pp=0; pp<32; pp++) - buf66[10+pp]=machPara.location[pp]; - dc2prot_setReadData(42, buf66); - -*/ -} - - -// .................................................................................... - - - - - -static uint16_t hwapi_shutterTime; - -// locks, 2.Level: (Motor stops automatical on end switch or by 5s timeout) -uint8_t hwapi::lock_openUpperDoor(void) const -{ - //bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4); - // commands are defined in PIdefines.h - sendWRcmd_setSendCommand4(SENDDIRCMD_OPENUP_DOOR, 1, 0, 0, 0); - // paras: dat2: 1=upper door lock 2=lower - // dat1: 1=open 2=close - return 0; -} - - -uint8_t hwapi::lock_closeUpperDoor(void) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_OPENUP_DOOR, 2, 0, 0, 0); - return 0; -} - -uint8_t hwapi::lock_openLowerDoor(void) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_OPENDN_DOOR, 1, 0, 0, 0); - return 0; -} - -uint8_t hwapi::lock_closeLowerDoor(void) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_OPENDN_DOOR, 2, 0, 0, 0); - return 0; -} - -void hwapi::shut_openOnce(void) const -{ - // and close automatic after shutter time - uint16_t zeit=hwapi_shutterTime; - zeit/=100; - sendWRcmd_setSendCommand4(SENDDIRCMD_SHUTOPENBYTIME, uint8_t(zeit) ,0,0,0); - -} - -void hwapi::shut_openForCoin(bool start) const -{ - // start=true: start opening flap if coin is attached - // start=false: stop process - - uint16_t zeit=hwapi_shutterTime; - zeit/=100; - sendWRcmd_setSendCommand4(SENDDIRCMD_SHUTOPENBYCOIN, uint8_t(start), uint8_t(zeit),0,0); - -} - -void hwapi::shut_sendOpeningTime(uint16_t timeIn_ms ) const -{ - // after this time without retrigger the flap is closed - //sendWRcmd_setSendCommand4(SENDDIRCMD_SHUT_SENDTIME, timeIn100ms,0,0,0); - hwapi_shutterTime=timeIn_ms; - -} - - -void hwapi::esc_takeMoney(void) const -{ - // and close automatically after escrow time (1s) - sendWRcmd_setSendCommand0(SENDDIRCMD_ESCRO_TAKE); -} - -void hwapi::esc_returnMoney(void) const -{ - // and close automatically after time - sendWRcmd_setSendCommand0(SENDDIRCMD_ESCRO_GIVE); - -} - - - - - - - -// ---------------------------------------------------------------------------------------------------------- -// --------------------------------------------- MIFARE ----------------------------------------------------- -// ---------------------------------------------------------------------------------------------------------- - - -uint8_t hwapi::mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const -{ - // retval 0=OK 1=error host buffer too small - - /* data description: - - new fast version: - byte 0= still the same: current read state: - 0=power off 1=reader-fault 2=ready - 3=just reading 4=read complete - 5=read partial, removed too early - 6=state unknown - - byte 1: reader state 1=ok 0=nok - byte 2: card present (0,1) - byte 3: card selected (0) - byte 4: card type: 0...5 - byte 5: card allowed (0=no 1=MifareClassic 1k or 4k) - byte 6: CardSize: 1 or 4 (kB) - byte 7: length of UID 4 or 7 (byte) - */ - - return epi_restoreMifState(buf, maxBufferSize); -} - -/* OLD data description: -byte 0: current read state: 0=power off 1=reader-fault 2=ready - 3=just reading 4=read complete - 5=read partial, removed too early - 6=state unknown -byte 1,2: read data length from card -3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader -4...15: reader version, expected "ATB25-1.8" -16: 1=card is present 0:not -17: 0 -18: card type reported from reader -19: 1=allowed card type 0=not -20: card size: 1 or 4 (dec) = card size -21: LengthOfUID: 4 or 7 (dec) (byte) -22: UID 8 byte in hex -byte 30: sector logged: 0 -byte 31: current sector: 0 -byte 32: result, always 0 -*/ - -bool hwapi::mif_readerIsOK(void) const -{ - - uint8_t buf[40]; // old version had 40 bytes, new version only 8 - uint8_t ret= epi_restoreMifState(buf, 40); - if (ret==0 && buf[0]>1 && buf[1]>0) - return 1; - return 0; // error -} - -bool hwapi::mif_cardAttached(void) const -{ - - uint8_t buf[40]; - uint8_t ret= epi_restoreMifState(buf, 40); - if (ret==0 && buf[0]>1 && buf[2]>0) // reader OK - if (buf[16]>0) - return 1; - return 0; // error -} - -uint8_t hwapi::mif_readResult(void) const -{ - // result: 0: unknown or still in progress - // 1: card read successful - // 2: reading error - - uint8_t buf[40]; - uint8_t ret= epi_restoreMifState(buf, 40); - // data read successful && Reader OK && card attached && ... - if (ret==0 && buf[1]>0 && buf[2]>0) - { -// byte 0: current read state: 0=power off 1=reader-fault 2=ready -// 3=just reading 4=read complete -// 5=read partial, removed too early -// 6=state unknown - - if (buf[0]==1 || buf[0]==5 || buf[0]==6) - return 2; - if (buf[0]==4) - return 1; - - } - return 0; // error - -} - - -QString hwapi::mif_cardUID(void) const -{ - QString myStr; - - uint8_t buf[65], ret; - - //uint8_t ret= epi_restoreMifState(buf, 40); - myStr.clear(); -/* - if (ret==0 && buf[0]==4 && buf[3]>0 && buf[16]>0 && buf[19]>0) - { - // UID in buf[22...29] - for (int ii=0;ii<8; ii++) - { - - myStr+=QString::number(buf[ii+22],16); - myStr+=" "; // make a gap between numbers - } - } -*/ - - ret=epi_restoreMifData(0, buf, 64); - if (ret) - return myStr; // return empty string on error - else - { - buf[8]=0; - //myStr.append(buf); - for (int ii=0;ii<8; ii++) - { - - myStr+=QString::number(buf[ii],16); // 16: return in hex format - myStr+=" "; // make a gap between numbers - } - - return myStr; - } - - -} - - -uint8_t hwapi::mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const -{ - // blkNr=0...11 return buf[64] maxBufferSize must be >=64 - - return epi_restoreMifData(blkNr, buf, maxBufferSize); - // blkNr=0...11 return buf[64] - -} - -QString hwapi::mif_getCardDataStr(uint8_t blockNumber) const -{ - // with blockNumber=0...11 - QString myStr; - uint8_t buf[66]; - - myStr.clear(); - if (blockNumber>11) - return myStr; - - epi_restoreMifData(blockNumber, buf, 66); - - for (int ii=0; ii<64; ii++) - { - //myStr+=QString::number(buf[ii],10); // decimals as ascii - myStr+=QString::number(buf[ii],16); // hex numbers as ascii - myStr+=" "; // make a gap between numbers - } - return myStr; -} - - - - - -// ---------------------------------------------------------------------------------------------------------- -// --------------------------------------------- PRINTER ---------------------------------------------------- -// ---------------------------------------------------------------------------------------------------------- - -// already above: -// void hwapi::prn_switchPower(bool on) 0x2A01 -// bool hwapi::prn_readyINisActive(void) -// bool hwapi::prn_isPrinterPowerOn(void) -// void hwapi::request_PrinterHwState() 0x2A02 -// void hwapi::request_PrinterCurrentFonts() 0x2A12 -// void hwapi::request_PrinterStateComplete() // =request_PrinterHwState + request_PrinterCurrentFonts - -uint8_t hwapi::prn_getHwState(struct Tprn_hw_state *prn_hw_state) const -{ - // return printer hardware state: power is on? rs-driver on? rs_switch ok? hw-ready-line ok? - // printer on error or ok? - uint8_t prnHWstate[20]; - - epi_restorePrinterState(prnHWstate); - // byte 1...6 come right from printer, see printer manual - // byte 0 = all important infos: - // byte 0 = 0: prnter OK, >0: error - // bit0: paper low 1: no paper 2: temperature error - // 3: head open 4: paper jam in cutter - // 6: no response 7: bad response from printer - - prn_hw_state->powerRdBk = epi_getDI_printerPwr(); - prn_hw_state->rsSwOk = epi_getDO_serialMux1isSetToPrinter(); // mux1 off: serial is switched to printer - prn_hw_state->rsDrvOk = epi_getDO_serialDriverIsOn(); - prn_hw_state->ReadyLine = epi_getDI_prnReady(); - - if (prnHWstate[0]==0) - prn_hw_state->inIdle = true; // no errors - else - prn_hw_state->inIdle = false; // off or errors - - if (prnHWstate[0] & 1) - prn_hw_state->paperNearEnd=true; - else - prn_hw_state->paperNearEnd = false; - - if (prnHWstate[0] & 2) - prn_hw_state->noPaper=true; - else - prn_hw_state->noPaper = false; - - if (prnHWstate[0] & 4) - prn_hw_state->ErrorTemp=true; - else - prn_hw_state->ErrorTemp = false; - - if (prnHWstate[0] & 8) - prn_hw_state->HeadOpen=true; - else - prn_hw_state->HeadOpen = false; - - if (prnHWstate[0] & 16) - prn_hw_state->cutterJam=true; - else - prn_hw_state->cutterJam = false; - - - if (prnHWstate[0] & 64) - prn_hw_state->noResponse=true; - else - prn_hw_state->noResponse = false; - - if (prnHWstate[0] & 128) - prn_hw_state->badResponse=true; - else - prn_hw_state->badResponse = false; - return prnHWstate[0]; - -} - -bool hwapi::prn_isUpAndReady(void) const -{ - struct Tprn_hw_state prnHwNow; - - prn_getHwState(&prnHwNow); - if (prnHwNow.inIdle && prnHwNow.rsSwOk && prnHwNow.rsDrvOk && prnHwNow.powerRdBk ) - return true; - return false; -} - -void hwapi::prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const -{ - uint8_t prnFonts[22]; - - epi_restorePrinterFonts(&prnFonts[0]); - prn_fonts->currFont = prnFonts[0]; - prn_fonts->currSize = prnFonts[1]; - prn_fonts->currHeigth= prnFonts[2]; - prn_fonts->currWidth = prnFonts[3]; - prn_fonts->nowBold = prnFonts[4]; - prn_fonts->nowInvers = prnFonts[5]; - prn_fonts->nowUnderlined= prnFonts[6]; - prn_fonts->currDensity = prnFonts[7]; - prn_fonts->currSpeed = prnFonts[8]; - prn_fonts->nowAligned = prnFonts[9]; - -} - - -void hwapi::prn_sendText(QByteArray *buf) const -{ - sub_storeSendingText(buf); - epi_storeUserOfSendingTextBuffer(1,0,0,0,0); // 1=print text - - -} - - -void hwapi::prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) const -{ - // send three byte through to printer, see printers manual - sendWRcmd_setSendCommand8(SENDDIRCMD_PRN_SYS_CMD, para1, para2, 0, para3); -} - -void hwapi::prn_sendPrnEscCmd(uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4) const -{ - // send four byte through to printer, see printers manual - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_ESC_CMD, para1, para2, para3, para4); -} - -void hwapi::prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) const -{ - // send 5 byte: byte 0,1: speed 5...250 mm/s - // byte2: density 0....(25)....50 - // byte3: alignment 'l', 'c', 'r' = left, center, right - // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) - // not batched! don't use twice within 100ms - - uint8_t buf[10]; - uint16_t uitmp; - - uitmp=paperSpeed; - buf[0]=uint8_t(uitmp); - uitmp>>=8; - buf[1]=uint8_t(uitmp); - buf[2]=density; - buf[3]=alignment; - buf[4]=orientation; - buf[5]=0; - epi_store64ByteSendData(5, buf); - sendWRcmd_setSendCommand0(SENDDIRCMD_PRN_SETUP); -} - -void hwapi::prn_movePaper(uint8_t wayInMm, uint8_t direction) const -{ - //direction: 1=forward 2=backward - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_MOVE, wayInMm, direction, 0,0); -} - - -void hwapi::prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const -{ - // font = kind of font 0...8 - // size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge - // width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) - // heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_SETFONT, font, size, width, height); -} - - -void hwapi::prn_setLetters(uint8_t bold, uint8_t invers, uint8_t underlined) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_SETLETT, bold, invers, underlined, 0); -} - -void hwapi::prn_cut(uint8_t kindof) const -{ - // kindof = 1: full cut 2: partial cut 3=eject (5xLF + full cut) - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_CUT, kindof,0,0,0); -} - -void hwapi::prn_newLine(uint8_t nrOfLines) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_LF, nrOfLines, 0, 0, 0); -} - -void hwapi::prn_printCompleteFontTable(void) const -{ - sendWRcmd_setSendCommand0(SENDDIRCMD_PRN_FONTTAB); -} - - -void hwapi::prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) const -{ - uint8_t buf[66], nn; - //uint16_t uitmp; - - if (dataLeng>58) - dataLeng=58; - - buf[0]=kindOf; - buf[1]=withText; - buf[2]=offset; - buf[3]=rotation; - buf[4]=dataLeng; - // rest: Barcode-data: - for (nn=0; nn1278) - return false; - ticketTemplate.append(text); - qDebug()<<"\nText added "<1266) - return false; - ticketTemplate.append(tmpStr); - return true; -} - -bool hwapi::pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const -{ - // always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5 - /* complete list of possible commands: - group 50 : paper - attribute 10 : move forward - p1: wayInMm p2: direction - attribute 11 : cut - p1: kind of, 1=full 2=partial, 3=eject - attribute 12 : new line(s) - p1: nr of lines 1...100 - - group 51 : fonts - attribute 10 : kind of font see description above - p1: possible: 0...22, expedient: 5...11 - attribute 11 : font size - p1: 6...20 12=normal 6=tiny - attribute 12 : font width - p1: 0...4 - attribute 13 : font heigth - p1: 0...7 - attribute 14 : switch bold print on/off - p1: 0=off 1=on - attribute 15 : switch invers print on/off - p1: 0=off 1=on - attribute 16 : switch underlined print on/off - p1: 0=off 1=on - - group 52 : print graphics - attribute 10 : print barcode with dynamic data 6 and 7 - p1...p5 = kindOf, withText, offset, rotation, dataLeng, see description above - attribute 11 : print QRcode with preset data - - attribute 12 : print Logo - p1=nrOfLogo, p2=offset - - group 53 : print dynamics - attribute 10 : 1...8 = print dynData 0..7 at this place - -*/ - - - char tmpStr[10]; - - // command has always fixed length of 8 byte - if (ticketTemplate.length()>1270) - return false; - if (group<50 || group>59) - return false; - if (attribute<10 || attribute>30) - return false; - - tmpStr[0]=0x1B; // ESC - tmpStr[1]=group; - tmpStr[2]=attribute; - tmpStr[3]=p1; - tmpStr[4]=p2; - tmpStr[5]=p3; - tmpStr[6]=p4; - tmpStr[7]=p5; - - ticketTemplate.append(tmpStr, 8); - - - qDebug()<<"\ncmd added "<1277) - return false; - ticketTemplate.append("\n"); - return true; -} - -bool hwapi::pri_TD_addSign(char sign) const -{ - if (ticketTemplate.length()>1277) - return false; - ticketTemplate.append(sign); - return true; -} - - -char hwapi::prn_clearDocument(uint8_t documentNumber) const -{ - if (documentNumber>15) - return false; - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_CLEARDOC, documentNumber, 0, 0, 0); - return true; -} - - -bool hwapi::prn_store_Document(uint8_t documentNumber ) const -{ - // send to DC - // documentNumber=0...15, stored in Eeprom - // maximal 1280 bytes each - // allowed: 0x20...0xFF, 0x0A, 0x0C, 0x1B (LF, CR, Esc) - // 0x1B=start of embedded command (next 7bytes = command) - - if (documentNumber>15) - return false; - sub_storeSendingText(&ticketTemplate); - epi_storeUserOfSendingTextBuffer(3,documentNumber,0,0,0); // 3=store document - return true; -} - - -bool hwapi::prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const -{ - if (documentNumber>15) - return false; - epi_store64ByteSendData(64, &(dynTicketData->licensePlate[0])); - sendWRcmd_setSendCommand4(SENDDIRCMD_PRN_DOC, documentNumber, 0, 0, 0); - return true; -} - - - - - - -// ---------------------------------------------------------------------------------------------------------- -// ------------------------------------------- MDB Bus ------------------------------------------------------ -// ---------------------------------------------------------------------------------------------------------- - - - -void hwapi::mdb_sendBusReset(void) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_RES, 0,0,0,0); - -} - -#define mdb_device_coinChk 0 -#define mdb_device_changer 1 -#define mdb_device_bill 2 -//#define mdb_device_credit 3 // obsolete - - -void hwapi::mdb_sendCommand(uint8_t toMdbDevice, uint8_t mdbCommand) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_SENDCMD, toMdbDevice, mdbCommand, 0,0); - -} - -void hwapi::mdb_sendMessage(uint8_t toMdbDevice, uint8_t mdbCommand, uint8_t nrOfData, uint8_t *dataBuffer) const -{ - // nrOfData = sizeOf(dataBuffer) maximal 34 byte according mdb specs - uint8_t myBuf[64], ii; - - tslib_strclr(myBuf, 0, 64); - myBuf[0]=toMdbDevice; - myBuf[1]=mdbCommand; - if (nrOfData>34) nrOfData=34; - myBuf[2]=nrOfData; - for (ii=0; ii>=8; - myBuf[1]=uint8_t (uitmp); - myBuf[2]=tokenChannel; - pp=3; - for (ii=0; ii<16; ii++) - { - uitmp=coinDenomination[ii]; - myBuf[pp]=uint8_t(uitmp); - uitmp>>=8; - myBuf[pp+1]=uint8_t(uitmp); - pp+=2; - } - - epi_store64ByteSendData(35, myBuf); - sendWRcmd_setSendCommand0(SENDDIRCMD_EMP_SETT); - -} - -void hwapi::emp_pollingOnOff(uint8_t on) const -{ - // on: 1=start polling the coin accepter 0=stop - sendWRcmd_setSendCommand4(SENDDIRCMD_EMP_POLL, on,0,0,0); - -} - -void hwapi::emp_startCoinAcceptance(void) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_EMP_STARPPAY, 0,0,0,0); - -} - -void hwapi::emp_stopCoinAcceptance(void) const -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_EMP_STOPPAY, 0,0,0,0); - -} - - - -void hwapi::emp_getAllParameters(struct T_emp *emp) const -{ - uint8_t leng, data[66], ii, pp; - epi_restoreEmpSettings(&leng, data); // expected length = 64 byte - - // get 64 bytes about EMP: see h-file - - emp->gotSetup = data[0]; - emp->state = data[1]; - emp->shaft = data[2]; - emp->countryCode= uchar2uint(data[4], data[3]); - emp->scale = data[5]; - emp->decimals = data[6]; - for (ii=0; ii<16; ii++) - emp->coinValues[ii] = data[7+ii]; - emp->coinAccept = uchar2uint(data[24], data[23]); - emp->tokenChannel = data[25]; - emp->pollingRunning = data[26]; - emp->paymentRunning = data[27]; - - pp=28; - for (ii=0; ii<16; ii++) - { - emp->denomination[ii] = uchar2uint(data[pp+1], data[pp]); - pp+=2; - } - emp->routing= uchar2uint(data[61], data[60]); - -} - -/* -static bool emp_newCoin; -static uint8_t emp_newCoinSignal; -static uint16_t emp_newCoinValue; -static uint8_t emp_newCoinError; - -uint8_t hwapi::emp_chkIfCoinInserted(void) -{ - // retval: 1=got coin 0xFF=emp reported an error 0=got nothing - // comes only one time after each coin, vaslues are stored - uint8_t leng, data[8]; - - epi_restoreEmpCoinSignal(&leng, data); - // 5 byte per inserted coin: - // data[0]: 1=got coin, data set valid - // data[1]: emp-signal of last inserted coin - // data[2]: emp-error or warning - // data[3,4]: emp-value of last inserted coin 3=low byte - - //epi_clearEmpCoinSignal(); - - if (data[0]>0) - { - emp_newCoin=data[0]; // anything came in, coin or error or both - - if (data[0] & 0x80) - { - emp_newCoinError=data[4]; - } - if (data[0] &0x0F) - { - emp_newCoinSignal=data[1]; - emp_newCoinValue=uchar2uint(data[3], data[2]); - } - return emp_newCoin; - } - return 0; - -} - -uint8_t hwapi::emp_getInsertedCoinSignal(void) -{ - uint8_t uctmp=emp_newCoinSignal; - emp_newCoinSignal=0; // return only once - return uctmp; - -} - - -uint16_t hwapi::emp_getInsertedCoinValue(void) -{ - uint16_t uitmp=emp_newCoinValue; - emp_newCoinValue=0; // return only once - return uitmp; -} - -uint8_t hwapi::emp_getCoinError(void) -{ - uint8_t uctmp=emp_newCoinError; - emp_newCoinError=0; // return only once - return uctmp; -} -*/ - -uint8_t hwapi::emp_chkIfCoinInserted(void) const -{ - // retval: 0...16 coins left in FIFO - return epi_isNewCoinLeft(); -} - - -void hwapi::emp_getNewCoinRecord(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) const -{ - - epi_restoreEmpCoinSignal(valid, signal, error, value); -} - -uint8_t hwapi::emp_giveLastCoin(uint16_t *value, uint8_t *signal) const -{ - // retval: 0: NO coin stored 1: valid coin 2: got wrong coin or coin denied - // value: if retval1: value of the coin if reval=2: error number - // signal: channel nr reported from checker - - uint8_t valid, chan, error; - uint16_t wert; - - epi_restoreEmpCoinSignal(&valid, &chan, &error, &wert); - - if (valid && error==0xFF ) - { - *value=wert; - *signal=chan; - return 1; - } - - if (valid && error<0xFF ) - { - *value=error; - *signal=chan; // normally 0, but sometimes we get both - return 2; - } - return 0; -} - -uint8_t hwapi::emp_returnLastCoin(uint16_t *value, uint8_t *signal) const -{ - // use this for coin changer - - uint8_t valid, chan, error; - uint16_t wert; - - epi_restoreEmpCoinSignal(&valid, &chan, &error, &wert); - - if (error) - { - *value=0; - *signal=error; - return 0; - } - *value=wert; - *signal=chan; - return valid; -} - -// ---------------------------------------------------------------------------------------------------------- -// --------------------------------------------- Bill Validator ----------------------------------- -// ---------------------------------------------------------------------------------------------------------- -/* -// Coin checker and changer mdb4.2 / section 5 -// Level 2 Commands (predefined device msg acc. mdb manual and auto-poll) -uint8_t hwapi::mdb_bill_startPolling(bool on) -{ - // send ether one command (from list below) - // or a poll command in the proper polling grid (e.g. every 100ms) - epi_storeConfig08(mdbPollBills,on); - //sendWRcmd_setSendCommand0(SENDDIRCMD_WR_CONF_08); - return 0; -} - -// the following functions tell the DC to send a mdb command to any mdb slave -// in opposite to mdb_sendData() the exact telegrams don't have to be formed here, DC does it. -uint8_t hwapi::mdb_bill_reset() -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_BillAll, 1, 0, 0, 0); - - return 0; -} - -uint8_t hwapi::mdb_bill_setup() -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_BillAll, 2, 0, 0, 0); - - return 0; -} - -uint8_t hwapi::mdb_bill_security(uint16_t secLevel) -{ - - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_BillAll, 3, uint8_t(secLevel), uint8_t(secLevel>>8), 0); - - return 0; -} - -uint8_t hwapi::mdb_bill_pollManually(void) -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_BillAll, 4, 0, 0, 0); - - return 0; -} - -uint8_t hwapi::mdb_bill_billType(uint16_t billEnable, uint16_t escrowEnable) -{ - - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_BillType, - uint8_t(billEnable), uint8_t(billEnable>>8), - uint8_t(escrowEnable), uint8_t(escrowEnable>>8)); - - return 0; -} - -uint8_t hwapi::mdb_bill_escrow(uint8_t action) -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_BillAll, 5, action, 0, 0); - - return 0; -} - -uint16_t hwapi::mdb_bill_stacker(void) -{ - sendWRcmd_setSendCommand4(SENDDIRCMD_MDB_BillAll, 6, 0, 0, 0); - - return 0; -} - -uint8_t hwapi::mdb_bill_expansion(uint8_t subCmd, uint8_t send[32]) -{ - uint8_t sendbuf[34], nn; - - // 1) insert subCmd into buffer - for (nn=0; nn<32; nn++) - sendbuf[nn+1]=send[nn]; - sendbuf[0]=subCmd; - sendbuf[33]=0; - epi_storeMdbSendData(34, sendbuf); - sendWRcmd_setSendCommand0(SENDDIRCMD_MDB_BillExp); - return 0; -} - - -uint8_t hwapi::mdb_bill_gotPollResponse(void) -{ - // 0: no response 1: got ACK 2: got NAK 3 got ACK with additional data - return epi_getMdbResponse(); // request only once, then epi_getMdbRecLength()==0 - -} - - -uint8_t hwapi::mdb_bill_getDataLen(void) -{ - // return nr of byte received from any mdb device - return epi_getMdbRecLength(); -} - -uint8_t hwapi::mdb_bill_getPollData(uint8_t *mdb_data, uint8_t maxBufferSize) -{ - uint8_t len, buf[64], LL; - len=epi_getMdbRecLength(); - epi_restoreMdbRecData(buf); // request only once, then epi_getMdbRecLength()==0 - (maxBufferSizepowerRdBk=epi_restoreReadDIs(DIBYTE0, RB_VGSM); - if (epi_cntchk_swRs1toModem()) - mod_hw_state->rsSwOk=1; - else - mod_hw_state->rsSwOk=0; - - mod_hw_state->rsDrvOk=epi_cntchk_enabDrv01(); // can never be false - mod_hw_state->HwState=false; - mod_hw_state->CommState=false; - mod_hw_state->gotAnswer=false; - - return 0; -} - - -uint8_t hwapi::mod_setCondition(uint16_t chgCmd) -{ - // e.g. change to state registered, sleep, open, off.... - return uint8_t(chgCmd); -} - -uint16_t hwapi::mod_getCondition(void) -{ - // e.g. now socket open - - return 0; -} - -bool hwapi::mod_sendBufferFree(void) -{ - // sending allowed (before writing) and sending finished (after writing) - - return 0; -} - -void hwapi::mod_wantReadData(uint16_t nrOfData) -{ - // start reading - nrOfData=0; - -} - -uint8_t hwapi::mod_sendDataBlk(uint16_t len, uint8_t *buf) -{ - len=buf[0]; - return uint8_t(len); -} - -uint16_t hwapi::mod_gotData(void) -{ - // return nr of received bytes - - return 0; -} - -uint8_t hwapi::mod_loadDataBlk(uint16_t len, uint8_t *buf) -{ - len=buf[0]; - return uint8_t(len); - - -} - -uint8_t hwapi::mod_setupSerial(struct TserialParams serialParameter) -{ - // Baudrate and so on... - return 0; -} - -uint8_t hwapi::mod_getCurrentSerialSettings(struct TserialParams *serialParameter) -{ - // Baudrate and so on... - - return 0; -} -*/ - - - - - - - - - - -// neu, 25.8.21 - - - - -QString hwapi::dc_getTxt4RsDiagWin(void) const -{ - return epi_getTxt4RsDiagWin(); -} - -void hwapi::dc_clrTxt4RsDiagWin(void) const -{ - epi_clrTxt4RsDiagWin(); -} - -QString hwapi::dc_get2ndTxt4RsDiagWin(void) const -{ - return epi_get2ndTxt4RsDiagWin(); -} - -void hwapi::dc_clr2ndTxt4RsDiagWin(void) const -{ - epi_clr2ndTxt4RsDiagWin(); -} - -QString hwapi::dc_getTxt4HsStateLine(void) const -{ - // Crash! - return epi_getTxt4HsStateLine(); -} - -void hwapi::dc_clrTxt4HsStateLine(void) const -{ - epi_clrTxt4HsStateLine(); -} - - -QString hwapi::dc_getTxt4masterStateLine(void) const -{ - return epi_getTxt4masterStateLine(); -} - -void hwapi::dc_clrTxt4masterStateLine(void) const -{ - epi_clrTxt4masterStateLine(); -} - -QString hwapi::dc_getTxt4resultStateLine(void) const -{ - return epi_getTxt4resultStateLine(); -} - -void hwapi::dc_clrTxt4resultStateLine(void) const -{ - epi_clrTxt4resultStateLine(); -} - -QString hwapi::dc_getdataStateLine(void) const -{ - return epi_getTxt4dataStateLine(); -} - -void hwapi::dc_clrTxt4dataStateLine(void) const -{ - epi_clrTxt4dataStateLine(); -} - - -QString hwapi::dc_getdatifLine(void) const -{ - return epi_getTxt4datifLine(); -} - -void hwapi::dc_clrTxt4datifLine(void) const -{ - epi_clrTxt4datifLine(); -} - - - - -// using DC2 Bootloader - -void hwapi::bl_iniChain(void) const -{ - dcBL_iniChain(); -} - - -bool hwapi::bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const -{ - return dcBL_importBinFile(readBinFile, fileSize, withDispl); -} - -uint8_t hwapi::bl_activatBootloader(uint8_t *sendData) const -{ - return dcBL_activatBootloader(sendData); -} - -uint8_t hwapi::bl_startChain(void) const -{ - return dcBL_startChain(); -} - -uint8_t hwapi::bl_readBLversion(uint8_t *sendData) const -{ - // minimum size of sendData-buffer: 5byte retval: length - - return dcBL_readBLversion(sendData); -} - -uint8_t hwapi::bl_readFWversion(uint8_t *sendData) const -{ - // minimum size of sendData-buffer: 5byte retval: length - return dcBL_readFWversion(sendData); - -} - -uint8_t hwapi::bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const -{ -// make BL protocol, retval = outbuf length (5...133) -// bring data in correct form: start always with 0x02 finish with 0x03 and append checksum -// 0x02 Cmd < ...sendData ..> CRC CRC 0x03 -// Data length = 0...64 -// special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 -// so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 - - return dcBL_prepareDC_BLcmd(Cmd, SendDataLength, sendData, outBuf); - -} - -uint8_t hwapi::bl_exitBL(uint8_t *sendData) const -{ - // minimum size of sendData-buffer: 5byte retval: length - return dcBL_exitBL(sendData); -} - -void hwapi::led_switchLedIllumination(uint8_t on) const -{ - if (on) - { - - } - -} - - - -// neu, 25.3.23 - -// ------------------------------------------------------------------------------------ -// 27.3.2023: Use Device-Controller's Bootloader to send hex-file -// ------------------------------------------------------------------------------------ - -void hwapi::bl_rebootDC(void) const -{ - uint8_t len, buf[20]; - - len=dcBL_restartDC(buf); - sendWRcmd_setSendBlock160(len, buf); -} - -void hwapi::bl_startBL(void) const { - uint8_t len, buf[20]; - memset(buf, 0x00, sizeof(buf)); - - len=dcBL_activatBootloader(buf); - sendWRcmd_setSendBlock160(len, buf); -} - -bool hwapi::bl_checkBL(void) const -{ - uint8_t len, buf[20]; - - //len=dcBL_readBLversion(buf); - len=dcBL_readFWversion(buf); - sendWRcmd_setSendBlock160(len, buf); - - return (len > 0); -} - -bool hwapi::bl_isUp(void) const -{ - uint8_t receivedData[160]; - uint8_t LL; - - memset(receivedData, 0x00, sizeof(receivedData)); - - LL=epi_getRawRecLength(); - if (LL>0) - { - epi_getRawReceivedData(receivedData); - //epi_clrRawReceivedString(); - - //qDebug() << " *** got " << LL << " data bytes from BL: " << - // receivedData[0] << " " << receivedData[1] << " " << receivedData[2] << " " << - // receivedData[3] << " " << receivedData[4] << " " << receivedData[5] << " "; - - // response to "readFWversion" - if (receivedData[0]==2 && receivedData[1]==146 && receivedData[2]==45 && - receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176) - { - dcBL_iniLoading(); - return true; - } - // response to "start BL" - if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 && - receivedData[3]==223 && receivedData[4] ==131 ) - { - dcBL_iniLoading(); - return true; - } - - } - return false; -} - - -void hwapi::bl_sendAddress(uint16_t blockNumber) const -{ - // send start address, nr of 64byte-block, start with 0 - // will be sent only for folling block-numbers: - // 0, 1024, 2048, 3072 and 4096, so basically every 64kByte - uint32_t dcBL_BlkCtr=(uint32_t)blockNumber; - uint8_t len, buf[20]; - - tslib_strclr(buf, 0, 20); - if (dcBL_BlkCtr==0 || dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096) - { - dcBL_BlkCtr*=64; - len=dcBL_sendFlashStartAddr2BL(dcBL_BlkCtr, buf); // make command string - // uint8_t dcBL_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData) - // minimum size of sendData-buffer: 13byte retval: length (9...13) - sendWRcmd_setSendBlock160(len, buf); // send command to BL - } -} - -uint8_t hwapi::bl_wasSendingAddOK(void) const -{ - // return val: 0: no response by now 1:error 10: OK - - return dcBL_sendSuccess(0x21); - // return val: 0: no response by now 1:error 10: OK - // lastCommand=0x21 for sendAddr or 0x22 for send data - -} - -void hwapi::bl_openBinary(void) const -{ - - dcBL_loadBinary(0); -} - -void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const -{ - // send 64 byte from bin file - uint8_t LL=length, sendBuf[80], sendLen; - if (LL>64) LL=64; - - tslib_strclr(sendBuf,0,80); -/* hier ist alles richtig - qDebug() << "bl_sendDataBlock "<rtc_hour; - temp[1]= DateTime->rtc_min; - temp[2]= DateTime->rtc_sec; - temp[3]= 20; - temp[4]= DateTime->rtc_year; - temp[5]= DateTime->rtc_month; - temp[6]= DateTime->rtc_dayOfMonth; - temp[7]= DateTime->rtc_dayOfWeek; - b_ret=longFDcmd_set(20,0,0,8,temp); - return b_ret; -} - -bool hwapi::rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const -{ - epi_restoreExtendedTime(leng, data); - return true; - -/* - buf[0]=GlobTime.Hours; - buf[1]=GlobTime.Min; - buf[2]=GlobTime.Sec; - buf[3]=GlobTime.Year; - buf[4]=GlobTime.Month; - buf[5]=GlobTime.Day; - buf[6]=GlobTime.DOW; - buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master! - uitmp=GlobTime.MinOfDay; - buf[8]=swl_getOneByteFromUint(uitmp, 0); - buf[9]=swl_getOneByteFromUint(uitmp, 1); - buf[10]=' '; - buf[11]=' '; - ultmp=GlobTime.SecOfDay; - buf[12]=swl_getOneByteFromUlong(ultmp, 0); - buf[13]=swl_getOneByteFromUlong(ultmp, 1); - buf[14]=swl_getOneByteFromUlong(ultmp, 2); - buf[15]=swl_getOneByteFromUlong(ultmp, 3); - - buf[16]=swl_isLeap(GlobTime.Year); - buf[17]=swl_getNextLeapYear(GlobTime.Year); - buf[18]=swl_getLastLeapYear(GlobTime.Year); - buf[19]=swl_hoursOfThisWeek(GlobTime.DOW, GlobTime.Hours); - - uitmp=swl_minutesOfThisWeek(GlobTime.DOW, GlobTime.Hours, GlobTime.Min); - buf[20]=swl_getOneByteFromUint(uitmp, 0); // 0=low byte 1=high byte - buf[21]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_hoursOfThisMonth(GlobTime.Day, GlobTime.Hours); - buf[22]=swl_getOneByteFromUint(uitmp, 0); - buf[23]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_minutesOfThisMonth(GlobTime.Day, GlobTime.Hours, GlobTime.Min); - buf[24]=swl_getOneByteFromUint(uitmp, 0); - buf[25]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_GetDaysOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day); - buf[26]=swl_getOneByteFromUint(uitmp, 0); - buf[27]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_GetHoursOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day, GlobTime.Hours); - buf[28]=swl_getOneByteFromUint(uitmp, 0); - buf[29]=swl_getOneByteFromUint(uitmp, 1); - buf[30]=0; - buf[31]=0; - ultmp= swl_GetMinutesOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day, - GlobTime.Hours, GlobTime.Min); - buf[32]=swl_getOneByteFromUlong(ultmp, 0); - buf[33]=swl_getOneByteFromUlong(ultmp, 1); - buf[34]=swl_getOneByteFromUlong(ultmp, 2); - buf[35]=swl_getOneByteFromUlong(ultmp, 3); - - buf[36]=rtc_getSqwaveSettings(); - buf[37]=0; - buf[38]=0; - buf[39]=0; - - ultmp= 0; // Minutes of the Millenium - buf[40]=swl_getOneByteFromUlong(ultmp, 0); - buf[41]=swl_getOneByteFromUlong(ultmp, 1); - buf[42]=swl_getOneByteFromUlong(ultmp, 2); - buf[43]=swl_getOneByteFromUlong(ultmp, 3); - - dc2prot_setReadData(44, buf); - - */ - -} - -bool hwapi::rtc_getExtendedTime(struct T_extTime *exTime) const -{ - uint8_t len; - uint16_t LL, nn; - uint8_t *start; - uint8_t buf[66]; - - epi_restoreExtendedTime(&len, buf); - // Puffer in struct eintragen: - LL=sizeof(struct T_extTime); - start = &(exTime->Hours); - nn=0; - do - { - *start = buf[nn]; - start++; - } while(++nn800) dateiLang=800; - tslib_strcpy(content, inhaltOfJson, dateiLang); // enthaelt genaue Laenge, Rest =0 - nrOfBlocks=dateiLang/64; - if (dateiLang%64>0) - nrOfBlocks++; - dateiLang=nrOfBlocks; - dateiLang<<=6; // auf volle 64byte aufgerundet - - // check free memory - frei=check4freeFDlongCmd(); - // Command-Stack sollte 16 Commands fassen, je 64byte Nutzdaten = 1024byte - // frei gibt also die Anzahl freier 64byte Bloecke zurueck - // das Json-File hat max 800 byte = 13 bloecke - if (frei<16) // Puffer muss ganz leer sein! nicht dass was durcheinander kommt - return false; - - // Start- und Stop auch als langes Kommando schicken - // PROBLEM: wuerden sie in einem anderen Batch gespeichert (short command stack), - // dann kann die Reihenfolge nicht gewaehrleistet werden - // Das Startkommando muss sicher zuerst kommen - // Das Abschlusskommando muss sicher zuletzt kommen - - tslib_strclr(temp,0,65); - temp[0]=dateiArt; - temp[1]=NummDesTempl; - longFDcmd_set(30, 0,0, 2,temp); // sende "Starte-file-DL" - uitmp=0; bn=0; - do - { - biox_CopyBlock(inhaltOfJson, uitmp, temp, 0, 64); - longFDcmd_set(31,0, bn++, 64, temp); - //uitmp<<=6; // falsch - uitmp+=64; - } while(uitmp < dateiLang); - - longFDcmd_set(32, 0,0, 0,temp); // Abschluss - - return true; -} - -//char prn_dynPrnVal[8][8]; -bool hwapi::prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const -// dynPrnVal = array of 8 Variables with 8 byte each, come as ascii string -// like: char prn_dynPrnVal[8][8]; -// return true if sending, false if cmd-stack is full -{ - - uint8_t temp[66]; - - - tslib_strcpy(dynPrnVal, temp, 64); // Vorsicht, kann \0en enthalten - return longFDcmd_set(33,0,0, 64, temp); - -} - - -bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const - // print one of the templates loaded by Json prior - // nr = 1..32 -{ - // return true if sending, false if cmd-stack is full - return sendFDcmd_set(152, 0,0, nrOftemplate,0,0,0); -} - -void hwapi::log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const -{ - // returns all acc nrs of the backuped vault records - // use: uint16_t backupedAccNumbers[8] - - epi_restoreDCbackupAccNr(nrOfVals, accNr); -} - - - -bool hwapi::log_selectVaultRecord(uint16_t accountNr ) const -{ - // return true if sending, false if cmd-stack is full - // and trigger transfer - - uint8_t dat1, dat2; - bool ret; - - uint8_t frei=check4freeFDshortCmd(); - if (frei<8) - return false; - - epi_iniVRstorage(); - dat1=uint2uchar(accountNr, LOWBYTE); - dat2=uint2uchar(accountNr, HIGHBYTE); - ret=sendFDcmd_set(153, 0,0, dat1,dat2,0,0); // select this record - // true means "will be sent" - sendFDcmd_set(0,38,0, 0,0,0,0); // return VaultRecord block-Nr.0 - sendFDcmd_set(0,38,1, 0,0,0,0); // return VaultRecord block-Nr.1 - sendFDcmd_set(0,38,2, 0,0,0,0); // return VaultRecord block-Nr.2 - sendFDcmd_set(0,38,3, 0,0,0,0); // return VaultRecord block-Nr.3 - sendFDcmd_set(0,38,4, 0,0,0,0); // return VaultRecord block-Nr.4 - sendFDcmd_set(0,38,5, 0,0,0,0); // return VaultRecord block-Nr.4 - // 38: <100 to get long 64byte response - - return ret; -} - -bool hwapi::log_chkIfVaultRecordAvailable(void) const -{ - // return true if completly received - return epi_checkIfVaultRecordAvailable(); - return false; -} - -bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const - // which was selected by: log_selectVaultRecord() - // to be forwarded to Ismas - // return true if completly received -{ - - uint16_t LL, nn, len; - char *start; - uint8_t buf[400]; - bool ret; - - ret=epi_restoreVaultRecord(&len, buf); // true if completly received - if (ret==false) - return false; - // Puffer in struct eintragen: - LL=sizeof(struct T_vaultRecord); // =320 - start = &retVR->startbuffer[0]; - nn=0; - do - { - *start = buf[nn]; - start++; - } while(++nnstart(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 - - //qCritical() << "empState = " << empState; - - 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(); -} - -uint16_t hwapi::getLastInsertedCoin(void) const -{ - return epi_CurrentPaymentGetLastCoin(); -} - -bool hwapi::getAllInsertedCoins(uint16_t *types, uint16_t *values) const -{ - // alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert, max 64 - return epi_CurrentPaymentGetAllCoins(types, values); - -} - - -bool hwapi::cash_cancelPayment(void) const - // and return coins -{ - // DB1: 1=encash 2=cancel & return coins - // 3=stop and keep coins in escrow - return sendFDcmd_set(156, 0,0, 2,0,0,0); -} -bool hwapi::cash_stopPayment(void) const - // and keep coins in escrow -{ - // DB1: 1=encash 2=cancel & return coins - // 3=stop and keep coins in escrow - emit hwapi_payStopByPushbutton(); - return sendFDcmd_set(156, 0,0, 3,0,0,0); - -} -// after ticket/goods issue: -bool hwapi::vend_success(void) const - // conclude payment process, encash all inserted coins to vault. Printing was successful - // if possible return change -{ - // DB1: 1=encash 2=cancel & return coins - // 3=stop and keep coins in escrow - return sendFDcmd_set(156, 0,0, 1,0,0,0); - -} -bool hwapi::vend_failed(void) const - // conclude payment process and return all inserted coins -{ - // DB1: 1=encash 2=cancel & return coins - // 3=stop and keep coins in escrow - return sendFDcmd_set(156, 0,0, 2,0,0,0); - -} - - - - - - -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 -{ - uint8_t type, buf[8], nn; - char ctmp; - - memset(buf, 0x00, sizeof(buf)); - - type=epi_mifGetCardType(&buf[0]); - //holder[8] = name of card holder - // retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins - for (nn=0;nn<8; nn++) { - ctmp=buf[nn]; - cardholder[nn]=ctmp; - - } - return type; -} - -uint64_t hwapi::sys_getWakeSource(void) const -{ - // retval: 6 bytes, bit coded, 1=event keeps DC awake - return epi_getWakeSources(); -} - -uint8_t hwapi::sys_getWakeReason(void) const -{ - // Master was woken by following reason: - // 1: MDB Event - // 2: Coin Event - // ( 3: Master Event) - will not set the wake line - // ( 4: 32s pulse) - will not set the wake line - // 5: Door Event - // ( 6: Diag Event) - will not set the wake line - // 7: 30min-Pulse for HB - - return epi_getWakeReason(); -} - - -void hwapi::sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const -{ - //uint8_t leng, data[66]; - epi_restoreDeviceConditions(leng, data); -} - -void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const -{ - uint16_t LL, nn; - uint8_t *start; - uint8_t buf[70], leng; - - epi_restoreDeviceConditions(&leng, buf); - - // Puffer in struct eintragen: - LL=sizeof(struct T_moduleCondition); - start = &devCond->ram; - nn=0; - do - { - *start = buf[nn]; - start++; - } while(++nnallDoorsDebounced; - nn=0; - do - { - *start = buf[nn]; - start++; - } while(++nn0) - { - // print was started - lastState=res; - } - } else - { - if (lastState==0) - { - // result hat sich auf 1 oder 2 geändert, d.h. Druck ist fertig - if (res==1) - { - - //emit hwapi_templatePrintFinished_OK(); - } else - if (res==2) - { - - //emit hwapi_templatePrintFinished_Err(); - } - lastState=res; - } - } - return res; -} - -uint8_t hwapi::prn_getCurrentPrinterState() const -{ - // 0: printer OK - // bit0: near paper end bit1: no paper - // bit2: temperature error bit3: error head open - // bit4: paper jam in cutter - // bit6: no response bit7: serial rec. error - // bit5: printer not ready - - - uint8_t lastPrinterStatus; - uint8_t buf[70], leng; - - // 2nd way to get dyn.conditions: - epi_restoreDynMachineConditions(&leng, buf); - lastPrinterStatus=buf[53]; - - return lastPrinterStatus; -} - - -// 21.4.23TS: change function "sendDeviceSettings()" to use this struct: "struct T_devices" -void hwapi::sys_sendDeviceParameter(struct T_devices *deviceSettings) const -{ - // same as "sendDeviceSettings()" but with much more data - uint8_t buf[64]; - uint16_t LL, nn; - tslib_strclr(buf,0,64); - uint8_t *start; - - // den gesamten struct in einen Puffer kopieren - LL=sizeof(struct T_devices); - start = &deviceSettings->kindOfPrinter; - nn=0; - do - { - buf[nn] = *start; - start++; - } while(++nnkindOfPrinter; - nn=0; - do - { - *start = buf[nn]; - start++; - } while(++nn0 in case of error - // is inncluded in sys_superviseSystem - - struct T_moduleCondition *modCond=0; - sys_getDeviceConditions(modCond); - - struct T_dynamicCondition *dynMaCond=0; - sys_getDynMachineConditions(dynMaCond); - - struct T_devices *devPara=0; - sys_restoreDeviceParameter(devPara); - - if (modCond->rtc>=200) - return 1; - if (modCond->printer==200 || modCond->printer==201) // 200: not connected 201: printer-HW-error 202: no paper - return 2; - if (modCond->printer==202) - return 3; - - if (modCond->coinBlocker>=200) - return 4; - if (modCond->mdbBus>=200) - return 5; - if (modCond->intEe>=200) - return 6; - - if (devPara->kindOfCoinChecker==1 || devPara->kindOfCoinChecker==2) // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW) - { - if (modCond->coinChecker>=200 || modCond->coinEscrow>=200) - { - // Fehler Münzver. - return 7; - } - if (modCond->coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok - { - return 8; - } - } else - if (devPara->kindOfCoinChecker==3) - { - if (modCond->changer>=200) - { - // Fehler Münzver. - return 7; - } - if (modCond->coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok - { - return 8; - } - } - - if ( modCond->billReader>=200 && devPara->BillAcceptor>0) - { - // Fehler BNA - return 9; - } - - if (dynMaCond->onAlarm>0) - return 10; - - if (dynMaCond->modeAbrech>0) - return 11; - - if (dynMaCond->nowCardTest>0) - return 12; - - if (dynMaCond->startupTestIsRunning>0) - return 13; - - if (modCond->voltage>=200) - return 14; - if (modCond->temper>=200) - return 15; - - return 0; -} - - -// retrigger System-Check with: -// bool hwapi::sys_runCompleteTest(void) const - - -uint8_t hwapi::sys_superviseSystem(void) const -{ - // this function proofs if vending is possible depending of doors state - - struct T_dynamicCondition *dynMaCond=0; - struct T_moduleCondition *modCond=0; - - if (!gpi_areDcDataValid()) - { - // es gibt keinerlei gültige Daten vom DC - return 0; - } - - // jetzt sind die DC-Daten aktuell, also reinholen: - sys_getDynMachineConditions(dynMaCond); - sys_getDeviceConditions(modCond); - - if (!modCond->allModulesChecked) - { - // noch keine Testergebnisse - if (dynMaCond->startupTestIsRunning) - return 2; // Starttest läuft gerade - else - return 1; // Starttest ist noch nicht gelaufen - } - - // all doors: 99: undefined 0:closed 1:open - if (dynMaCond->lowerDoor || dynMaCond->upperDoor) - return 3; - if (dynMaCond->middleDoor) - return 4; - - if (sys_componentAssessment() >0) - return 5; // errors found - - return 6; // everything fine -} - - - -uint8_t hwapi::sys_getSystemErrors(void) const -{ - - return sys_componentAssessment(); - - -} - - diff --git a/src/prot.cpp b/src/prot.cpp deleted file mode 100644 index 8c13052..0000000 --- a/src/prot.cpp +++ /dev/null @@ -1,768 +0,0 @@ -#include "prot.h" -#include -#include "controlBus.h" -#include "dcBL.h" - - -T_prot::T_prot() -{ - - mySerialPort = new T_com(); - connect(mySerialPort, SIGNAL(receivingFinished()), this, SLOT( analyseRecData() )); - //connect(mySerialPort, SIGNAL(sendingFinished()), this, SLOT(sendeFin())); - - for (int nn=0; nnisPortOpen(); -} - -bool T_prot::isSerialFree(void) -{ - return true; // ohne HS's kann er nicht blockiert sein -} - -void T_prot::setRecLen(uint16_t WriteCmd) -{ - if (WriteCmd<100) - { - RdDataLength=DATALEN_RECEIVE_LONG; // store here already because it's no longer - // returned from slave - mySerialPort->receiveFixLen(TELEGRAMLEN_RECEIVE_LONG); - } else - { - RdDataLength=DATALEN_RECEIVE_FAST; - mySerialPort->receiveFixLen(TELEGRAMLEN_RECEIVE_FAST); - } -} - -void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, uint8_t *data) -{ - WriteCommand=WriteCmd; - WriteAddr=WrAddr; - WrDataLength=WrDatLen; - if (WrDataLength>FRAME_DATALEN) - WrDataLength=FRAME_DATALEN; - - for (int nn=0; nnsetRecLen(WriteCmd); - -} - -void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr) -{ - WriteCommand=WriteCmd; - WriteAddr=WrAddr; - WrDataLength=0; - for (int nn=0; nnsetRecLen(WriteCmd); - -} - -void T_prot::setUserWriteData(uint16_t WriteCmd) -{ - WriteCommand=WriteCmd; - WriteAddr=0; - WrDataLength=0; - for (int nn=0; nnsetRecLen(WriteCmd); - -} - -void T_prot::setUserWrite1DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val) -{ - // wie oben, jedoch einfachere Datenübergabe - WriteCommand=WriteCmd; - WriteAddr=WrAddr; - WrDataLength=1; - ui8OutputData[0]=val; - SendDataValid=1; // always set WR first - kindOfData=0; // 0: binaries, 1:text - this->setRecLen(WriteCmd); - -} - -void T_prot::setUserWrite2DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, uint8_t val1) -{ - WriteCommand=WriteCmd; - WriteAddr=WrAddr; - WrDataLength=2; - ui8OutputData[0]=val0; - ui8OutputData[1]=val1; - SendDataValid=1; // always set WR first - kindOfData=0; // 0: binaries, 1:text - this->setRecLen(WriteCmd); - -} - -void T_prot::setUserWriteText(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, char *data) -{ - WriteCommand=WriteCmd; - WriteAddr=WrAddr; - WrDataLength=WrDatLen; - if (WrDataLength>FRAME_DATALEN) - WrDataLength=FRAME_DATALEN; - - for (int nn=0; nnsetRecLen(WriteCmd); - -} - -void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reserv) -{ - ReadCommand=ReadCmd; - ReadAddr=RdAddr; - reserve=reserv; - SendDataValid |=2; - readAddress=RdAddr; // store here already because it's no longer returned from slave - readSource=ReadCmd; -} - -void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr) -{ - ReadCommand=ReadCmd; - ReadAddr=RdAddr; - reserve=0; - SendDataValid |=2; - readAddress=RdAddr; // store here already because it's no longer returned from slave - readSource=ReadCmd; -} - -void T_prot::setUserReadData( uint16_t ReadCmd) -{ - ReadCommand=ReadCmd; - ReadAddr=0; - reserve=0; - SendDataValid |=2; - readAddress=0; // store here already because it's no longer returned from slave - readSource=ReadCmd; -} - -void T_prot::setBLsendData( uint8_t len, uint8_t *buf) -{ - for (int nn=0; nnBL_DATA_LEN) BLsendDataLength=BL_DATA_LEN; - for (int nn=0; nnsetRecLen(100); // how many?? - //readAddress= // needed?? - - //qDebug()<<"prot: got BL data " << len << "bytes, "; - //for (int i=0; ireceiveFixLen(nrOfbytesToReceive); -} - -void T_prot::sendUserData(uint16_t slaveAdr) -{ - // man könnte hier noch "SendDataValid" abfragen, - // muss immer 3 sein, muss man aber nicht - - //qDebug() << "prot send user data "<writeToSerial(packBuf_2, BLsendDataLength); - - - } else - startFastPacking(); // quicker since 15.12.21TS - //startPacking(); -} - -void T_prot::startFastPacking(void) -{ - uint16_t mycrc; - uint16_t sendLen; - uint8_t uctmp, nn, pp, CrcLp; - char sendBuffer[FRAME_MAXLEN], ctmp; - - //qDebug() << "prot start fast packing "<9 && WriteCommand<100) - { - // long command 10...99 - // WriteCommand==0 if only read request, then use short sending - sendBuffer[0]=STARTSIGN_SEND_LONG; - WrDataLength=DATALEN_SEND_LONG; // immer - //qDebug() << "send long cmd, len: " << WrDataLength; - } else - { - // fast command - sendBuffer[0]=STARTSIGN_SEND_FAST; - WrDataLength=DATALEN_SEND_FAST; // immer - //qDebug() << "send fast cmd, len: " << WrDataLength; - } - sendBuffer[1]= uint8_t(WriteCommand); - sendBuffer[2]= uint8_t(ReadCommand); - if (WriteAddr>0) - sendBuffer[3]= char(WriteAddr); // bei fast nur EINE adresse, wr hat Vorrang - else - sendBuffer[3]= char(ReadAddr); - // beim Fast prot. ist das reserve dann ists egal was drin steht - - if (kindOfData) // 0: binaries, 1:text - { - for (nn=0; nn>=8; - sendBuffer[CrcLp+1]=char(mycrc); - sendLen=CrcLp+2; - - // send to VCP: - QByteArray packBuff; - packBuff.clear(); - packBuff.append(sendBuffer, sendLen); // ohne sendLen wird beim ersten \0 abgeschnitten!!! - mySerialPort->writeToSerial(packBuff, sendLen); - -} - -/* -void T_prot::startPacking(void) -{ - uint16_t mycrc; - uint16_t uitmp, sendLen; - uint8_t uctmp, nn, pp, CrcLp; - char sendBuffer[FRAME_MAXLEN], ctmp; - - //qDebug() << "prot start packing "<>=8; - sendBuffer[2]= char(uitmp); - - uitmp=WriteCommand; - sendBuffer[3]= char(uitmp); - uitmp>>=8; - sendBuffer[4]= char(uitmp); - - uitmp=WriteAddr; - sendBuffer[5]= char(uitmp); - uitmp>>=8; - sendBuffer[6]= char(uitmp); - - uitmp=ReadCommand; - sendBuffer[7]= char(uitmp); - uitmp>>=8; - sendBuffer[8]= char(uitmp); - - uitmp=ReadAddr; - sendBuffer[9]= char(uitmp); - uitmp>>=8; - sendBuffer[10]= char(uitmp); - - uitmp=reserve; - sendBuffer[11]= '-'; //char(uitmp); - uitmp>>=8; - sendBuffer[12]= '-'; //char(uitmp); - - sendBuffer[13]= char(WrDataLength); - CrcLp= 14 + WrDataLength; - - if (kindOfData) // 0: binaries, 1:text - { - for (nn=0; nn>=8; - sendBuffer[CrcLp+1]=char(mycrc); - sendLen=CrcLp+2; - - sendBuffer[CrcLp+2]=13; - sendBuffer[CrcLp+3]=10; - sendLen+=2; - - // send to VCP: - QByteArray packBuff; - packBuff.clear(); - packBuff.append(sendBuffer, sendLen); // ohne sendLen wird beim ersten \0 abgeschnitten!!! - mySerialPort->writeToSerial(packBuff, sendLen); - // void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength) -} -*/ - -// --------------------------------------------------------------------------------------------------------- -// receiving..... -// --------------------------------------------------------------------------------------------------------- - - -void T_prot::analyseRecData(void) -{ - // Aufruf per connect aus serialcontrol wenn Daten empfangen wurden - // getRecData(QByteArray &data, uint16_t &sendLength); - - QByteArray Indata; - QString myString, tempStr; -//char recBuffer[FRAME_MAXLEN]; -uint8_t recBuffer[FRAME_MAXLEN]; - - uint16_t recLength; - - INdataValid=false; - gpi_setTxt4HsStateLine(""); - gpi_setTxt4masterStateLine(""); - gpi_setTxt4resultStateLine(""); - gpi_setTxt4dataStateLine(""); - gpi_setTxt4datifLine(""); - - // read from "VCP": - mySerialPort->readFromSerial(Indata, recLength); - //qCritical()<<"prot: got data " << recLength; - //qCritical()<<" Indata: " << Indata; - if (recLength>FRAME_MAXLEN) - recLength=FRAME_MAXLEN; - for (int nn=0; nn FRAME_DATALEN) //[9]=reported data lenght - return 3; // reported datalen too big - - if ((datalen !=(rawInLen-12)) && (datalen !=(rawInLen-13)) && (datalen !=(rawInLen-14)) ) - { - // angehängtes CR und/oder LF tolerieren - qDebug() << "wrong data length, " << datalen << " " << rawInLen; - return 4; // data len does not match to complete length - - } - crcL_Addr=datalen+10; // weil im definierten protocol 10 bytes vor den Daten stehen - recCrc=0; - - recCrc=uchar2uint(uint8_t(Inbuf[crcL_Addr+1]), uint8_t(Inbuf[crcL_Addr])); - myCrc=0; - for (nn=0; nnSlave) - switch (slaveresult) - { -// received message (from master) analysis: -// 0: got valid request -// this errors can only come back from a single device (not bus) -// or from a bus slave in local mode -// 1: wrong start 2: wrong length -// 3: wrong crc 4: wrong addr - - case 1: gpi_setTxt4resultStateLine("slave got wrong start sign"); break; - case 2: gpi_setTxt4resultStateLine("slave got wrong length"); break; - case 3: gpi_setTxt4resultStateLine("slave got wrong crc"); break; - case 4: gpi_setTxt4resultStateLine("slave got wrong addr"); break; - - case 10: gpi_setTxt4resultStateLine("slave is in local mode"); break; - case 13: gpi_setTxt4resultStateLine("local mode with wrong crc"); break; - case 14: gpi_setTxt4resultStateLine("local mode with wrong addr"); break; - // wenn 1..4 dann konnte der Slave das Mastertelegramm gar nicht verwenden, also hier Stoppen - } - if (slaveresult>0 && slaveresult<10) - return 1; - - // Slave hat gültiges Kommando empfangen: - // 2.result auswerten: - // recBuffer[3]; // Write result, d.h. Ergebnis des Schreibvorganges (z.B. DOs) des Slaves - // recBuffer[4]; // Read result, d.h. Ergebnis des Lesevorganges (z.B. DIs) des Slaves - // bisher nicht bekannt welche Fehlercodes es gibt, also den code direkt ausgeben. - // bisher bekannt: 0=OK - - myString.clear(); - myString = "Slave OUT and IN Result: "; - tempStr.setNum(Inbuf[3],16); - myString.append(tempStr); - myString.append(" "); - tempStr.setNum(Inbuf[4],16); - myString.append(tempStr); - gpi_setTxt4resultStateLine(myString); - return 0; -} - - - -uint8_t T_prot::ShowFastInData(uint8_t *recBuffer) -{ - QString myString=nullptr, tempStr=nullptr; - uint8_t result; - - RecSlaveAddr=0; - result=recBuffer[1]; // total result - result &=0x60; // only read result (bit 5,6) - - if (result==0) // read result =OK, - // dann sind die Eingangsdaten gültig - { - myString.append("valid INdata: "); - INdataValid=true; - //readSource already set with sending - readAddress=0; - // RdDataLength already set with sending - if (RdDataLength>FRAME_DATALEN) - RdDataLength=FRAME_DATALEN; - for (int ii=0; iiFRAME_DATALEN) - RdDataLength=FRAME_DATALEN; - for (int ii=0; ii -#include -#include -#include "tslib.h" -#include "sendWRcmd.h" - - -void indat_PrnPwr(void); - - -void sendWRcmd_INI(void) -{ - - sendWRcmd_clrCmdStack(); - sendWRcmd_clrCmd4Stack(); - sendFDcmd_clrStack(); - longFDcmd_clrStack(); -} - -// Command Stack for commands without parameters - - -static uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH]; -static uint8_t nrOfCmdsInQueue; -/* convention: use simple (not rotating) FIFO Stack: -Example: nrOfCmdsInQueue=4 then - nextAsynchsendCmd0[0]=cmd1 // was stored as first - nextAsynchsendCmd0[1]=cmd2 - nextAsynchsendCmd0[2]=cmd3 - nextAsynchsendCmd0[3]=cmd4 // came in as last - - Send: [0] first, then move buffer 1 down: - nextAsynchsendCmd0[0]=cmd2 - nextAsynchsendCmd0[1]=cmd3 - nextAsynchsendCmd0[2]=cmd4 - nextAsynchsendCmd0[3]=0; - nrOfCmdsInQueue=3 now -*/ - -void sendWRcmd_clrCmdStack(void) -{ - uint8_t nn; - for (nn=0; nn=CMDSTACKDEPTH) - { - qDebug() << "cannot save cmd because stack is full"; - return false; // not possible - } - nextAsynchsendCmd0[nrOfCmdsInQueue++]=nextCmd; - //qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue; - return true; // ok, will be sent -} - -uint16_t sendWRcmd_getSendCommand0(void) -{ - uint16_t nxtAsynchCmd; - uint8_t nn, ll; - if (nrOfCmdsInQueue==0 || nrOfCmdsInQueue>CMDSTACKDEPTH) - return 0; // error - nxtAsynchCmd=nextAsynchsendCmd0[0]; - - // move Puffer down by one element - if (CMDSTACKDEPTH>0) - ll=CMDSTACKDEPTH-1; - else - ll=0; - for (nn=0; nn0) - nrOfCmdsInQueue--; - //qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue; - return nxtAsynchCmd; -} - -//--------------------------------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------------------------------- -// Command Stack for commands with 4 parameters - - - -static uint16_t nextAsynchsendCmd4[CMD4STACKDEPTH]; -static uint8_t nextCmd4para1[CMD4STACKDEPTH]; -static uint8_t nextCmd4para2[CMD4STACKDEPTH]; -static uint8_t nextCmd4para3[CMD4STACKDEPTH]; -static uint8_t nextCmd4para4[CMD4STACKDEPTH]; -static uint8_t nrOfCmds4InQueue; -/* convention: use simple (not rotating) FIFO Stack: -Example: nrOfCmdsInQueue=4 then - nextAsynchsendCmd0[0]=cmd1 // was stored as first - nextAsynchsendCmd0[1]=cmd2 - nextAsynchsendCmd0[2]=cmd3 - nextAsynchsendCmd0[3]=cmd4 // came in as last - - Send: [0] first, then move buffer 1 down: - nextAsynchsendCmd0[0]=cmd2 - nextAsynchsendCmd0[1]=cmd3 - nextAsynchsendCmd0[2]=cmd4 - nextAsynchsendCmd0[3]=0; - nrOfCmdsInQueue=3 now -*/ - - -void sendWRcmd_clrCmd4Stack(void) -{ - uint8_t nn; - for (nn=0; nn=CMD4STACKDEPTH) - { - qDebug() << "cannot save cmd because stack is full"; - return false; // not possible - } - nextAsynchsendCmd4[nrOfCmds4InQueue]=nextCmd; - nextCmd4para1[nrOfCmds4InQueue]=dat1; - nextCmd4para2[nrOfCmds4InQueue]=dat2; - nextCmd4para3[nrOfCmds4InQueue]=dat3; - nextCmd4para4[nrOfCmds4InQueue]=dat4; - //qDebug() << "data with 4 data byte saved, pp=" << nrOfCmds4InQueue; - //qDebug() << " dat1=" << nextCmd4para1[nrOfCmds4InQueue] << " dat2=" << nextCmd4para2[nrOfCmds4InQueue] - // << " dat3=" << nextCmd4para3[nrOfCmds4InQueue] << " dat4=" << nextCmd4para4[nrOfCmds4InQueue]; - nrOfCmds4InQueue++; - return true; // ok, will be sent -} - -uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4) -{ - uint16_t nxtAsynchCmd; - uint8_t nn, ll; - - if (nrOfCmds4InQueue==0 || nrOfCmds4InQueue>CMD4STACKDEPTH) - return 0; // error - nxtAsynchCmd=nextAsynchsendCmd4[0]; - *dat1=nextCmd4para1[0]; - *dat2=nextCmd4para2[0]; - *dat3=nextCmd4para3[0]; - *dat4=nextCmd4para4[0]; - //qDebug() << "cmd4 restored to send from [0]; pp=" << nrOfCmds4InQueue; - //qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] << - // " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0]; - - // move Puffer down by one element - if (CMD4STACKDEPTH>0) - ll=CMD4STACKDEPTH-1; - else - ll=0; - for (nn=0; nn0) - nrOfCmds4InQueue--; - //qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue; - return nxtAsynchCmd; -} - - - - - -static uint16_t nextAsynchsendCmd8[CMD8STACKDEPTH]; -static uint8_t nextCmd8para1[CMD8STACKDEPTH]; -static uint8_t nextCmd8para2[CMD8STACKDEPTH]; -static uint16_t nextCmd8para3[CMD8STACKDEPTH]; -static uint32_t nextCmd8para4[CMD8STACKDEPTH]; -static uint8_t nrOfCmds8InQueue; - -void sendWRcmd_clrCmd8Stack(void) -{ - uint8_t nn; - for (nn=0; nn=CMD8STACKDEPTH) - { - qDebug() << "cannot save cmd because stack is full"; - return false; // not possible - } - nextAsynchsendCmd8[nrOfCmds8InQueue]=nextCmd; - nextCmd8para1[nrOfCmds8InQueue]=dat1; - nextCmd8para2[nrOfCmds8InQueue]=dat2; - nextCmd8para3[nrOfCmds8InQueue]=dat3; - nextCmd8para4[nrOfCmds8InQueue]=dat4; - nrOfCmds8InQueue++; - return true; // ok, will be sent -} - -uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4) -{ - uint16_t nxtAsynchCmd; - uint8_t nn, ll; - - if (nrOfCmds8InQueue==0 || nrOfCmds8InQueue>CMD8STACKDEPTH) - return 0; // error - nxtAsynchCmd=nextAsynchsendCmd8[0]; - *dat1=nextCmd8para1[0]; - *dat2=nextCmd8para2[0]; - *dat3=nextCmd8para3[0]; - *dat4=nextCmd8para4[0]; - - // move buffer down by one element - if (CMD8STACKDEPTH>0) - ll=CMD8STACKDEPTH-1; - else - ll=0; - for (nn=0; nn0) - nrOfCmds8InQueue--; - return nxtAsynchCmd; -} - - - - - - - -static uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer -static uint8_t sendAsyDatLen; - -bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf) -{ - //qDebug() << "pi epi: storing send data"; - if (leng>160) leng=160; - sendAsyDatLen=leng; - tslib_strclr(sendAsynchDataBuf, 0, 160); - for (uint8_t nn=0; nn=MAXNROF_PRNBLOCKS) - return 1; // not possible, no free mem - - //len=tslib_strlen(buf); // kennt keine Binärzeichen!!!!!! - len=leng; - if (len>MAXNROF_PRNBYTES) - len=MAXNROF_PRNBYTES; - - tslib_strclr(Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES); - - for (nn=0; nn0) - pPrnDataBuff--; - pp=pPrnDataBuff; - // example: pp=4: then buffers [0...3] are still occupied, pp=0: all buffers empty - - // now clear highest copyed line (which got free now) - tslib_strclr(Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES); - - // optionally: clear all remaining higher lines: - for (nn=(pp+1); nn0: nr of 64byte-blocks - return (pPrnDataBuff); -} - - - - - - - - - - -// --------------------------------------------------------------------------------- -// 11.4.23 neu, Kommando direkt an "FastDevice"-protokoll senden, nicht mehr umsetzen -// --------------------------------------------------------------------------------- - - -// short command, 4 data bytes -static uint8_t nextFDwrCmd[FDCMD_STACKDEPTH]; -static uint8_t nextFDrdCmd[FDCMD_STACKDEPTH]; -static uint8_t nextFDblkNr[FDCMD_STACKDEPTH]; - -static uint8_t nextFDpara1[FDCMD_STACKDEPTH]; -static uint8_t nextFDpara2[FDCMD_STACKDEPTH]; -static uint8_t nextFDpara3[FDCMD_STACKDEPTH]; -static uint8_t nextFDpara4[FDCMD_STACKDEPTH]; -static uint8_t p_nextFDcmdsInQueue; -/* convention: use simple (not rotating) FIFO Stack: -Example: nrOfCmdsInQueue=4 then - nextAsynchsendCmd0[0]=cmd1 // was stored as first - nextAsynchsendCmd0[1]=cmd2 - nextAsynchsendCmd0[2]=cmd3 - nextAsynchsendCmd0[3]=cmd4 // came in as last - - Send: [0] first, then move buffer 1 down: - nextAsynchsendCmd0[0]=cmd2 - nextAsynchsendCmd0[1]=cmd3 - nextAsynchsendCmd0[2]=cmd4 - nextAsynchsendCmd0[3]=0; - nrOfCmdsInQueue=3 now -*/ - - -void sendFDcmd_clrStack(void) -{ - uint8_t nn; - for (nn=0; nn=FDCMD_STACKDEPTH) - { - qDebug() << "cannot save cmd because stack is full"; - return false; // not possible - } - nextFDwrCmd[p_nextFDcmdsInQueue]=nextWrCmd; - nextFDrdCmd[p_nextFDcmdsInQueue]=nextRdCmd; - nextFDblkNr[p_nextFDcmdsInQueue]=blockNum; - nextFDpara1[p_nextFDcmdsInQueue]=dat1; - nextFDpara2[p_nextFDcmdsInQueue]=dat2; - nextFDpara3[p_nextFDcmdsInQueue]=dat3; - nextFDpara4[p_nextFDcmdsInQueue]=dat4; - //qDebug() << "data with 4 data byte saved, pp=" << nrOfCmds4InQueue; - //qDebug() << " dat1=" << nextCmd4para1[nrOfCmds4InQueue] << " dat2=" << nextCmd4para2[nrOfCmds4InQueue] - // << " dat3=" << nextCmd4para3[nrOfCmds4InQueue] << " dat4=" << nextCmd4para4[nrOfCmds4InQueue]; - p_nextFDcmdsInQueue++; - return true; // ok, will be sent -} - -bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4) -{ - uint8_t nn, ll; - - if (p_nextFDcmdsInQueue==0 || p_nextFDcmdsInQueue>FDCMD_STACKDEPTH) - return false; // not possible - - *nextWrCmd=nextFDwrCmd[0]; - *nextRdCmd=nextFDrdCmd[0]; - *blockNum=nextFDblkNr[0]; - *dat1=nextFDpara1[0]; - *dat2=nextFDpara2[0]; - *dat3=nextFDpara3[0]; - *dat4=nextFDpara4[0]; - //qDebug() << "cmd4 restored to send from [0]; pp=" << nrOfCmds4InQueue; - //qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] << - // " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0]; - - // move Puffer down by one element - if (FDCMD_STACKDEPTH>0) - ll=FDCMD_STACKDEPTH-1; - else - ll=0; - for (nn=0; nn0) - p_nextFDcmdsInQueue--; - //qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue; - return true; // ok, will be sent -} - -uint8_t check4FDshortCmd(void) -{ - // returns number of waiting command, max FDCMD_STACKDEPTH - return p_nextFDcmdsInQueue; -} - - -uint8_t check4freeFDshortCmd(void) -{ - // returns number of free places in short-command stack - return FDCMD_STACKDEPTH - p_nextFDcmdsInQueue; -} - - -// long command, 64 data bytes -static uint8_t longFDwrCmd[FDLONG_STACKDEPTH]; -static uint8_t longFDrdCmd[FDLONG_STACKDEPTH]; -static uint8_t longFDblkNr[FDLONG_STACKDEPTH]; -static uint8_t longFDlength[FDLONG_STACKDEPTH]; - -static uint8_t longFDpara[FDLONG_STACKDEPTH][64]; -static uint8_t p_longFDcmdsInQueue; - - -void longFDcmd_clrStack(void) -{ - uint8_t nn, mm; - for (nn=0; nn=FDLONG_STACKDEPTH) - { - qDebug() << "cannot save cmd because stack is full"; - return false; // not possible - } - longFDwrCmd[p_longFDcmdsInQueue]=nextWrCmd; - longFDrdCmd[p_longFDcmdsInQueue]=nextRdCmd; - longFDblkNr[p_longFDcmdsInQueue]=blockNum; - longFDlength[p_longFDcmdsInQueue]=length; - for (nn=0; nn<64; nn++) - longFDpara[p_longFDcmdsInQueue][nn]=data[nn]; - - p_longFDcmdsInQueue++; - return true; // ok, will be sent -} - -bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data) -{ - uint8_t nn, mm, ll; - - if (p_longFDcmdsInQueue==0 || p_longFDcmdsInQueue>FDLONG_STACKDEPTH) - return false; // not possible - - *nextWrCmd= longFDwrCmd[0]; - *nextRdCmd= longFDrdCmd[0]; - *blockNum = longFDblkNr[0]; - *length = longFDlength[0]; - for (mm=0; mm<64; mm++) - data[mm] = longFDpara[0][mm]; - - // move Puffer down by one element - if (FDLONG_STACKDEPTH>0) - ll=FDLONG_STACKDEPTH-1; - else - ll=0; - for (nn=0; nn0) - p_longFDcmdsInQueue--; - - return true; // ok, will be sent -} - -uint8_t check4FDlongCmd(void) -{ - // returns number of waiting command - return p_longFDcmdsInQueue; -} - -uint8_t check4freeFDlongCmd(void) -{ - // returns number of free places in command stack - return FDLONG_STACKDEPTH - p_longFDcmdsInQueue; -} - - - - -static uint8_t Sdata_DeviceParameter[64]; -static uint8_t Sdata_DevParaLen; - -uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf) -{ - // HWapi writes data to be stored - uint8_t nn; - for (nn=0; nn -#include - -#ifdef QT_POSIX_IPC - // The POSIX backend can be explicitly selected using the -feature-ipc_posix - // option to the Qt configure script. If it is enabled, the QT_POSIX_IPC - // macro will be defined. -> we use SystemV shared memory -#error "QT_POSIX_IPC defined" -#else -#include // ftok -#endif - -// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false}; - -QSharedMemory *SharedMemBuffer::getShm(std::size_t size) { - static QSharedMemory shMem; - if (size > 0) { - static const long nativeKey = ftok("/etc/os-release", 'H'); - static const QString fkey = std::to_string(nativeKey).c_str(); - shMem.setKey(fkey); - if (!shMem.isAttached()) { - if (shMem.create(size)) { - return &shMem; - } else { - if (shMem.error() == QSharedMemory::AlreadyExists) { - if (shMem.attach()) { - return &shMem; - } - } - } - qCritical() << shMem.nativeKey() << shMem.key() << shMem.data() - << shMem.error() << shMem.errorString(); - return nullptr; - } - } - return &shMem; -} diff --git a/src/storeINdata.cpp b/src/storeINdata.cpp deleted file mode 100644 index dca481f..0000000 --- a/src/storeINdata.cpp +++ /dev/null @@ -1,1370 +0,0 @@ -#include -#include - -#include -#include -#include "storeINdata.h" -#include "tslib.h" -#include "shared_mem_buffer.h" - - -// gpi: grafical access to PI: access from external devices over device controller FOR GUI -// epi: external access from GUI to PI: FOR external devices (DC) - - -// store power on/off condition of the devices to control the data request - -static bool indat_savePrnPwr; - -void indat_storePrinterPower(bool isOn) { - indat_savePrnPwr=isOn; -} - -bool indat_isPrinterOn() { - return indat_savePrnPwr; -} - - -static bool indat_saveMifPwr; - -void indat_storeMifarePower(bool isOn) { - indat_saveMifPwr=isOn; -} - -bool indat_isMifareOn() { - return indat_saveMifPwr; -} - - -static bool indat_MdbIsOn; - -void indat_storeMDBisOn(bool isOn) { - indat_MdbIsOn=isOn; -} - -bool indat_isMdbOn() { - return indat_MdbIsOn; -} - - -// ////////////////////////////////////////////////////////////////////////// - - - -void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits, - uint8_t parity, uint8_t NrStopBits) { - // store numbers - SharedMemBuffer::getData()->ndbs = NrDataBits; - SharedMemBuffer::getData()->pari = parity; - SharedMemBuffer::getData()->nsb = NrStopBits; - SharedMemBuffer::getData()->br = slaveBaudRate; -} - -void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits, - uint8_t *parity, uint8_t *NrStopBits) { - - *NrDataBits = SharedMemBuffer::getDataConst()->ndbs; - *parity = SharedMemBuffer::getDataConst()->pari; - *NrStopBits = SharedMemBuffer::getDataConst()->nsb; - *slaveBaudRate = SharedMemBuffer::getDataConst()->br; -} - -QString epi_getSlaveParamSTR() { - QString mySt; - - switch (SharedMemBuffer::getDataConst()->br) { - case 1: mySt="1200 ";break; - case 2: mySt="9600 ";break; - case 3: mySt="19200 ";break; - case 4: mySt="38400 ";break; - case 5: mySt="57600 ";break; - case 6: mySt="115200 ";break; - } - - char ctmp = SharedMemBuffer::getDataConst()->ndbs; - ctmp += 0x30; - mySt.append(ctmp); - ctmp = SharedMemBuffer::getDataConst()->pari; - mySt.append(ctmp); - ctmp = SharedMemBuffer::getDataConst()->nsb; - ctmp += 0x30; - mySt.append(ctmp); - return mySt; -} - -// static QString genStrings[MAXNROF_GENSTR]; - // 0=HW 1=SW 2=State - -void gpi_storeGenerals(uint8_t genNr, QString text) { - // 0=HW 1=SW 2=State - if (genNr < MAXNROF_GENSTR) { - strncpy(&SharedMemBuffer::getData()->genStrings[genNr][0], - text.toStdString().c_str(), - sizeof(SharedMemBuffer::getDataConst()->genStrings[0])); - } - -} - -QString epi_loadGenerals(uint8_t genNr) { - if (genNr < MAXNROF_GENSTR) { - if (genNr==2) { // DC2 State is shorter (8byte, not 64) - //genStrings[2][8]=0; - SharedMemBuffer::getData()->genStrings[2][8] = '\0'; - } - return QString(SharedMemBuffer::getDataConst()->genStrings[genNr]); - } - return " "; -} - - - - -// ------------------------------- - -void gpi_storeUID(uint8_t const *buf8byteUid) { - uint64_t udltmp=0; - - for (int ii=0; ii<8; ii++) { - SharedMemBuffer::getData()->Sdata.UIDstr[ii] = buf8byteUid[ii]; - udltmp |= buf8byteUid[ii]; - udltmp <<= 8; - } - SharedMemBuffer::getData()->Sdata.slaveUID = udltmp; -} - -void epi_getUIDdec(uint8_t *buf8byteUid) { - for (int ii=0; ii<8; ii++) { - buf8byteUid[ii] = SharedMemBuffer::getDataConst()->Sdata.UIDstr[ii]; - } -} - -QString epi_getUIDstr() { - // die UID besteht aus 8 bytes (8 dezimalzahlen) - // -> umformen in hexstring - - QString myStr; - for (int ii=0;ii<8; ii++) { - myStr += QString::number(SharedMemBuffer::getDataConst()->Sdata.UIDstr[ii], 16); - myStr += " "; - } - return myStr; -} - -void gpi_backupSquareMode(uint8_t squMode) { - SharedMemBuffer::getData()->getGlobalTime.squareOutMode = squMode; -} - -uint8_t epi_getSquareMode() { - return SharedMemBuffer::getDataConst()->getGlobalTime.squareOutMode; -} - -void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng) { - /* - // Daten kommen in gleicher Reihenfolge vom Slave - uint8_t *pTime; - pTime=&getGlobalTime.hour; - if (Leng>44) Leng=44; // mehr brauch ma ned - for (int nn=0; nngetGlobalTime.second = Leng; // nur damit CompilerWarnung weg ist - - SharedMemBuffer::getData()->getGlobalTime.DayOfWeek = timeBuffer[0]; - SharedMemBuffer::getData()->getGlobalTime.minute = timeBuffer[1]; - SharedMemBuffer::getData()->getGlobalTime.second = timeBuffer[2]; - SharedMemBuffer::getData()->getGlobalTime.hour = timeBuffer[3]; - SharedMemBuffer::getData()->getGlobalTime.Year = timeBuffer[4]; - SharedMemBuffer::getData()->getGlobalTime.Month = timeBuffer[5]; - SharedMemBuffer::getData()->getGlobalTime.DayOfMonth = timeBuffer[6]; -} - -void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) { - *hh = SharedMemBuffer::getDataConst()->getGlobalTime.hour; - *mm = SharedMemBuffer::getDataConst()->getGlobalTime.minute; - *ss = SharedMemBuffer::getDataConst()->getGlobalTime.second; -} - -void epi_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) { - *yy = SharedMemBuffer::getDataConst()->getGlobalTime.Year; - *mm = SharedMemBuffer::getDataConst()->getGlobalTime.Month; - *dd = SharedMemBuffer::getDataConst()->getGlobalTime.DayOfMonth; -} - -void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) { - *dow = SharedMemBuffer::getDataConst()->getGlobalTime.DayOfWeek; - *minOfToday = SharedMemBuffer::getDataConst()->getGlobalTime.MinutesOfToday; - *secOfToday = SharedMemBuffer::getDataConst()->getGlobalTime.SecondsOfToday; -} - -bool epi_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) { - *lastLeapYear = SharedMemBuffer::getDataConst()->getGlobalTime.lastLeap; - *NextLeapYear = SharedMemBuffer::getDataConst()->getGlobalTime.nextLeap; - return SharedMemBuffer::getDataConst()->getGlobalTime.IsLeapyear; -} - -bool epi_isLeapYear() { - return SharedMemBuffer::getDataConst()->getGlobalTime.IsLeapyear; -} - -void epi_getSpecialWeekTimeDate(uint8_t *DayOfWeek, - uint8_t *HoursOfWeek, - uint16_t *MinutesOfWeek) { - *DayOfWeek = SharedMemBuffer::getDataConst()->getGlobalTime.DayOfWeek; - *HoursOfWeek = SharedMemBuffer::getDataConst()->getGlobalTime.hoursOfWeek; - *MinutesOfWeek = SharedMemBuffer::getDataConst()->getGlobalTime.minOfWeek; -} - -void epi_getSpecialMonthTimeDate(uint8_t *DayOfMonth, - uint16_t *HoursOfMonth, - uint16_t *MinutesOfMonth) { - *DayOfMonth = SharedMemBuffer::getDataConst()->getGlobalTime.DayOfMonth; - *HoursOfMonth = SharedMemBuffer::getDataConst()->getGlobalTime.hoursOfMonth; - *MinutesOfMonth = SharedMemBuffer::getDataConst()->getGlobalTime.minOfMonth; -} - -void epi_getSpecialYearTimeDate(uint16_t *DayOfYear, - uint16_t *HoursOfYear, - uint32_t *MinutesOfYear) { - *DayOfYear = SharedMemBuffer::getDataConst()->getGlobalTime.dayOfYear; - *HoursOfYear = SharedMemBuffer::getDataConst()->getGlobalTime.hoursOfYear; - *MinutesOfYear = SharedMemBuffer::getDataConst()->getGlobalTime.minOfYear; -} - -QString epi_getRtcTimeStr(uint8_t timeStyle) { - // style: 0: hh:mm 1: hh:mm:ss - QString mystr=nullptr, tempStr=nullptr; - - tempStr.setNum(SharedMemBuffer::getDataConst()->getGlobalTime.hour, 10); - mystr=tempStr.rightJustified(2,'0',false); // macht feste Länge, 5->05 - mystr.append(':'); - tempStr.setNum(SharedMemBuffer::getDataConst()->getGlobalTime.minute, 10); - //mystr.append(tempStr); - mystr+=tempStr.rightJustified(2,'0',false); - //mystr.append(':'); // so - //mystr+=':'; // oder so, =gleich - - if (timeStyle==1) // hh:mm:ss - { - mystr.append(':'); - tempStr.setNum(SharedMemBuffer::getDataConst()->getGlobalTime.second, 10); - mystr.append(tempStr.rightJustified(2,'0',false)); // wie += - } - return mystr; -} - -QString epi_getRtcDateStr(uint8_t dateStyle) { - // 1=german dd.mm.yy 2=american yy/mm/dd 3=mm.dd.yy - QString tmpStr=nullptr, YYstr=nullptr, MMstr=nullptr, DDstr=nullptr, mystr=nullptr; - mystr.clear(); - - tmpStr.setNum(SharedMemBuffer::getDataConst()->getGlobalTime.Year, 10); - YYstr=tmpStr.rightJustified(4,'0',false); // immer vierstellig - YYstr[0]='2'; // 2000 dazu - - tmpStr.setNum(SharedMemBuffer::getDataConst()->getGlobalTime.Month, 10); - MMstr=tmpStr.rightJustified(2,'0',false); - - tmpStr.setNum(SharedMemBuffer::getDataConst()->getGlobalTime.DayOfMonth, 10); - DDstr=tmpStr.rightJustified(2,'0',false); - - if (dateStyle==1) // Germany dd.mm.yy - { - mystr=DDstr + '.' + MMstr + '.' + YYstr; - } else - if (dateStyle==2) // american yy/mm/dd - { - mystr=YYstr + '/' + MMstr + '/' + DDstr; - } else - // mm.dd.yy - { - mystr=MMstr + '.' + DDstr + '.' + YYstr; - } - return mystr; -} - - -QString epi_getSlaveTimeDateStr() { - QString myStr; - myStr=epi_getRtcTimeStr(1) + " " + epi_getRtcDateStr(1); - return myStr; - -} - - -// /////////////////////////////////////////////////////////////////////////////////// -// analog values -// /////////////////////////////////////////////////////////////////////////////////// - - -uint8_t gpi_getMaxNrAIs() { - return MAXNROF_AI; -} - -void gpi_storeAIs(uint8_t aiNr, uint16_t val) { - if (aiNr < MAXNROF_AI) { - SharedMemBuffer::getData()->AI_val[aiNr] = val; - } -} - -uint16_t epi_loadAIs(uint8_t aiNr) { - if (aiNr < MAXNROF_AI) { - return SharedMemBuffer::getDataConst()->AI_val[aiNr]; - } - return 0; -} - - -//-------------- -// measurement values -// ADC0: temp -// 1: voltage -// 2: brightness -#define MAXNROF_MEASURE 4 - -uint32_t epi_loadMeasureValue(uint8_t ValueNr) { - // ValueNr 0=ADC0, 1=ADC1 aso... - if (ValueNr < MAXNROF_MEASURE) { - return SharedMemBuffer::getDataConst()->Sdata.measurement[ValueNr]; - } - return 0; -} - -void gpi_storeMeasureValue(uint8_t ValueNr, uint32_t val) { - // in mV, also bis 65,535V - if (ValueNr < MAXNROF_MEASURE) { - SharedMemBuffer::getData()->Sdata.measurement[ValueNr] = val; - } -} - -QString epi_getSlaveTemperatureStr() { - char myStr[8], halfDegree=0, Minus=0, oneChar; - int16_t val=0, pp, einer, zehner; - QString myqStr; - - //qDebug() << "AIN0: " << epi_loadAIs(0) << "AIN1: " << epi_loadAIs(1); - - uint32_t meas_temper=epi_loadMeasureValue(MEASCHAN_TEMPERATURE); - // im SaxFormat gespeichert, hier umwandeln in String - - //qDebug() << "meas_temper: " << meas_temper; - - - for (pp=0; pp<8; pp++) myStr[pp]=0; - if (meas_temper&1) // ungerade, also ,5°C - { - halfDegree=1; - meas_temper &=0xFFFE; // um 0,5°C abrunden - } - if (meas_temper<100) - { - Minus=1; - val=int16_t(meas_temper)/2; - val-=50; - } else - { - val=int16_t(meas_temper)-100; - val/=2; - } - pp=0; // pointer auf string - if (Minus) - myStr[pp++]='-'; - // val is now 0..150 for pos Temp or 0..49 for negativ temperature - if (val<10) - { - // only one digit, just change to ascii - oneChar = char(val)+0x30; - if (tslib_isDecAsciiNumber(oneChar)) - myStr[pp++]=oneChar; - else - myStr[pp++]='0'; - } else - if (val<100) - { - // 10...99 - einer=val%10; - zehner=val/10; - //myStr[pp++]=char(zehner); - //myStr[pp++]=char(einer); - - oneChar = char(zehner)+0x30; - if (tslib_isDecAsciiNumber(oneChar)) - myStr[pp++]=oneChar; - else - myStr[pp++]='0'; - - oneChar = char(einer)+0x30; - if (tslib_isDecAsciiNumber(oneChar)) - myStr[pp++]=oneChar; - else - myStr[pp++]='0'; - - } else - { - // 100...150 - myStr[pp++]='1'; // hunderter Stelle immer 1 - val-=100; - einer=val%10; - zehner=val/10; - //myStr[pp++]=char(zehner)+0x30; - //myStr[pp++]=char(einer)+0x30; - oneChar = char(zehner)+0x30; - if (tslib_isDecAsciiNumber(oneChar)) - myStr[pp++]=oneChar; - else - myStr[pp++]='0'; - - oneChar = char(einer)+0x30; - if (tslib_isDecAsciiNumber(oneChar)) - myStr[pp++]=oneChar; - else - myStr[pp++]='0'; - } - myStr[pp++]=','; - if (halfDegree) - myStr[pp++]='5'; - else - myStr[pp++]='0'; - myqStr.clear(); - myqStr.append(myStr); - myqStr.append("°C"); - return myqStr; -} - -QString epi_getSlaveVoltageStr() -{ - // value in "meas_volt" in mV, also bis 65,535V. Value range [6000...16000] (6V...16V) - QString myqStr; - uint32_t vor, nach, tmp32; - uint16_t pp; - char myStr[12], ke; //, kz, kh; - - uint32_t ultmp=epi_loadMeasureValue(MEASCHAN_VOLTAGE); - for (pp=0; pp<12; pp++) myStr[pp]=0; - - //qDebug() << ultmp << "mV"; - - myqStr.clear(); - vor=ultmp/1000; - //qDebug() << "vor: " << vor; - - nach=ultmp%1000; - //qDebug() << "nach: " << nach; - pp=0; - if (vor>9) - { - myStr[pp++]=char(vor/10)+0x30; - } - myStr[pp++]=char(vor%10)+0x30; - myStr[pp++]=','; - - ke=char(nach/100); - //qDebug() << "ke: " << ke; - myStr[pp++]=char(ke)+0x30; - - tmp32=nach%100; - ke=char(tmp32/10); - //qDebug() << "ke: " << ke; - myStr[pp++]=char(ke)+0x30; - - tmp32=nach%10; - ke=char(tmp32); - //qDebug() << "ke: " << ke; - myStr[pp++]=char(ke)+0x30; - - - myStr[pp++]='V'; - myqStr.append(myStr); - return myqStr; -} - - - -// /////////////////////////////////////////////////////////////////////////////////// -// digital inputs -// /////////////////////////////////////////////////////////////////////////////////// - -/* come all in with 0x1201: -D0: upper door D1: low door D2:vault door -D3: cash box D4: bill box in -D5: bit 0: upper lockbar up bit1:down -D6: bit 0: lower lockbar up bit1:down - -D7: 0 -D7: DI_contact Power Is On - -D8: OptoIn 1,2 -D9: Aux0...5 -D10:Wake from ptu -D11: DI Wake From Mdb -D12: Ready from printer -D13: Coin Shutter Input -D14: CoinEscrow switch -D15: Mifare IN -D16: Modem_Wake In - -D18: DI Mif Pwr is on -D19: DI MDB_TxD_rdBack -D20: DI Aux Pwr is on -D21: DI GSM Pwr from PO2 is ON -D22: DI Credit Pwr from PO2 is on - =DI RdBack Credit Wake -D23: DI Printer Pwr from PO2 is on -D24: DI MDB Pwr from PO2 is on - */ - -void gpi_storeDI_doorSwitches(uint8_t upperDoor, - uint8_t lowerDoor, - uint8_t vaultDoor) { - SharedMemBuffer::getData()->din.doorSwitch = 0; - if (upperDoor) SharedMemBuffer::getData()->din.doorSwitch |= 1; - if (lowerDoor) SharedMemBuffer::getData()->din.doorSwitch |= 2; - if (vaultDoor) SharedMemBuffer::getData()->din.doorSwitch |= 4; -} - -uint8_t epi_getDI_doorSwitches(void) { - // bit0: upper door 1: low door 2:vault door - return SharedMemBuffer::getDataConst()->din.doorSwitch; -} - -void gpi_storeDI_vaultSwitches(uint8_t CashBoxIn, uint8_t BillBoxIn) { - SharedMemBuffer::getData()->din.vaultSwitch = 0; - if (CashBoxIn) SharedMemBuffer::getData()->din.vaultSwitch |= 1; - if (BillBoxIn) SharedMemBuffer::getData()->din.vaultSwitch |= 2; -} - -uint8_t epi_getDI_vaultSwitches(void) { - // bit0: cash box 1: bill box in - return SharedMemBuffer::getData()->din.vaultSwitch; -} - -void gpi_storeDI_lockSwitches(uint8_t indatUL, uint8_t indatLL) { - // D5: bit 0: upper lockbar up bit1:down - // D6: bit 0: lower lockbar up bit1:down - SharedMemBuffer::getData()->din.lockSwitch = 0; - if (indatUL & 1) SharedMemBuffer::getData()->din.lockSwitch |= 1; - if (indatUL & 2) SharedMemBuffer::getData()->din.lockSwitch |= 2; - if (indatLL & 1) SharedMemBuffer::getData()->din.lockSwitch |= 4; - if (indatLL & 2) SharedMemBuffer::getData()->din.lockSwitch |= 8; -} - -uint8_t epi_getDI_lockSwitches(void) { - // retval: bit 0: upper lockbar up bit1: upper lockbar is down - // bit 2: lower lockbar up bit1: lower lockbar is down - return SharedMemBuffer::getData()->din.lockSwitch; -} - -void gpi_storeDI_optos(uint8_t indatOpto) { - // OptoIn bit 0,1: optoin 1,2 - SharedMemBuffer::getData()->din.opto = 0; - if (indatOpto & 1) SharedMemBuffer::getData()->din.opto |= 1; - if (indatOpto & 2) SharedMemBuffer::getData()->din.opto |= 2; -} - -uint8_t epi_getDI_optos(void) { - // bit0: opto in 1 1: opto in 2 - return SharedMemBuffer::getDataConst()->din.opto; -} - -uint8_t gpi_storeDI_auxIn(uint8_t aux) { // Aux0...5 - return SharedMemBuffer::getData()->din.aux = aux; -} - -uint8_t epi_getDI_auxIn(void) { // bit0: auxin 1 ... 5: auxin 6 - return SharedMemBuffer::getDataConst()->din.aux; -} - -bool gpi_storeDI_ptuWake(bool w) { - return SharedMemBuffer::getData()->din.wakeFromPtu = w; -} - -bool epi_getDI_ptuWake(void) { - return SharedMemBuffer::getDataConst()->din.wakeFromPtu; -} - -bool gpi_storeDI_mbdWake(bool w) { - return SharedMemBuffer::getData()->din.wakeFromMdb = w; -} - -bool epi_getDI_mdbWake(void) { - return SharedMemBuffer::getDataConst()->din.wakeFromMdb; -} - -bool gpi_storeDI_prnReady(bool ready) { - return SharedMemBuffer::getData()->din.PrnReady = ready; -} - -bool epi_getDI_prnReady(void) { - return SharedMemBuffer::getDataConst()->din.PrnReady; -} - -bool gpi_storeDI_CoinAttach(bool attach) { - return SharedMemBuffer::getData()->din.CoinAttach = attach; -} - -bool epi_getDI_CoinAttach(void) { - return SharedMemBuffer::getDataConst()->din.CoinAttach; -} - -bool gpi_storeDI_CoinEscrow(bool ce) { - return SharedMemBuffer::getData()->din.CoinEscrowOpen = ce; -} - -bool epi_getDI_CoinEscrow(void) { - return SharedMemBuffer::getDataConst()->din.CoinEscrowOpen; -} - -bool gpi_storeDI_mifareCardTapped(bool tapped) { - return SharedMemBuffer::getData()->din.mifCardTap = tapped; -} - -bool epi_getDI_mifareCardTapped(void) { - return SharedMemBuffer::getDataConst()->din.mifCardTap; -} - -bool gpi_storeDI_modemWake(bool w) { - return SharedMemBuffer::getData()->din.wakeFromModem = w; -} - -bool epi_getDI_modemWake(void) { - return SharedMemBuffer::getDataConst()->din.mifCardTap; -} - -bool gpi_storeDI_contactPowerIsOn(bool on) { - return SharedMemBuffer::getData()->din.contactPwrOn = on; -} - -bool epi_getDI_contactPwr(void) { // invertiert! - return !SharedMemBuffer::getDataConst()->din.contactPwrOn; -} - -bool gpi_storeDI_MifarePowerIsOn(bool on) { - return SharedMemBuffer::getData()->din.mifarePwrOn = on; -} - -bool epi_getDI_mifarePwr(void) { - return SharedMemBuffer::getDataConst()->din.mifarePwrOn; -} - -bool gpi_storeDI_readbackMdbTxD(bool rdbkMdbTxd) { - return SharedMemBuffer::getData()->din.rdbk_mdbTxd = rdbkMdbTxd; -} - -bool epi_getDI_mdbTxd(void) { - return SharedMemBuffer::getDataConst()->din.rdbk_mdbTxd; -} - -bool gpi_storeDI_AuxPowerIsOn(bool on) { - return SharedMemBuffer::getData()->din.AuxPwrOn = on; -} - -bool epi_getDI_auxPwr(void) { - return SharedMemBuffer::getDataConst()->din.AuxPwrOn; -} - -bool gpi_storeDI_GsmPowerIsOn(bool on) { - return SharedMemBuffer::getData()->din.gsmPwrOn = on; -} - -bool epi_getDI_gsmPwr(void) { - return SharedMemBuffer::getDataConst()->din.gsmPwrOn; -} - -bool gpi_storeDI_CreditPowerIsOn(bool on) { - // invertieren!!! - return SharedMemBuffer::getData()->din.creditPwrOn = !on; -} - -bool epi_getDI_creditPwr(void) { - return SharedMemBuffer::getDataConst()->din.creditPwrOn; -} - -bool gpi_storeDI_PrinterPowerIsOn(bool on) { - return SharedMemBuffer::getData()->din.printerPwrOn = on; -} - -bool epi_getDI_printerPwr(void) { - return SharedMemBuffer::getDataConst()->din.printerPwrOn; -} - -bool gpi_storeDI_MdbPowerIsOn(bool on) { - return SharedMemBuffer::getData()->din.mdbPwrOn = on; -} - -bool epi_getDI_mdbPwr(void) { - return SharedMemBuffer::getDataConst()->din.mdbPwrOn; -} - -bool gpi_storeDI_rejMot_home(bool reject) { - return SharedMemBuffer::getData()->din.rejMot_home = reject; -} - -bool epi_getDI_rejectMotor_homepos(void) { - return SharedMemBuffer::getDataConst()->din.rejMot_home; -} - -uint8_t gpi_storeDI_paperLow(uint8_t sensor) { - // 0: Sensor sees paper 1: no paper 99: off - return SharedMemBuffer::getData()->din.npe_sensor = sensor; -} - -uint8_t epi_getDI_npe_sensor(void) { - return SharedMemBuffer::getDataConst()->din.npe_sensor; -} - - - -// /////////////////////////////////////////////////////////////////////////////////// -// readaback digital outputs -// /////////////////////////////////////////////////////////////////////////////////// - - -/* -D0 bit0: MDB devices 0=off 1=on - bit1: MDB bus power - bit2: MDB WakeOut - -D1=Printer -D2=Credit -D3=Modem - -D5: serial drv on/off, Serial mux1, Serial mux2 -D6: Leds, Fan, -D7: Siren and relay -D8: PtuWakeOut -D9: Power Aux/Barcode -D10: AuxDir 1...6 -D11: AuxOut 1...6 -D12: Coin shutter output -D13: CoinEscrow Outputs -*/ - -uint8_t gpi_storeDO_mdbRxTst(uint8_t mdbRxTst) { - return SharedMemBuffer::getData()->dout.mbdRxTst = mdbRxTst; -} - -bool epi_getDO_mdbRxTestOut(void) { - return SharedMemBuffer::getData()->dout.mbdRxTst & 1; -} - -uint8_t gpi_storeDO_motorOutputs(uint8_t motorBits) { - //D1: motor outputs bit0: upper lock forw bit 1 backw - // Bit2: lowLock forw bit3: LL backw - return SharedMemBuffer::getData()->dout.motorBits = motorBits; -} - -uint8_t epi_getDO_motorOuts(void) { - // bit0: upper lock forward bit 1 backward - // bit2: lower lock forward bit 3 backward - return SharedMemBuffer::getDataConst()->dout.motorBits; -} - -uint8_t gpi_storeDO_serialSwitch(uint8_t serialSwitch) { // serial drv on/off, Serial mux1, Serial mux2 - return SharedMemBuffer::getData()->dout.serialSwitch = serialSwitch; -} - -uint8_t epi_getDO_serialSwitch(void) { - // serial drv on/off, Serial mux1, Serial mux2 - return SharedMemBuffer::getDataConst()->dout.serialSwitch; -} - -bool epi_getDO_serialDriverIsOn(void) { - return SharedMemBuffer::getDataConst()->dout.serialSwitch & 1; -} - -bool epi_getDO_serialMux1isSetToPrinter(void) { - // mux1 off: serial is switched to printer - return (SharedMemBuffer::getDataConst()->dout.serialSwitch & 2) == 0; -} - -bool epi_getDO_serialMux1isSetToModem(void) { - // mux1 on: serial is switched to modem - return (SharedMemBuffer::getDataConst()->dout.serialSwitch & 2) > 0; -} - -bool epi_getDO_serialMux2isSetToCredit(void) { - // mux2 off: serial is switched to credit card terminal - return (SharedMemBuffer::getDataConst()->dout.serialSwitch & 4) == 0; -} - -bool epi_getDO_serialMux2isSetToMifare(void) { - // mux2 on: serial is switched to mifare reader - return (SharedMemBuffer::getDataConst()->dout.serialSwitch & 4) > 0; -} - -uint8_t gpi_storeDO_ledsAndFan(uint8_t ledState) { - // bit0: coinled 1:front_illu 2: paper-led 3:pinpad-led 4:start-led 5:service-led 6:fan - return SharedMemBuffer::getData()->dout.ledsAndFan = ledState; -} - -bool epi_getDO_led_coin(void) { - return (SharedMemBuffer::getDataConst()->dout.ledsAndFan & 1); -} - -bool epi_getDO_led_front(void) { - return (SharedMemBuffer::getDataConst()->dout.ledsAndFan & 2); -} - -bool epi_getDO_led_ticket(void) { - return (SharedMemBuffer::getDataConst()->dout.ledsAndFan & 4); -} - -bool epi_getDO_led_pin(void) { - return (SharedMemBuffer::getDataConst()->dout.ledsAndFan & 8); -} - -bool epi_getDO_led_start(void) { - return (SharedMemBuffer::getDataConst()->dout.ledsAndFan & 16); -} - -bool epi_getDO_led_inside(void) { - return (SharedMemBuffer::getDataConst()->dout.ledsAndFan & 32); -} - -bool epi_getDO_fan(void) { - return (SharedMemBuffer::getDataConst()->dout.ledsAndFan & 64); -} - -uint8_t gpi_storeDO_sirenAndRelay(uint8_t sirenRelay) { - // bit0: siren 1:relay - return SharedMemBuffer::getData()->dout.laermUndRelay = sirenRelay; -} - -bool epi_getDO_sirene(void) { - return SharedMemBuffer::getDataConst()->dout.laermUndRelay & 1; -} - -bool epi_getDO_relay(void) { - return SharedMemBuffer::getDataConst()->dout.laermUndRelay & 2; -} - -uint8_t gpi_storeDO_ptuWake(uint8_t state) { - return SharedMemBuffer::getData()->dout.ptuWake = state; -} - -bool epi_getDO_ptuWake(void) { - return SharedMemBuffer::getDataConst()->dout.ptuWake > 0; -} - -uint8_t gpi_storeDO_auxPower(uint8_t pwr) { - return SharedMemBuffer::getData()->dout.auxPower = pwr; -} - -bool epi_getDO_auxPower(void) { - return SharedMemBuffer::getDataConst()->dout.auxPower > 0; -} - -uint8_t gpi_storeDO_coinShutter(uint8_t state) { - return SharedMemBuffer::getData()->dout.coinShutter = state; -} - -bool epi_getDO_coinShutterOpen(void) { - // bit0: Coin shutter output, bit1: input-test-output - return SharedMemBuffer::getDataConst()->dout.coinShutter & 1; -} - -bool epi_getDO_coinShutterTest(void) { - // bit0: Coin shutter output, bit1: input-test-output - return SharedMemBuffer::getDataConst()->dout.coinShutter & 2; -} - -uint8_t gpi_storeDO_coinEscrow(uint8_t state) { - return SharedMemBuffer::getData()->dout.coinEscrow = state; -} - -uint8_t epi_getDO_coinEscrow(void) { - // retval: 1:return flap is open 2:take flap is open 0:closed - if (SharedMemBuffer::getData()->dout.coinEscrow & 1) { - return 1; // return flap is open - } - if (SharedMemBuffer::getData()->dout.coinEscrow & 2) { - return 2; // take flap is open - } - return 0; -} - -uint8_t gpi_storeDO_printerPwrOn(uint8_t state) { - return SharedMemBuffer::getData()->dout.printerPower = state; -} - -uint8_t epi_getDO_printerPwr(void) { - return SharedMemBuffer::getDataConst()->dout.printerPower; -} - -//------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------ -//----------------------------- Mifare Card Reader ----------------------------------- -uint8_t gpi_storeMifReaderStateAndCardType(uint8_t const *buf) { - // retval 0=OK 1=error host buffer too small - memset(SharedMemBuffer::getData()->Sdata.MIF_STATE, 0x00, - sizeof(SharedMemBuffer::getData()->Sdata.MIF_STATE)); - memcpy(SharedMemBuffer::getData()->Sdata.MIF_STATE, buf, 8); - return 0; // OK -} - -/* data description: - -new fast version: -byte 0= still the same: current read state: - 0=power off 1=reader-fault 2=ready - 3=just reading 4=read complete - 5=read partial, removed too early - 6=state unknown - -byte 1: reader state 1=ok 0=nok -byte 2: card preent (0,1) -byte 3: card selected (0) -byte 4: card type: 0...5 -byte 5: card allowed (0=no 1=MifareClassic 1k or 4k) -byte 6: CardSize: 1 or 4 (kB) -byte 7: length of UID 4 or 7 (byte) - - -old long version -byte 0: current read state: 0=power off 1=reader-fault 2=ready - 3=just reading 4=read complete - 5=read partial, removed too early - 6=state unknown -byte 1,2: read data length from card -3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader -4...15: reader version, expected "SL025-1.8" -byte16: 1=card is present 0:not -17: 0 -18: card type reported from reader -19: 1=allowed card type 0=not -20: card size: 1 or 4 (dec) = card size -21: LengthOfUID: 4 or 7 (dec) (byte) -22: UID 8 byte in hex -byte 30: sector logged: 0 -byte 31: current sector: 0 -byte 32: result, always 0 -*/ - -uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize) { - // HWapi can read States from DC - if (maxBufferSize<8) { - return 1; // error - } - memcpy(buf, SharedMemBuffer::getData()->Sdata.MIF_STATE, 8); - return 0; // OK -} - -// data come in blockwise, so safe them blockwise as well -bool gpi_storeMifCardData(uint8_t blkNr, uint8_t const *receivedData) { - if (blkNr<12) { - memcpy(&SharedMemBuffer::getData()->Sdata.MIF_DATA[blkNr][0], receivedData, 64); - return true; - } - return false; -} - -uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) { - if (blkNr>11 || maxBufferSize<64) { - return 1; // error - } - - memcpy(buf, &SharedMemBuffer::getDataConst()->Sdata.MIF_DATA[blkNr][0], 64); - return 0; // ois OK -} - -void gpi_storeNewMifareCard(uint8_t typ, uint8_t const *holder) { - SharedMemBuffer::getData()->mif_cardType = typ; - strncpy((char *)holder, (char *)SharedMemBuffer::getData()->mif_cardHolder, 7); - SharedMemBuffer::getData()->mif_cardHolder[7] = '\0'; -} - -uint8_t epi_mifGetCardType(uint8_t const *holder) { - //holder[8] = name of card holder - // retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins - strncpy((char *)SharedMemBuffer::getData()->mif_cardHolder, (char *)holder, 7); - return SharedMemBuffer::getData()->mif_cardType; -} - -void epi_restorePrinterState(uint8_t *buf) { - memcpy((char *)buf, (char *)SharedMemBuffer::getData()->Sdata.PRN_STATE, - sizeof(SharedMemBuffer::getData()->Sdata.PRN_STATE)); -} - -void gpi_storePrinterState(uint8_t const *buf) { - memcpy((char *)SharedMemBuffer::getData()->Sdata.PRN_STATE, (char *)buf, - sizeof(SharedMemBuffer::getData()->Sdata.PRN_STATE)); -} - -void epi_restorePrinterFonts(uint8_t *buf) { - memcpy((char *)buf, (char *)SharedMemBuffer::getData()->Sdata.PRN_FONTS, - sizeof(SharedMemBuffer::getData()->Sdata.PRN_FONTS)); -} - -void gpi_storePrinterFonts(uint8_t const *buf) { - memcpy((char *)SharedMemBuffer::getData()->Sdata.PRN_FONTS, (char *)buf, - sizeof(SharedMemBuffer::getData()->Sdata.PRN_FONTS)); -} - -/* - qDebug()<<"printer fonts stored " <Sdata.mdb_busRdy = busReady; - SharedMemBuffer::getData()->Sdata.mdb_V12on = V12on; - SharedMemBuffer::getData()->Sdata.mdb_V5on = V5on; - return true; -} - -bool epi_restoreMdbBusReady(void) { - return SharedMemBuffer::getDataConst()->Sdata.mdb_busRdy; -} - -bool epi_restoreMdbV12Ready(void) { - return SharedMemBuffer::getDataConst()->Sdata.mdb_V12on; -} - -bool epi_restoreMdbV5Ready(void) { - return SharedMemBuffer::getDataConst()->Sdata.mdb_V5on; -} - -// last received mdb answer (from mdb device) -// only needed if a special command was sent directly -// DB0: mdb Device-Nr -// DB1: last sent mdb command -// DB2: nr of received (payload) data bytes (apart from ACK, can be 0....34) -// DB3...DB38: rec.data (payload) -void gpi_storeMdbResponse(uint8_t leng, uint8_t const *data) { - memset(&SharedMemBuffer::getData()->Sdata.RecBuff[0], 0x00, - sizeof(SharedMemBuffer::getData()->Sdata.RecBuff)); - SharedMemBuffer::getData()->Sdata.mdbNrOfRecData = leng; - memcpy((char *)&SharedMemBuffer::getData()->Sdata.RecBuff[0], - (char const *)data, leng); -} - -void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data) { - *leng = SharedMemBuffer::getDataConst()->Sdata.mdbNrOfRecData; - memcpy((char *)data, - (char *)&SharedMemBuffer::getDataConst()->Sdata.RecBuff[0], *leng); -} - -void gpi_storeEmpSettings(uint8_t leng, uint8_t const *data) { - leng = std::min(leng, (uint8_t)(64)); - memset(&SharedMemBuffer::getData()->Sdata.emp_settingsBuff[0], 0x00, - sizeof(SharedMemBuffer::getData()->Sdata.emp_settingsBuff)); - SharedMemBuffer::getData()->Sdata.empNrOfsettings = leng; - memcpy((char *)&SharedMemBuffer::getData()->Sdata.emp_settingsBuff[0], - (char const *)data, leng); -} - -void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data) { - *leng = SharedMemBuffer::getDataConst()->Sdata.empNrOfsettings; - memcpy((char *)data, - (char *)&SharedMemBuffer::getData()->Sdata.emp_settingsBuff[0], - *leng); -} - -// ...................................................................... -// Münzbuffer[10]: Münze für Münze auslesen (LIFO) -// 4.5.21 - -static void sub_enterData(uint8_t valid, uint8_t signal, - uint8_t error, uint16_t value) { - if (SharedMemBuffer::getDataConst()->ctr_gotCoin < MEMDEPTH_GOTCOINS) { - uint8_t const gc = SharedMemBuffer::getDataConst()->ctr_gotCoin; - SharedMemBuffer::getData()->gotCoin[gc].valid = valid; - SharedMemBuffer::getData()->gotCoin[gc].signal = signal; - SharedMemBuffer::getData()->gotCoin[gc].error = error; - SharedMemBuffer::getData()->gotCoin[gc].value = value; - } - SharedMemBuffer::getData()->ctr_gotCoin += 1; -} - -void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t const *data) { - // leng is number of coin record with 5 bytes each - uint8_t LL = leng; // nr of coin records - uint16_t vv, pp = 0; - - //while (LL>0) // with FastProtocol only one coin - { - vv=uchar2uint(data[pp+4], data[pp+3]); - sub_enterData(data[pp], data[pp+1], data[pp+2], vv ); - -//qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1] -// << " " <ctr_gotCoin; -} - -void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, - uint8_t *error, uint16_t *value) { - SharedMemBuffer::getData()->ctr_gotCoin -= 1; - if (SharedMemBuffer::getDataConst()->ctr_gotCoin < MEMDEPTH_GOTCOINS) { - uint8_t const gc = SharedMemBuffer::getDataConst()->ctr_gotCoin; - *valid = SharedMemBuffer::getDataConst()->gotCoin[gc].valid; - *signal = SharedMemBuffer::getDataConst()->gotCoin[gc].signal; - *error = SharedMemBuffer::getDataConst()->gotCoin[gc].error; - *value = SharedMemBuffer::getDataConst()->gotCoin[gc].value; - } -} - -void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t const *data) { // getestet am 12.4.23TS - leng = std::min(leng, (uint8_t)(64)); - SharedMemBuffer::getData()->Sdata.NrOfDeviceSetting = leng; - memset((char *)&SharedMemBuffer::getData()->Sdata.DeviceSettingBuff[0], - 0x00, sizeof(SharedMemBuffer::getData()->Sdata.DeviceSettingBuff)); - memcpy((char *)&SharedMemBuffer::getData()->Sdata.DeviceSettingBuff[0], - (char const *)data, leng); -} - -void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data) { // getestet am 12.4.23TS - *leng = SharedMemBuffer::getDataConst()->Sdata.NrOfDeviceSetting; - memcpy((char *)data, - (char const *)&SharedMemBuffer::getDataConst()->Sdata.DeviceSettingBuff[0], - *leng); -} - -void gpi_storeMachineIDsettings(uint8_t leng, uint8_t const *data) { - leng = std::min(leng, (uint8_t)(64)); - SharedMemBuffer::getData()->Sdata.NrOfMachineIDSetting = leng; - memset((char *)&SharedMemBuffer::getData()->Sdata.NrOfMachineIDBuff[0], - 0x00, sizeof(SharedMemBuffer::getData()->Sdata.NrOfMachineIDBuff)); - memcpy((char *)&SharedMemBuffer::getData()->Sdata.NrOfMachineIDBuff[0], - (char const *)data, leng); -} - -void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data) { - *leng = SharedMemBuffer::getDataConst()->Sdata.NrOfMachineIDSetting; - memcpy((char *)data, - (char const *)&SharedMemBuffer::getDataConst()->Sdata.NrOfMachineIDBuff[0], - *leng); -} - - -static uint8_t p_lastCoin; - -void epi_clearCurrentPayment(void) { - // call at beginning of coin collection - SharedMemBuffer::getData()->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, - uint16_t lastCoinType, uint16_t lastCoinValue) { - 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) { - return SharedMemBuffer::getDataConst()->store.insertedAmount; -} - -uint16_t epi_CurrentPaymentGetLastCoin(void) { - uint8_t pp = p_lastCoin; - if (pp==0) { - return 0; // noch keine Münze erhalten - } - if (pp>0) { - pp--; - } - return SharedMemBuffer::getDataConst()->store.lastCoinValue[pp]; -} - -bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values) { - // alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht - if (p_lastCoin==0) { - return false; - } - for (int nn=0; nn<64; nn++) { - types[nn] = SharedMemBuffer::getDataConst()->store.lastCoinType[nn]; - values[nn] = SharedMemBuffer::getDataConst()->store.lastCoinValue[nn]; - } - return true; -} - -void gpi_storeWakeSources(uint8_t const *receivedData) { - SharedMemBuffer::getData()->store.wakeSrc = 0; - for (int nn=5; nn>=0; nn--) { - uint8_t const uctmp = receivedData[nn]; - SharedMemBuffer::getData()->store.wakeSrc |= uctmp; - SharedMemBuffer::getData()->store.wakeSrc <<= 8; - } - SharedMemBuffer::getData()->store.wakeReason = receivedData[6]; - -} - -uint64_t epi_getWakeSources(void) { - return SharedMemBuffer::getDataConst()->store.wakeSrc; -} - -uint8_t epi_getWakeReason(void) -{ - return SharedMemBuffer::getDataConst()->store.wakeReason; -} - - - -void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data) { - leng = std::min(leng, (uint8_t)(64)); - SharedMemBuffer::getData()->store.rbDevParamLen = leng; - memset((char *)(&SharedMemBuffer::getData()->store.rbDevParams[0]), 0x00, - sizeof(SharedMemBuffer::getData()->store.rbDevParams)); - memcpy((char *)(&SharedMemBuffer::getData()->store.rbDevParams[0]), - (char const *)data, leng); -} - -void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data) { - *leng = SharedMemBuffer::getDataConst()->store.rbDevParamLen; - memcpy((char *)data, - (char const *)(&SharedMemBuffer::getData()->store.rbDevParams[0]), - *leng); -} - -// store device conditions -void gpi_storeDeviceConditions(uint8_t leng, uint8_t const *data) { - leng = std::min(leng, (uint8_t)(64)); - SharedMemBuffer::getData()->store.deviceCondLen = leng; - memset((char *)(&SharedMemBuffer::getData()->store.deviceCond[0]), 0x00, - sizeof(SharedMemBuffer::getData()->store.deviceCond)); - memcpy((char *)(&SharedMemBuffer::getData()->store.deviceCond[0]), - (char const *)data, leng); -} - -void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data) { - *leng = SharedMemBuffer::getDataConst()->store.deviceCondLen; - memcpy((char *)data, - (char const *)(&SharedMemBuffer::getData()->store.deviceCond[0]), - *leng); -} - - - -// store dynamic machine conditions -void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data) { - SharedMemBuffer::getData()->store.machCondLen = leng; - memset((char *)(&SharedMemBuffer::getData()->store.machCond[0]), 0x00, - sizeof(SharedMemBuffer::getData()->store.machCond)); - memcpy((char *)(&SharedMemBuffer::getData()->store.machCond[0]), - (char const *)data, leng); -} - -void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data) { - *leng = SharedMemBuffer::getDataConst()->store.machCondLen; - memcpy((char *)data, - (char const *)(&SharedMemBuffer::getData()->store.machCond[0]), - *leng); -} - -void gpi_storeDCbackupAccNr(uint8_t /*leng*/, uint8_t const *data) { - // if (leng > 32) { - // leng = 32; - // } - SharedMemBuffer::getData()->store.DcBackupAccNr[0] = uchar2uint(data[1], data[0]); - SharedMemBuffer::getData()->store.DcBackupAccNr[1] = uchar2uint(data[3], data[2]); - SharedMemBuffer::getData()->store.DcBackupAccNr[2] = uchar2uint(data[5], data[4]); - SharedMemBuffer::getData()->store.DcBackupAccNr[3] = uchar2uint(data[7], data[6]); - SharedMemBuffer::getData()->store.DcBackupAccNr[4] = uchar2uint(data[9], data[8]); - SharedMemBuffer::getData()->store.DcBackupAccNr[5] = uchar2uint(data[11], data[10]); - SharedMemBuffer::getData()->store.DcBackupAccNr[6] = uchar2uint(data[13], data[12]); - SharedMemBuffer::getData()->store.DcBackupAccNr[7] = uchar2uint(data[15], data[14]); - SharedMemBuffer::getData()->store.DcBackupNrOfAccNr = 8; -} - -void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs) { - // return accNrs[0..7] - *leng = SharedMemBuffer::getDataConst()->store.DcBackupNrOfAccNr; - for (int nn=0; nn<8; nn++) { - accNrs[nn] = SharedMemBuffer::getDataConst()->store.DcBackupAccNr[nn]; - } -} - -void epi_iniVRstorage(void) { - memset((char *)(&SharedMemBuffer::getData()->store.vaultrecord[0]), 0x00, - sizeof(SharedMemBuffer::getData()->store.vaultrecord)); - SharedMemBuffer::getData()->store.gotNrBlocksOfVaultRec = 0; -} - -void gpi_storeVaultRecord(uint8_t blkNr, uint8_t const *data) { - uint16_t start = blkNr; - - // setze pro Block ein bit, wir brauchen block 0...4 - // also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen - SharedMemBuffer::getData()->store.gotNrBlocksOfVaultRec |= (1<store.vaultrecord[start+ii] = data[ii]; - } -} - -bool epi_checkIfVaultRecordAvailable(void) { - return SharedMemBuffer::getDataConst()->store.gotNrBlocksOfVaultRec == 0x1F; -} - -bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf) { - *length = 0; - if (SharedMemBuffer::getDataConst()->store.gotNrBlocksOfVaultRec == 0x1F) { - *length = 320; - memcpy((char *)buf, - (char const *)SharedMemBuffer::getDataConst()->store.vaultrecord, - *length); - return true; - } - return false; -} - -void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins) { - SharedMemBuffer::getData()->store.amount = amount; - SharedMemBuffer::getData()->store.nrOfCoins = nrOfCoins; -} - -uint32_t epi_getCashBoxContent(void) { - return SharedMemBuffer::getDataConst()->store.amount; -} - -uint16_t epi_getNrOfCoinsInCashBox(void) { - return SharedMemBuffer::getDataConst()->store.nrOfCoins; -} - - - - - -void gpi_storeDcDataValid(bool isVal) -{ - SharedMemBuffer::getData()->store.dcDataValid = isVal; -} - - -bool gpi_areDcDataValid() -{ - return SharedMemBuffer::getDataConst()->store.dcDataValid; -} - - -bool epi_areDcDataValid() -{ - return SharedMemBuffer::getData()->store.dcDataValid; -} diff --git a/src/tslib.cpp b/src/tslib.cpp deleted file mode 100644 index a257256..0000000 --- a/src/tslib.cpp +++ /dev/null @@ -1,598 +0,0 @@ -#include "tslib.h" -#include - -//tslib::tslib() -//{ - - -//} - - -/* -uint16_t tslib::uchar2uint(uint8_t Highbyte, uint8_t Lowbyte) -{ - uint16_t uitmp; - uitmp=0; - uitmp |= uint8_t(Highbyte); - uitmp<<=8; - uitmp |= uint8_t(Lowbyte); - return uitmp; -} - -uint8_t tslib::uint2uchar(uint16_t uival, bool getHighB) -{ - // getHighB: low=GetLowByte - uint16_t uitmp=uival; - if (getHighB==0) - return uint8_t(uitmp); - uitmp>>=8; - return uint8_t(uitmp); - -}*/ - -uint16_t uchar2uint(char Highbyte, char Lowbyte) -{ - uint16_t uitmp; - uitmp=0; - uitmp |= uint8_t(Highbyte); - uitmp<<=8; - uitmp |= uint8_t(Lowbyte); - return uitmp; -} - -uint16_t uchar2uint(uint8_t Highbyte, uint8_t Lowbyte) -{ - uint16_t uitmp; - uitmp=0; - uitmp |= uint8_t(Highbyte); - uitmp<<=8; - uitmp |= uint8_t(Lowbyte); - return uitmp; -} - -uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t Lowbyte) -{ - uint32_t ultmp=0; - - ultmp |= uint8_t(Highbyte); - ultmp<<=8; - ultmp |= uint8_t(MHbyte); - ultmp<<=8; - ultmp |= uint8_t(MLbyte); - ultmp<<=8; - ultmp |= uint8_t(Lowbyte); - return ultmp; -} - -uint8_t uint2uchar(uint16_t uival, bool getHighB) -{ - // getHighB: low=GetLowByte - uint16_t uitmp=uival; - if (getHighB==0) - return uint8_t(uitmp); - uitmp>>=8; - return uint8_t(uitmp); - -} - - -uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr) -{ - // getBytNr: 0=LSB 3=MSB - uint32_t ultmp=ulval; - if (getBytNr==0) - return uint8_t(ultmp); - ultmp>>=8; - if (getBytNr==1) - return uint8_t(ultmp); - ultmp>>=8; - if (getBytNr==2) - return uint8_t(ultmp); - ultmp>>=8; - return uint8_t(ultmp); - -} - -void delay(uint16_t MilliSec) -{ - QThread::msleep(uint32_t(MilliSec)); -} - - -void GetTimeString(uint8_t hours, uint8_t minutes, uint8_t seconds, uint8_t System12h, uint8_t ShowSec, uint8_t *buf) -{ - // Zahlenwerte in String wandeln, 12/24h-Format // 12byte für buf! - uint8_t usa; - uint16_t jj; - uint8_t hh, mm, ss, with_sec; - - // buf[0]= ganz linkes Zeichen - hh=hours; - mm=minutes; - ss=seconds; - - // 15.10.12, Plausibilitätsprüfung -------------------------------------------------- - if (hh>23) hh=0; - if (mm>59) mm=0; - if (ss>59) ss=0; - - with_sec=ShowSec; - for (jj=0; jj<12; jj++) buf[jj]=0; - usa = System12h; // 1:12h 0:24h - - // Stunden: - if (usa) - { - // 12h System - if (hh==0 || hh==12) - { - // 12AM (Mitternacht) oder 12PM (Mittag) - buf[0]=0x31; - buf[1]=0x32; - } else - if (hh<12) - { - // 1..11AM - buf[0]=hh/10+0x30; - buf[1]=hh%10+0x30; - } else - { - //13:00 bis 23Uhr - buf[0]=(hh-12)/10+0x30; - buf[1]=(hh-12)%10+0x30; - } - } else - { - // 24h System - buf[0]=hh/10+0x30; - buf[1]=hh%10+0x30; - } - - // Minuten: - buf[2]=':'; - buf[3]=mm/10+0x30; - buf[4]=mm%10+0x30; - - jj=5; - if (with_sec) - { - buf[jj++]=':'; - buf[jj++]=ss/10+0x30; - buf[jj++]=ss%10+0x30; - } - if (usa) - { - buf[jj++]=' '; - if (hh<12) - buf[jj++]='A'; - else - buf[jj++]='P'; - buf[jj++]='M'; - } - -} - -// ------------------- ******************************************************************************** - -void GetDateString(uint8_t day, uint8_t month, uint8_t yearhigh, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf) -{ - // generate date as ascii string from integers day/month/year - // yearhigh: 10..29, in europe always 20 (not in arabia!) comes as hex number, e.g. 0x20 - // format= 0: dd.mm.yyyy (deutsch) - // 1: mm.dd.yyyy (amerika) - // 2: yyyy.mm.dd (Iran, Dubai) - // 3: dd.yyyy.mm - // 4: mm.yyyy.dd - // 5: yyyy.dd.mm - // sep: 0: use . as seperator 1: use / as seperator - // return String in *buf // 11byte für buf! - - - uint8_t tag, mon, jahr, d10, d1, m10, m1, y1000, y100, y10, y1; - uint8_t slash; - - - y100= (yearhigh & 0x0F)+0x30; - y1000=((yearhigh & 0xF0)>>4)+0x30; -// if (yearhigh>=20) -// { -// y1000='2'; -// y100=28+yearhigh; // '0' + (yearhigh-20) -// } else -// if (yearhigh<20) -// { -// y1000='1'; -// y100=38-yearhigh; // '9' - (19-yearhigh) -// } - - tag=day; - mon=month; - jahr=yearlow; - - if (mon>12 || mon==0) mon=1; // 23.10.12 - if (tag>31 || tag==0) tag=1; - if (jahr>50 || jahr<11) jahr=1; - - if (sep==0) - slash='.'; // slash==0 - else if (sep==1) - slash='/'; - else - if (sep>=0x20) - slash=sep; - else - slash='.'; - - d10 =tag/10; - d1 =tag%10; - m10 =mon/10; - m1 =mon%10; - y10 =jahr/10; - y1 =jahr%10; - - d10 +=0x30; // in Asccii wandeln - d1 +=0x30; - m10 +=0x30; - m1 +=0x30; - y10 +=0x30; - y1 +=0x30; - - switch (format) - { - // 0: dd.mm.yyyy - case 0: buf[0]=d10; buf[1]=d1; buf[2]=slash; buf[3]=m10; buf[4]=m1; buf[5]=slash; - buf[6]=y1000; buf[7]=y100; buf[8]=y10; buf[9]=y1; break; - - // 1: mm.dd.yyyy - case 1: buf[0]=m10; buf[1]=m1; buf[2]=slash; buf[3]=d10; buf[4]=d1; buf[5]=slash; - buf[6]=y1000; buf[7]=y100; buf[8]=y10; buf[9]=y1; break; - - // 2: yyyy.mm.dd - case 2: buf[0]=y1000; buf[1]=y100; buf[2]=y10; buf[3]=y1; buf[4]=slash; buf[5]=m10; - buf[6]=m1; buf[7]=slash; buf[8]=d10; buf[9]=d1; break; - - // 3: dd.yyyy.mm - case 3: buf[0]=d10; buf[1]=d1; buf[2]=slash; buf[3]=y1000; buf[4]=y100; - buf[5]=y10; buf[6]=y1; buf[7]=slash; buf[8]=m10; buf[9]=m1; break; - - // 4: mm.yyyy.dd - case 4: buf[0]=m10; buf[1]=m1; buf[2]=slash; buf[3]=y1000; buf[4]=y100; - buf[5]=y10; buf[6]=y1; buf[7]=slash; buf[8]=d10; buf[9]=d1; break; - - // 5: yyyy.dd.mm - case 5: buf[0]=y1000; buf[1]=y100; buf[2]=y10; buf[3]=y1; buf[4]=slash; buf[5]=d10; - buf[6]=d1; buf[7]=slash; buf[8]=m10; buf[9]=m1; break; - - } - buf[10]=0; - - -} - -// ------------------- ******************************************************************************** - -void GetShortDateString(uint8_t day, uint8_t month, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf) -{ - // generate date as ascii string from integers day/month/year - // format= 0: dd.mm.yy (deutsch) - // 1: mm.dd.yy (amerika) - // 2: yy.mm.dd (Iran, Dubai) - // 3: dd.yy.mm - // 4: mm.yy.dd - // 5: yy.dd.mm - // sep: 0: use . as seperator 1: use / as seperator - // return String in *buf // 11byte für buf! - - - uint8_t tag, mon, jahr, d10, d1, m10, m1, y10, y1; - uint8_t slash; - - - tag=day; - mon=month; - jahr=yearlow; - - if (mon>12 || mon==0) mon=1; // 23.10.12 - if (tag>31 || tag==0) tag=1; - if (jahr>50 || jahr<11) jahr=1; - - if (sep==0) - slash='.'; // slash==0 - else if (sep==1) - slash='/'; - else if (sep>=0x20) - slash=sep; - else - slash='.'; - - d10 =tag/10; - d1 =tag%10; - m10 =mon/10; - m1 =mon%10; - y10 =jahr/10; - y1 =jahr%10; - - d10 +=0x30; // in Asccii wandeln - d1 +=0x30; - m10 +=0x30; - m1 +=0x30; - y10 +=0x30; - y1 +=0x30; - - switch (format) - { - // 0: dd.mm.yyyy - case 0: buf[0]=d10; buf[1]=d1; buf[2]=slash; buf[3]=m10; buf[4]=m1; buf[5]=slash; - buf[6]=y10; buf[7]=y1; break; - - // 1: mm.dd.yyyy - case 1: buf[0]=m10; buf[1]=m1; buf[2]=slash; buf[3]=d10; buf[4]=d1; buf[5]=slash; - buf[6]=y10; buf[7]=y1; break; - - // 2: yyyy.mm.dd - case 2: buf[0]=y10; buf[1]=y1; buf[2]=slash; buf[3]=m10; - buf[4]=m1; buf[5]=slash; buf[6]=d10; buf[7]=d1; break; - - // 3: dd.yyyy.mm - case 3: buf[0]=d10; buf[1]=d1; buf[2]=slash; - buf[3]=y10; buf[4]=y1; buf[5]=slash; buf[6]=m10; buf[7]=m1; break; - - // 4: mm.yyyy.dd - case 4: buf[0]=m10; buf[1]=m1; buf[2]=slash; - buf[3]=y10; buf[4]=y1; buf[5]=slash; buf[6]=d10; buf[7]=d1; break; - - // 5: yyyy.dd.mm - case 5: buf[0]=y10; buf[1]=y1; buf[2]=slash; buf[3]=d10; - buf[4]=d1; buf[5]=slash; buf[6]=m10; buf[7]=m1; break; - - } - buf[8]=0; - - -} - -uint16_t tslib_strlen(char *buf) -{ - uint16_t nn; - - for (nn=0; nn<0xFFF0; nn++) - if (buf[nn]==0) - return nn; - return 0; -} - -uint16_t tslib_strlen(uint8_t *buf) -{ - uint16_t nn; - - for (nn=0; nn<0xFFF0; nn++) - if (buf[nn]==0) - return nn; - return 0; -} - -void tslib_strclr(char *buf, char clrsign, uint16_t len) -{ - uint16_t nn; - - for (nn=0; nn=0x30 && sign<=0x39) - return true; - return false; -} - -bool tslib_isHexAsciiNumber(char sign) -{ - if (sign>=0x30 && sign<=0x39) - return true; - if (sign>=0x61 && sign<=0x66) // a...f - return true; - if (sign>=0x41 && sign<=0x46) // A...F - return true; - return false; -} - -int tslib_getMinimum(int val1, int val2) -{ - if (val1maxArayLen) LL=maxArayLen; - for (ii=0; ii> (7 - nn)) & 0x01); - if (B15H) - { - crc ^= 0x1021; - } - } - } - - for (nn = 0; nn < 16; nn++) - { - B15H = 0; - if(crc & 0x8000) - B15H = 1; - crc = (crc << 1) | 0x00; - if (B15H) - { - crc ^= 0x1021; - } - } - return crc; - -} - -static uint8_t LastBLcmd; // stored the last sent cmd in order to analys response - // cmd echo'ed: error cmd or'ed with 0x80: OK - -uint8_t tslib_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) -{ - // make BL protocol, retval = outbuf length (5...133) - // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum - // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 - // Data length = 0...64 - // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 - // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 - - uint8_t myBuf[140], pp=0, nn, uctmp, currLen=0; - uint16_t calcCrc; - - tslib_strclr(myBuf, 0, 140); - - myBuf[pp++]=2; // STX - myBuf[pp++]=Cmd; - LastBLcmd=Cmd; - - // append data: - for (nn=0; nn>8) & 0x00FF); - myBuf[pp++]=3; - currLen=pp; - - return currLen; -} - -// some special commands (right out of bootloader manual) -uint8_t tslib_readBLversion(uint8_t *sendData) -{ - // minimum size of sendData-buffer: 5byte retval: length - uint8_t myBuf[2]; - tslib_strclr(myBuf, 0, 2); - return tslib_prepareDC_BLcmd(0x11, 0, myBuf, sendData); -} - -uint8_t tslib_readFWversion(uint8_t *sendData) -{ - // minimum size of sendData-buffer: 5byte retval: length - uint8_t myBuf[2]; - tslib_strclr(myBuf, 0, 2); - return tslib_prepareDC_BLcmd(0x12, 0, myBuf, sendData); -} - -uint8_t tslib_exitBL(uint8_t *sendData) -{ - // minimum size of sendData-buffer: 5byte retval: length - uint8_t myBuf[2]; - tslib_strclr(myBuf, 0, 2); - return tslib_prepareDC_BLcmd(0x18, 0, myBuf, sendData); -} - -uint8_t tslib_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData) -{ - // minimum size of sendData-buffer: 13byte retval: length (9...13) - uint8_t myBuf[2]; - tslib_strclr(myBuf, 0, 2); - return tslib_prepareDC_BLcmd(0x11, 0, myBuf, sendData); -} -*/ - -// ----------------------------------------------------------------------------------------------- - - -void biox_CopyBlock(uint8_t *src, uint16_t srcPos, uint8_t *dest, uint16_t destPos, uint16_t len) -{ - // both buffers starting from pos 0 - uint16_t xx,yy,zz,ii; - - xx = srcPos; - yy = destPos; - zz = len; - - for (ii = 0; ii < zz; ++ii) - { - dest[yy + ii] = src[xx + ii]; - } -} From 2717c614e384418412b33c72748508eda737d539 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 5 Jun 2023 12:51:55 +0200 Subject: [PATCH 2/4] Update interface hwapi 3.6 --- include/interfaces.h | 3479 +++++++++++----------- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 5 +- 2 files changed, 1757 insertions(+), 1727 deletions(-) mode change 100644 => 100755 include/interfaces.h diff --git a/include/interfaces.h b/include/interfaces.h old mode 100644 new mode 100755 index 43c683d..03cd81a --- a/include/interfaces.h +++ b/include/interfaces.h @@ -1,1725 +1,1754 @@ -#ifndef INTERFACE_H -#define INTERFACE_H - -#include -#include - -struct T_emp { - // Fixdata from EMP: - uint8_t shaft; // = changer level - uint16_t countryCode; - uint8_t scale; - uint8_t decimals; - uint8_t coinValues[16]; - uint16_t routing; - - // Master specs: - uint8_t gotSetup; // 1: got specifications from master 0: no specs - uint16_t coinAccept; // bit 0 = coin1 bit H=accept - uint8_t tokenChannel; - uint16_t denomination[16]; - - // dynamic: - uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine): - // 0=Emp & Bus power off, 1=powered, poll off 2=polling on - // 3=device responded, requesting status - // 4=waiting for status 5=have status, - // 6: IDLE, have paramters from master, polling running, ready for payment - // Master can stop/start polling and acceptance - // 7: end of transaction, polling on, accept off, reporting coins, (wait for last coin) - // 8: transaction running, polling on, acceptance on, reporting coins, - - uint8_t pollingRunning; - uint8_t paymentRunning; -}; - -struct Trtc_DateTime { - uint8_t rtc_hour; - uint8_t rtc_min; - uint8_t rtc_sec; - uint8_t rtc_dayOfMonth; - uint8_t rtc_month; - uint8_t rtc_year; - uint8_t rtc_dayOfWeek; -}; - -struct Tprn_hw_state { - // hardware (IO's) - bool powerRdBk; // prn pwr is on - bool rsSwOk; // serial switch (printer or modem) is set to printer - bool rsDrvOk; // RS232 converter for PTU, Printer and Modem in on - - bool ReadyLine; // HW signal from printer showing ready - bool inIdle; // powered and free from errors - bool paperNearEnd; // paper roll runs out - bool noPaper; - bool ErrorTemp; - bool HeadOpen; - bool cutterJam; - bool noResponse; // printer is not connected, cable broken, wrong baudrate - bool badResponse; -}; - -struct Tprn_currentSettings { - uint8_t currFont; - uint8_t currSize; - uint8_t currHeigth; - uint8_t currWidth; - bool nowBold; - bool nowInvers; - bool nowUnderlined; - uint8_t currDensity; - uint8_t currSpeed; - bool nowAligned; -}; - -struct T_dynDat { - uint8_t licensePlate[8]; - uint8_t vendingPrice[8]; - uint8_t parkingEndTime[8]; - uint8_t parkingEndDate[8]; - uint8_t currentDate[8]; - uint8_t dynDat5[8]; - uint8_t dynDat6[8]; - uint8_t dynDat7[8]; -}; - -struct T_vaultRecord { - // Kassenbeleg (Abrechnungsdatensatz = Kassenwechsel-Datensatz) - char startbuffer[4]; // Psa> // never move or change this 1st entry - uint16_t AccountingNumber; - uint16_t CUNU; - uint16_t MANU; - uint16_t resint1; - //uint16_t resint2; - - char label1buffer[4]; // tim> - uint8_t year; - uint8_t month; - uint8_t dom; - uint8_t hour; - uint8_t min; - uint8_t sec; - uint8_t DoW; - uint8_t reschar3; - - char label2buffer[4]; // abs> - uint32_t AbsIncome1; - uint32_t AbsReserve; - uint32_t AbsNrOfCuts; - -//16 - char label3buffer[4]; // mw > - - // Verkauf, Tür zu: - uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen - uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben -//88 - // Service, Tür offen: - uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen - uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben - uint16_t resint3; - uint16_t resint4; - uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand - uint16_t resint5; - uint16_t resint6; -// 56 - char label4buffer[4]; // box> - uint16_t coinsInVault[16]; - uint16_t billsInStacker[8]; -// 48 - char label5buffer[4]; // val> - // actually constant unless exchange rate is changed - uint16_t coinDenomination[16]; // 5..50000 (z.B. 2? sind in Ungarn 760Ft) - uint16_t billDenom[8]; - uint16_t tubeDenom[6]; - uint16_t exchangeRate; - uint16_t resint9; -// 64 - char endofblock[4]; // end> -// 316 byte Block im Speicher -}; - -struct T_moduleCondition { - // store conditon of all system components, hold in RAM - // 0 means unknown, not yet tested/used - // 1 means OK - // 50..99 = HINT / Notification - // 100..150 = WARNING - // 200..250 = ERROR - - uint8_t ram; - uint8_t intEe; - uint8_t extEe; - - uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error - uint8_t boardHw; - uint8_t printer; - uint8_t modem; - - uint8_t signal; // 1...99 - uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime - uint8_t mdbBus; - uint8_t coinChecker; // EMP, OMP or mei-cashflow - - uint8_t coinEscrow; - uint8_t mifareReader; - uint8_t creditTerm; - uint8_t coinReject; - - uint8_t coinSafe; - uint8_t billSafe; - uint8_t voltage; // 1:11..14V - uint8_t temper; - - uint8_t poweronTest; - uint8_t doorState; // 1: alles zu 200: t?r offen + bit1(S) +bit2(CB) + bit3(CB) - uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened - uint8_t changer; // can only be tested by usage - - uint8_t coinBlocker; // can only be tested by usage - uint8_t billReader; // can only be tested by usage - uint8_t ResetReason; - uint8_t allModulesChecked; - -}; - -struct T_dynamicCondition { - char allDoorsDebounced; // 99: undefined, 0=all closed, bit1=upper door open 2=midlle door open 3=lower door open - char openedAuthorized; - uint8_t CBinDebounced; - char upperDoor; // 99: undefined 0:closed 1:open - char middleDoor; // 99: undefined 0:closed 1:open - char lowerDoor; // 99: undefined 0:closed 1:open - char reserve; // not used, always 0 - char billBox; - char modeAbrech; - char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest - char nowCardTest; - char nowPayment; - char lastMifCardType; - uint8_t lastSDoorState; - uint8_t lastVDoorState; - uint8_t lastCBstate; // 99: undefined 0:not there 1:insered - char paymentInProgress; - char res1; - uint16_t U_Batt; - uint16_t Temperatur; - uint16_t nrCoinsInBox; - uint32_t amountInBox; - uint32_t totalTransVolume; - uint32_t totalNrOfVends; - char jsonValid_config; - char jsonValid_device; - char jsonValid_cash; - char jsonValid_print; - char jsonValid_serial; - char jsonValid_time; - char lastFileType; -// 44 - uint8_t MifCardHolder[8]; - uint8_t resultOfLastTemplPrint; - // 0: unknown or printing in progress - // 1: OK, doc was printed 2: error, doc was not printed - uint8_t lastPrinterStatus; - // 0: printer OK - // bit0: near paper end bit1: no paper - // bit2: temperature error bit3: error head open - // bit4: paper jam in cutter - // bit6: no response bit7: serial rec. error - // bit5: printer not ready - uint8_t startupTestIsRunning; - //54 -}; - -struct T_extTime { - uint8_t Hours; - uint8_t Min; - uint8_t Sec; - uint8_t Year; - uint8_t Month; - uint8_t Day; - uint8_t DOW; - uint8_t res1; - uint16_t MinOfDay; - uint16_t res2; - uint32_t SecOfDay; - uint8_t isLeapYear; - uint8_t nxtLeapYear; - uint8_t lastLeapYear; - uint8_t hoursOfThisWeek; - uint16_t minutesOfThisWeek; - uint16_t hoursOfThisMonth; - uint16_t daysOfThisYear; - uint16_t GetHoursOfYear; - uint16_t res3; - uint32_t GetMinutesOfYear; - uint8_t getWakeIntvSec; - uint8_t res4; - uint16_t res5; - uint32_t MinutesOfMillenium; -}; - -typedef uint8_t UCHAR; -typedef uint16_t UINT; - -struct T_devices -{ - // set by master, used(1) or notused (0) or type 2....20 - - UCHAR kindOfPrinter; // 0:off 1:Gebe - UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW) - UCHAR kindOfMifareReader; // by now only stronglink SL025 =1 - UCHAR suppressSleepMode; // 0:sleep allowed 1: no sleep - - UCHAR kindOfModem; // 0:off 1:Sunlink - UCHAR kindOfCreditcard; // 0:off 1:Feig NFC - UCHAR CoinEscrow; - UCHAR CoinRejectUnit; - - UCHAR CoinShutter; - UCHAR BillAcceptor; - UCHAR usevaultLock; - UCHAR autoAlarm; // 1: switch on siren for 1min in doors opened unauthorized - - UCHAR autoOpen; // 1: open door covers after valid ATBcard - UCHAR printAccReceipt; // 0/1 - UCHAR printDoorReceipt; - UCHAR printTokenTicket; - - UINT VaultFullWarnLevel; - UINT VaultFullErrorLevel; - -}; - - -class hwinf { -public: - enum class DownloadResult {OK, ERROR, TIMEOUT, NOP}; - enum class FileTypeJson {CONFIG=1, DEVICE, CASH, SERIAL, TIME, PRINTER}; - - virtual ~hwinf() {} - - virtual QStringList dc_getStatus() const = 0; - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // Use serial interface and protocol stack in Cashagent-Library - // Sending Output data to DeviceController DC2b - // Sending input requests to DC2 (single or auto-batch) - // Getting input data as receiver payload - // Furthermore the Cashagent-Library answers with status strings about sending and reading result - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const = 0; - // Command: open serial interface - // BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200 - // BaudStr: for exapmle "19200" - // ComName: for example "COM48" - // connect: 0, 1 - - virtual bool dc_closeSerial(void) const = 0; - // Command: close serial interface in order to save power while power down - // or if another port must be used - - virtual bool dc_isPortOpen(void) const =0; - // returns true if port open (don't send unless open. Sending to closed port will crash program) - - - - virtual uint8_t test_serialState(void) const =0; - // test on-board signals for the serials - // serial drv on/off, Serial mux1, Serial mux2 - - virtual bool test_serialIsOn(void) const =0; - - virtual bool dc_updateDC(QString binFileName, - QString baudrate, - QString comPort) const = 0; - // download binary file down into device controller - - virtual bool dc_updatePrinterTemplate(enum FileTypeJson type, - QVector templateIdx, - QVector fnames, - QString br, - QString serial = QString()) const = 0; - - virtual bool dc_printTemplate(enum FileTypeJson type, - QVector templateIdx, - QString br, - QString serial = QString()) const = 0; - - virtual void dc_autoRequest(bool on) const =0; - // on = true: select that all READ-Requests are sent automatically - // on = false: select that all READ-Requests are sent manually one by one - // Every input information from DC2 must be requested - // ( digital and analog sensors, get time/date, get status information ) - - virtual uint8_t dc_isRequestDone(void) const =0; - // retval: 0: request is still in progress - // 1: answer from DC2 was OK - // 2: wrong answer from DC2 - - virtual uint16_t dc_getCompletePayLoad(uint16_t plBufSiz, uint8_t *payLoad) const =0; - // get data back in "payLoad", max 64 byte, can be used for diagnosis - // retval = nr of bytes received. If host buffer too small then - // only plBufSiz bytes are copied to "payLoad" - // plBufSiz­z=size of host buffer - - virtual void dc_requTestResponse() const =0; - // tell DC2 to send a test-string, useful to see if cable and baudrate is OK - - virtual bool dc_readAnswTestResponse() const =0; - // retval: true: test was successful, got right response - - virtual uint8_t getRawRecLength(void) const =0; - // only needed if protocol stack in Cashagent-Library is bypassed - - virtual uint8_t getRawReceivedData(uint8_t *receivedData) const =0; - // only needed if protocol stack in Cashagent-Library is bypassed - - virtual QString dc_getSerialState(void) const =0; - // get result of opening-command like "ttyS0 opened with 115200 8N1! - // or error messages like "comport not available..." - // was saved by last opening event, can be passed for 100ms - - virtual void dc_clrSerialStateText(void) const =0; - // clear above text to avoid multiple repetive displaying - - - virtual QString dc_getTxt4HsStateLine(void) const =0; - // return string with status of handshakes - - virtual void dc_clrTxt4HsStateLine(void) const =0; - // clear above text to avoid multiple repetive displaying - - - virtual QString dc_getTxt4masterStateLine(void) const =0; - // returns string telling if the received packet is valid and complies protocol - // if OK: "slave response OK" in case of error: "wrong length received", "wrong start sign received", - // "received datalen to big", "wrong data len received", "wrong crc received" - - virtual void dc_clrTxt4masterStateLine(void) const =0; - // clear above text to avoid multiple repetive displaying - - - virtual QString dc_getTxt4resultStateLine(void) const =0; - // returns string telling response of DC. First question: did DC get a correct request telegram? - // and if: 2nd question did DC perform the contained output and input commands - // if OK: "Slave OUT and IN Result: 0 0" - // in case of error: "slave got wrong start sign" ..length" ...crc" ... address" - // slave does not perform and command! - // 2nd) received telegram was OK, DC tried to perform the master commands. result - // result of writing data (e.g switching leds and motors, sending stuff to printer...) - // OUT = 0: OK 1: unknown command 2: operation not possible - // result of reading data (e.g. switches, voltages, accepted coins, printer status....) - // IN = 0: OK 1: unknown command 2: could not read due to hardware error 3: could not read because device is off - - virtual void dc_clrTxt4resultStateLine(void) const =0; - // clear above text to avoid multiple repetive displaying - - - virtual QString dc_getdataStateLine(void) const =0; - // check if recveied input data are ok/valid - // OK-string : "valid INdata...." with protocol details - // not OK: string empty - - virtual void dc_clrTxt4dataStateLine(void) const =0; - // clear above text to avoid multiple repetive displaying - - - virtual QString dc_getdatifLine(void) const =0; - // returns string with result of function dc_requTestResponse() - // "correct" or "false" - - virtual void dc_clrTxt4datifLine(void) const =0; - // clear above text to avoid multiple repetive displaying - - - virtual QString dc_getTxt4RsDiagWin(void) const =0; - // returns string to be displayed in "serial traffic" window - // details about sent and received protocol - - virtual void dc_clrTxt4RsDiagWin(void) const =0; - // clear above text to avoid multiple repetive displaying - - virtual QString dc_get2ndTxt4RsDiagWin(void) const =0; - // returns string to be displayed in "serial traffic" window - // details about sent and received protocol - - virtual void dc_clr2ndTxt4RsDiagWin(void) const =0; - // clear above text to avoid multiple repetive displaying - - -// 28 functions - - - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // DC2b internal data - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - - virtual QString dc_getSerialParams(void) const =0; - // get DC2 serial settings (not very meaningful as they will not come if different from master settings) - - virtual QString dc_getHWversion(void) const =0; - // get DC2 hardware version - - virtual QString dc_getSWversion(void) const =0; - // get DC2 software version - - virtual QString dc_getState(void) const =0; - // get DC2 status (every OK or any error/warning? ) - - - // UID - unique number, different in every DC - virtual void dc_getUID8byte(uint8_t *buf8byteUid) const =0; - // get 8 single bytes in buffer - - virtual QString dc_getUIDstr() const =0; - // get as string - - virtual uint64_t dc_getUIDnumber(void) const =0; - // get UID as one long number - - // Analog values: - virtual uint32_t dc_getTemperature(void) const =0; - // in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C) - - virtual QString dc_getTemperaturStr(void) const =0; - // as string like "-12,5°C" - - virtual uint32_t dc_getVoltage(void) const =0; - // as value in mV, 0...65,535V - - virtual QString dc_getVoltagStr(void) const =0; - // as string in mV - - virtual bool dc_mainFuseIsOk(void) const=0; - // true if 12V fuse is OK - // false: fuse blown, DC will continue working but no 12V device can be used! - - virtual void dc_setWakeFrequency(uint8_t period) const =0; - // RTC wakes DC2 (and PTU) by hardware signal every 32seconds - // change wake signal period to 1...64s - - virtual void dc_OrderToReset(void) const =0; - // want DC2 to reset (in order to start Bootloader) - - - - // all read-requests can be sent manually by the following functions - // or automatically in background by: void hwapi::dc_autoRequest(bool on) - // in other words: - // if automatic-reading is on, then there's no need to send any of these commands, - // but it's allowed to send them in order to speed up the refreshing of the inputs - - virtual void request_DC2serialConfig() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - - virtual void request_DC2_HWversion() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - virtual void request_DC2_SWversion() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - virtual void request_DC2_condition() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - virtual void request_DC2_UID() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - - - virtual void request_DC2_analogues() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - virtual void request_DC2_digitalInputs() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - virtual void request_DC2_digitalOutputs() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - -// 22 - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // using DC2 Bootloader - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void bl_sendDataDirectly(uint8_t length, uint8_t *buf) const =0; - // send without protocol frame, needed for the DC bootloader - - virtual void bl_iniChain(void) const =0; - - virtual bool bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const =0; - - virtual uint8_t bl_activatBootloader(uint8_t *sendData) const =0; - - virtual uint8_t bl_startChain(void) const =0; - - virtual uint8_t bl_readBLversion(uint8_t *sendData) const =0; - // minimum size of sendData-buffer: 5byte retval: length - - virtual uint8_t bl_readFWversion(uint8_t *sendData) const =0; - // minimum size of sendData-buffer: 5byte retval: length - - virtual uint8_t bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const =0; - // make BL protocol, retval = outbuf length (5...133) - // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum - // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 - // Data length = 0...64 - // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 - // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 - - virtual uint8_t bl_exitBL(uint8_t *sendData) const =0; - // minimum size of sendData-buffer: 5byte retval: length - - - - -// 9 - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // get Time and Date from DC2b (contains a buffered real time clock) valid for about three days without power - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual uint8_t rtc_getDateTime(struct Trtc_DateTime *rtc_DateTime) const =0; - - virtual uint8_t rtc_setDateTime(void) const =0; - // synch DC2 with PC or PTU system time and date - - virtual void rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const =0; - // get time directly - - virtual void rtc_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) const =0; - // get date directly - - virtual uint8_t rtc_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) const =0; - // dow=day of week, 1=monday...7 - // minOfToday: 0=midnight...1439= 23:59 - // secOfToday: 0=midnight...86399= 23:59:59 - - virtual bool rtc_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) const =0; - // retval true: this year is leap year - - virtual bool rtc_isLeapYear() const =0; - - virtual void rtc_getWeek(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) const =0; - // DayOfWeek: 1=monday...7 - // HoursOfWeek: 0=Monday 0:00 o'clock...167=Sunday 23:00 - // MinutesOfWeek: 0=Monday 0:00 o'clock...10079=Sunday 23:59 - - virtual void rtc_getMonth(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) const =0; - // DayOfMonth: 1...31 - // HoursOfMonth: 0 = 0:00o'clock of 1.day in month up to 743 - // MinutesOfMonth:0 = 0:00o'clock of 1.day in month up to 44639 - - virtual void rtc_getYear(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) const =0; - // DayOfYear: 1...366 1= 1.Jan of this current year - // HoursOfYear: 0=1.Jan 0:00o'clock ...8783=31.12 23 o'clock - // MinutesOfYear: 0=1.Jan 0:00o'clock ...527039=31.12 23:59 o'clock - - virtual QString rtc_getTimStr(void) const =0; - virtual QString rtc_getDatStr(void) const =0; - virtual QString rtc_getTimDatStr(void) const =0; - - - - - virtual void request_DC2_TimeAndDate() const =0; - // read-request can be sent manually by this function, not needed if auto-request is on - - - -// 14 - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // PTU, Master - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void ptu_switchWake(bool WAKEACTIVE) const =0; - - virtual bool ptu_WakeINisActive(void) const =0; - - virtual bool ptu_WakeOutIsOn(void) const =0; - - virtual void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, - uint8_t kindOfMifareReader, uint8_t suppressSleep, - uint8_t kindOfModem, uint8_t kindOfCredit ) const =0; - // enable hardware in device controller: - // kindOfPrinter: 0:off 1: GPT4672 (only this one implemented) - // kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer - // kindOfMifareReader: 0:off 1: SL025 (only this one implemented) - // suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason - // kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented) - // kindOfCredit: 0:off 1: cVendTopp 2:cVendPin (not yet implemented) - - - virtual void request_ReadbackDeviceSettings() const =0; - - virtual void readback_DeviceSettings(uint8_t *length, uint8_t *data) const =0; -/* - buf66[0]=devPara.kindOfPrinter; - buf66[1]=devPara.kindOfCoinChecker; - buf66[2]=devPara.kindOfMifareReader; - buf66[3]=devPara.suppressSleepMode; - buf66[4]=devPara.kindOfModem; - buf66[5]=devPara.kindOfCreditcard; - buf66[6]=devPara.CoinEscrow; - buf66[7]=devPara.CoinRejectUnit; - buf66[8]=devPara.CoinShutter; - buf66[9]=devPara.BillAcceptor; - buf66[10]=devPara.usevaultLock; - buf66[11]=devPara.autoAlarm; - buf66[12]=devPara.autoOpen; - buf66[13]=devPara.printAccReceipt; - buf66[14]=devPara.printDoorReceipt; - buf66[15]=devPara.printTokenTicket; - uitmp=devPara.VaultFullWarnLevel; - buf66[16]=swl_getOneByteFromUint(uitmp, GETLOWBYT); - buf66[17]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); - uitmp=devPara.VaultFullErrorLevel; - buf66[18]=swl_getOneByteFromUint(uitmp, GETLOWBYT); - buf66[19]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); - -*/ - - virtual void sendMachineID(uint16_t customerNr, uint16_t machineNr, - uint16_t borough, uint16_t zone, - uint16_t alias, char *location) const =0; - - virtual void request_ReadbackMachineID() const =0; - - virtual void readback_machineIDdata(uint8_t *length, uint8_t *data) const =0; - // state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number - // byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name - // byte[10...41]=location - // 12.4.23TS still the same - - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // Printer - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - - - virtual void prn_switchPower(bool on) const =0; - - virtual bool prn_isPrinterPowerOn(void) const =0; - - virtual uint8_t prn_PrnFuseIsOk(void) const=0; - //retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off - - virtual bool prn_readyINisActive(void) const =0; - - virtual uint8_t cash_getLowPaperSensor(void) const=0; - // 0: Sensor sees paper 1: no paper 99: off - - // the following device state requests are deployed only if device is powered up: - virtual void request_PrinterHwState() const =0; - virtual void request_PrinterCurrentFonts() const =0; - virtual void request_PrinterStateComplete() const =0; - - virtual bool test_serialMux1isSetToPrinter(void) const =0; - - // read printer condition and settings - - virtual uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const =0; - // retval: status byte - // byte 0 = 0: prnter OK, >0: error - // bit0: paper low 1: no paper 2: temperature error - // 3: head open 4: paper jam in cutter - // 6: no response 7: bad response from printer - // and return struct "Tprn_hw_state" - - virtual bool prn_isUpAndReady(void) const =0; - // true: printer is powered, serial is ok, no error, printer is connected and resonding - - virtual void prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const =0; - - - // send Commands to printer: - - virtual void prn_sendText(QByteArray *buf) const =0; - // up to 1280 bytes - - virtual void prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) const =0; - // send three byte through to printer, see printers manual - - virtual void prn_sendPrnEscCmd(uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4) const =0; - // send four byte through to printer, see printers manual - - - virtual void prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) const =0; - // send 5 byte: byte 0,1: speed 5...250 mm/s - // byte2: density 0....(25)....50 - // byte3: alignment 'l', 'c', 'r' = left, center, right - // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) - // not batched! don't use twice within 100ms - - virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0; - //direction: 1=forward 2=backward - // - virtual void prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const =0; - // font = kind of font 5...11 (0..22) - // size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge - // width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) - // heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense - - virtual void prn_setLetters(uint8_t bold, uint8_t invers, uint8_t underlined) const =0; - // bold: 0/1 - // invers: 0/1 - // underlined: 0/1 - - virtual void prn_cut(uint8_t kindof) const =0; - // kindof: 1=full cut 2=partial cut 3=eject (5xLF + full cut) - - virtual void prn_newLine(uint8_t nrOfLines) const =0; - - virtual void prn_printCompleteFontTable(void) const =0; - - virtual void prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) const =0; - // kind of barcode: 0=Code39 1=Code128 2=EAN13 3= 2/5interleaved 4=UPC-A 5=EAN8 - // withText: print readable text below - // offset: move by pixel from left border - // rotation - // dataLeng in byte - - virtual void prn_sendQRdata(QByteArray *buf) const =0; - // maximal 150 alphanummeric bytes - - virtual void prn_printQRcode(void) const =0; - // QRcode may have 1...150 alphanummeric data, must be transfered in advance - - - virtual void prn_printLogo(uint8_t nrOfLogo, uint8_t offset ) const =0; - // nrOfLogo: 1..4 in flash 5...8 in Ram - // offset: in mm form left border - - - - // ......................................................... - // Parking Ticket (print-out document) designer TD - // ......................................................... - - // Predefine document Layout (e.g. parking ticket) in advance and stroe it for quick and easy use - // in opposite to the above "single" commands you need only one or a few commands at vending time. - // Stored text is just send to printer once the printing command is issued - // stored commands within the text are interpreted and executed right at the place (in ticket) they are - // example: start bold, , stop bold - // Predefinition of up to 16 ticket Layouts is possible, 0...1280 byte each - // Number 0..15, al keept non-volatile - // up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command - // example: print current time at this point (the time of printing not the storage time!!) - - virtual void pri_startTicketDesign(void) const =0; - // start for every new printer document, reseting collecting buffer - - // all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed - // return val of the appending functions: true=ok false=too long, buffer full - - virtual int pri_TD_getCurrentSize(void) const =0; - // retval: 0...1278 - - virtual bool pri_TD_addText(QByteArray text) const =0; - // example: pri_TD_addText("Hello") const =0; - // example: pri_TD_addText(tempStr) const =0; - // retval: true=ok false=too long, buffer full - - virtual bool pri_TD_addValue(int val) const =0; - // +/- 0...2^(31) - - virtual bool pri_TD_addNewLine(void) const =0; - - virtual bool pri_TD_addSign(char sign) const =0; - // example: '.' ' ' 0x20 'W' '$' - - virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0; - // always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5 - /* complete list of possible commands: - group 50 : paper - attribute 10 : move forward - p1: wayInMm p2: direction - attribute 11 : cut - p1: kind of, 1=full 2=partial, 3=eject - attribute 12 : new line(s) - p1: nr of lines 1...100 - - group 51 : fonts - attribute 10 : kind of font see description above - p1: 0...8 - attribute 11 : font size - p1: 6...20 - attribute 12 : font width - p1: 0...4 - attribute 13 : font heigth - p1: 0...7 - attribute 14 : switch bold print on/off - p1: 0=off 1=on - attribute 15 : switch invers print on/off - p1: 0=off 1=on - attribute 16 : switch underlined print on/off - p1: 0=off 1=on - - group 52 : print graphics - attribute 10 : print barcode with dynamic data 6 and 7 - p1...p5 = kindOf, withText, offset, rotation, dataLeng, see description above - attribute 11 : print QRcode with preset data - - attribute 12 : print Logo - p1=nrOfLogo, p2=offset - - group 53 : print dynamics - attribute 10 : - p1: 1...8 = print dynData 0..7 at this place - - */ - - virtual char prn_clearDocument(uint8_t documentNumber) const =0; - // clear memory buffer for ONE document - // function takes a second! don't send right before "store doc" - - virtual bool prn_store_Document(uint8_t documentNumber ) const =0; - // send the predefined Layout (generated with above TD functions) to DeviceController to save - // documentNumber=0...15 - // maximal 1280 bytes each - // allowed: 0x20...0xFF, 0x0A, 0x0C, 0x1B (LF, CR, Esc) - // 0x1B=start of embedded command (next 7bytes = command) - - // with a print command a set of 8 dynamic strings can be sent - // the place in the ticket layout is predefined (already in DC memory) - // the dynamics are first calculated at printing time - - virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0; - - -// 36 - - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // Mifare Card Reader - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void mif_readerOn(bool on) const =0; - - virtual bool mif_cardIsAttached(void) const =0; - virtual bool mif_isMifarePowerOn(void) const =0; - - virtual void request_MifareReaderState() const =0; - virtual void request_MifareCardType() const =0; - virtual void request_MifareAtbType() const =0; - virtual void request_MifareID() const =0; - virtual void request_MifareData(uint8_t dataBlockNumber) const =0; - //virtual void request_MifareData() const =0; - - // dataBlockNumber must be 0....11, returns 64byte of data - - - virtual bool test_serialMux2isSetToMifare(void) const =0; - - virtual void mif_creatAtbCard(uint8_t cardType) const =0; - - /* data description: - byte 0: current read state: 0=power off 1=reader-fault 2=ready - 3=just reading 4=read complete - 5=read partial, removed too early - 6=state unknown - byte 1,2: read data length from card - 3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader - 4...15: reader version, expected "ATB25-1.8" - byte16: 1=card is present 0:not - 17: 0 - 18: card type reported from reader - 19: 1=allowed card type 0=not - 20: card size: 1 or 4 (dec) = card size - 21: LengthOfUID: 4 or 7 (dec) (byte) - 22: UID 8 byte in hex - byte 30: sector logged: 0 - byte 31: current sector: 0 - byte 32: result, always 0 - */ - virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const =0; - // retval 0=OK 1=error host buffer too small - - virtual bool mif_readerIsOK(void) const =0; - - virtual bool mif_cardAttached(void) const =0; - - virtual uint8_t mif_readResult(void) const =0; - // result: 0: unknown or still in progress - // 1: card read successful - // 2: reading error - - //virtual void mif_clearDataBuffer(void) const =0; - - virtual QString mif_cardUID(void) const =0; - // returns string with 8 byte - - //virtual bool mif_isBlockAvailable(uint8_t blkNr) const =0; - //blkNr=0...11 - - //virtual uint32_t mif_getAvailableDataBlocks(void) const =0; - // bit0=1 if block 0 = valid ...up to ... bit 11=1 if block 11=read - - virtual uint8_t mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const =0; - - virtual QString mif_getCardDataStr(uint8_t blockNumber) const =0; - // with blockNumber=0...11 - - // read mifare data independant from blocks - //virtual uint16_t mif_getNrOfAvailableDataBytes(void) const =0; - - //virtual bool mif_getCardData768byteDec(uint8_t *buf, uint16_t bufferSize) const =0; - - //virtual bool mif_getCardDataDec(uint16_t fromAddr, uint16_t toAddr, uint8_t *buf, uint16_t bufferSize) const =0; - - //virtual QString mif_getCardDataStr(bool useHexFormat, char seperator) const =0; - -// 16 - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // Credit Card Terminal - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void credit_switchPower(bool on) const =0; - // the same as modem power - - virtual bool cred_isCreditPowerOn(void) const =0; - - virtual bool test_serialMux2isSetToCredit(void) const =0; - - virtual void credit_switchWake(bool WAKEACTIVE) const =0; - -// 4 - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // Modem - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void mod_switchPower(bool on) const=0; - - virtual bool mod_isGsmPowerOn(void) const =0; - - virtual bool test_serialMux1isSetToModem(void) const =0; - - virtual void mod_switchWake(bool WAKEACTIVE) const=0; - -// 2 - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // MDB Bus - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void mdb_switchPower(bool on) const =0; - virtual void mdb_switchWake(bool WAKEACTIVE) const =0; - - virtual bool mdb_WakeINisActive(void) const =0; - virtual bool mdb_testIsmdbTxDon(void) const =0; - virtual bool mdb_isMdbPowerOn(void) const =0; - - virtual void request_MDB_Status() const =0; - virtual void request_MDB_lastResponse() const =0; - - virtual bool test_getDO_mdbRXtst(void) const =0; - // readback digital outputs of connected devices - // these functions are not needed for normal operation - // but can be used to test and verify conditions - - virtual void mdb_sendBusReset(void) const =0; - - virtual void mdb_sendCommand(uint8_t toMdbDevice, uint8_t mdbCommand) const =0; - // send one bus command directly over mdb bus, refer to mdb manual for commands - // this command is not needed in normal operation, just for new or special things - - virtual void mdb_sendMessage(uint8_t toMdbDevice, uint8_t mdbCommand, uint8_t nrOfData, uint8_t *dataBuffer) const =0; - // nrOfData = sizeOf(dataBuffer) maximal 34 byte according mdb specs - // same as mdb_sendCommand, just with data - - virtual bool mdb_busIsReadyToWork() const =0; - - virtual bool mdb_deviceVoltageOK() const =0; - - virtual bool mdb_busVoltageOk() const =0; - - virtual uint8_t mdb_getLastDeviceResponse(uint8_t *fromDevice, uint8_t *lastRequest, - uint8_t *responseLength, uint8_t *responseBuffer) const =0; - // fromDevice: device nr from which data was requested 0,1,2,3 - // lastRequest: sent mdb command - // responseLength: nr of payload data (after mdb-ack) 0...34 - // responseBuffer holds payload data (answer from mdb device) - // return val: mdb result of this request: 1=got ACK 2=got 3xNAK 3=no or bad response 4:got Data (after ACK) - - -// 15 - - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // Coin Changer, Checker (EMP) - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void request_EMP_allParameters() const =0; - - virtual void request_EMP_lastCoin() const =0; - - virtual uint8_t emp_returnLastCoin(uint16_t *value, uint8_t *signal) const =0; - // use for changer - - - // ---------------------------------- Electronic Coin Validator EMP ----------------------------------------- - - virtual void emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const =0; - // coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation) - // tokenChannel 0...31: if this signal comes from emp then a token was inserted - // coinDenomination = array of 16 coin values (e.g. 5, 10, 20...) - - virtual void emp_pollingOnOff(uint8_t on) const =0; - - virtual void emp_startCoinAcceptance(void) const =0; - - virtual void emp_stopCoinAcceptance(void) const =0; - - virtual void emp_getAllParameters(struct T_emp *emp) const =0; - // see struct in hwapi.h - // usage example: - // hwapi *HWaccess const =0; - // HWaccess = new hwapi() const =0; - // struct T_emp myEmp const =0; - // HWaccess->emp_getAllParameters(&myEmp) const =0; - // readval=myEmp.pollingRunning const =0; - - virtual uint8_t emp_chkIfCoinInserted(void) const =0; - // retval: 0...16 coins left in FIFO - - virtual void emp_getNewCoinRecord(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) const =0; - // with every call ONE coin is taken out of FIFO and pointer decremented - // valid: should be 1 - // signal: comes right from coin checker, 0...15 (0=first programmed coin type) 0xFF=no signal - // error: was reported from EMP as dynamic signal right after coin insertion (instead of - // coin signal), example: 3=unknown coin 4=coin is blocked by host. 0xFF=no error - // value: of the coin. Depends on parameter "coinDenomination" in function "emp_sendSettings" - // if coinDenomination[coin 0..15] = 0 then the value programmed in coin checker is taken - // if coinDenomination > 0 then this value is taken. - // Useful in case of two currencies (adapt to local currency) or for token. - - // function gives more details as "emp getLastCoin()" but "emp getLastCoin()" is easier to use - - // alternativ to emp_getNewCoinRecord( ): - virtual uint8_t emp_giveLastCoin(uint16_t *value, uint8_t *signal) const =0; - // retval: 0: NO coin stored 1: valid coin 2: got wrong coin or coin denied - // value: if retval1: value of the coin if reval=2: error number - // 0xFF means NO error or NO signal (as 0 is a valid error/signal) - // signal: channel nr reported from checker 0...15 - -// 11 - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // Coin blocker, Coin Escrow, Coin reject - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void shut_move(bool open) const =0; - virtual void esc_moveFlaps(uint8_t flap ) const =0; - // 0: close both 1: open take-flap 2: open return - - virtual void coin_switchRejectMotor(uint8_t dir) const =0; - virtual bool coid_isAttached(void) const =0; - virtual bool coin_escrowIsOpen(void) const =0; - virtual bool cash_getRejectMotorHomePos(void) const=0; - - - virtual bool coin_shutterIsOpen(void) const =0; - virtual bool coin_shutterTestOutput(void) const =0; - - virtual uint8_t coin_escrowFlapOpened(void) const =0; - // retval: 1:return flap is open 2:take flap is open 0:closed - - virtual void shut_openOnce(void) const =0; - // and close automatic after shutter time - - virtual void shut_openForCoin(bool start) const =0; - // open flap if coin is attached - // once process is started it runs until stop command - - virtual void shut_sendOpeningTime(uint16_t timeIn_ms ) const =0; - // after this time without retrigger the flap is closed - - virtual void esc_takeMoney(void) const =0; - // and close automatically after escrow time (1s) - - virtual void esc_returnMoney(void) const =0; - // and close automatically after escrow time (1s) - - virtual void coin_rejectCoins(void) const =0; - -// 15 - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // MDB Bill evaluator - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - - - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // doors, locks, cashboxes - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void lock_switchContactPower(bool on) const =0; - - virtual bool door_isContactPowerOn(void) const =0; - - virtual uint8_t door_getLocks(void) const =0; - // retval bit0: upper lever is up (=open) - // bit1: upper lever is down (=locked) - // bit2: lower lever is up - // bit3: lower lever is down (=locked) - - virtual bool door_upperDoorIsLocked(void) const =0; - - virtual bool door_upperDoorIsUnlocked(void) const =0; - - virtual uint8_t lock_switchUpperLock(uint8_t dir) const =0; - // dir 0=off 1=up 2=down - // move lock until stop cmd (0) - - virtual uint8_t lock_openUpperDoor(void) const =0; - // Locks stops automatically at end switch or by timeout - - virtual uint8_t lock_closeUpperDoor(void) const =0; - // Locks stops automatically at end switch or by timeout - - virtual uint8_t door_getSwitches(void) const =0; - // retval: bit0: upper door 1: low door 2:vault door - - virtual bool door_isUpperDoorOpen(void) const =0; - - - virtual bool door_lowerDoorIsLocked(void) const =0; - - virtual bool door_lowerDoorIsUnlocked(void) const =0; - - virtual uint8_t lock_switchLowerLock(uint8_t dir) const =0; - // dir 0=off 1=up 2=down - // move lock until stop cmd (0) - - virtual uint8_t lock_getDO_motors(void) const =0; - // bit0: upper lock forward bit 1 backward - // bit2: lower lock forward bit 3 backward - - virtual uint8_t lock_openLowerDoor(void) const =0; - // there's no closing function as Lock always makes one complete cycle and can be locked again immed. - - virtual uint8_t lock_closeLowerDoor(void) const =0; - - virtual bool door_isLowerDoorOpen(void) const =0; - - virtual uint8_t vault_getSwitches(void) const =0; - // retval bit0: cash box, bit 1: bill box - - virtual bool vault_isVaultDoorOpen(void) const =0; - - virtual void lock_switchVaultDoor(void) const =0; - - virtual bool vault_isCoinVaultIn(void) const =0; - - virtual bool vault_isBillVaultIn(void) const =0; - -// 21 - - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - // LEDs, Barrier, Alarm, Relais, Aux - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - virtual void led_switchLedIllumination(uint8_t on) const = 0; - - virtual void led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const =0; - - virtual bool led_coinIsOn(void) const =0; - // read back digital output from DC-uC-Port - virtual bool led_frontIsOn(void) const =0; - - virtual void led_switchLedService(uint8_t on) const =0; - // on=1 off=0 - virtual bool led_insideIsOn(void) const =0; - - virtual void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const =0; - virtual bool led_ticketIsOn(void) const =0; - - virtual void led_switchLedStart(uint8_t on, uint8_t ton, uint8_t tof) const =0; - virtual bool led_StartIsOn(void) const =0; - - virtual void led_switchLedPinPad(uint8_t on, uint8_t ton, uint8_t tof) const =0; - virtual bool led_pinIsOn(void) const =0; - - - virtual void fan_switchFan(bool on) const =0; - virtual void alarm_switchSiren(bool on) const =0; - virtual bool fan_isOn(void) const =0; - - virtual bool siren_isOn(void) const =0; - - virtual void bar_OpenBarrier(bool open) const =0; - virtual bool bar_relayIsOn(void) const =0; - - virtual bool bar_optoIn1isOn(void) const =0; - - virtual bool bar_optoIn2isOn(void) const =0; - - virtual void aux_power(bool on) const =0; - virtual bool aux_powerIsOn(void) const =0; - - virtual void aux_setUsage(uint8_t PinDirection) const =0; - virtual void aux_setOutputs(uint8_t PinIsHigh) const =0; - - virtual bool aux_isAuxPowerOn(void) const =0; - - virtual uint8_t aux_getAuxInputs(void) const =0; - - - -// ------------------------------------------------------------------------------------ -// 27.3.2023: Use Device-Controller's Bootloader to send hex-file -// ------------------------------------------------------------------------------------ - - virtual void bl_rebootDC(void) const =0; - - virtual void bl_startBL(void) const = 0; - // send command within 4s after DC power-on, otherwise bl is left - - virtual bool bl_checkBL(void) const = 0; - // send command to verify if bl is up - - virtual bool bl_isUp(void) const =0; - // return true is bl is up and running - // also initializes "sendFile" - - virtual void bl_sendAddress(uint16_t blockNumber) const=0; - // send start address, nr of 64byte-block, start with 0 - // will be sent only for following block-numbers: - // 0, 1024, 2048, 3072 and 4096, so basically every 64kByte - // for other addresses nothing happens - - virtual uint8_t bl_wasSendingAddOK(void) const=0; - // return val: 0: no response by now 1:error 10: OK - - virtual void bl_openBinary(void) const=0; - // to be used within CashAgent, momentary not processed - - virtual void bl_sendDataBlock(uint8_t length, uint8_t *buffer) const=0; - // send 64 byte from bin file - - virtual void bl_sendLastBlock(void) const=0; - // send this command after all data are transfered - - virtual uint8_t bl_wasSendingDataOK(void) const=0; - // return val: 0: no response by now 1:error 10: OK - - virtual void bl_stopBL(void) const=0; - // leave BL and start (the new) application - - //virtual bool bl_isDiagAvailable(void) const=0; - - //virtual QString dc_getDiagText(void) const=0; - - - // Komplett-schreib Funktion, noch nicht getestet - // Nachteil: keine Rückmeldung wie lang's noch dauert - //virtual void bl_startSending(void) const=0; - // call once after BL is working and file is loaded - //virtual void bl_sendFile(void) const=0; - // call cyclic while loading bin-file to bootloader - - - - -// ------------------------------------------------------------------------------------ -// 6.4.2023: new functions for coin collection and printing -// some new system functions -// ------------------------------------------------------------------------------------ - - virtual bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const=0; - // return true if sending, false if cmd-stack is full - - virtual bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const=0; -/* - buf[0]=GlobTime.Hours; - buf[1]=GlobTime.Min; - buf[2]=GlobTime.Sec; - buf[3]=GlobTime.Year; - buf[4]=GlobTime.Month; - buf[5]=GlobTime.Day; - buf[6]=GlobTime.DOW; - buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master! - uitmp=GlobTime.MinOfDay; - buf[8]=swl_getOneByteFromUint(uitmp, 0); - buf[9]=swl_getOneByteFromUint(uitmp, 1); - buf[10]=' '; - buf[11]=' '; - ultmp=GlobTime.SecOfDay; - buf[12]=swl_getOneByteFromUlong(ultmp, 0); - buf[13]=swl_getOneByteFromUlong(ultmp, 1); - buf[14]=swl_getOneByteFromUlong(ultmp, 2); - buf[15]=swl_getOneByteFromUlong(ultmp, 3); - - buf[16]=swl_isLeap(GlobTime.Year); - buf[17]=swl_getNextLeapYear(GlobTime.Year); - buf[18]=swl_getLastLeapYear(GlobTime.Year); - buf[19]=swl_hoursOfThisWeek(GlobTime.DOW, GlobTime.Hours); - - uitmp=swl_minutesOfThisWeek(GlobTime.DOW, GlobTime.Hours, GlobTime.Min); - buf[20]=swl_getOneByteFromUint(uitmp, 0); // 0=low byte 1=high byte - buf[21]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_hoursOfThisMonth(GlobTime.Day, GlobTime.Hours); - buf[22]=swl_getOneByteFromUint(uitmp, 0); - buf[23]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_minutesOfThisMonth(GlobTime.Day, GlobTime.Hours, GlobTime.Min); - buf[24]=swl_getOneByteFromUint(uitmp, 0); - buf[25]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_GetDaysOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day); - buf[26]=swl_getOneByteFromUint(uitmp, 0); - buf[27]=swl_getOneByteFromUint(uitmp, 1); - - uitmp=swl_GetHoursOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day, GlobTime.Hours); - buf[28]=swl_getOneByteFromUint(uitmp, 0); - buf[29]=swl_getOneByteFromUint(uitmp, 1); - buf[30]=0; - buf[31]=0; - ultmp= swl_GetMinutesOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day, - GlobTime.Hours, GlobTime.Min); - buf[32]=swl_getOneByteFromUlong(ultmp, 0); - buf[33]=swl_getOneByteFromUlong(ultmp, 1); - buf[34]=swl_getOneByteFromUlong(ultmp, 2); - buf[35]=swl_getOneByteFromUlong(ultmp, 3); - - buf[36]=rtc_getSqwaveSettings(); - buf[37]=0; - buf[38]=0; - buf[39]=0; - - ultmp= 0; // Minutes of the Millenium - buf[40]=swl_getOneByteFromUlong(ultmp, 0); - buf[41]=swl_getOneByteFromUlong(ultmp, 1); - buf[42]=swl_getOneByteFromUlong(ultmp, 2); - buf[43]=swl_getOneByteFromUlong(ultmp, 3); - - dc2prot_setReadData(44, buf); - - */ - - virtual bool rtc_getExtendedTime(struct T_extTime *exTime) const=0; - - virtual bool sys_runCompleteTest(void) const=0; - // warning: lasts 20s in one pace - // return true if sending, false if cmd-stack is full - - virtual bool sys_ready4sending(void) const=0; - // return true if a Json-file can be sent - - virtual bool sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8_t *content ) const=0; - // kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer - // nrOfTemplate=1...32 if kindOfFile==6 - // content = content of the Json file, max 800byte ascii signs - // file is 0-terminated - // return true if sending, false if cmd-stack is full - - virtual bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const=0; - // dynPrnVal = array of 8 Variables with 8 byte each, come as ascii string - // like: char prn_dynPrnVal[8][8]; - // return true if sending, false if cmd-stack is full - - virtual bool prn_printTemplate(uint8_t nrOftemplate) const=0; - // print one of the templates loaded by Json prior - // nr = 1..32 - // return true if sending, false if cmd-stack is full - - virtual void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const=0; - // returns all acc nrs of the backuped vault records - // use: uint16_t backupedAccNumbers[8] - - virtual bool log_selectVaultRecord(uint16_t accountNr ) const=0; - // return true if sending, false if cmd-stack is full - // and trigger transfer - - virtual bool log_chkIfVaultRecordAvailable(void) const=0; - // return true if completly received - - virtual bool log_getVaultRecord(struct T_vaultRecord *retVR) const=0; - // which was selected by: log_selectVaultRecord() - // to be forwarded to Ismas - - virtual bool prn_printAccountReceipt(void) const=0; - // return true if sending to DC OK, false if cmd-stack is full - - virtual bool prn_printTestTicket(void) const=0; - // return true if sending to DC OK, false if cmd-stack is full - - 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; - - virtual bool getAllInsertedCoins(uint16_t *types, uint16_t *values) const=0; - // all inserted coins (max 64) since "cash_startPayment" - - virtual bool cash_cancelPayment(void) const=0; - // and return coins - - virtual bool cash_stopPayment(void) const=0; - // and keep coins in escrow - - // after ticket/goods issue: - virtual bool vend_success(void) const=0; - // conclude payment process, encash all inserted coins to vault. Printing was successful - // if possible return change - - virtual bool vend_failed(void) const=0; - // conclude payment process and return all inserted coins - - - virtual uint8_t mif_getCardType(QString *cardholder) const=0; - // return 1,2,3,4 = upper, lower access card, printer test, coin test - // cardholder: 7byte Name-String - - virtual uint64_t sys_getWakeSource(void) const =0; - // retval: 6 bytes, bit coded, 1=event keeps DC awake - - virtual uint8_t sys_getWakeReason(void) const=0; - // Master was woken by following reason: - // 1: MDB Event - // 2: Coin Event - // ( 3: Master Event) - will not set the wake line - // ( 4: 32s pulse) - will not set the wake line - // 5: Door Event - // ( 6: Diag Event) - will not set the wake line - // 7: 30min-Pulse for HB - - virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const=0; - /* - - outBuf[0]=modCond.ram; - outBuf[1]=modCond.intEe; - outBuf[2]=modCond.extEe; - outBuf[3]=modCond.rtc; - outBuf[4]=modCond.boardHw; - outBuf[5]=modCond.printer; - outBuf[6]=modCond.modem; - outBuf[7]=modCond.signal; - outBuf[8]=modCond.regist; - outBuf[9]=modCond.mdbBus; - outBuf[10]=modCond.coinChecker; - outBuf[11]=modCond.coinEscrow; - outBuf[12]=modCond.mifareReader; - outBuf[13]=modCond.creditTerm; - outBuf[14]=modCond.coinReject; - outBuf[15]=modCond.coinSafe; - outBuf[16]=modCond.billSafe; - outBuf[17]=modCond.voltage; - outBuf[18]=modCond.temper; - outBuf[19]=modCond.poweronTest; - outBuf[20]=modCond.doorState; - outBuf[21]=modCond.doorWasOpened; - outBuf[22]=modCond.changer; - outBuf[23]=modCond.coinBlocker; - outBuf[24]=modCond.billReader; - outBuf[25]=modCond.ResetReason; - outBuf[26]=modCond.allModulesChecked; - outBuf[27]=modCond.alarmState; - outBuf[28]=0; - outBuf[29]=0; - - */ - - virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0; - virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0; -/* - - outBuf[pBuf++]=dynCond.allDoorsDebounced; - outBuf[pBuf++]=dynCond.openedAuthorized; - outBuf[pBuf++]=dynCond.CBinDebounced; - outBuf[pBuf++]=dynCond.upperDoor; - - outBuf[pBuf++]=dynCond.middleDoor; - outBuf[pBuf++]=dynCond.lowerDoor; - outBuf[pBuf++]=dynCond.coinBox; - outBuf[pBuf++]=dynCond.billBox; - - outBuf[pBuf++]=dynCond.modeAbrech; - outBuf[pBuf++]=dynCond.onAlarm; - outBuf[pBuf++]=dynCond.nowCardTest; - outBuf[pBuf++]=dynCond.nowPayment; - - outBuf[pBuf++]=dynCond.lastMifCardType; - outBuf[pBuf++]=dynCond.lastSDoorState; - outBuf[pBuf++]=dynCond.lastVDoorState; - outBuf[pBuf++]=dynCond.lastCBstate; - - outBuf[pBuf++]=dynCond.paymentInProgress; - outBuf[pBuf++]=0; - uitmp=dynCond.U_Batt; - outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETLOWBYT); - outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); - uitmp=dynCond.Temperatur; - outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETLOWBYT); - outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); - - uitmp=dynCond.nrCoinsInBox; // send seperate also - outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETLOWBYT); - outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); - - ultmp=dynCond.amountInBox; // send seperate also - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWESTBYT); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWMID); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHMID); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHESTBYT); - - ultmp=dynCond.totalTransVolume; - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWESTBYT); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWMID); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHMID); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHESTBYT); - - ultmp=dynCond.totalNrOfVends; - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWESTBYT); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWMID); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHMID); - outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHESTBYT); -// 36 - outBuf[pBuf++]=dynCond.jsonValid_config; - outBuf[pBuf++]=dynCond.jsonValid_device; - outBuf[pBuf++]=dynCond.jsonValid_cash; - outBuf[pBuf++]=dynCond.jsonValid_print; - outBuf[pBuf++]=dynCond.jsonValid_serial; - outBuf[pBuf++]=dynCond.jsonValid_time; - outBuf[pBuf++]=dynCond.lastFileType; - outBuf[pBuf++]=0; - -*/ - - virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0; - - // content of Cashbox - virtual uint32_t cash_getAmountInVault(void) const=0; - - virtual uint16_t cash_getNrCoinsInVault(void) const=0; - - - virtual uint8_t prn_getPrintResult() const=0; - - // in case of print-error get detailed error: - virtual uint8_t prn_getCurrentPrinterState() const=0; - // 0: printer OK - // bit0: near paper end bit1: no paper - // bit2: temperature error bit3: error head open - // bit4: paper jam in cutter - // bit6: no response bit7: serial rec. error - // bit5: printer not ready - - virtual void sys_sendDeviceParameter(struct T_devices *deviceSettings) const=0; - - 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 - - 1. check if DC startup test is through, retrigger if not - 2. get results and find errors - 3. in case of error check if component is used (e.g. billreader is seldom used) - 4: check doors - 5. return value: 0: no response from DC - 1: no Test results and Test not running. need retrigger! - 2: state not clear by now, test ongoing, wait - 3: Service or battery door is open, goto INTRUSION MODE - from here: after valid ID-card goto SERVICE MODE - 4: vault door is open, goto INTRUSION MODE - from here: after valid ID-card and vault door closed goto TEST MODE - in TEST MODE: complete system check decides if vending mode allowed - 5: All doors are closed but errors found, - goto OOO MODE (out-of-order) - from here: run system test until problem is fixed - 6: All doors are closed, no error, maybe warnings, - goto VENDING MODE (normal operation) - (priority sinks from 0 to 6) - - --------------------------------------------------------------------------------------------- */ - - virtual uint8_t sys_componentAssessment(void) const=0; - // this function decides if vending mode is possible, independant from door - // return >0 in case of error - // is inncluded in sys_superviseSystem - - virtual uint8_t sys_superviseSystem(void) const=0; - // this function proofs if vending is possible depending of doors state - - virtual uint8_t sys_getSystemErrors(void) const=0; - - - // retrigger System-Check with: - // bool hwapi::sys_runCompleteTest(void) const - - - - - - - - - // --------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------- - -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_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; - -}; - - -// 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 -// 14.04.2023: V3.4 new features extended: sys_getDynMachineConditions, sys_getDeviceConditions and -// rtc_getExtendedTime return struct in addition. New function to select and get VaultRecord -// - -//#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" -//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.4" -#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.5" - - - -Q_DECLARE_INTERFACE(hwinf, HWINF_iid) - - -#endif - - - +#ifndef INTERFACE_H +#define INTERFACE_H + +#include + + + +struct T_emp +{ + + // Fixdata from EMP: + uint8_t shaft; // = changer level + uint16_t countryCode; + uint8_t scale; + uint8_t decimals; + uint8_t coinValues[16]; + uint16_t routing; + + // Master specs: + uint8_t gotSetup; // 1: got specifications from master 0: no specs + uint16_t coinAccept; // bit 0 = coin1 bit H=accept + uint8_t tokenChannel; + uint16_t denomination[16]; + + // dynamic: + uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine): + // 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 + + + uint8_t pollingRunning; + uint8_t paymentRunning; + +}; + +struct Trtc_DateTime +{ + uint8_t rtc_hour; + uint8_t rtc_min; + uint8_t rtc_sec; + uint8_t rtc_dayOfMonth; + uint8_t rtc_month; + uint8_t rtc_year; + uint8_t rtc_dayOfWeek; +}; + +struct Tprn_hw_state +{ + // hardware (IO's) + bool powerRdBk; // prn pwr is on + bool rsSwOk; // serial switch (printer or modem) is set to printer + bool rsDrvOk; // RS232 converter for PTU, Printer and Modem in on + + bool ReadyLine; // HW signal from printer showing ready + bool inIdle; // powered and free from errors + bool paperNearEnd; // paper roll runs out + bool noPaper; + bool ErrorTemp; + bool HeadOpen; + bool cutterJam; + bool noResponse; // printer is not connected, cable broken, wrong baudrate + bool badResponse; +}; + + struct Tprn_currentSettings +{ + uint8_t currFont; + uint8_t currSize; + uint8_t currHeigth; + uint8_t currWidth; + bool nowBold; + bool nowInvers; + bool nowUnderlined; + uint8_t currDensity; + uint8_t currSpeed; + bool nowAligned; +}; + +// obsolete + struct T_dynDat +{ + uint8_t licensePlate[8]; + uint8_t vendingPrice[8]; + uint8_t parkingEnd[8]; + uint8_t currentTime[8]; + uint8_t currentDate[8]; + uint8_t dynDat5[8]; + uint8_t dynDat6[8]; + uint8_t dynDat7[8]; +}; + + +struct T_vaultRecord +{ + + // Kassenbeleg (Abrechnungsdatensatz = Kassenwechsel-Datensatz) + char startbuffer[4]; // Psa> // never move or change this 1st entry + uint16_t AccountingNumber; + uint16_t CUNU; + uint16_t MANU; + uint16_t resint1; + //uint16_t resint2; + + char label1buffer[4]; // tim> + uint8_t year; + uint8_t month; + uint8_t dom; + uint8_t hour; + uint8_t min; + uint8_t sec; + uint8_t DoW; + uint8_t reschar3; + + char label2buffer[4]; // abs> + uint32_t AbsIncome1; + uint32_t AbsReserve; + uint32_t AbsNrOfCuts; + +//16 + char label3buffer[4]; // mw > + + // Verkauf, Tür zu: + uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen + uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben +//88 + + // Service, Tür offen: + uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen + uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben + uint16_t resint3; + uint16_t resint4; + uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand + uint16_t resint5; + uint16_t resint6; +// 56 + + char label4buffer[4]; // box> + uint16_t coinsInVault[16]; + uint16_t billsInStacker[8]; +// 48 + + char label5buffer[4]; // val> + // actually constant unless exchange rate is changed + uint16_t coinDenomination[16]; // 5..50000 (z.B. 2? sind in Ungarn 760Ft) + uint16_t billDenom[8]; + uint16_t tubeDenom[6]; + uint16_t exchangeRate; + uint16_t resint9; + +// 64 + + char endofblock[4]; // end> + +// 316 byte Block im Speicher + +}; + +struct T_moduleCondition +{ + // store conditon of all system components, hold in RAM + // 0 means unknown, not yet tested/used + // 1 means OK + // 50..99 = HINT / Notification + // 100..150 = WARNING + // 200..250 = ERROR + + uint8_t ram; + uint8_t intEe; + uint8_t extEe; + + uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error + uint8_t boardHw; + uint8_t printer; + uint8_t modem; + + uint8_t signal; // 1...99 + uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime + uint8_t mdbBus; + uint8_t coinChecker; // EMP, OMP or mei-cashflow + + uint8_t coinEscrow; + uint8_t mifareReader; + uint8_t creditTerm; + uint8_t coinReject; + + uint8_t coinSafe; + uint8_t billSafe; + uint8_t voltage; // 1:11..14V + uint8_t temper; + + uint8_t poweronTest; + uint8_t doorState; // 1: alles zu 200: t?r offen + bit1(S) +bit2(CB) + bit3(CB) + uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened + uint8_t changer; // can only be tested by usage + + uint8_t coinBlocker; // can only be tested by usage + uint8_t billReader; // can only be tested by usage + uint8_t ResetReason; + uint8_t allModulesChecked; + + uint8_t alarmState; + uint8_t res11; + uint8_t res12; + uint8_t res13; + +}; + +struct T_dynamicCondition +{ + char allDoorsDebounced; + char openedAuthorized; + uint8_t CBinDebounced; // 0:fehlt 1:drin + char upperDoor; // 99: undefined 0:closed 1:open + char middleDoor; // 99: undefined 0:closed 1:open + char lowerDoor; // 99: undefined 0:closed 1:open + char reserve; + char billBox; + char modeAbrech; + char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest + char nowCardTest; + char nowPayment; // not used, always 0 + char lastMifCardType; + uint8_t lastSDoorState; + uint8_t lastVDoorState; + uint8_t lastCBstate; + char 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 + + + char res1; + uint16_t U_Batt; + uint16_t Temperatur; + uint16_t nrCoinsInBox; + uint32_t amountInBox; + uint32_t totalTransVolume; + uint32_t totalNrOfVends; + char jsonValid_config; + char jsonValid_device; + char jsonValid_cash; + char jsonValid_print; + char jsonValid_serial; + char jsonValid_time; + char lastFileType; +// 44 + uint8_t MifCardHolder[8]; + uint8_t resultOfLastTemplPrint; + // 0: unknown or printing in progress + // 1: OK, doc was printed 2: error, doc was not printed + uint8_t lastPrinterStatus; + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + uint8_t startupTestIsRunning; + + //54 +}; + +struct T_extTime +{ + uint8_t Hours; + uint8_t Min; + uint8_t Sec; + uint8_t Year; + uint8_t Month; + uint8_t Day; + uint8_t DOW; + uint8_t res1; + uint16_t MinOfDay; + uint16_t res2; + uint32_t SecOfDay; + uint8_t isLeapYear; + uint8_t nxtLeapYear; + uint8_t lastLeapYear; + uint8_t hoursOfThisWeek; + uint16_t minutesOfThisWeek; + uint16_t hoursOfThisMonth; + uint16_t daysOfThisYear; + uint16_t GetHoursOfYear; + uint16_t res3; + uint32_t GetMinutesOfYear; + uint8_t getWakeIntvSec; + uint8_t res4; + uint16_t res5; + uint32_t MinutesOfMillenium; + +}; + + +typedef uint8_t UCHAR; +typedef uint16_t UINT; + +struct T_devices +{ + // set by master, used(1) or notused (0) or type 2....20 + + UCHAR kindOfPrinter; // 0:off 1:Gebe + UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW) + UCHAR kindOfMifareReader; // by now only stronglink SL025 =1 + UCHAR suppressSleepMode; // 0:sleep allowed 1: no sleep + + UCHAR kindOfModem; // 0:off 1:Sunlink + UCHAR kindOfCreditcard; // 0:off 1:Feig NFC + UCHAR CoinEscrow; + UCHAR CoinRejectUnit; + + UCHAR CoinShutter; + UCHAR BillAcceptor; + UCHAR usevaultLock; + UCHAR autoAlarm; // 1: switch on siren for 1min in doors opened unauthorized + + UCHAR autoOpen; // 1: open door covers after valid ATBcard + UCHAR printAccReceipt; // 0/1 + UCHAR printDoorReceipt; + UCHAR printTokenTicket; + + UINT VaultFullWarnLevel; + UINT VaultFullErrorLevel; + +}; + + + +class hwinf +{ + +public: + virtual ~hwinf() {} + + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Use serial interface and protocol stack in Cashagent-Library + // Sending Output data to DeviceController DC2b + // Sending input requests to DC2 (single or auto-batch) + // Getting input data as receiver payload + // Furthermore the Cashagent-Library answers with status strings about sending and reading result + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const =0; + // Command: open serial interface + // BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200 + // BaudStr: for exapmle "19200" + // ComName: for example "COM48" + // connect: 0, 1 + + virtual void dc_closeSerial(void) const =0; + // Command: close serial interface in order to save power while power down + // or if another port must be used + + virtual bool dc_isPortOpen(void) const =0; + // returns true if port open (don't send unless open. Sending to closed port will crash program) + + + + virtual uint8_t test_serialState(void) const =0; + // test on-board signals for the serials + // serial drv on/off, Serial mux1, Serial mux2 + + virtual bool test_serialIsOn(void) const =0; + + + + virtual void dc_autoRequest(bool on) const =0; + // on = true: select that all READ-Requests are sent automatically + // on = false: select that all READ-Requests are sent manually one by one + // Every input information from DC2 must be requested + // ( digital and analog sensors, get time/date, get status information ) + + virtual uint8_t dc_isRequestDone(void) const =0; + // retval: 0: request is still in progress + // 1: answer from DC2 was OK + // 2: wrong answer from DC2 + + virtual uint16_t dc_getCompletePayLoad(uint16_t plBufSiz, uint8_t *payLoad) const =0; + // get data back in "payLoad", max 64 byte, can be used for diagnosis + // retval = nr of bytes received. If host buffer too small then + // only plBufSiz bytes are copied to "payLoad" + // plBufSiz­z=size of host buffer + + virtual void dc_requTestResponse() const =0; + // tell DC2 to send a test-string, useful to see if cable and baudrate is OK + + virtual bool dc_readAnswTestResponse() const =0; + // retval: true: test was successful, got right response + + virtual uint8_t getRawRecLength(void) const =0; + // only needed if protocol stack in Cashagent-Library is bypassed + + virtual uint8_t getRawReceivedData(uint8_t *receivedData) const =0; + // only needed if protocol stack in Cashagent-Library is bypassed + + virtual QString dc_getSerialState(void) const =0; + // get result of opening-command like "ttyS0 opened with 115200 8N1! + // or error messages like "comport not available..." + // was saved by last opening event, can be passed for 100ms + + virtual void dc_clrSerialStateText(void) const =0; + // clear above text to avoid multiple repetive displaying + + + virtual QString dc_getTxt4HsStateLine(void) const =0; + // return string with status of handshakes + + virtual void dc_clrTxt4HsStateLine(void) const =0; + // clear above text to avoid multiple repetive displaying + + + virtual QString dc_getTxt4masterStateLine(void) const =0; + // returns string telling if the received packet is valid and complies protocol + // if OK: "slave response OK" in case of error: "wrong length received", "wrong start sign received", + // "received datalen to big", "wrong data len received", "wrong crc received" + + virtual void dc_clrTxt4masterStateLine(void) const =0; + // clear above text to avoid multiple repetive displaying + + + virtual QString dc_getTxt4resultStateLine(void) const =0; + // returns string telling response of DC. First question: did DC get a correct request telegram? + // and if: 2nd question did DC perform the contained output and input commands + // if OK: "Slave OUT and IN Result: 0 0" + // in case of error: "slave got wrong start sign" ..length" ...crc" ... address" + // slave does not perform and command! + // 2nd) received telegram was OK, DC tried to perform the master commands. result + // result of writing data (e.g switching leds and motors, sending stuff to printer...) + // OUT = 0: OK 1: unknown command 2: operation not possible + // result of reading data (e.g. switches, voltages, accepted coins, printer status....) + // IN = 0: OK 1: unknown command 2: could not read due to hardware error 3: could not read because device is off + + virtual void dc_clrTxt4resultStateLine(void) const =0; + // clear above text to avoid multiple repetive displaying + + + virtual QString dc_getdataStateLine(void) const =0; + // check if recveied input data are ok/valid + // OK-string : "valid INdata...." with protocol details + // not OK: string empty + + virtual void dc_clrTxt4dataStateLine(void) const =0; + // clear above text to avoid multiple repetive displaying + + + virtual QString dc_getdatifLine(void) const =0; + // returns string with result of function dc_requTestResponse() + // "correct" or "false" + + virtual void dc_clrTxt4datifLine(void) const =0; + // clear above text to avoid multiple repetive displaying + + + virtual QString dc_getTxt4RsDiagWin(void) const =0; + // returns string to be displayed in "serial traffic" window + // details about sent and received protocol + + virtual void dc_clrTxt4RsDiagWin(void) const =0; + // clear above text to avoid multiple repetive displaying + + virtual QString dc_get2ndTxt4RsDiagWin(void) const =0; + // returns string to be displayed in "serial traffic" window + // details about sent and received protocol + + virtual void dc_clr2ndTxt4RsDiagWin(void) const =0; + // clear above text to avoid multiple repetive displaying + + +// 28 functions + + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // DC2b internal data + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + + virtual QString dc_getSerialParams(void) const =0; + // get DC2 serial settings (not very meaningful as they will not come if different from master settings) + + virtual QString dc_getHWversion(void) const =0; + // get DC2 hardware version + + virtual QString dc_getSWversion(void) const =0; + // get DC2 software version + + virtual QString dc_getState(void) const =0; + // get DC2 status (every OK or any error/warning? ) + + + // UID - unique number, different in every DC + virtual void dc_getUID8byte(uint8_t *buf8byteUid) const =0; + // get 8 single bytes in buffer + + virtual QString dc_getUIDstr() const =0; + // get as string + + virtual uint64_t dc_getUIDnumber(void) const =0; + // get UID as one long number + + // Analog values: + virtual uint32_t dc_getTemperature(void) const =0; + // in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C) + + virtual QString dc_getTemperaturStr(void) const =0; + // as string like "-12,5°C" + + virtual uint32_t dc_getVoltage(void) const =0; + // as value in mV, 0...65,535V + + virtual QString dc_getVoltagStr(void) const =0; + // as string in mV + + virtual bool dc_mainFuseIsOk(void) const=0; + // true if 12V fuse is OK + // false: fuse blown, DC will continue working but no 12V device can be used! + + virtual void dc_setWakeFrequency(uint8_t period) const =0; + // RTC wakes DC2 (and PTU) by hardware signal every 32seconds + // change wake signal period to 1...64s + + virtual void dc_OrderToReset(void) const =0; + // want DC2 to reset (in order to start Bootloader) + + + + // all read-requests can be sent manually by the following functions + // or automatically in background by: void hwapi::dc_autoRequest(bool on) + // in other words: + // if automatic-reading is on, then there's no need to send any of these commands, + // but it's allowed to send them in order to speed up the refreshing of the inputs + + virtual void request_DC2serialConfig() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + + virtual void request_DC2_HWversion() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_SWversion() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_condition() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_UID() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + + + virtual void request_DC2_analogues() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_digitalInputs() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_digitalOutputs() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + +// 22 + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // using DC2 Bootloader + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void bl_sendDataDirectly(uint8_t length, uint8_t *buf) const =0; + // send without protocol frame, needed for the DC bootloader + + virtual void bl_iniChain(void) const =0; + + virtual bool bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const =0; + + virtual uint8_t bl_activatBootloader(uint8_t *sendData) const =0; + + virtual uint8_t bl_startChain(void) const =0; + + virtual uint8_t bl_readBLversion(uint8_t *sendData) const =0; + // minimum size of sendData-buffer: 5byte retval: length + + virtual uint8_t bl_readFWversion(uint8_t *sendData) const =0; + // minimum size of sendData-buffer: 5byte retval: length + + virtual uint8_t bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const =0; + // make BL protocol, retval = outbuf length (5...133) + // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum + // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 + // Data length = 0...64 + // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 + // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 + + virtual uint8_t bl_exitBL(uint8_t *sendData) const =0; + // minimum size of sendData-buffer: 5byte retval: length + + + + +// 9 + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // get Time and Date from DC2b (contains a buffered real time clock) valid for about three days without power + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual uint8_t rtc_getDateTime(struct Trtc_DateTime *rtc_DateTime) const =0; + + virtual uint8_t rtc_setDateTime(void) const =0; + // synch DC2 with PC or PTU system time and date + + virtual void rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const =0; + // get time directly + + virtual void rtc_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) const =0; + // get date directly + + virtual uint8_t rtc_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) const =0; + // dow=day of week, 1=monday...7 + // minOfToday: 0=midnight...1439= 23:59 + // secOfToday: 0=midnight...86399= 23:59:59 + + virtual bool rtc_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) const =0; + // retval true: this year is leap year + + virtual bool rtc_isLeapYear() const =0; + + virtual void rtc_getWeek(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) const =0; + // DayOfWeek: 1=monday...7 + // HoursOfWeek: 0=Monday 0:00 o'clock...167=Sunday 23:00 + // MinutesOfWeek: 0=Monday 0:00 o'clock...10079=Sunday 23:59 + + virtual void rtc_getMonth(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) const =0; + // DayOfMonth: 1...31 + // HoursOfMonth: 0 = 0:00o'clock of 1.day in month up to 743 + // MinutesOfMonth:0 = 0:00o'clock of 1.day in month up to 44639 + + virtual void rtc_getYear(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) const =0; + // DayOfYear: 1...366 1= 1.Jan of this current year + // HoursOfYear: 0=1.Jan 0:00o'clock ...8783=31.12 23 o'clock + // MinutesOfYear: 0=1.Jan 0:00o'clock ...527039=31.12 23:59 o'clock + + virtual QString rtc_getTimStr(void) const =0; + virtual QString rtc_getDatStr(void) const =0; + virtual QString rtc_getTimDatStr(void) const =0; + + + + + virtual void request_DC2_TimeAndDate() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + + + +// 14 + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // PTU, Master + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void ptu_switchWake(bool WAKEACTIVE) const =0; + + virtual bool ptu_WakeINisActive(void) const =0; + + virtual bool ptu_WakeOutIsOn(void) const =0; + + virtual void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, + uint8_t kindOfMifareReader, uint8_t suppressSleep, + uint8_t kindOfModem, uint8_t kindOfCredit ) const =0; + // enable hardware in device controller: + // kindOfPrinter: 0:off 1: GPT4672 (only this one implemented) + // kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer + // kindOfMifareReader: 0:off 1: SL025 (only this one implemented) + // suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason + // kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented) + // kindOfCredit: 0:off 1: cVendTopp 2:cVendPin (not yet implemented) + + + virtual void request_ReadbackDeviceSettings() const =0; + + virtual void readback_DeviceSettings(uint8_t *length, uint8_t *data) const =0; +/* + buf66[0]=devPara.kindOfPrinter; + buf66[1]=devPara.kindOfCoinChecker; + buf66[2]=devPara.kindOfMifareReader; + buf66[3]=devPara.suppressSleepMode; + buf66[4]=devPara.kindOfModem; + buf66[5]=devPara.kindOfCreditcard; + buf66[6]=devPara.CoinEscrow; + buf66[7]=devPara.CoinRejectUnit; + buf66[8]=devPara.CoinShutter; + buf66[9]=devPara.BillAcceptor; + buf66[10]=devPara.usevaultLock; + buf66[11]=devPara.autoAlarm; + buf66[12]=devPara.autoOpen; + buf66[13]=devPara.printAccReceipt; + buf66[14]=devPara.printDoorReceipt; + buf66[15]=devPara.printTokenTicket; + uitmp=devPara.VaultFullWarnLevel; + buf66[16]=swl_getOneByteFromUint(uitmp, GETLOWBYT); + buf66[17]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); + uitmp=devPara.VaultFullErrorLevel; + buf66[18]=swl_getOneByteFromUint(uitmp, GETLOWBYT); + buf66[19]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); + +*/ + + virtual void sendMachineID(uint16_t customerNr, uint16_t machineNr, + uint16_t borough, uint16_t zone, + uint16_t alias, char *location) const =0; + + virtual void request_ReadbackMachineID() const =0; + + virtual void readback_machineIDdata(uint8_t *length, uint8_t *data) const =0; + // state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number + // byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name + // byte[10...41]=location + // 12.4.23TS still the same + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Printer + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + + + virtual void prn_switchPower(bool on) const =0; + + virtual bool prn_isPrinterPowerOn(void) const =0; + + virtual uint8_t prn_PrnFuseIsOk(void) const=0; + //retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off + + virtual bool prn_readyINisActive(void) const =0; + + virtual uint8_t cash_getLowPaperSensor(void) const=0; + // 0: Sensor sees paper 1: no paper 99: off + + // the following device state requests are deployed only if device is powered up: + virtual void request_PrinterHwState() const =0; + virtual void request_PrinterCurrentFonts() const =0; + virtual void request_PrinterStateComplete() const =0; + + virtual bool test_serialMux1isSetToPrinter(void) const =0; + + // read printer condition and settings + + virtual uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const =0; + // retval: status byte + // byte 0 = 0: prnter OK, >0: error + // bit0: paper low 1: no paper 2: temperature error + // 3: head open 4: paper jam in cutter + // 6: no response 7: bad response from printer + // and return struct "Tprn_hw_state" + + virtual bool prn_isUpAndReady(void) const =0; + // true: printer is powered, serial is ok, no error, printer is connected and resonding + + virtual void prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const =0; + + + // send Commands to printer: + + virtual void prn_sendText(QByteArray *buf) const =0; + // up to 1280 bytes + + virtual void prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) const =0; + // send three byte through to printer, see printers manual + + virtual void prn_sendPrnEscCmd(uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4) const =0; + // send four byte through to printer, see printers manual + + + virtual void prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) const =0; + // send 5 byte: byte 0,1: speed 5...250 mm/s + // byte2: density 0....(25)....50 + // byte3: alignment 'l', 'c', 'r' = left, center, right + // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) + // not batched! don't use twice within 100ms + + virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0; + //direction: 1=forward 2=backward + // + virtual void prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const =0; + // font = kind of font 5...11 (0..22) + // size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge + // width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) + // heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense + + virtual void prn_setLetters(uint8_t bold, uint8_t invers, uint8_t underlined) const =0; + // bold: 0/1 + // invers: 0/1 + // underlined: 0/1 + + virtual void prn_cut(uint8_t kindof) const =0; + // kindof: 1=full cut 2=partial cut 3=eject (5xLF + full cut) + + virtual void prn_newLine(uint8_t nrOfLines) const =0; + + virtual void prn_printCompleteFontTable(void) const =0; + + virtual void prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) const =0; + // kind of barcode: 0=Code39 1=Code128 2=EAN13 3= 2/5interleaved 4=UPC-A 5=EAN8 + // withText: print readable text below + // offset: move by pixel from left border + // rotation + // dataLeng in byte + + virtual void prn_sendQRdata(QByteArray *buf) const =0; + // maximal 150 alphanummeric bytes + + virtual void prn_printQRcode(void) const =0; + // QRcode may have 1...150 alphanummeric data, must be transfered in advance + + + virtual void prn_printLogo(uint8_t nrOfLogo, uint8_t offset ) const =0; + // nrOfLogo: 1..4 in flash 5...8 in Ram + // offset: in mm form left border + + + + // ......................................................... + // Parking Ticket (print-out document) designer TD + // ......................................................... + + // Predefine document Layout (e.g. parking ticket) in advance and stroe it for quick and easy use + // in opposite to the above "single" commands you need only one or a few commands at vending time. + // Stored text is just send to printer once the printing command is issued + // stored commands within the text are interpreted and executed right at the place (in ticket) they are + // example: start bold, , stop bold + // Predefinition of up to 16 ticket Layouts is possible, 0...1280 byte each + // Number 0..15, al keept non-volatile + // up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command + // example: print current time at this point (the time of printing not the storage time!!) + + // obsolete + //virtual void pri_startTicketDesign(void) const =0; + // start for every new printer document, reseting collecting buffer + + // all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed + // return val of the appending functions: true=ok false=too long, buffer full + + // obsolete + //virtual int pri_TD_getCurrentSize(void) const =0; + // retval: 0...1278 + + // obsolete + //virtual bool pri_TD_addText(QByteArray text) const =0; + // example: pri_TD_addText("Hello") const =0; + // example: pri_TD_addText(tempStr) const =0; + // retval: true=ok false=too long, buffer full + + // obsolete + //virtual bool pri_TD_addValue(int val) const =0; + // +/- 0...2^(31) + + // obsolete + //virtual bool pri_TD_addNewLine(void) const =0; + + // obsolete + //virtual bool pri_TD_addSign(char sign) const =0; + // example: '.' ' ' 0x20 'W' '$' + + // obsolete + //virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0; + // always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5 + /* complete list of possible commands: + group 50 : paper + attribute 10 : move forward + p1: wayInMm p2: direction + attribute 11 : cut + p1: kind of, 1=full 2=partial, 3=eject + attribute 12 : new line(s) + p1: nr of lines 1...100 + + group 51 : fonts + attribute 10 : kind of font see description above + p1: 0...8 + attribute 11 : font size + p1: 6...20 + attribute 12 : font width + p1: 0...4 + attribute 13 : font heigth + p1: 0...7 + attribute 14 : switch bold print on/off + p1: 0=off 1=on + attribute 15 : switch invers print on/off + p1: 0=off 1=on + attribute 16 : switch underlined print on/off + p1: 0=off 1=on + + group 52 : print graphics + attribute 10 : print barcode with dynamic data 6 and 7 + p1...p5 = kindOf, withText, offset, rotation, dataLeng, see description above + attribute 11 : print QRcode with preset data + + attribute 12 : print Logo + p1=nrOfLogo, p2=offset + + group 53 : print dynamics + attribute 10 : + p1: 1...8 = print dynData 0..7 at this place + + */ + + // obsolete + //virtual char prn_clearDocument(uint8_t documentNumber) const =0; + // clear memory buffer for ONE document + // function takes a second! don't send right before "store doc" + + // obsolete + //virtual bool prn_store_Document(uint8_t documentNumber ) const =0; + // send the predefined Layout (generated with above TD functions) to DeviceController to save + // documentNumber=0...15 + // maximal 1280 bytes each + // allowed: 0x20...0xFF, 0x0A, 0x0C, 0x1B (LF, CR, Esc) + // 0x1B=start of embedded command (next 7bytes = command) + + // with a print command a set of 8 dynamic strings can be sent + // the place in the ticket layout is predefined (already in DC memory) + // the dynamics are first calculated at printing time + +// obsolete + //virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0; + + +// 36 + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Mifare Card Reader + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void mif_readerOn(bool on) const =0; + + virtual bool mif_cardIsAttached(void) const =0; + virtual bool mif_isMifarePowerOn(void) const =0; + + virtual void request_MifareReaderState() const =0; + virtual void request_MifareCardType() const =0; + virtual void request_MifareAtbType() const =0; + virtual void request_MifareID() const =0; + virtual void request_MifareData(uint8_t dataBlockNumber) const =0; + //virtual void request_MifareData() const =0; + + // dataBlockNumber must be 0....11, returns 64byte of data + + + virtual bool test_serialMux2isSetToMifare(void) const =0; + + virtual void mif_creatAtbCard(uint8_t cardType) const =0; + + /* data description: + byte 0: current read state: 0=power off 1=reader-fault 2=ready + 3=just reading 4=read complete + 5=read partial, removed too early + 6=state unknown + byte 1,2: read data length from card + 3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader + 4...15: reader version, expected "ATB25-1.8" + byte16: 1=card is present 0:not + 17: 0 + 18: card type reported from reader + 19: 1=allowed card type 0=not + 20: card size: 1 or 4 (dec) = card size + 21: LengthOfUID: 4 or 7 (dec) (byte) + 22: UID 8 byte in hex + byte 30: sector logged: 0 + byte 31: current sector: 0 + byte 32: result, always 0 + */ + virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const =0; + // retval 0=OK 1=error host buffer too small + + virtual bool mif_readerIsOK(void) const =0; + + virtual bool mif_cardAttached(void) const =0; + + virtual uint8_t mif_readResult(void) const =0; + // result: 0: unknown or still in progress + // 1: card read successful + // 2: reading error + + //virtual void mif_clearDataBuffer(void) const =0; + + virtual QString mif_cardUID(void) const =0; + // returns string with 8 byte + + //virtual bool mif_isBlockAvailable(uint8_t blkNr) const =0; + //blkNr=0...11 + + //virtual uint32_t mif_getAvailableDataBlocks(void) const =0; + // bit0=1 if block 0 = valid ...up to ... bit 11=1 if block 11=read + + virtual uint8_t mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const =0; + + virtual QString mif_getCardDataStr(uint8_t blockNumber) const =0; + // with blockNumber=0...11 + + // read mifare data independant from blocks + //virtual uint16_t mif_getNrOfAvailableDataBytes(void) const =0; + + //virtual bool mif_getCardData768byteDec(uint8_t *buf, uint16_t bufferSize) const =0; + + //virtual bool mif_getCardDataDec(uint16_t fromAddr, uint16_t toAddr, uint8_t *buf, uint16_t bufferSize) const =0; + + //virtual QString mif_getCardDataStr(bool useHexFormat, char seperator) const =0; + +// 16 + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Credit Card Terminal + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void credit_switchPower(bool on) const =0; + // the same as modem power + + virtual bool cred_isCreditPowerOn(void) const =0; + + virtual bool test_serialMux2isSetToCredit(void) const =0; + + virtual void credit_switchWake(bool WAKEACTIVE) const =0; + +// 4 + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Modem + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void mod_switchPower(bool on) const=0; + + virtual bool mod_isGsmPowerOn(void) const =0; + + virtual bool test_serialMux1isSetToModem(void) const =0; + + virtual void mod_switchWake(bool WAKEACTIVE) const=0; + +// 2 + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // MDB Bus + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void mdb_switchPower(bool on) const =0; + virtual void mdb_switchWake(bool WAKEACTIVE) const =0; + + virtual bool mdb_WakeINisActive(void) const =0; + virtual bool mdb_testIsmdbTxDon(void) const =0; + virtual bool mdb_isMdbPowerOn(void) const =0; + + virtual void request_MDB_Status() const =0; + virtual void request_MDB_lastResponse() const =0; + + virtual bool test_getDO_mdbRXtst(void) const =0; + // readback digital outputs of connected devices + // these functions are not needed for normal operation + // but can be used to test and verify conditions + + virtual void mdb_sendBusReset(void) const =0; + + virtual void mdb_sendCommand(uint8_t toMdbDevice, uint8_t mdbCommand) const =0; + // send one bus command directly over mdb bus, refer to mdb manual for commands + // this command is not needed in normal operation, just for new or special things + + virtual void mdb_sendMessage(uint8_t toMdbDevice, uint8_t mdbCommand, uint8_t nrOfData, uint8_t *dataBuffer) const =0; + // nrOfData = sizeOf(dataBuffer) maximal 34 byte according mdb specs + // same as mdb_sendCommand, just with data + + virtual bool mdb_busIsReadyToWork() const =0; + + virtual bool mdb_deviceVoltageOK() const =0; + + virtual bool mdb_busVoltageOk() const =0; + + virtual uint8_t mdb_getLastDeviceResponse(uint8_t *fromDevice, uint8_t *lastRequest, + uint8_t *responseLength, uint8_t *responseBuffer) const =0; + // fromDevice: device nr from which data was requested 0,1,2,3 + // lastRequest: sent mdb command + // responseLength: nr of payload data (after mdb-ack) 0...34 + // responseBuffer holds payload data (answer from mdb device) + // return val: mdb result of this request: 1=got ACK 2=got 3xNAK 3=no or bad response 4:got Data (after ACK) + + +// 15 + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Coin Changer, Checker (EMP) + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void request_EMP_allParameters() const =0; + + virtual void request_EMP_lastCoin() const =0; + + virtual uint8_t emp_returnLastCoin(uint16_t *value, uint8_t *signal) const =0; + // use for changer + + + // ---------------------------------- Electronic Coin Validator EMP ----------------------------------------- + + virtual void emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const =0; + // coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation) + // tokenChannel 0...31: if this signal comes from emp then a token was inserted + // coinDenomination = array of 16 coin values (e.g. 5, 10, 20...) + + virtual void emp_pollingOnOff(uint8_t on) const =0; + + virtual void emp_startCoinAcceptance(void) const =0; + + virtual void emp_stopCoinAcceptance(void) const =0; + + virtual void emp_getAllParameters(struct T_emp *emp) const =0; + // see struct in hwapi.h + // usage example: + // hwapi *HWaccess const =0; + // HWaccess = new hwapi() const =0; + // struct T_emp myEmp const =0; + // HWaccess->emp_getAllParameters(&myEmp) const =0; + // readval=myEmp.pollingRunning const =0; + + virtual uint8_t emp_chkIfCoinInserted(void) const =0; + // retval: 0...16 coins left in FIFO + + virtual void emp_getNewCoinRecord(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) const =0; + // with every call ONE coin is taken out of FIFO and pointer decremented + // valid: should be 1 + // signal: comes right from coin checker, 0...15 (0=first programmed coin type) 0xFF=no signal + // error: was reported from EMP as dynamic signal right after coin insertion (instead of + // coin signal), example: 3=unknown coin 4=coin is blocked by host. 0xFF=no error + // value: of the coin. Depends on parameter "coinDenomination" in function "emp_sendSettings" + // if coinDenomination[coin 0..15] = 0 then the value programmed in coin checker is taken + // if coinDenomination > 0 then this value is taken. + // Useful in case of two currencies (adapt to local currency) or for token. + + // function gives more details as "emp getLastCoin()" but "emp getLastCoin()" is easier to use + + // alternativ to emp_getNewCoinRecord( ): + virtual uint8_t emp_giveLastCoin(uint16_t *value, uint8_t *signal) const =0; + // retval: 0: NO coin stored 1: valid coin 2: got wrong coin or coin denied + // value: if retval1: value of the coin if reval=2: error number + // 0xFF means NO error or NO signal (as 0 is a valid error/signal) + // signal: channel nr reported from checker 0...15 + +// 11 + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Coin blocker, Coin Escrow, Coin reject + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void shut_move(bool open) const =0; + virtual void esc_moveFlaps(uint8_t flap ) const =0; + // 0: close both 1: open take-flap 2: open return + + virtual void coin_switchRejectMotor(uint8_t dir) const =0; + virtual bool coid_isAttached(void) const =0; + virtual bool coin_escrowIsOpen(void) const =0; + virtual bool cash_getRejectMotorHomePos(void) const=0; + + + virtual bool coin_shutterIsOpen(void) const =0; + virtual bool coin_shutterTestOutput(void) const =0; + + virtual uint8_t coin_escrowFlapOpened(void) const =0; + // retval: 1:return flap is open 2:take flap is open 0:closed + + virtual void shut_openOnce(void) const =0; + // and close automatic after shutter time + + virtual void shut_openForCoin(bool start) const =0; + // open flap if coin is attached + // once process is started it runs until stop command + + virtual void shut_sendOpeningTime(uint16_t timeIn_ms ) const =0; + // after this time without retrigger the flap is closed + + virtual void esc_takeMoney(void) const =0; + // and close automatically after escrow time (1s) + + virtual void esc_returnMoney(void) const =0; + // and close automatically after escrow time (1s) + + virtual void coin_rejectCoins(void) const =0; + +// 15 + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // MDB Bill evaluator + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // doors, locks, cashboxes + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void lock_switchContactPower(bool on) const =0; + + virtual bool door_isContactPowerOn(void) const =0; + + virtual uint8_t door_getLocks(void) const =0; + // retval bit0: upper lever is up (=open) + // bit1: upper lever is down (=locked) + // bit2: lower lever is up + // bit3: lower lever is down (=locked) + + virtual bool door_upperDoorIsLocked(void) const =0; + + virtual bool door_upperDoorIsUnlocked(void) const =0; + + virtual uint8_t lock_switchUpperLock(uint8_t dir) const =0; + // dir 0=off 1=up 2=down + // move lock until stop cmd (0) + + virtual uint8_t lock_openUpperDoor(void) const =0; + // Locks stops automatically at end switch or by timeout + + virtual uint8_t lock_closeUpperDoor(void) const =0; + // Locks stops automatically at end switch or by timeout + + virtual uint8_t door_getSwitches(void) const =0; + // retval: bit0: upper door 1: low door 2:vault door + + virtual bool door_isUpperDoorOpen(void) const =0; + + + virtual bool door_lowerDoorIsLocked(void) const =0; + + virtual bool door_lowerDoorIsUnlocked(void) const =0; + + virtual uint8_t lock_switchLowerLock(uint8_t dir) const =0; + // dir 0=off 1=up 2=down + // move lock until stop cmd (0) + + virtual uint8_t lock_getDO_motors(void) const =0; + // bit0: upper lock forward bit 1 backward + // bit2: lower lock forward bit 3 backward + + virtual uint8_t lock_openLowerDoor(void) const =0; + // there's no closing function as Lock always makes one complete cycle and can be locked again immed. + + virtual uint8_t lock_closeLowerDoor(void) const =0; + + virtual bool door_isLowerDoorOpen(void) const =0; + + virtual uint8_t vault_getSwitches(void) const =0; + // retval bit0: cash box, bit 1: bill box + + virtual bool vault_isVaultDoorOpen(void) const =0; + + virtual void lock_switchVaultDoor(void) const =0; + + virtual bool vault_isCoinVaultIn(void) const =0; + + virtual bool vault_isBillVaultIn(void) const =0; + +// 21 + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // LEDs, Barrier, Alarm, Relais, Aux + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + virtual void led_switchLedIllumination(uint8_t on) const = 0; + + virtual void led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const =0; + + virtual bool led_coinIsOn(void) const =0; + // read back digital output from DC-uC-Port + virtual bool led_frontIsOn(void) const =0; + + virtual void led_switchLedService(uint8_t on) const =0; + // on=1 off=0 + virtual bool led_insideIsOn(void) const =0; + + virtual void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const =0; + virtual bool led_ticketIsOn(void) const =0; + + virtual void led_switchLedStart(uint8_t on, uint8_t ton, uint8_t tof) const =0; + virtual bool led_StartIsOn(void) const =0; + + virtual void led_switchLedPinPad(uint8_t on, uint8_t ton, uint8_t tof) const =0; + virtual bool led_pinIsOn(void) const =0; + + + virtual void fan_switchFan(bool on) const =0; + virtual void alarm_switchSiren(bool on) const =0; + virtual bool fan_isOn(void) const =0; + + virtual bool siren_isOn(void) const =0; + + virtual void bar_OpenBarrier(bool open) const =0; + virtual bool bar_relayIsOn(void) const =0; + + virtual bool bar_optoIn1isOn(void) const =0; + + virtual bool bar_optoIn2isOn(void) const =0; + + virtual void aux_power(bool on) const =0; + virtual bool aux_powerIsOn(void) const =0; + + virtual void aux_setUsage(uint8_t PinDirection) const =0; + virtual void aux_setOutputs(uint8_t PinIsHigh) const =0; + + virtual bool aux_isAuxPowerOn(void) const =0; + + virtual uint8_t aux_getAuxInputs(void) const =0; + + + +// ------------------------------------------------------------------------------------ +// 27.3.2023: Use Device-Controller's Bootloader to send hex-file +// ------------------------------------------------------------------------------------ + + virtual void bl_rebootDC(void) const =0; + + virtual void bl_startBL(void) const =0; + // send command within 4s after DC power-on, otherwise bl is left + + virtual void bl_checkBL(void) const =0; + // send command to verify if bl is up + + virtual bool bl_isUp(void) const =0; + // return true is bl is up and running + // also initializes "sendFile" + + virtual void bl_sendAddress(uint16_t blockNumber) const=0; + // send start address, nr of 64byte-block, start with 0 + // will be sent only for following block-numbers: + // 0, 1024, 2048, 3072 and 4096, so basically every 64kByte + // for other addresses nothing happens + + virtual uint8_t bl_wasSendingAddOK(void) const=0; + // return val: 0: no response by now 1:error 10: OK + + virtual void bl_openBinary(void) const=0; + // to be used within CashAgent, momentary not processed + + virtual void bl_sendDataBlock(uint8_t length, uint8_t *buffer) const=0; + // send 64 byte from bin file + + virtual void bl_sendLastBlock(void) const=0; + // send this command after all data are transfered + + virtual uint8_t bl_wasSendingDataOK(void) const=0; + // return val: 0: no response by now 1:error 10: OK + + virtual void bl_stopBL(void) const=0; + // leave BL and start (the new) application + + //virtual bool bl_isDiagAvailable(void) const=0; + + //virtual QString dc_getDiagText(void) const=0; + + + // Komplett-schreib Funktion, noch nicht getestet + // Nachteil: keine Rückmeldung wie lang's noch dauert + //virtual void bl_startSending(void) const=0; + // call once after BL is working and file is loaded + //virtual void bl_sendFile(void) const=0; + // call cyclic while loading bin-file to bootloader + + + + +// ------------------------------------------------------------------------------------ +// 6.4.2023: new functions for coin collection and printing +// some new system functions +// ------------------------------------------------------------------------------------ + + virtual bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const=0; + // return true if sending, false if cmd-stack is full + + virtual bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const=0; +/* + buf[0]=GlobTime.Hours; + buf[1]=GlobTime.Min; + buf[2]=GlobTime.Sec; + buf[3]=GlobTime.Year; + buf[4]=GlobTime.Month; + buf[5]=GlobTime.Day; + buf[6]=GlobTime.DOW; + buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master! + uitmp=GlobTime.MinOfDay; + buf[8]=swl_getOneByteFromUint(uitmp, 0); + buf[9]=swl_getOneByteFromUint(uitmp, 1); + buf[10]=' '; + buf[11]=' '; + ultmp=GlobTime.SecOfDay; + buf[12]=swl_getOneByteFromUlong(ultmp, 0); + buf[13]=swl_getOneByteFromUlong(ultmp, 1); + buf[14]=swl_getOneByteFromUlong(ultmp, 2); + buf[15]=swl_getOneByteFromUlong(ultmp, 3); + + buf[16]=swl_isLeap(GlobTime.Year); + buf[17]=swl_getNextLeapYear(GlobTime.Year); + buf[18]=swl_getLastLeapYear(GlobTime.Year); + buf[19]=swl_hoursOfThisWeek(GlobTime.DOW, GlobTime.Hours); + + uitmp=swl_minutesOfThisWeek(GlobTime.DOW, GlobTime.Hours, GlobTime.Min); + buf[20]=swl_getOneByteFromUint(uitmp, 0); // 0=low byte 1=high byte + buf[21]=swl_getOneByteFromUint(uitmp, 1); + + uitmp=swl_hoursOfThisMonth(GlobTime.Day, GlobTime.Hours); + buf[22]=swl_getOneByteFromUint(uitmp, 0); + buf[23]=swl_getOneByteFromUint(uitmp, 1); + + uitmp=swl_minutesOfThisMonth(GlobTime.Day, GlobTime.Hours, GlobTime.Min); + buf[24]=swl_getOneByteFromUint(uitmp, 0); + buf[25]=swl_getOneByteFromUint(uitmp, 1); + + uitmp=swl_GetDaysOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day); + buf[26]=swl_getOneByteFromUint(uitmp, 0); + buf[27]=swl_getOneByteFromUint(uitmp, 1); + + uitmp=swl_GetHoursOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day, GlobTime.Hours); + buf[28]=swl_getOneByteFromUint(uitmp, 0); + buf[29]=swl_getOneByteFromUint(uitmp, 1); + buf[30]=0; + buf[31]=0; + ultmp= swl_GetMinutesOfYear(GlobTime.Year, GlobTime.Month, GlobTime.Day, + GlobTime.Hours, GlobTime.Min); + buf[32]=swl_getOneByteFromUlong(ultmp, 0); + buf[33]=swl_getOneByteFromUlong(ultmp, 1); + buf[34]=swl_getOneByteFromUlong(ultmp, 2); + buf[35]=swl_getOneByteFromUlong(ultmp, 3); + + buf[36]=rtc_getSqwaveSettings(); + buf[37]=0; + buf[38]=0; + buf[39]=0; + + ultmp= 0; // Minutes of the Millenium + buf[40]=swl_getOneByteFromUlong(ultmp, 0); + buf[41]=swl_getOneByteFromUlong(ultmp, 1); + buf[42]=swl_getOneByteFromUlong(ultmp, 2); + buf[43]=swl_getOneByteFromUlong(ultmp, 3); + + dc2prot_setReadData(44, buf); + + */ + + virtual bool rtc_getExtendedTime(struct T_extTime *exTime) const=0; + + virtual bool sys_runCompleteTest(void) const=0; + // warning: lasts 20s in one pace + // return true if sending, false if cmd-stack is full + + virtual bool sys_ready4sending(void) const=0; + // return true if a Json-file can be sent + + virtual bool sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8_t *content ) const=0; + // kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer + // nrOfTemplate=1...32 if kindOfFile==6 + // content = content of the Json file, max 800byte ascii signs + // file is 0-terminated + // return true if sending, false if cmd-stack is full + + virtual bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const=0; + // dynPrnVal = array of 8 Variables with 8 byte each, come as ascii string + // like: char prn_dynPrnVal[8][8]; + // return true if sending, false if cmd-stack is full + + virtual bool prn_printTemplate(uint8_t nrOftemplate) const=0; + // print one of the templates loaded by Json prior + // nr = 1..32 + // return true if sending, false if cmd-stack is full + + virtual void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const=0; + // returns all acc nrs of the backuped vault records + // use: uint16_t backupedAccNumbers[8] + + virtual bool log_selectVaultRecord(uint16_t accountNr ) const=0; + // return true if sending, false if cmd-stack is full + // and trigger transfer + + virtual bool log_chkIfVaultRecordAvailable(void) const=0; + // return true if completly received + + virtual bool log_getVaultRecord(struct T_vaultRecord *retVR) const=0; + // which was selected by: log_selectVaultRecord() + // to be forwarded to Ismas + + virtual bool prn_printAccountReceipt(void) const=0; + // return true if sending to DC OK, false if cmd-stack is full + + virtual bool prn_printTestTicket(void) const=0; + // return true if sending to DC OK, false if cmd-stack is full + + virtual bool cash_startPayment(uint32_t amount) const=0; + // 17.4.23TS: extended to 32bit + + virtual uint8_t cash_paymentProcessing(void) const=0; + // 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 + + + virtual uint32_t getInsertedAmount(void) const=0; + + virtual uint16_t getLastInsertedCoin(void) const=0; + + virtual bool getAllInsertedCoins(uint16_t *types, uint16_t *values) const=0; + // all inserted coins (max 64) since "cash_startPayment" + + virtual bool cash_cancelPayment(void) const=0; + // and return coins + + virtual bool cash_stopPayment(void) const=0; + // and keep coins in escrow + + // after ticket/goods issue: + virtual bool vend_success(void) const=0; + // conclude payment process, encash all inserted coins to vault. Printing was successful + // if possible return change + + virtual bool vend_failed(void) const=0; + // conclude payment process and return all inserted coins + + + virtual uint8_t mif_getCardType(QString *cardholder) const=0; + // return 1,2,3,4 = upper, lower access card, printer test, coin test + // cardholder: 7byte Name-String + + virtual uint64_t sys_getWakeSource(void) const =0; + // retval: 6 bytes, bit coded, 1=event keeps DC awake + + virtual uint8_t sys_getWakeReason(void) const=0; + // Master was woken by following reason: + // 1: MDB Event + // 2: Coin Event + // ( 3: Master Event) - will not set the wake line + // ( 4: 32s pulse) - will not set the wake line + // 5: Door Event + // ( 6: Diag Event) - will not set the wake line + // 7: 30min-Pulse for HB + + virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const=0; + /* + + outBuf[0]=modCond.ram; + outBuf[1]=modCond.intEe; + outBuf[2]=modCond.extEe; + outBuf[3]=modCond.rtc; + outBuf[4]=modCond.boardHw; + outBuf[5]=modCond.printer; + outBuf[6]=modCond.modem; + outBuf[7]=modCond.signal; + outBuf[8]=modCond.regist; + outBuf[9]=modCond.mdbBus; + outBuf[10]=modCond.coinChecker; + outBuf[11]=modCond.coinEscrow; + outBuf[12]=modCond.mifareReader; + outBuf[13]=modCond.creditTerm; + outBuf[14]=modCond.coinReject; + outBuf[15]=modCond.coinSafe; + outBuf[16]=modCond.billSafe; + outBuf[17]=modCond.voltage; + outBuf[18]=modCond.temper; + outBuf[19]=modCond.poweronTest; + outBuf[20]=modCond.doorState; + outBuf[21]=modCond.doorWasOpened; + outBuf[22]=modCond.changer; + outBuf[23]=modCond.coinBlocker; + outBuf[24]=modCond.billReader; + outBuf[25]=modCond.ResetReason; + outBuf[26]=modCond.allModulesChecked; + outBuf[27]=modCond.alarmState; + outBuf[28]=0; + outBuf[29]=0; + + */ + + virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0; + + + virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0; +/* + + outBuf[pBuf++]=dynCond.allDoorsDebounced; + outBuf[pBuf++]=dynCond.openedAuthorized; + outBuf[pBuf++]=dynCond.CBinDebounced; + outBuf[pBuf++]=dynCond.upperDoor; + + outBuf[pBuf++]=dynCond.middleDoor; + outBuf[pBuf++]=dynCond.lowerDoor; + outBuf[pBuf++]=dynCond.coinBox; + outBuf[pBuf++]=dynCond.billBox; + + outBuf[pBuf++]=dynCond.modeAbrech; + outBuf[pBuf++]=dynCond.onAlarm; + outBuf[pBuf++]=dynCond.nowCardTest; + outBuf[pBuf++]=dynCond.nowPayment; + + outBuf[pBuf++]=dynCond.lastMifCardType; + outBuf[pBuf++]=dynCond.lastSDoorState; + outBuf[pBuf++]=dynCond.lastVDoorState; + outBuf[pBuf++]=dynCond.lastCBstate; + + outBuf[pBuf++]=dynCond.paymentInProgress; + outBuf[pBuf++]=0; + uitmp=dynCond.U_Batt; + outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETLOWBYT); + outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); + uitmp=dynCond.Temperatur; + outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETLOWBYT); + outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); + + uitmp=dynCond.nrCoinsInBox; // send seperate also + outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETLOWBYT); + outBuf[pBuf++]=swl_getOneByteFromUint(uitmp, GETHIGHBYT); + + ultmp=dynCond.amountInBox; // send seperate also + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWESTBYT); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWMID); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHMID); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHESTBYT); + + ultmp=dynCond.totalTransVolume; + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWESTBYT); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWMID); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHMID); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHESTBYT); + + ultmp=dynCond.totalNrOfVends; + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWESTBYT); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETLOWMID); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHMID); + outBuf[pBuf++]=swl_getOneByteFromUlong(ultmp, GETHIGHESTBYT); +// 36 + outBuf[pBuf++]=dynCond.jsonValid_config; + outBuf[pBuf++]=dynCond.jsonValid_device; + outBuf[pBuf++]=dynCond.jsonValid_cash; + outBuf[pBuf++]=dynCond.jsonValid_print; + outBuf[pBuf++]=dynCond.jsonValid_serial; + outBuf[pBuf++]=dynCond.jsonValid_time; + outBuf[pBuf++]=dynCond.lastFileType; + outBuf[pBuf++]=0; + +*/ + + virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0; + + // content of Cashbox + virtual uint32_t cash_getAmountInVault(void) const=0; + + virtual uint16_t cash_getNrCoinsInVault(void) const=0; + + virtual uint8_t prn_getPrintResult() const=0; + // return: 0: unknown + // 1: OK - last template was printed succesful + // 2: error - last template was not printed + + // in case of print-error get detailed error: + virtual uint8_t prn_getCurrentPrinterState() const=0; + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + + + virtual void sys_sendDeviceParameter(struct T_devices *deviceSettings) const=0; + + virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const=0; + + virtual bool sys_areDCdataValid(void) const=0; + + virtual bool sys_sendingTest(void) const =0; + + virtual void prn_requestCurrentDynData(void) const =0; + + virtual bool prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const =0; + // which was sent with: bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const override; + + virtual bool prn_dynDataAreEqual(uint8_t *buf) const =0; + + virtual bool prn_printKombiticket(uint8_t nrOfKombi) const=0; + // print four of the templates loaded by Json prior + // nr = 1..8 + + + +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_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; + +}; + + +// 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 +// 14.04.2023: V3.4 new features extended: sys_getDynMachineConditions, sys_getDeviceConditions and +// rtc_getExtendedTime return struct in addition. New function to select and get VaultRecord +// +// 19.04.2023: V3.5 new function: sys_getWakeReason(); +// 17.05.2023: V3.6 new function: cash_isCollectionActive(), cash_isPayProcessActive() +// new signals: hwapi_coinCollectionJustStopped, hwapi_coinCollectionJustStarted +// getAllInsertedCoins() fixed, also in datif and storeINdata + + + +//#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" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.4" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.5" +#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.6" + + + +Q_DECLARE_INTERFACE(hwinf, HWINF_iid) + + +#endif + + + diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 0cbc9f5..d58559e 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -122,10 +122,11 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHashvendingPrice, ba_amount.data(), std::min(ba_amount.size(),8)); QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm")); - memcpy((char*)dynTicketData->parkingEndTime, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8)); + memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8)); QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("dd.MM.yy")); - memcpy((char*)dynTicketData->parkingEndDate, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8)); + memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8)); + // ! and yes... 'ParkingEndDate' is 'currentTime' QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("dd.MM.yy")); memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8)); From 98ef7b7b26c03eaa4cacc6e70b79478ae7f869b5 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 5 Jun 2023 18:04:34 +0200 Subject: [PATCH 3/4] Send cashInputFinished(), when cash input is finished --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 18 ++++++++++++++++++ src/ATBAPP/ATBDeviceControllerPlugin.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index d58559e..d604f99 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -75,6 +75,9 @@ void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount) void ATBDeviceControllerPlugin::requestStopCashInput() { hw->cash_stopPayment(); + + // we need new cash value in application... + QTimer::singleShot(500, this, SLOT(onCashPayStoped())); } void ATBDeviceControllerPlugin::cashCollect() @@ -322,6 +325,21 @@ void ATBDeviceControllerPlugin::onCashPayStopByTimeout() ""); } +void ATBDeviceControllerPlugin::onCashPayStoped() +{ + // DEBUG + qCritical() << "ATBDeviceControllerPlugin::onCashPayStoped()"; + + uint32_t amountInt = this->hw->getInsertedAmount(); + + QString amountString = QString::number(amountInt); + + emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS, + amountString, + "", + ""); +} + bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName) { diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.h b/src/ATBAPP/ATBDeviceControllerPlugin.h index b8eba92..2278375 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.h +++ b/src/ATBAPP/ATBDeviceControllerPlugin.h @@ -127,6 +127,7 @@ private slots: // cash payment void onCashGotCoin(); + void onCashPayStoped(); void onCashPayStopByMax(); void onCashPayStopByEscrow(); void onCashPayStopByError(); From f5568f6f813c30fd30e586a9e1cfeb0d1f907532 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 5 Jun 2023 18:07:12 +0200 Subject: [PATCH 4/4] Add comment --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index d604f99..7f7e733 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -29,7 +29,6 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject( connect(dynamic_cast(hw), SIGNAL(hwapi_payStopByEscrow()), this, SLOT(onCashPayStopByEscrow())); connect(dynamic_cast(hw), SIGNAL(hwapi_payStopByError()), this, SLOT(onCashPayStopByError())); connect(dynamic_cast(hw), SIGNAL(hwapi_payStopByTimeout()), this, SLOT(onCashPayStopByTimeout())); - } ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {} @@ -341,6 +340,13 @@ void ATBDeviceControllerPlugin::onCashPayStoped() } + +/** + * Load CashAgentLib + * @brief ATBDeviceControllerPlugin::private_loadCashAgentLib + * @param pluginName + * @return + */ bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName) { if (pluginName == "") {