forked from GerhardHoffmann/DCLibraries
		
	Start repository
This commit is contained in:
		
							
								
								
									
										107
									
								
								include/com.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								include/com.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,107 @@ | ||||
| //CAT is always master, no receive before request | ||||
|  | ||||
| #ifndef SER_H | ||||
| #define SER_H | ||||
| #include <stdint.h> | ||||
| #include <QMainWindow> | ||||
| //#include <QString> | ||||
| #include <QTimer> | ||||
| #include <QSerialPort> | ||||
| #include "tslib.h" | ||||
| #include "controlBus.h" | ||||
| #include "interfaces.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 | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										213
									
								
								include/controlBus.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										213
									
								
								include/controlBus.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,213 @@ | ||||
| #ifndef CONTROLBUS_H | ||||
| #define CONTROLBUS_H | ||||
|  | ||||
|  | ||||
| #include "tslib.h" | ||||
| #include <QString> | ||||
| #include "interfaces.h" | ||||
| //#include "hwapi.h" | ||||
| #include <QDebug> | ||||
| #include "shared_mem_buffer.h" | ||||
|  | ||||
|  | ||||
| // /////////////////////////////////////////////////////////////////////////////////// | ||||
| //          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 | ||||
|  | ||||
| //  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); | ||||
|  | ||||
| //#endif | ||||
|  | ||||
| void gpi_serialIsOpen(bool offen); | ||||
|  | ||||
| bool epi_isSerialPortOpen(); | ||||
|     // true: port is open   false: port is closed | ||||
|  | ||||
|  | ||||
|  | ||||
| // Actions, GUI Buttons -> API, start cyclic transmission | ||||
| void epi_startEmmision(bool start);   // 1: start sending activated | ||||
|  | ||||
| // Meldung von TabCom an Datif: starte zyklische Sendung: | ||||
| bool gpi_isEmmisionOn(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); | ||||
|  | ||||
| //#endif | ||||
|  | ||||
| // /////////////////////////////////////////////////////////////////////////////////// | ||||
| //          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 | ||||
| // /////////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
|  | ||||
| void gpi_startNewRequest(); | ||||
|     // called by Datif | ||||
|  | ||||
| void 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 *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 | ||||
|  | ||||
| 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_storeLastResult(uint8_t letzteAntwort); | ||||
|  | ||||
| uint8_t epi_getLastResult(void); | ||||
|     // return: 0xFF: result unknown      0=OK | ||||
|     // 1= wrong length    2=wrong start sign           5= wrong crc | ||||
|     // 6= slave: master cmd was wrong       7: slave: could not write/read data | ||||
|     // 8=timeout, got no response from slave | ||||
|  | ||||
|  | ||||
| void epi_startSupervision(); | ||||
| bool gpi_wantToResetSupervision(); | ||||
|  | ||||
|  | ||||
|  | ||||
| void gpi_storeOverallResult(uint8_t letzteAntwort); | ||||
|  | ||||
| uint8_t epi_getBatchResult(void ); | ||||
|     // 0xFF: no command sent by now | ||||
|     // 0: started, in progress | ||||
|     // 1: done and OK | ||||
|     // done and error | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										206
									
								
								include/datIf.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										206
									
								
								include/datIf.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,206 @@ | ||||
| // 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 "tslib.h" | ||||
| #include "prot.h" | ||||
| #include "dcBL.h" | ||||
| //#include <QMainWindow> | ||||
| #include <QString> | ||||
| #include <QTimer> | ||||
| #include <QDebug> | ||||
| #include <QDateTime> | ||||
| #include <QDate> | ||||
| #include <QTime> | ||||
| #include "interfaces.h" | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| #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_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 | ||||
|  | ||||
|  | ||||
|  | ||||
| #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 | ||||
|  | ||||
|     int     datif_noResponseCtr; | ||||
|  | ||||
|     T_prot *myDCIF; | ||||
|     QTimer *datif_trigger; | ||||
|     uint8_t selectedSlaveAddr; | ||||
|  | ||||
| private slots: | ||||
|     char datif_cycleSend(); | ||||
|     void StoredRecData(); | ||||
|  | ||||
| public: | ||||
|     T_datif(QObject *parent = nullptr); | ||||
|  | ||||
|     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); | ||||
|  | ||||
|     void startSupervision(void); | ||||
|     //void getOverallResult(void); | ||||
|         // 0xFF: no command sent by now | ||||
|         // 0: started, in progress | ||||
|         // 1: done and OK | ||||
|         // 2: done and error | ||||
|  | ||||
|     void getOverallResult(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 | ||||
							
								
								
									
										201
									
								
								include/datei.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										201
									
								
								include/datei.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,201 @@ | ||||
| #ifndef DATEI_H | ||||
| #define DATEI_H | ||||
|  | ||||
| #include <QFile> | ||||
| #include <QFileInfo> | ||||
| #include <QDebug> | ||||
| #include "tslib.h" | ||||
| #include <QString> | ||||
| #include <QJsonDocument> | ||||
| #include <QJsonObject> | ||||
| #include <QJsonArray> | ||||
| #include <QJsonParseError> | ||||
|  | ||||
|     // create csv file with: | ||||
| #define FILESEPERATOR       ',' | ||||
|  | ||||
|     // pasre csv with: | ||||
| #define FILESEP1       ',' | ||||
| #define FILESEP2       ';' | ||||
|  | ||||
| #define NEWLINEINFILE       '\n' | ||||
| #define MAXNUMBEROFSEQUENCES      200 | ||||
|     // only for csv files | ||||
|  | ||||
|  | ||||
| // all generated files located in sudirectory "dynamic machine data - dmd" | ||||
|  | ||||
| #define FILENAME_SHAREDDATA            "../dmd/DCshare.csv" | ||||
| #define FILENAME_SHARED_UID            "../dmd/DC_UID.csv" | ||||
|  | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
| // ------------------------------------------------------ create csv file ------------------------------- | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
|  | ||||
|  | ||||
| // create array with strings and values (to be written to file) | ||||
| void csv_startCreatingFile(void); | ||||
| void csv_addTextToFile(QString myText); | ||||
| void csv_addIntToFile(int myValue); | ||||
| void csv_addUintToFile(uint myValue); | ||||
| void csv_addLongvalToFile(qlonglong myValue); | ||||
| void csv_addUlongvalToFile(qulonglong myValue); | ||||
| //void csv_addCurrentTimeToFile(void); | ||||
| //void csv_addCurrentDateToFile(void); | ||||
| void csv_addNewlineToFile(void); | ||||
| QByteArray csv_readbackArray(void); | ||||
|  | ||||
|  | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
| // ------------------------------------------------------ parse csv file ------------------------------- | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
|  | ||||
|  | ||||
| // return number of entries in the just read file (entries are seperated by | ||||
| // comma or line-feed) | ||||
| uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile); | ||||
|  | ||||
| // before: QByteArray sourceFile=datei_readFromFile(filename); | ||||
|  | ||||
| QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr); | ||||
| // not needed, just for test       // sequNr: 0....(size-1) | ||||
|  | ||||
| // get single entries of of the just read file: | ||||
| int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr); | ||||
|     // sequNr: 0....(size-1) | ||||
|  | ||||
| int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr); | ||||
|     // sequNr: 0....(size-1) | ||||
|  | ||||
| uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr); | ||||
|     // sequNr: 0....(size-1) | ||||
|  | ||||
| uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr); | ||||
|     // sequNr: 0....(size-1) | ||||
|  | ||||
| uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr); | ||||
|     // sequNr: 0....(size-1) | ||||
|  | ||||
| uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr); | ||||
|     // sequNr: 0....(size-1) | ||||
|  | ||||
| QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr); | ||||
|     // sequNr: 0....(size-1) | ||||
|  | ||||
|  | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
| // ------------------------------------------------------ create Json Record ------------------------------- | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
|  | ||||
| void json_startRecord(void); | ||||
|     // clear buffer and write opening curly bracket { | ||||
|  | ||||
| void json_enterIntToRecord(QString attribute, ulong i_value); | ||||
|     // example: "parameter":1234567890 | ||||
|  | ||||
| void json_enterTextToRecord(QString attribute, QString txt_value); | ||||
|     // example: "parameter":"slow" | ||||
|  | ||||
| //void json_addCurrentTimeToRecord(QString attribute); | ||||
|     // example: if attribute=myTime:  "myTime":"hh_mm_ss" | ||||
|  | ||||
| //void json_addCurrentDateToRecord(QString attribute); | ||||
|     // example: if attribute=myDate:  "myDate":"dd.mm.yyyy" | ||||
|     // also / possible as seperator | ||||
|     // further possible forms: | ||||
|     // 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 | ||||
|  | ||||
| void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals); | ||||
|     // add array of numbers with "nrofVals" elements | ||||
|  | ||||
| void json_enterStructToRecord(QString attribute); | ||||
|     // every call must be concluded with an extra "json_finishFile()" | ||||
|     // example: "sname":{ | ||||
|  | ||||
| void json_finishStruct(void); | ||||
|  | ||||
| void json_finishRecord(void); | ||||
|     // close curly bracket | ||||
|  | ||||
|  | ||||
| QString json_readbackRecordStr(void); | ||||
|  | ||||
| QByteArray json_readbackRecordBa(void); | ||||
|  | ||||
|  | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
| // ------------------------------------------------------ parse Json file ------------------------------- | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
|  | ||||
| // first: QByteArray datei_readFromFile(QString filename); | ||||
|  | ||||
| //void datei_json_readTestFile(QString filename); | ||||
|  | ||||
| int json_nrOfPairsInFile(QByteArray filename); | ||||
|  | ||||
| bool json_exists(QByteArray filename, QString searchForKey); | ||||
|     // look for "searchForKey" =name of the pair (left of : ) | ||||
|     // retval true if exists | ||||
|  | ||||
| bool json_remove(QByteArray filename, QString searchFor); | ||||
|     // look for "searchFor" =name of the pair (left of : ) and remove the record from file | ||||
|     // retval true if removed | ||||
|  | ||||
| QString json_searchForStringInFile(QByteArray filename, QString searchFor); | ||||
|     // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String | ||||
|  | ||||
| int json_searchForIntInFile(QByteArray filename, QString searchFor); | ||||
|     // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String | ||||
|  | ||||
| //....................... | ||||
|  | ||||
| QJsonObject json_searchForObjectInFile(QByteArray filename, QString searchFor); | ||||
|     // return an object from the json file | ||||
|  | ||||
| int json_nrOfPairsInObject(QJsonObject objname); | ||||
|  | ||||
| QString json_searchForStringInObject(QJsonObject objname, QString searchFor); | ||||
|     // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String | ||||
|  | ||||
| int json_searchForIntInObject(QJsonObject objname, QString searchFor); | ||||
|     // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String | ||||
|  | ||||
| //....................... | ||||
|  | ||||
| QJsonArray json_searchForArrayInFile(QByteArray filename, QString searchFor); | ||||
|     // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String | ||||
|  | ||||
| int json_nrOfValuesInArray(QJsonArray arrayname); | ||||
|  | ||||
| bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize); | ||||
|     // assuming that the array consists of integers | ||||
|  | ||||
|  | ||||
|  | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
| // ------------------------------------------------------ read, write, copy files ------------------- | ||||
| // ------------------------------------------------------------------------------------------------- | ||||
|  | ||||
| void datei_closeFile(QString filename); | ||||
|  | ||||
| // read content of an exiting file: | ||||
| QByteArray datei_readFromFile(QString filename); | ||||
|  | ||||
| bool datei_ifFileExists(QString filename); | ||||
|  | ||||
| char datei_writeToFile(QString filename, QByteArray content); | ||||
|     // retval=0 if successful     1: no write access allowed | ||||
|     //      2:cannot open to append     3:cannot create new file | ||||
|  | ||||
| bool datei_copyFile(QString currentFileName, QString newFileName); | ||||
|     // retval=true if successful | ||||
|  | ||||
| bool datei_clearFile(QString filename); | ||||
|     // retval=true if successful | ||||
|  | ||||
| #endif // DATEI_H | ||||
							
								
								
									
										122
									
								
								include/dcBL.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								include/dcBL.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,122 @@ | ||||
| #ifndef DCBL_H | ||||
| #define DCBL_H | ||||
| #include "qbytearray.h" | ||||
| #include "qstring.h" | ||||
| #include <QFile> | ||||
| #include "storeINdata.h" | ||||
|  | ||||
|  | ||||
| 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 | ||||
|  | ||||
|  | ||||
| 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); | ||||
|  | ||||
| char dcBL_loadBinSafe(QString fileName); | ||||
|  | ||||
|  | ||||
| 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) | ||||
|  | ||||
| uint16_t dcBL_getNrOfBlocks(void); | ||||
|     // size of the loaded bin file in 64byte blocks | ||||
|  | ||||
| uint16_t dcBL_getFileCrc(void); | ||||
|     // checksum of the loaded bin file | ||||
|  | ||||
| uint32_t dcBL_getFileSize(void); | ||||
|     // length of the loaded bin file in byte | ||||
|  | ||||
| uint8_t dcBL_getSizeOfLastBlock(void); | ||||
|  | ||||
| bool dcBL_sendOneBlockCpl(uint16_t blockNumber); | ||||
|  | ||||
| int8_t dcBL_getBlockResult(void); | ||||
|  | ||||
| char dcBL_cycle(void); | ||||
|     // to be called cyclic every 100ms | ||||
|  | ||||
|  | ||||
|  | ||||
| /* | ||||
| 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 see what's going on.... | ||||
| //  1: connected to BL | ||||
| //  2: transmission started | ||||
| //  3: transmission successful | ||||
| */ | ||||
|  | ||||
| /* move to storeINdata and use shared mem as ptu-updater uses CAslave Lib 6.9.23TS | ||||
| #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(); | ||||
|     // not used | ||||
|  | ||||
| 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 | ||||
							
								
								
									
										55
									
								
								include/dc_result.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								include/dc_result.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| #ifndef DC_RESULT_H_INCLUDED | ||||
| #define DC_RESULT_H_INCLUDED | ||||
|  | ||||
|  | ||||
| #include <QMetaType> | ||||
| #include <QString> | ||||
| #include <QDebug> | ||||
|  | ||||
| class DCResult { | ||||
| public: | ||||
|     enum class PLUGIN_STATE : quint8 { | ||||
|         NOT_INITIALIZED = 0, | ||||
|         INITIALIZED = 1 | ||||
|     }; | ||||
|  | ||||
|     enum class RESULT_STATE : quint8 { | ||||
|         SUCCESS = 1,                // operation was successfull | ||||
|         ERROR_BACKEND,              // error from backend (e.g. backend replies with error) | ||||
|         ERROR_TIMEOUT,              // the operation timed out | ||||
|         ERROR_PROCESS,              // internal plugin error, should not occur (this is a bug in implementation) | ||||
|         ERROR_RETRY,                // retry operation | ||||
|         INFO                        // informational (e.g. display a message, log something etc.) | ||||
|     }; | ||||
|  | ||||
|     enum class CASH_STATE   : quint8 { | ||||
|         CACHE_EMPTY,                // Cache still empty, default state | ||||
|         CACHE_INPUT,                // Coins are in Cache | ||||
|         OVERPAYED, | ||||
|         NOT_AVAILABLE | ||||
|         /* t.b.d. */ | ||||
|     }; | ||||
|  | ||||
|     explicit DCResult(); | ||||
|     explicit DCResult(PLUGIN_STATE, RESULT_STATE, QString errorCode = "", | ||||
|                       QString errorDescription = "", | ||||
|                       QString cashValue = ""); | ||||
|     explicit DCResult(PLUGIN_STATE, RESULT_STATE, CASH_STATE, | ||||
|                       QString errorCode = "", | ||||
|                       QString errorDescription = "", | ||||
|                       QString cashValue = ""); | ||||
|  | ||||
|     PLUGIN_STATE m_pluginState; | ||||
|     RESULT_STATE m_resultState; | ||||
|     CASH_STATE m_cashState; | ||||
|  | ||||
|     QString m_errorCode; | ||||
|     QString m_errorDescription; | ||||
|     QString m_newCashValue; | ||||
| }; | ||||
|  | ||||
| QDebug operator<<(QDebug d, DCResult const &result); | ||||
|  | ||||
| Q_DECLARE_METATYPE(DCResult) | ||||
|  | ||||
| #endif // DC_RESULT_H_INCLUDED | ||||
							
								
								
									
										305
									
								
								include/globdefs.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										305
									
								
								include/globdefs.h
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,305 @@ | ||||
| // global defines | ||||
| // ab 6.Juli2020: neuese Board DC2b | ||||
|  | ||||
| #ifndef GLOBDEFS_H | ||||
| #define GLOBDEFS_H | ||||
|  | ||||
| #include <bios19/biosdefs.h> | ||||
|  | ||||
| //#define        VERSION_DC_HW    "DC2b_25.02.2020" | ||||
| #define        VERSION_DC_HW    "DC2c_oct2022" | ||||
| //#define        VERSION_PO_HW    "PO2d_27.03.2020" | ||||
| #define        VERSION_PO_HW    "PO2e_nov2022" | ||||
| #define        VERSION_SW       "DC2c.04.12 06.04.2023" | ||||
| //#define        VERSION_SW       "DC2c.04.04b14.02.2023" | ||||
| //#define        VERSION_SW       "DC2c.04.04c14.02.2023" | ||||
|  | ||||
|  | ||||
| #define		USE1256MODE		1 | ||||
| #define		SEND_DIAG_TO_MASTER		1 | ||||
|  | ||||
| #define MAX_DATA_FROM_MASTER        64 | ||||
| #define MAX_RECLEN_FROM_MASTER      MAX_DATA_FROM_MASTER+20 | ||||
|  | ||||
| #define MAX_DATA_TO_MASTER          64 | ||||
| #define MAX_SENDLEN_TO_MASTER       MAX_DATA_TO_MASTER+16 | ||||
|  | ||||
| #define WORK_WITHOUT_HANDSHAKES | ||||
|  | ||||
| #define PAGEBUFFERSIZE	1026 | ||||
| extern UCHAR PageBuffer[PAGEBUFFERSIZE]; | ||||
|  | ||||
| #define WAKESRC_NONE    0 | ||||
| #define WAKESRC_MDB     1 | ||||
| #define WAKESRC_COIN    2 | ||||
| #define WAKESRC_MASTER  3 | ||||
| #define WAKESRC_RTC     4 | ||||
| #define WAKESRC_DOOR    5 | ||||
| #define WAKESRC_DIAG    6 | ||||
| #define WAKESRC_HB      7 | ||||
|  | ||||
| struct T_power | ||||
| { | ||||
|     char busy; | ||||
|     char sleepAllowed; | ||||
|     UCHAR WakeSource; | ||||
|     char everythingUP; | ||||
|     char WokenByDevice; | ||||
|     char NoExternalEventNow; | ||||
|     char WakePulseNowActive; | ||||
| 	UCHAR DC_status;			// 0:POR    1:board ini    2:running HWtest    3: device ini   4: start-up-test | ||||
| 								// 5: SW Module ini    | ||||
| 	UCHAR storeWakeReason[6];	 | ||||
| 	char blockRS2forMif;	 | ||||
| 	char blockRS1forPrinter;						 | ||||
| }; | ||||
|  | ||||
|  | ||||
| struct T_globTime | ||||
| { | ||||
|     UCHAR Year; | ||||
|     UCHAR Month; | ||||
|     UCHAR Day; | ||||
|     UCHAR DOW;          // 1(Mo)....7(So) | ||||
|     UCHAR Hours; | ||||
|     UCHAR Min; | ||||
|     UCHAR Sec; | ||||
|     UINT  MinOfDay;     // Anzahl Minuten des Tages 0...1439 | ||||
|     ULONG SecOfDay; | ||||
|     //UCHAR IsLeap; | ||||
|     //UCHAR aktuell;      // 0,1  der der liest kann es auf 0 setzen | ||||
|                         //  und sieht dann wanns wieder aktuell | ||||
| }; | ||||
| extern struct T_globTime   GlobTime; | ||||
|  | ||||
| extern UCHAR main_getWakeEvent(void); | ||||
|  | ||||
| struct T_out    // f<>r alle Levels | ||||
| { | ||||
|     UINT  WrCmd;            // was soll gemacht/gesetzt werden | ||||
|     UINT  address;          // z.B. bei Datenspeicher. Bin<69>r. | ||||
|     UCHAR datLen;           // Anzahl nachfolgender Datenbytes | ||||
|     UCHAR inBuf[MAX_DATA_FROM_MASTER];        // kam so vom Master rein, soll ausgegeben werden | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
| struct T_in    // f<>r alle Levels | ||||
| { | ||||
|     UINT  RdCmd;            // was soll gemacht/gesetzt werden | ||||
|     UINT  address;          // z.B. bei Datenspeicher. Bin<69>r. | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| struct T_serial | ||||
| { | ||||
| 	// basic machine settings ("DIP-Switches") | ||||
|     // to be stored in eeprom | ||||
|     UCHAR   crcCheckOn;     // 1,0 | ||||
|     UCHAR   baudRate;       // 1...8 | ||||
|     UCHAR   parity;         // 'E' 'O' 'N' | ||||
|     //UCHAR   myAddr;         // not needed | ||||
|     //UCHAR   NowTestmode;    // 1=on | ||||
| 	UCHAR	dataBits;		// 8 | ||||
| 	UCHAR	stopBits;		// 1 | ||||
| 	UCHAR	pad6; | ||||
| }; | ||||
|  | ||||
|  | ||||
| struct T_devices | ||||
| { | ||||
| 	// set by master, used(1) or notused (0) or type 2....20 | ||||
| 	// to be stored in eeprom | ||||
| 	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; | ||||
| 	 | ||||
| }; | ||||
|  | ||||
| /* | ||||
| struct T_cashAccept // 1.version des cash.json files | ||||
| { | ||||
| 	// Values come from Json File | ||||
| 	UINT  coinsToAccept;	// bit 15...0,   je 1=accept   0=do not	 | ||||
| 	UCHAR billsToAccept;	// bit 7...0,   je 1=accept   0=do not	 | ||||
| 	UCHAR tokenChannel;	 | ||||
|  | ||||
| 	ULONG exchgRate;	// Multiplikator local -->foreign currency | ||||
| 						// eg: hungary: 380    (380Ft = 1EUR) | ||||
|  | ||||
| 	UINT foreignCoinValue[8];		 | ||||
| 	UINT localCoinValues[8];	// read from coin checker | ||||
| 	 | ||||
| };   */ | ||||
|  | ||||
| struct T_cashAccept | ||||
| { | ||||
| 	// all Values come from Json File | ||||
| 	// struct will be stored in eeprom. respect 4byte-borders | ||||
| 	 | ||||
| 	UINT CoinDenomination[16];	// 15...8 =foreign coins    7..0 =local coins | ||||
| 	UINT CoinValues[16];		// 15...8 =foreign coins    7..0 =local coins | ||||
| 		// bei der lokalen Landesw<73>hrung wird der Wert eines Geldst<73>ckes 		 | ||||
| 		// direkt verwendet, da steht genau das gleiche drin wie in "Denom"  | ||||
| 		// Die ausl<73>ndischen M<>nzen werden hier umgerechnet, z.B. 100cent=378Huf | ||||
| 	//char Coins2Accept[16]; | ||||
| 		// kommt jetzt direkt aus Json und ersetzt: | ||||
| 	UINT  coinAcceptance;	// bit 15...0,   je 1=accept   0=do not	 | ||||
|  | ||||
| 	ULONG exchgRate;	// Multiplikator local -->foreign currency | ||||
| 						// eg: hungary: 380    (380Ft = 1EUR) | ||||
| 	UCHAR tokenChannel;		// 0=off, oder 1..16 | ||||
| 	UCHAR  res1; | ||||
| 	UCHAR  res2; | ||||
| 	UCHAR  res3;	 | ||||
| 	 | ||||
| 	UINT billValues[8];		 | ||||
|  | ||||
| 	//UCHAR localTaxRate; | ||||
| 	//UCHAR foreignTaxRate;	 | ||||
| 		 | ||||
| 	//UINT	surcharge; | ||||
| 	//UINT	discount; | ||||
| 	//UINT	res4; | ||||
| 	//UINT	res5; | ||||
| 	 | ||||
| }; | ||||
|  | ||||
| struct T_machID | ||||
| { | ||||
| 	// liegen im int. eeprom | ||||
| 	// to be stored in eeprom | ||||
| 	UINT	customerNumber; | ||||
| 	UINT	machineNumber; | ||||
| 	UINT	borough;	// =group | ||||
| 	UINT	zone; | ||||
| 	UINT	alias;				// for example another machine number for customer | ||||
| 	UINT	firstrun; | ||||
| 	UCHAR   location[32]; | ||||
| 	 | ||||
| }; | ||||
|  | ||||
| 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  | ||||
| 	 | ||||
| 	UCHAR	structStart;		// always first!!! | ||||
| 	UCHAR	ram;				// v | ||||
| 	UCHAR	intEe;				// v | ||||
| 	UCHAR	extEe;				// v | ||||
| 	 | ||||
| 	UCHAR	rtc;				// 1: time/date OK   100: time not plausible  200: hardware error    | ||||
| 	UCHAR	boardHw;			// v | ||||
| 	UCHAR	printer;			// v | ||||
| 	UCHAR	modem;				// v | ||||
| 	 | ||||
| 	UCHAR	signal;				//		1...99 | ||||
| 	UCHAR	regist;				// 100:not  1:reg  2:ping OK   3:gotTime | ||||
| 	UCHAR	mdbBus;		 | ||||
| 	UCHAR	coinChecker;		// EMP, OMP or mei-cashflow | ||||
| 	 | ||||
| 	UCHAR	coinEscrow;			// v | ||||
| 	UCHAR	mifareReader;		// v | ||||
| 	UCHAR	creditTerm;			// not available | ||||
| 	UCHAR	coinReject;			// v | ||||
| 	 | ||||
| 	UCHAR	coinSafe;			// v | ||||
| 	UCHAR   billSafe;			// v | ||||
| 	UCHAR	voltage;			// v	// 1:11..14V | ||||
| 	UCHAR   temper;				// v | ||||
| 	 | ||||
| 	UCHAR	poweronTest; | ||||
| 	UCHAR   doorState;			// 1: alles zu  200: t<>r offen + bit1(S) +bit2(CB) + bit3(CB) | ||||
| 	UCHAR	doorWasOpened;		// 1: all doors are closed   200: any door was just opened | ||||
| 	UCHAR	changer;			// can only be tested by usage | ||||
| 	 | ||||
| 	UCHAR   coinBlocker;		// can only be tested by usage | ||||
| 	UCHAR   billReader;			// can only be tested by usage | ||||
| 	UCHAR   ResetReason;	 | ||||
| 	UCHAR	allModulesChecked; | ||||
| 	 | ||||
| 	UCHAR   alarmState;	 | ||||
| 	UCHAR   res11; | ||||
| 	UCHAR   res12; | ||||
| 	UCHAR   res13; | ||||
| 	 | ||||
| }; | ||||
|  | ||||
| struct T_dynamicCondition | ||||
| { | ||||
| 	// dynamic conditions, change rapidly and frequently | ||||
| 	// these are values for the Heartbeat | ||||
| 	 | ||||
| 	// T<>rschalter entprellt: | ||||
| 	char upperDoor;		// 0:fehlt  1:drin | ||||
| 	char middleDoor; | ||||
| 	char lowerDoor; | ||||
| 	char coinBox; | ||||
|  | ||||
| 	char billBox; | ||||
| 	char modeAbrech; | ||||
| 	char onAlarm; | ||||
| 	char nowCardTest; | ||||
|  | ||||
| 	char nowPayment; | ||||
| 	char lastMifCardType; | ||||
| 	char openedAuthorized; | ||||
| 	char allDoorsDebounced; | ||||
| 	 | ||||
| 	UCHAR lastSDoorState; | ||||
| 	UCHAR lastVDoorState; | ||||
| 	UCHAR CBinDebounced; | ||||
| 	UCHAR lastCBstate;	 | ||||
| 	 | ||||
| 	char  paymentInProgress; | ||||
| 	char res1; | ||||
| 	char res2; | ||||
| 	char res3; | ||||
| 		 | ||||
| 	UINT	U_Batt; | ||||
| 	UINT	Temperatur; | ||||
| 		 | ||||
| 	UINT	cash_storedaccNumbers[8];	// List all stored accounting numbers in ext. eeprom | ||||
| 	 | ||||
| 	UINT	nrCoinsInBox; | ||||
| 	UINT	resui1; | ||||
| 	 | ||||
| 	ULONG	amountInBox; | ||||
| 	ULONG	amountJustPaid; | ||||
|  | ||||
| 	UINT	lastInsCoinType;	// wahrscheinlich uchar | ||||
| 	UINT	resui2;	 | ||||
| 	 | ||||
| 	ULONG	totalTransVolume; | ||||
| 	ULONG	totalNrOfVends; | ||||
| 	 | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										1386
									
								
								include/hwapi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1386
									
								
								include/hwapi.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1683
									
								
								include/interfaces.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										1683
									
								
								include/interfaces.h
									
									
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										6
									
								
								include/plugin.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								include/plugin.h
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| #ifndef PLUGIN_H | ||||
| #define PLUGIN_H | ||||
| //#include "../plugins/interfaces.h" | ||||
| #include "../MasterPlug/interfaces.h" | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										134
									
								
								include/prot.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								include/prot.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,134 @@ | ||||
|  | ||||
| #ifndef SERIAL_FRAME_H | ||||
| #define SERIAL_FRAME_H | ||||
| #include <QMainWindow> | ||||
| #include <QString> | ||||
| #include <QTimer> | ||||
| #include "tslib.h" | ||||
| #include "com.h" | ||||
| #include "interfaces.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         200 | ||||
|  | ||||
| #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 QMainWindow | ||||
| { | ||||
|     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]; | ||||
|     uint8_t  prot_storeResult; | ||||
|  | ||||
|     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_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); | ||||
|  | ||||
|     void setBLsendData( uint8_t len, uint8_t *buf); | ||||
|  | ||||
|     void receiveFixLen(int64_t nrOfbytesToReceive); | ||||
|  | ||||
|     void sendUserData(uint16_t slaveAdr); | ||||
|  | ||||
|     uint8_t ifDataReceived(); | ||||
|         // return: 0xFF: result unknown      0=OK | ||||
|         // 1= wrong length    2=wrong start sign           5= wrong crc | ||||
|         // 6= slave: master cmd was wrong       7: slave: could not write/read data | ||||
|  | ||||
|     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 | ||||
							
								
								
									
										86
									
								
								include/runProc.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										86
									
								
								include/runProc.h
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,86 @@ | ||||
|  | ||||
| #ifndef RUN_PROCESS_H | ||||
| #define RUN_PROCESS_H | ||||
|  | ||||
| #include <QMainWindow> | ||||
| #include <QString> | ||||
| #include <QTimer> | ||||
| #include "tslib.h" | ||||
| #include "com.h" | ||||
| #include "interfaces.h" | ||||
|  | ||||
| #include <QtPlugin> | ||||
| #include <QObject> | ||||
| #include <QDebug> | ||||
| #include "datIf.h" | ||||
| #include <QSharedMemory> | ||||
| #include "sendWRcmd.h" | ||||
| #include "controlBus.h" | ||||
| #include "storeINdata.h" | ||||
| #include "dcBL.h" | ||||
| #include "shared_mem_buffer.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| class T_runProc : public QObject | ||||
| { | ||||
|     Q_OBJECT | ||||
|     QTimer *hwapi_TimerPayment, *hwapi_triggerBL; | ||||
|  | ||||
|     void sub_emp_getAllParameters(struct T_emp *emp); | ||||
|     void changer_getAllParameters(struct T_changer *mw); | ||||
|  | ||||
|     void sub_getDynMachineConditions(struct T_dynamicCondition *dynMachCond); | ||||
|  | ||||
|     void restoreDeviceParameter(struct T_devices *deviceSettings); | ||||
|  | ||||
| private slots: | ||||
|     void runProc_slotProcess(void); | ||||
|     bool bl_performComplStart(void); | ||||
|  | ||||
| public: | ||||
|     T_runProc(); | ||||
|  | ||||
|     bool cash_startPayment(uint32_t amount); | ||||
|     uint8_t cash_paymentProcessing(void); | ||||
|     uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf); | ||||
|     uint8_t epi_restore64BdevParameter(uint8_t *length, uint8_t *buf); | ||||
|     bool doors_supervise(void); | ||||
|     uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state); | ||||
|     void bl_completeStart(void); | ||||
|     void dc_autoRequest(bool on); | ||||
|     void bl_rebootDC(void); | ||||
|     void bl_startBL(void); | ||||
|     void bl_checkBL(void); | ||||
|     bool bl_isUp(void); | ||||
|  | ||||
|  | ||||
| signals: | ||||
|     //void runProc_templatePrintFinished_OK(void) const override; | ||||
|     //void runProc_templatePrintFinished_Err(void) const override; | ||||
|  | ||||
|     void runProc_coinCollectionJustStarted(void); | ||||
|     void runProc_coinCollectionAborted(void); | ||||
|  | ||||
|     void runProc_gotNewCoin(void); | ||||
|     void runProc_payStopByMax(void); | ||||
|     void runProc_payStopByPushbutton(void); | ||||
|  | ||||
|     void runProc_payStopByEscrow(void); | ||||
|     void runProc_payStopByError(void); | ||||
|     void runProc_payStopByTimeout(void); | ||||
|     void runProc_payCancelled(void); | ||||
|     void runProc_coinProcessJustStopped(void); | ||||
|  | ||||
|     void runProc_doorServiceDoorOpened(void); | ||||
|     void runProc_doorVaultDoorOpened(void); | ||||
|     void runProc_doorCoinBoxRemoved(void); | ||||
|     void runProc_doorCoinBoxInserted(void); | ||||
|     void runProc_doorCBinAndAllDoorsClosed(void); | ||||
|     void runProc_doorAllDoorsClosed(void); | ||||
|  | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										262
									
								
								include/sendWRcmd.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										262
									
								
								include/sendWRcmd.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,262 @@ | ||||
|  | ||||
| #ifndef SENDWRCMDS_DEFS_H | ||||
| #define SENDWRCMDS_DEFS_H | ||||
| #include "tslib.h" | ||||
| #include <QString> | ||||
|  | ||||
| // 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!!! | ||||
|  | ||||
|  | ||||
| // aug2023: used with setSendCommand0 | ||||
| //#define SENDDIRCMD_TestSerial           1 | ||||
| //#define SENDDIRCMD_MakeReset            2 | ||||
| //#define SENDDIRCMD_setTime              3 | ||||
| //#define SENDDIRCMD_setWakeFrequ         4 | ||||
|  | ||||
| //#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 | ||||
| //#define SENDDIRCMD_MIF_ATBCREATE        33 | ||||
|  | ||||
| //#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 | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| // TODO: | ||||
| //#define SENDDIRCMD_PRN_SETUP            72 | ||||
| //#define SENDDIRCMD_MDB_SNDMSG           92 | ||||
| //#define SENDDIRCMD_EMP_SETT             93 | ||||
| //#define SENDDIRCMD_PRN_BC               80 | ||||
|  | ||||
|  | ||||
|  | ||||
| // 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_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_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_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 / 32 | ||||
| // short and long commands are queued into the same stack to guaranty right order | ||||
| 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 check4usedFDstack(void); | ||||
|     // returns number of waiting command, maxFDCMD_STACKDEPTH | ||||
|  | ||||
| uint8_t checkNextFDcmd(void); | ||||
|     // return 0: no command waiting | ||||
| //          1: short cmd | ||||
| //          2: long cmd | ||||
|  | ||||
| uint8_t check4freeFDstack(void); | ||||
|     // returns number of free places in FD-command stack | ||||
|  | ||||
|  | ||||
| bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data); | ||||
| bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, QByteArray *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); | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
							
								
								
									
										351
									
								
								include/shared_mem_buffer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										351
									
								
								include/shared_mem_buffer.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,351 @@ | ||||
| #ifndef SHARED_MEM_BUFFER_INCLUDED_H | ||||
| #define SHARED_MEM_BUFFER_INCLUDED_H | ||||
|  | ||||
| #include <cinttypes> | ||||
| #include <atomic> | ||||
|  | ||||
| #include <QSharedMemory> | ||||
| #include <QtGlobal> | ||||
|  | ||||
|  | ||||
| bool shdMem_firstUse(void); | ||||
|  | ||||
| // Vorsicht: im shared memory ist kein QString erlaubt!!!!!!!!!!!!!!!!!!!!!! | ||||
| //    nur standard C Typen!!!!!! | ||||
| //    also auch kein QByteArray o.ä. | ||||
|  | ||||
| // Vorsicht: Zugriffe auf Comport NICHT ins shared mem --> Absturz!!!! | ||||
|  | ||||
| struct SharedMem | ||||
| { | ||||
|     // ------------------ Comport Control -------------------------------- | ||||
|     bool     rs_portIsOpen; | ||||
|     bool     AutoEmissionOn; | ||||
|     bool     Sdata_serialTestResult; | ||||
|     uint8_t  Sdata_pProtResultOk; | ||||
|     uint16_t Sdata_receivedDataLength; | ||||
|     uint8_t  Sdata_receivedDataBlock[64]; | ||||
|     uint8_t  ndbs, pari, nsb, br; | ||||
|  | ||||
|     uint8_t  Sdata_lastResult; | ||||
|     uint8_t  Sdata_OverallResult; | ||||
|     bool     Sdata_startSV; | ||||
|  | ||||
|     // ------------------ Data INPUT -------------------------------- | ||||
|  | ||||
|     bool indat_savePrnPwr; | ||||
|     bool indat_saveMifPwr; | ||||
|     bool indat_MdbIsOn; | ||||
|     //QString indat_HWversion; | ||||
|     //QString indat_SWversion; | ||||
|     //QString indat_DCstate; | ||||
|  | ||||
|     #define versionBufferLen   32 | ||||
|     char indat_HWversion[versionBufferLen]; | ||||
|     char indat_SWversion[versionBufferLen]; | ||||
|     char indat_DCstate[versionBufferLen]; | ||||
|  | ||||
|     struct Sdata | ||||
|     { | ||||
|         uint64_t slaveUID; | ||||
|         uint8_t UIDstr[8]; | ||||
|     } Sdata; | ||||
|  | ||||
|     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; | ||||
|  | ||||
|     #define MAXNROF_AI              4 | ||||
|     uint16_t   AI_val[MAXNROF_AI]; | ||||
|  | ||||
|     #define MAXNROF_MEASURE         4 | ||||
|     uint32_t   Sdata_measurement[MAXNROF_MEASURE]; | ||||
|  | ||||
|     uint8_t di_doorSwitch; | ||||
|     uint8_t di_vaultSwitch; | ||||
|     uint8_t di_lockSwitch; | ||||
|     uint8_t di_opto; | ||||
|     uint8_t di_aux; | ||||
|     bool di_wakeFromPtu; | ||||
|     bool di_wakeFromMdb; | ||||
|     bool di_PrnReady; | ||||
|     bool di_CoinAttach; | ||||
|     bool di_CoinEscrowOpen; | ||||
|     bool di_mifCardTap; | ||||
|     bool di_wakeFromModem; | ||||
|     bool di_contactPwrOn; | ||||
|     bool di_mifarePwrOn; | ||||
|     bool di_rdbk_mdbTxd; | ||||
|     bool di_AuxPwrOn; | ||||
|     bool di_gsmPwrOn; | ||||
|     bool di_creditPwrOn; | ||||
|     bool di_printerPwrOn; | ||||
|     bool di_mdbPwrOn; | ||||
|     bool di_rejMot_home; | ||||
|     uint8_t di_npe_sensor; | ||||
|  | ||||
|     uint8_t do_mbdRxTst; | ||||
|     uint8_t do_motorBits; | ||||
|     uint8_t do_serialSwitch; | ||||
|     uint8_t do_ledsAndFan; | ||||
|     uint8_t do_laermUndRelay; | ||||
|     uint8_t do_ptuWake; | ||||
|     uint8_t do_auxPower; | ||||
|     uint8_t do_coinShutter; | ||||
|     uint8_t do_coinEscrow; | ||||
|     uint8_t do_printerPower; | ||||
|  | ||||
|     //#define NROFMIFSTATEBYTES   40 | ||||
|     //uint8_t Sdata_MIF_STATE[NROFMIFSTATEBYTES]; | ||||
|     uint8_t Sdata_MIF_DATA[64]; | ||||
|     //uint8_t mif_cardType; | ||||
|     //uint8_t mif_cardHolder[8]; | ||||
|     uint8_t Sdata_MIF_ATB[64]; | ||||
|  | ||||
|     #define pi_prnStateArraySize    20 | ||||
|     uint8_t Sdata_PRN_STATE[pi_prnStateArraySize]; | ||||
|  | ||||
|     #define pi_prnFontArraySize     20 | ||||
|     uint8_t Sdata_PRN_FONTS[pi_prnFontArraySize]; | ||||
|  | ||||
|     bool Sdata_mdb_busRdy; | ||||
|     bool Sdata_mdb_V12on; | ||||
|     bool Sdata_mdb_V5on; | ||||
|  | ||||
|     uint8_t Sdata_mdbNrOfRecData; | ||||
|     uint8_t Sdata_RecBuff[40]; | ||||
|  | ||||
|     uint8_t Sdata_empNrOfsettings; | ||||
|     uint8_t Sdata_emp_settingsBuff[66]; | ||||
|  | ||||
|     struct T_coin | ||||
|     { | ||||
|         uint8_t valid; | ||||
|         uint8_t signal; | ||||
|         uint8_t error; | ||||
|         uint8_t pad; | ||||
|         uint16_t value; | ||||
|     }; | ||||
|  | ||||
|     #define     MEMDEPTH_GOTCOINS       16 | ||||
|     struct T_coin gotCoin[MEMDEPTH_GOTCOINS]; | ||||
|     uint8_t ctr_gotCoin; | ||||
|  | ||||
|     uint8_t Sdata_NrOfDeviceSetting; | ||||
|     uint8_t Sdata_DeviceSettingBuff[66]; | ||||
|  | ||||
|     uint8_t SizeMachineIDBuff; | ||||
|     uint8_t MachineIDBuff[66]; | ||||
|  | ||||
|     uint32_t store_insertedAmount; | ||||
|     uint16_t store_lastCoinType[64]; | ||||
|     uint16_t store_lastCoinValue[64]; | ||||
|     uint8_t  p_lastCoin; | ||||
|     char     store_curPayNewCoin; | ||||
|  | ||||
|     uint64_t stor_wakSrc; | ||||
|     uint8_t  stor_reason; | ||||
|  | ||||
|     uint8_t store_rbDevParamLen; | ||||
|     uint8_t store_rbDevParams[66]; | ||||
|  | ||||
|     uint8_t store_deviceCondLen; | ||||
|     uint8_t store_deviceCond[66]; | ||||
|  | ||||
|     uint8_t store_machCondLen; | ||||
|     uint8_t store_machCond[66]; | ||||
|  | ||||
|     uint8_t  store_DcBackupNrOfAccNr; | ||||
|     uint16_t store_DcBackupAccNr[16];    // z.Z. nur 8 | ||||
|  | ||||
|     #define PI_SIZOFVAULTRECORD    400 | ||||
|     uint8_t store_gotNrBlocksOfVaultRec; | ||||
|     uint8_t store_vaultrecord[PI_SIZOFVAULTRECORD]; | ||||
|  | ||||
|     uint32_t store_amount; | ||||
|     uint16_t store_nrOfCoins; | ||||
|  | ||||
|     bool store_DcDataAreValid; | ||||
|  | ||||
|     uint8_t storeDCdynPrinterData[64]; | ||||
|     uint8_t DCdynPrinterDataActual; | ||||
|  | ||||
|     uint16_t store_DCNextAccountNumber; | ||||
|  | ||||
|     uint16_t storeMifCardTypDataLen; | ||||
|     uint8_t  storeMcardTypData[64]; | ||||
|  | ||||
|     // new from 6.9.23: | ||||
|     #define RAW_BL_DATALEN      150 | ||||
|     uint8_t Sdata_rawData[RAW_BL_DATALEN]; | ||||
|     uint8_t Sdata_LengthRawData; | ||||
|  | ||||
| #define  numberOfJsons     36 | ||||
| #define  versionStringLength    16 | ||||
|     char    store_jsonVersion[versionStringLength][numberOfJsons]; | ||||
|  | ||||
|     uint8_t Sdata_changeResult; | ||||
|     uint32_t Sdata_changedAmount; | ||||
|     uint8_t  store_tubeLev[64]; | ||||
|  | ||||
|  | ||||
|     // Mitteilung von Hwapi zu Datif: | ||||
|     bool    Sdata_coinPaymentNow; | ||||
|     bool    Sdata_bootloadingNow; | ||||
|  | ||||
|  | ||||
|     // ------------------ Data OUTPUT -------------------------------- | ||||
|  | ||||
|     // sendWRcmd.cpp | ||||
|     #define CMDSTACKDEPTH   16 | ||||
|     uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH]; | ||||
|     uint8_t  nrOfCmdsInQueue; | ||||
|  | ||||
|     #define CMD4STACKDEPTH   8 | ||||
|     uint16_t    nextAsynchsendCmd4[CMD4STACKDEPTH]; | ||||
|     uint8_t     nextCmd4para1[CMD4STACKDEPTH]; | ||||
|     uint8_t     nextCmd4para2[CMD4STACKDEPTH]; | ||||
|     uint8_t     nextCmd4para3[CMD4STACKDEPTH]; | ||||
|     uint8_t     nextCmd4para4[CMD4STACKDEPTH]; | ||||
|     uint8_t     nrOfCmds4InQueue; | ||||
|  | ||||
|     #define CMD8STACKDEPTH   4 | ||||
|     uint16_t  nextAsynchsendCmd8[CMD8STACKDEPTH]; | ||||
|     uint8_t   nextCmd8para1[CMD8STACKDEPTH]; | ||||
|     uint8_t   nextCmd8para2[CMD8STACKDEPTH]; | ||||
|     uint16_t  nextCmd8para3[CMD8STACKDEPTH]; | ||||
|     uint32_t  nextCmd8para4[CMD8STACKDEPTH]; | ||||
|     uint8_t   nrOfCmds8InQueue; | ||||
|  | ||||
|     #define SENDASYDAT_BUFFSIZE     200 | ||||
|     uint8_t sendAsynchDataBuf[SENDASYDAT_BUFFSIZE]; // no stack, only ONE buffer | ||||
|     uint8_t sendAsyDatLen; | ||||
|  | ||||
|     #define MDBSEND_BUFFSIZE    64 | ||||
|     uint8_t     Sdata_mdbSendBuffer[MDBSEND_BUFFSIZE]; | ||||
|     uint8_t     Sdata_mdbSendLen; | ||||
|  | ||||
|     uint8_t     prnDataParameters[4]; | ||||
|     uint8_t     prnDataBufferUser; | ||||
|  | ||||
|  | ||||
|     // ONE printer doc consists of 20 x 64 byte | ||||
|     #define MAXNROF_PRNBYTES   64 | ||||
|     #define MAXNROF_PRNBLOCKS  20 | ||||
|     char        Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES]; | ||||
|     uint8_t     pPrnDataBuff;        // points to next PRINTER_BLOCK | ||||
|  | ||||
|  | ||||
|     //#define     FDCMD_STACKDEPTH    16      // up to 1024 byte | ||||
|     #define     FDCMD_STACKDEPTH    32      // up to 2048 byte | ||||
|     // header | ||||
|     uint8_t nextFDwrCmd[FDCMD_STACKDEPTH]; | ||||
|     uint8_t nextFDrdCmd[FDCMD_STACKDEPTH]; | ||||
|     uint8_t nextFDblkNr[FDCMD_STACKDEPTH]; | ||||
|     uint8_t nextFDshort[FDCMD_STACKDEPTH]; | ||||
|  | ||||
|     // short data | ||||
|     uint8_t  nextFDpara1[FDCMD_STACKDEPTH]; | ||||
|     uint8_t  nextFDpara2[FDCMD_STACKDEPTH]; | ||||
|     uint8_t  nextFDpara3[FDCMD_STACKDEPTH]; | ||||
|     uint8_t  nextFDpara4[FDCMD_STACKDEPTH]; | ||||
|     // long data: | ||||
|     uint8_t longFDlength[FDCMD_STACKDEPTH]; | ||||
|     uint8_t longFDpara[FDCMD_STACKDEPTH][64]; | ||||
|  | ||||
|     uint8_t  p_nextFDcmdsInQueue; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     static QSharedMemory *getShm(std::size_t s = 0); | ||||
|  | ||||
|     static SharedMem *getData() | ||||
|     { | ||||
|         Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr"); | ||||
|         return (SharedMem *)getShm()->data(); | ||||
|     } | ||||
|  | ||||
|     static SharedMem const *getDataConst() | ||||
|     { | ||||
|         Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr"); | ||||
|         return (SharedMem const *)getShm()->data(); | ||||
|     } | ||||
|  | ||||
| //    static SharedMemBuffer *write() | ||||
|     static SharedMem *write() | ||||
|     { | ||||
|         Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr"); | ||||
|         return (SharedMem *)getShm()->data(); | ||||
|     } | ||||
|  | ||||
| //    static SharedMemBuffer const *read() | ||||
|     static SharedMem const *read() | ||||
|     { | ||||
|         Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr"); | ||||
|         return (SharedMem const *)getShm()->data(); | ||||
|     } | ||||
|  | ||||
|     bool thisIsTheFirstUse(void); | ||||
|  | ||||
|     #if 0 | ||||
|     static std::atomic<bool> __sharedMemLocked; | ||||
|  | ||||
|     static bool sharedMemLocked() { | ||||
|         return __sharedMemLocked; | ||||
|     } | ||||
|     static void setSharedMemLocked() { | ||||
|         __sharedMemLocked = true; | ||||
|     } | ||||
|     static void setSharedMemUnlocked() { | ||||
|         __sharedMemLocked = false; | ||||
|     } | ||||
|     #endif | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| }; | ||||
|  | ||||
| #endif // SHARED_MEM_BUFFER_INCLUDED_H | ||||
							
								
								
									
										614
									
								
								include/storeINdata.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										614
									
								
								include/storeINdata.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,614 @@ | ||||
|  | ||||
| #ifndef STOREINDATA_H | ||||
| #define STOREINDATA_H | ||||
| #include "tslib.h" | ||||
| #include <QString> | ||||
|  | ||||
|  | ||||
| #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_storeHWver(QString text); | ||||
| QString epi_loadHWver(void); | ||||
|  | ||||
| void gpi_storeSWver(QString text); | ||||
| QString epi_loadSWver(void); | ||||
|  | ||||
| void gpi_storeDCstate(QString text); | ||||
| QString epi_loadDCstate(void); | ||||
|  | ||||
|  | ||||
| void gpi_storeUID(uint8_t const *buf8byteUid); | ||||
| //void gpi_storeUID(uint8_t *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 | ||||
| // /////////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
|  | ||||
| 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 | ||||
|  | ||||
| void gpi_storeDI_auxIn(uint8_t indatAuxIn); | ||||
|     // Aux0...5 | ||||
|  | ||||
| uint8_t epi_getDI_auxIn(void); | ||||
|     // bit0: auxin 1  ...  5: auxin 6 | ||||
|  | ||||
| void gpi_storeDI_ptuWake(uint8_t indat); | ||||
|  | ||||
| bool epi_getDI_ptuWake(void); | ||||
|  | ||||
| void gpi_storeDI_mbdWake(uint8_t indat); | ||||
|  | ||||
| bool epi_getDI_mdbWake(void); | ||||
|  | ||||
| void gpi_storeDI_prnReady(uint8_t indat); | ||||
|  | ||||
| bool epi_getDI_prnReady(void); | ||||
|  | ||||
| void gpi_storeDI_CoinAttach(uint8_t indat); | ||||
|  | ||||
| bool epi_getDI_CoinAttach(void); | ||||
|  | ||||
| void gpi_storeDI_CoinEscrow(uint8_t indat); | ||||
|  | ||||
| bool epi_getDI_CoinEscrow(void); | ||||
|  | ||||
| void gpi_storeDI_mifareCardTapped(uint8_t indat); | ||||
|  | ||||
| bool epi_getDI_mifareCardTapped(void); | ||||
|  | ||||
| void gpi_storeDI_modemWake(uint8_t indat); | ||||
|  | ||||
| bool epi_getDI_modemWake(void); | ||||
|  | ||||
|  | ||||
| void gpi_storeDI_contactPowerIsOn(bool di_contact_PwrOn); | ||||
|  | ||||
| bool epi_getDI_contactPwr(void); | ||||
|  | ||||
| void gpi_storeDI_MifarePowerIsOn(bool di_mifare_PwrOn); | ||||
|  | ||||
| bool epi_getDI_mifarePwr(void); | ||||
|  | ||||
| void gpi_storeDI_readbackMdbTxD(bool di_rdbkMdbTxd); | ||||
|  | ||||
| bool epi_getDI_mdbTxd(void); | ||||
|  | ||||
| void gpi_storeDI_AuxPowerIsOn(bool di_Aux_PwrOn); | ||||
|  | ||||
| bool epi_getDI_auxPwr(void); | ||||
|  | ||||
| void gpi_storeDI_GsmPowerIsOn(bool di_gsm_PwrOn); | ||||
|  | ||||
| bool epi_getDI_gsmPwr(void); | ||||
|  | ||||
| void gpi_storeDI_CreditPowerIsOn(bool di_credit_PwrOn); | ||||
|  | ||||
| bool epi_getDI_creditPwr(void); | ||||
|  | ||||
| void gpi_storeDI_PrinterPowerIsOn(bool di_printer_PwrOn); | ||||
|  | ||||
| bool epi_getDI_printerPwr(void); | ||||
|  | ||||
| void gpi_storeDI_MdbPowerIsOn(bool di_mdb_PwrOn); | ||||
|  | ||||
| bool epi_getDI_mdbPwr(void); | ||||
|  | ||||
|  | ||||
| void gpi_storeDI_rejMot_home(bool di); | ||||
|  | ||||
| bool epi_getDI_rejectMotor_homepos(void); | ||||
|  | ||||
| void 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 | ||||
| // /////////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| void gpi_storeDO_mdbRxTst(uint8_t do_mbdRxTst); | ||||
|  | ||||
| bool epi_getDO_mdbRxTestOut(void); | ||||
|  | ||||
|  | ||||
| void 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 | ||||
|  | ||||
|  | ||||
| void 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 | ||||
|  | ||||
|  | ||||
| void 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); | ||||
|  | ||||
| void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay); | ||||
|  | ||||
| bool epi_getDO_sirene(void); | ||||
|  | ||||
| bool epi_getDO_relay(void); | ||||
|  | ||||
| void gpi_storeDO_ptuWake(uint8_t state); | ||||
|  | ||||
| bool epi_getDO_ptuWake(void); | ||||
|  | ||||
| void gpi_storeDO_auxPower(uint8_t pwr); | ||||
|  | ||||
| bool epi_getDO_auxPower(void); | ||||
|  | ||||
|  | ||||
| void gpi_storeDO_coinShutter(uint8_t state); | ||||
|  | ||||
| bool epi_getDO_coinShutterOpen(void); | ||||
|  | ||||
| bool epi_getDO_coinShutterTest(void); | ||||
|  | ||||
|  | ||||
| void 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 | ||||
|  | ||||
|  | ||||
| void 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 | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| void gpi_clearMifHwData(void); | ||||
|  | ||||
| void gpi_storeMifHwData(uint8_t *receivedData); | ||||
|     // blkNr=0...11    receivedData[64] | ||||
|  | ||||
| uint8_t epi_restoreMifHwData(uint8_t *buf, uint8_t maxBufferSize); | ||||
|     // blkNr=0...11    return buf[64] | ||||
|     // retval: 1=error 0=OK | ||||
|  | ||||
|  | ||||
| void gpi_clearMifAtbData(void); | ||||
|  | ||||
| void gpi_storeMifAtbData(uint8_t *receivedData); | ||||
|  | ||||
| uint8_t epi_restoreMifAtbData( uint8_t *buf, uint8_t maxBufferSize); | ||||
|  | ||||
|  | ||||
|  | ||||
| void epi_restorePrinterState(uint8_t *buf); | ||||
|  | ||||
| void gpi_storePrinterState(uint8_t *buf); | ||||
|  | ||||
| void epi_restorePrinterFonts(uint8_t *buf); | ||||
|  | ||||
| void gpi_storePrinterFonts(uint8_t *buf); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| void gpi_storeMdbState(uint8_t busReady, uint8_t V12on, uint8_t V5on ); | ||||
|  | ||||
| bool epi_restoreMdbBusReady(void); | ||||
|  | ||||
| bool epi_restoreMdbV12Ready(void); | ||||
|  | ||||
| bool epi_restoreMdbV5Ready(void); | ||||
|  | ||||
|  | ||||
| void gpi_storeMdbResponse(uint8_t leng, uint8_t *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 *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 *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 *data); | ||||
|  | ||||
| void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data); | ||||
|  | ||||
|  | ||||
| void gpi_storeMachineIDsettings(uint8_t leng, uint8_t *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 *receivedData); | ||||
|  | ||||
| uint64_t epi_getWakeSources(void); | ||||
|  | ||||
| uint8_t epi_getWakeReason(void); | ||||
|  | ||||
|  | ||||
|  | ||||
| void gpi_storeExtendedTime(uint8_t leng, uint8_t *data); | ||||
|  | ||||
| void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data); | ||||
|  | ||||
|  | ||||
| void epi_clearDeviceConditions(void); | ||||
|  | ||||
| void gpi_storeDeviceConditions(uint8_t leng, uint8_t *data); | ||||
|  | ||||
| void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data); | ||||
|  | ||||
|  | ||||
| void epi_clearDynMachineConditions(void);   // new, 24.6.23 | ||||
|  | ||||
| void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data); | ||||
|  | ||||
| void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data); | ||||
|  | ||||
|  | ||||
| void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *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 *data ); | ||||
|  | ||||
| bool epi_checkIfVaultRecordAvailable(void); | ||||
|  | ||||
| uint8_t epi_getLoadedVaultBlocks(void); | ||||
|     // return 0x0011 1111 if all 6 blocks arer loaded (one bit per block) | ||||
|  | ||||
| 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 *holder ); | ||||
|  | ||||
| uint8_t epi_mifGetCardType(uint8_t *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 epi_areDcDataValid(); | ||||
|  | ||||
|  | ||||
|  | ||||
| void epi_clearDynData(void); | ||||
|  | ||||
| void gpi_storeDynData(uint8_t *DCdynDat); | ||||
|     // buffer size: 64 byte | ||||
|  | ||||
| bool epi_getDynPrnData(uint8_t *DCdynDat); | ||||
|     // buffer size: 64 byte | ||||
|     // return true if data are new and valid | ||||
|  | ||||
|  | ||||
|  | ||||
| void gpi_storeNextDCaccNr(uint16_t nxtDcAccNr); | ||||
|  | ||||
| uint16_t epi_getNextDCaccNr(void ); | ||||
|  | ||||
|  | ||||
| void gpi_storeMifCardType(uint16_t length, uint8_t *data); | ||||
|  | ||||
| void epi_restoreMifCardType(uint16_t *length, uint8_t *data); | ||||
|  | ||||
|  | ||||
|  | ||||
| // move here from dcBL and use shared mem as ptu-updater uses CAslave Lib 6.9.23TS | ||||
| //#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(); | ||||
| // not used | ||||
|  | ||||
| void epi_clrRawReceivedString(); | ||||
|  | ||||
|  | ||||
|  | ||||
| // new from 28.9.23 and earliest from DC version 4.45 | ||||
| // store all versions of the DC-Jsons | ||||
| //#define  numberOfJsons     36 | ||||
| //#define  versionStringLength    16 | ||||
| //char    store_jsonVersion[versionStringLength][numberOfJsons]; | ||||
|  | ||||
| void gpi_storeJsonVersion(uint8_t  jsonNr, uint8_t *versionString); | ||||
|     // jsonNr=1...36, 1=config file (cust.Nr) 2=devices  3=cash  4=res. | ||||
|     //      5=printer template 1 ..... 36= template 32 | ||||
|     // length of buffer is always 16 byte | ||||
|  | ||||
| void epi_getJsonVersion(uint8_t  jsonNr, char *versionString); | ||||
|     // jsonNr=1...36, 1=config file (cust.Nr) 2=devices  3=cash  4=res. | ||||
|     //      5=printer template 1 ..... 36= template 32 | ||||
|     // length of buffer is always 16 byte | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| void epi_setNowCoinPay(bool on_off); | ||||
|  | ||||
| bool gpi_getNowCoinPay(void); | ||||
|  | ||||
|  | ||||
| void epi_setNowIsBootload(bool on_off); | ||||
|  | ||||
| bool gpi_getNowIsBootload(void); | ||||
|  | ||||
| void gpi_storeChangerResult(uint8_t  result, uint32_t amount); | ||||
|  | ||||
| uint8_t epi_getChangerResult(uint32_t *returnedAmount); | ||||
|     // get result of coin dispensing | ||||
|     // receivedData[0]: 0: not yet started      1:amount returned | ||||
|     //                  2:only partial return   3: no return possible | ||||
|     // receivedData[2,3,4,5]: returned amount | ||||
|  | ||||
|  | ||||
| void gpi_storeTubeLevel(uint8_t  *data); | ||||
|  | ||||
| void epi_restoreTubeLevel(uint8_t  *data); | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										93
									
								
								include/tslib.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								include/tslib.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,93 @@ | ||||
| #ifndef TSLIB_H | ||||
| #define TSLIB_H | ||||
| #include <QByteArray> | ||||
|  | ||||
|  | ||||
| #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 | ||||
|  | ||||
| bool tslib_strComp(uint8_t *buf, char *compStr); | ||||
|  | ||||
| #endif // TSLIB_H | ||||
|  | ||||
|  | ||||
| // qDebug << QDateTime::currentDateTime().toString(Qt::ISODateWithMs) << QByteArray((const char*)dataSendBuf,dataBufLen).toHex(':'); | ||||
		Reference in New Issue
	
	Block a user