#include #include #include #include "storeINdata.h" #include "tslib.h" #include "shared_mem_buffer.h" #include "datei.h" // gpi: grafical access to PI: access from external devices over device controller FOR GUI // epi: external access from GUI to PI: FOR external devices (DC) // store power on/off condition of the devices to control the data request //static bool indat_savePrnPwr; void indat_storePrinterPower(bool isOn) { SharedMem::write()->indat_savePrnPwr=isOn; } bool indat_isPrinterOn() { return SharedMem::read()->indat_savePrnPwr; } //static bool indat_saveMifPwr; void indat_storeMifarePower(bool isOn) { SharedMem::write()->indat_saveMifPwr=isOn; } bool indat_isMifareOn() { return SharedMem::read()->indat_saveMifPwr; } //static bool indat_MdbIsOn; void indat_storeMDBisOn(bool isOn) { SharedMem::write()->indat_MdbIsOn=isOn; } bool indat_isMdbOn() { return SharedMem::read()->indat_MdbIsOn; } //QString indat_HWversion; //QString indat_SWversion; //QString indat_DCstate; // im shared memory ist kein QString erlaubt!!!!!!!!!!!!!!!!!!!!!! // nur standard C Typen!!!!!! void gpi_storeHWver(QString text) { // change Qstring to array of chars, because shared mem allowes no QString! int nn, LL = text.length(); if (LL >= versionBufferLen) LL=versionBufferLen-1; // leave place for termination for (nn=0; nnindat_HWversion[nn] = text.at(nn).toLatin1(); } for (nn=LL; nnindat_HWversion[nn] =0; } QString epi_loadHWver(void) { // load array of chars from SM and change to QString int nn, LL = versionBufferLen; char cc; QString myStr; myStr.clear(); for (nn=0; nnindat_HWversion[nn]; myStr.append(cc); } return myStr; } void gpi_storeSWver(QString text) { int nn, LL = text.length(); if (LL >= versionBufferLen) LL=versionBufferLen-1; // leave place for termination for (nn=0; nnindat_SWversion[nn] = text.at(nn).toLatin1(); } for (nn=LL; nnindat_SWversion[nn] =0; } QString epi_loadSWver(void) { int nn, LL = versionBufferLen; char cc; QString myStr; myStr.clear(); for (nn=0; nnindat_SWversion[nn]; myStr.append(cc); } return myStr; } void gpi_storeDCstate(QString text) { //text.chop(8); // DC2 State is shorter (8byte) //SharedMem::write()->indat_DCstate=text; int nn, LL = text.length(); if (LL >= versionBufferLen) LL=versionBufferLen-1; // leave place for termination for (nn=0; nnindat_DCstate[nn] = text.at(nn).toLatin1(); } for (nn=LL; nnindat_DCstate[nn] =0; } QString epi_loadDCstate(void) { int nn, LL = versionBufferLen; char cc; QString myStr; myStr.clear(); for (nn=0; nnindat_DCstate[nn]; myStr.append(cc); } return myStr; } // ------------------------------- /* static uint64_t Sdata_slaveUID; static uint8_t Sdata_UIDstr[8]; static QString Sdata_DcUidStr; void write2file_UID(void) { QByteArray myBA; csv_startCreatingFile(); csv_addUintToFile(Sdata_UIDstr[0]); csv_addUintToFile(Sdata_UIDstr[1]); csv_addUintToFile(Sdata_UIDstr[2]); csv_addUintToFile(Sdata_UIDstr[3]); csv_addUintToFile(Sdata_UIDstr[4]); csv_addUintToFile(Sdata_UIDstr[5]); csv_addUintToFile(Sdata_UIDstr[6]); csv_addUintToFile(Sdata_UIDstr[7]); csv_addNewlineToFile(); csv_addUlongvalToFile(Sdata_slaveUID); csv_addNewlineToFile(); csv_addTextToFile(Sdata_DcUidStr); csv_addNewlineToFile(); myBA=csv_readbackArray(); datei_clearFile(FILENAME_SHARED_UID); datei_writeToFile(FILENAME_SHARED_UID, myBA); } void gpi_storeUID(uint8_t *buf8byteUid) { uint64_t udltmp=0; QString myStr; //qDebug()<< "store UID "; for (int ii=0; ii<8; ii++) { //qDebug()<< buf8byteUid[ii] << " "; Sdata_UIDstr[ii]=buf8byteUid[ii]; udltmp|=buf8byteUid[ii]; udltmp<<=8; } Sdata_slaveUID=udltmp; Sdata_DcUidStr.clear(); for (int ii=0;ii<8; ii++) { Sdata_DcUidStr+=QString::number(Sdata_UIDstr[ii],16); Sdata_DcUidStr+=" "; } write2file_UID(); } void epi_getUIDdec(uint8_t *buf8byteUid) { //qDebug()<< "get UID "; for (int ii=0; ii<8; ii++) { //qDebug()< umformen in hexstring QString myStr; for (int ii=0;ii<8; ii++) { myStr+=QString::number(Sdata_UIDstr[ii],16); myStr+=" "; } return myStr; } */ /* read from file: void epi_getUIDfromFile(uint8_t *buf8byteUid) { QByteArray myBA; int nn; myBA=datei_readFromFile(FILENAME_SHARED_UID); for (nn=0; nn<8; nn++) buf8byteUid[nn]=csv_getEntryAsUshort(myBA, nn); } uint64_t epi_getUIDnumberFromFile(void) { QByteArray myBA; myBA=datei_readFromFile(FILENAME_SHARED_UID); return csv_getEntryAs2Ulong(myBA, 8); } QString epi_getUIDstrFromFile(void) { QByteArray myBA; myBA=datei_readFromFile(FILENAME_SHARED_UID); return csv_getEntryAsString(myBA, 9); } */ // the same with shared memory : void gpi_storeUID(uint8_t const *buf8byteUid) { uint64_t udltmp=0; for (int ii=0; ii<8; ii++) { // SharedMem::getData()->Sdata.UIDstr[ii] = buf8byteUid[ii]; SharedMem::write()->Sdata.UIDstr[ii] = buf8byteUid[ii]; udltmp |= buf8byteUid[ii]; udltmp <<= 8; } // SharedMem::getData()->Sdata.slaveUID = udltmp; SharedMem::write()->Sdata.slaveUID = udltmp; } void epi_getUIDdec(uint8_t *buf8byteUid) { for (int ii=0; ii<8; ii++) { //buf8byteUid[ii] = SharedMem::getDataConst()->Sdata.UIDstr[ii]; buf8byteUid[ii] = SharedMem::read()->Sdata.UIDstr[ii]; } } QString epi_getUIDstr() { // die UID besteht aus 8 bytes (8 dezimalzahlen) // -> umformen in hexstring QString myStr; for (int ii=0;ii<8; ii++) { //myStr += QString::number(SharedMem::getDataConst()->Sdata.UIDstr[ii], 16); myStr += QString::number(SharedMem::read()->Sdata.UIDstr[ii], 16); myStr += " "; } return myStr; } // /////////////////////////////////////////////////////////////////////////////////// // Time and Date // /////////////////////////////////////////////////////////////////////////////////// /* 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; }; static T_globTime getGlobalTime; */ void gpi_backupSquareMode(uint8_t squMode) { SharedMem::write()->getGlobalTime.squareOutMode=squMode; } uint8_t epi_getSquareMode() { return SharedMem::read()->getGlobalTime.squareOutMode; } void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng) { /* // Daten kommen in gleicher Reihenfolge vom Slave uint8_t *pTime; pTime=&getGlobalTime.hour; if (Leng>44) Leng=44; // mehr brauch ma ned for (int nn=0; nngetGlobalTime.second=Leng; // nur damit CompilerWarnung weg ist SharedMem::write()->getGlobalTime.DayOfWeek=timeBuffer[0]; SharedMem::write()->getGlobalTime.minute=timeBuffer[1]; SharedMem::write()->getGlobalTime.second=timeBuffer[2]; SharedMem::write()->getGlobalTime.hour=timeBuffer[3]; SharedMem::write()->getGlobalTime.Year=timeBuffer[4]; SharedMem::write()->getGlobalTime.Month=timeBuffer[5]; SharedMem::write()->getGlobalTime.DayOfMonth=timeBuffer[6]; } void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) { *hh=SharedMem::read()->getGlobalTime.hour; *mm=SharedMem::read()->getGlobalTime.minute; *ss=SharedMem::read()->getGlobalTime.second; } void epi_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) { *yy=SharedMem::read()->getGlobalTime.Year; *mm=SharedMem::read()->getGlobalTime.Month; *dd=SharedMem::read()->getGlobalTime.DayOfMonth; } void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) { *dow=SharedMem::read()->getGlobalTime.DayOfWeek; *minOfToday=SharedMem::read()->getGlobalTime.MinutesOfToday; *secOfToday=SharedMem::read()->getGlobalTime.SecondsOfToday; } bool epi_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) { *lastLeapYear=SharedMem::read()->getGlobalTime.lastLeap; *NextLeapYear=SharedMem::read()->getGlobalTime.nextLeap; if (SharedMem::read()->getGlobalTime.IsLeapyear) return true; return false; } bool epi_isLeapYear() { if (SharedMem::read()->getGlobalTime.IsLeapyear) return true; return false; } void epi_getSpecialWeekTimeDate(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) { *DayOfWeek=SharedMem::read()->getGlobalTime.DayOfWeek; *HoursOfWeek=SharedMem::read()->getGlobalTime.hoursOfWeek; *MinutesOfWeek=SharedMem::read()->getGlobalTime.minOfWeek; } void epi_getSpecialMonthTimeDate(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) { *DayOfMonth=SharedMem::read()->getGlobalTime.DayOfMonth; *HoursOfMonth=SharedMem::read()->getGlobalTime.hoursOfMonth; *MinutesOfMonth=SharedMem::read()->getGlobalTime.minOfMonth; } void epi_getSpecialYearTimeDate(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) { *DayOfYear=SharedMem::read()->getGlobalTime.dayOfYear; *HoursOfYear=SharedMem::read()->getGlobalTime.hoursOfYear; *MinutesOfYear=SharedMem::read()->getGlobalTime.minOfYear; } QString epi_getRtcTimeStr(uint8_t timeStyle) { // style: 0: hh:mm 1: hh:mm:ss QString mystr=nullptr, tempStr=nullptr; tempStr.setNum(SharedMem::read()->getGlobalTime.hour,10); mystr=tempStr.rightJustified(2,'0',false); // macht feste Länge, 5->05 mystr.append(':'); //tempStr.clear(); tempStr.setNum(SharedMem::read()->getGlobalTime.minute,10); // mit 16 statt 10 wirds in HEX angezeigt //mystr.append(tempStr); mystr+=tempStr.rightJustified(2,'0',false); //mystr.append(':'); // so //mystr+=':'; // oder so, =gleich if (timeStyle==1) // hh:mm:ss { mystr.append(':'); tempStr.setNum(SharedMem::read()->getGlobalTime.second,10); mystr.append(tempStr.rightJustified(2,'0',false)); // wie += } return mystr; } QString epi_getRtcDateStr(uint8_t dateStyle) { // 1=german dd.mm.yy 2=american yy/mm/dd 3=mm.dd.yy QString tmpStr=nullptr, YYstr=nullptr, MMstr=nullptr, DDstr=nullptr, mystr=nullptr; mystr.clear(); tmpStr.setNum(SharedMem::read()->getGlobalTime.Year,10); // itoa decimal YYstr=tmpStr.rightJustified(4,'0',false); // immer vierstellig YYstr[0]='2'; // 2000 dazu tmpStr.setNum(SharedMem::read()->getGlobalTime.Month,10); MMstr=tmpStr.rightJustified(2,'0',false); tmpStr.setNum(SharedMem::read()->getGlobalTime.DayOfMonth,10); DDstr=tmpStr.rightJustified(2,'0',false); if (dateStyle==1) // Germany dd.mm.yy { mystr=DDstr + '.' + MMstr + '.' + YYstr; } else if (dateStyle==2) // american yy/mm/dd { mystr=YYstr + '/' + MMstr + '/' + DDstr; } else // mm.dd.yy { mystr=MMstr + '.' + DDstr + '.' + YYstr; } return mystr; } QString epi_getSlaveTimeDateStr() { QString myStr; myStr=epi_getRtcTimeStr(1) + " " + epi_getRtcDateStr(1); return myStr; } // /////////////////////////////////////////////////////////////////////////////////// // analog values // /////////////////////////////////////////////////////////////////////////////////// //static uint16_t AI_val[MAXNROF_AI]; uint8_t gpi_getMaxNrAIs() { return MAXNROF_AI; } void gpi_storeAIs(uint8_t aiNr, uint16_t val) { if (aiNrAI_val[aiNr]=val; } uint16_t epi_loadAIs(uint8_t aiNr) { if (aiNrAI_val[aiNr]; return 0; } //-------------- // measurement values // ADC0: temp // 1: voltage // 2: brightness #define MAXNROF_MEASURE 4 //static uint32_t Sdata_measurement[MAXNROF_MEASURE]; uint32_t epi_loadMeasureValue(uint8_t ValueNr) { // ValueNr 0=ADC0, 1=ADC1 aso... if (ValueNrSdata_measurement[ValueNr]; return 0; } void gpi_storeMeasureValue(uint8_t ValueNr, uint32_t val) { // in mV, also bis 65,535V if (ValueNrSdata_measurement[ValueNr]=val; } QString epi_getSlaveTemperatureStr() { char myStr[8], halfDegree=0, Minus=0, oneChar; int16_t val=0, pp, einer, zehner; QString myqStr; //qDebug() << "AIN0: " << epi_loadAIs(0) << "AIN1: " << epi_loadAIs(1); uint32_t meas_temper=epi_loadMeasureValue(MEASCHAN_TEMPERATURE); // im SaxFormat gespeichert, hier umwandeln in String //qDebug() << "meas_temper: " << meas_temper; for (pp=0; pp<8; pp++) myStr[pp]=0; if (meas_temper&1) // ungerade, also ,5°C { halfDegree=1; meas_temper &=0xFFFE; // um 0,5°C abrunden } if (meas_temper<100) { Minus=1; val=int16_t(meas_temper)/2; val-=50; } else { val=int16_t(meas_temper)-100; val/=2; } pp=0; // pointer auf string if (Minus) myStr[pp++]='-'; // val is now 0..150 for pos Temp or 0..49 for negativ temperature if (val<10) { // only one digit, just change to ascii oneChar = char(val)+0x30; if (tslib_isDecAsciiNumber(oneChar)) myStr[pp++]=oneChar; else myStr[pp++]='0'; } else if (val<100) { // 10...99 einer=val%10; zehner=val/10; //myStr[pp++]=char(zehner); //myStr[pp++]=char(einer); oneChar = char(zehner)+0x30; if (tslib_isDecAsciiNumber(oneChar)) myStr[pp++]=oneChar; else myStr[pp++]='0'; oneChar = char(einer)+0x30; if (tslib_isDecAsciiNumber(oneChar)) myStr[pp++]=oneChar; else myStr[pp++]='0'; } else { // 100...150 myStr[pp++]='1'; // hunderter Stelle immer 1 val-=100; einer=val%10; zehner=val/10; //myStr[pp++]=char(zehner)+0x30; //myStr[pp++]=char(einer)+0x30; oneChar = char(zehner)+0x30; if (tslib_isDecAsciiNumber(oneChar)) myStr[pp++]=oneChar; else myStr[pp++]='0'; oneChar = char(einer)+0x30; if (tslib_isDecAsciiNumber(oneChar)) myStr[pp++]=oneChar; else myStr[pp++]='0'; } myStr[pp++]=','; if (halfDegree) myStr[pp++]='5'; else myStr[pp++]='0'; myqStr.clear(); myqStr.append(myStr); myqStr.append("°C"); return myqStr; } QString epi_getSlaveVoltageStr() { // value in "meas_volt" in mV, also bis 65,535V. Value range [6000...16000] (6V...16V) QString myqStr; uint32_t vor, nach, tmp32; uint16_t pp; char myStr[12], ke; //, kz, kh; uint32_t ultmp=epi_loadMeasureValue(MEASCHAN_VOLTAGE); for (pp=0; pp<12; pp++) myStr[pp]=0; //qDebug() << ultmp << "mV"; myqStr.clear(); vor=ultmp/1000; //qDebug() << "vor: " << vor; nach=ultmp%1000; //qDebug() << "nach: " << nach; pp=0; if (vor>9) { myStr[pp++]=char(vor/10)+0x30; } myStr[pp++]=char(vor%10)+0x30; myStr[pp++]=','; ke=char(nach/100); //qDebug() << "ke: " << ke; myStr[pp++]=char(ke)+0x30; tmp32=nach%100; ke=char(tmp32/10); //qDebug() << "ke: " << ke; myStr[pp++]=char(ke)+0x30; tmp32=nach%10; ke=char(tmp32); //qDebug() << "ke: " << ke; myStr[pp++]=char(ke)+0x30; myStr[pp++]='V'; myqStr.append(myStr); return myqStr; } // /////////////////////////////////////////////////////////////////////////////////// // digital inputs // /////////////////////////////////////////////////////////////////////////////////// /* come all in with 0x1201: D0: upper door D1: low door D2:vault door D3: cash box D4: bill box in D5: bit 0: upper lockbar up bit1:down D6: bit 0: lower lockbar up bit1:down D7: 0 D7: DI_contact Power Is On D8: OptoIn 1,2 D9: Aux0...5 D10:Wake from ptu D11: DI Wake From Mdb D12: Ready from printer D13: Coin Shutter Input D14: CoinEscrow switch D15: Mifare IN D16: Modem_Wake In D18: DI Mif Pwr is on D19: DI MDB_TxD_rdBack D20: DI Aux Pwr is on D21: DI GSM Pwr from PO2 is ON D22: DI Credit Pwr from PO2 is on =DI RdBack Credit Wake D23: DI Printer Pwr from PO2 is on D24: DI MDB Pwr from PO2 is on */ //static uint8_t di_doorSwitch; void gpi_storeDI_doorSwitches(uint8_t upperDoor, uint8_t lowerDoor, uint8_t vaultDoor) { SharedMem::write()->di_doorSwitch=0; if (upperDoor) SharedMem::write()->di_doorSwitch |=1; if (lowerDoor) SharedMem::write()->di_doorSwitch |=2; if (vaultDoor) SharedMem::write()->di_doorSwitch |=4; // qDebug()<<"storeINdata: "<di_doorSwitch; } //static uint8_t di_vaultSwitch; void gpi_storeDI_vaultSwitches(uint8_t CashBoxIn, uint8_t BillBoxIn) { SharedMem::write()->di_vaultSwitch=0; if (CashBoxIn) SharedMem::write()->di_vaultSwitch |=1; if (BillBoxIn) SharedMem::write()->di_vaultSwitch |=2; } uint8_t epi_getDI_vaultSwitches(void) { // bit0: cash box 1: bill box in return SharedMem::read()->di_vaultSwitch; } //static uint8_t di_lockSwitch; 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 SharedMem::write()->di_lockSwitch=0; if (indatUL & 1) SharedMem::write()->di_lockSwitch |=1; if (indatUL & 2) SharedMem::write()->di_lockSwitch |=2; if (indatLL & 1) SharedMem::write()->di_lockSwitch |=4; if (indatLL & 2) SharedMem::write()->di_lockSwitch |=8; } uint8_t epi_getDI_lockSwitches(void) { // retval: bit 0: upper lockbar up bit1: upper lockbar is down // bit 2: lower lockbar up bit1: lower lockbar is down return SharedMem::read()->di_lockSwitch; } //static uint8_t di_opto; void gpi_storeDI_optos(uint8_t indatOpto) { // OptoIn bit 0,1: optoin 1,2 SharedMem::write()->di_opto=0; if (indatOpto & 1) SharedMem::write()->di_opto |=1; if (indatOpto & 2) SharedMem::write()->di_opto |=2; } uint8_t epi_getDI_optos(void) { // bit0: opto in 1 1: opto in 2 return SharedMem::read()->di_opto; } //static uint8_t di_aux; void gpi_storeDI_auxIn(uint8_t indatAuxIn) { // Aux0...5 SharedMem::write()->di_aux=indatAuxIn; } uint8_t epi_getDI_auxIn(void) { // bit0: auxin 1 ... 5: auxin 6 return SharedMem::read()->di_aux; } //static bool di_wakeFromPtu; void gpi_storeDI_ptuWake(uint8_t indat) { if (indat) SharedMem::write()->di_wakeFromPtu=true; else SharedMem::write()->di_wakeFromPtu=false; } bool epi_getDI_ptuWake(void) { return SharedMem::read()->di_wakeFromPtu; } //static bool di_wakeFromMdb; void gpi_storeDI_mbdWake(uint8_t indat) { if (indat) SharedMem::write()->di_wakeFromMdb=true; else SharedMem::write()->di_wakeFromMdb=false; } bool epi_getDI_mdbWake(void) { return SharedMem::read()->di_wakeFromMdb; } //static bool di_PrnReady; void gpi_storeDI_prnReady(uint8_t indat) { if (indat) SharedMem::write()->di_PrnReady=true; else SharedMem::write()->di_PrnReady=false; } bool epi_getDI_prnReady(void) { return SharedMem::read()->di_PrnReady; } //static bool di_CoinAttach; void gpi_storeDI_CoinAttach(uint8_t indat) { if (indat) SharedMem::write()->di_CoinAttach=true; else SharedMem::write()->di_CoinAttach=false; } bool epi_getDI_CoinAttach(void) { return SharedMem::read()->di_CoinAttach; } //static bool di_CoinEscrowOpen; void gpi_storeDI_CoinEscrow(uint8_t indat) { if (indat) SharedMem::write()->di_CoinEscrowOpen=true; else SharedMem::write()->di_CoinEscrowOpen=false; } bool epi_getDI_CoinEscrow(void) { return SharedMem::read()->di_CoinEscrowOpen; } //static bool di_mifCardTap; void gpi_storeDI_mifareCardTapped(uint8_t indat) { if (indat) SharedMem::write()->di_mifCardTap=true; else SharedMem::write()->di_mifCardTap=false; } bool epi_getDI_mifareCardTapped(void) { return SharedMem::read()->di_mifCardTap; } //static bool di_wakeFromModem; void gpi_storeDI_modemWake(uint8_t indat) { if (indat) SharedMem::write()->di_wakeFromModem=true; else SharedMem::write()->di_wakeFromModem=false; } bool epi_getDI_modemWake(void) { return SharedMem::read()->di_wakeFromModem; } //static bool di_contactPwrOn; void gpi_storeDI_contactPowerIsOn(bool di_contact_PwrOn) { SharedMem::write()->di_contactPwrOn=di_contact_PwrOn; } bool epi_getDI_contactPwr(void) { // invertiert! if (SharedMem::read()->di_contactPwrOn) return false; return true; } //static bool di_mifarePwrOn; void gpi_storeDI_MifarePowerIsOn(bool di_mifare_PwrOn) { SharedMem::write()->di_mifarePwrOn=di_mifare_PwrOn; } bool epi_getDI_mifarePwr(void) { return SharedMem::read()->di_mifarePwrOn; } //static bool di_rdbk_mdbTxd; void gpi_storeDI_readbackMdbTxD(bool di_rdbkMdbTxd) { SharedMem::write()->di_rdbk_mdbTxd=di_rdbkMdbTxd; } bool epi_getDI_mdbTxd(void) { return SharedMem::read()->di_rdbk_mdbTxd; } //static bool di_AuxPwrOn; void gpi_storeDI_AuxPowerIsOn(bool di_Aux_PwrOn) { SharedMem::write()->di_AuxPwrOn=di_Aux_PwrOn; } bool epi_getDI_auxPwr(void) { return SharedMem::read()->di_AuxPwrOn; } //static bool di_gsmPwrOn; void gpi_storeDI_GsmPowerIsOn(bool di_gsm_PwrOn) { SharedMem::write()->di_gsmPwrOn=di_gsm_PwrOn; } bool epi_getDI_gsmPwr(void) { return SharedMem::read()->di_gsmPwrOn; } //static bool di_creditPwrOn; void gpi_storeDI_CreditPowerIsOn(bool di_credit_PwrOn) { // invertieren!!! if (di_credit_PwrOn) SharedMem::write()->di_creditPwrOn=0; else SharedMem::write()->di_creditPwrOn=1; } bool epi_getDI_creditPwr(void) { return SharedMem::read()->di_creditPwrOn; } //static bool di_printerPwrOn; void gpi_storeDI_PrinterPowerIsOn(bool di_printer_PwrOn) { SharedMem::write()->di_printerPwrOn=di_printer_PwrOn; } bool epi_getDI_printerPwr(void) { return SharedMem::read()->di_printerPwrOn; } //static bool di_mdbPwrOn; void gpi_storeDI_MdbPowerIsOn(bool di_mdb_PwrOn) { SharedMem::write()->di_mdbPwrOn=di_mdb_PwrOn; } bool epi_getDI_mdbPwr(void) { return SharedMem::read()->di_mdbPwrOn; } //static bool di_rejMot_home; void gpi_storeDI_rejMot_home(bool di) { SharedMem::write()->di_rejMot_home=di; } bool epi_getDI_rejectMotor_homepos(void) { return SharedMem::read()->di_rejMot_home; } //static uint8_t di_npe_sensor; void gpi_storeDI_paperLow(uint8_t di) { // 0: Sensor sees paper 1: no paper 99: off SharedMem::write()->di_npe_sensor=di; } uint8_t epi_getDI_npe_sensor(void) { return SharedMem::read()->di_npe_sensor; } // /////////////////////////////////////////////////////////////////////////////////// // readaback digital outputs // /////////////////////////////////////////////////////////////////////////////////// /* D0 bit0: MDB devices 0=off 1=on bit1: MDB bus power bit2: MDB WakeOut D1=Printer D2=Credit D3=Modem D5: serial drv on/off, Serial mux1, Serial mux2 D6: Leds, Fan, D7: Siren and relay D8: PtuWakeOut D9: Power Aux/Barcode D10: AuxDir 1...6 D11: AuxOut 1...6 D12: Coin shutter output D13: CoinEscrow Outputs */ //static uint8_t do_mbdRxTst; void gpi_storeDO_mdbRxTst(uint8_t mdbRxTst) { SharedMem::write()->do_mbdRxTst=mdbRxTst; } bool epi_getDO_mdbRxTestOut(void) { if (SharedMem::read()->do_mbdRxTst & 1) return true; return false; } //static uint8_t do_motorBits; void gpi_storeDO_motorOutputs(uint8_t Pwr) { //D1: motor outputs bit0: upper lock forw bit 1 backw // Bit2: lowLock forw bit3: LL backw SharedMem::write()->do_motorBits=Pwr; } uint8_t epi_getDO_motorOuts(void) { // bit0: upper lock forward bit 1 backward // bit2: lower lock forward bit 3 backward return SharedMem::read()->do_motorBits; } //static uint8_t do_serialSwitch; // serial drv on/off, Serial mux1, Serial mux2 void gpi_storeDO_serialSwitch(uint8_t state) // serial drv on/off, Serial mux1, Serial mux2 { SharedMem::write()->do_serialSwitch=state; } uint8_t epi_getDO_serialSwitch(void) { // serial drv on/off, Serial mux1, Serial mux2 return SharedMem::read()->do_serialSwitch; } bool epi_getDO_serialDriverIsOn(void) { if ( SharedMem::read()->do_serialSwitch & 1) return true; return false; } bool epi_getDO_serialMux1isSetToPrinter(void) { // mux1 off: serial is switched to printer if ((SharedMem::read()->do_serialSwitch & 2)==0) return true; return false; } bool epi_getDO_serialMux1isSetToModem(void) { // mux1 on: serial is switched to modem if ((SharedMem::read()->do_serialSwitch & 2)>0) return true; return false; } bool epi_getDO_serialMux2isSetToCredit(void) { // mux2 off: serial is switched to credit card terminal if ((SharedMem::read()->do_serialSwitch & 4)==0) return true; return false; } bool epi_getDO_serialMux2isSetToMifare(void) { // mux2 on: serial is switched to mifare reader if ((SharedMem::read()->do_serialSwitch & 4)>0) return true; return false; } //static uint8_t do_ledsAndFan; void gpi_storeDO_ledsAndFan(uint8_t ledState) { // bit0: coinled 1:front_illu 2: paper-led 3:pinpad-led 4:start-led 5:service-led 6:fan SharedMem::write()->do_ledsAndFan=ledState; } bool epi_getDO_led_coin(void) { if (SharedMem::read()->do_ledsAndFan & 1) return true; return false; } bool epi_getDO_led_front(void) { if (SharedMem::read()->do_ledsAndFan & 2) return true; return false; } bool epi_getDO_led_ticket(void) { if (SharedMem::read()->do_ledsAndFan & 4) return true; return false; } bool epi_getDO_led_pin(void) { if (SharedMem::read()->do_ledsAndFan & 8) return true; return false; } bool epi_getDO_led_start(void) { if (SharedMem::read()->do_ledsAndFan & 16) return true; return false; } bool epi_getDO_led_inside(void) { if (SharedMem::read()->do_ledsAndFan & 32) return true; return false; } bool epi_getDO_fan(void) { if (SharedMem::read()->do_ledsAndFan & 64) return true; return false; } //static uint8_t do_laermUndRelay; void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay) { // bit0: siren 1:relay SharedMem::write()->do_laermUndRelay=sirenRelay; } bool epi_getDO_sirene(void) { if (SharedMem::read()->do_laermUndRelay & 1) return true; return false; } bool epi_getDO_relay(void) { if (SharedMem::read()->do_laermUndRelay & 2) return true; return false; } //static uint8_t do_ptuWake; void gpi_storeDO_ptuWake(uint8_t state) { SharedMem::write()->do_ptuWake=state; } bool epi_getDO_ptuWake(void) { if (SharedMem::read()->do_ptuWake>0) return true; return false; } //static uint8_t do_auxPower; void gpi_storeDO_auxPower(uint8_t pwr) { SharedMem::write()->do_auxPower=pwr; } bool epi_getDO_auxPower(void) { if (SharedMem::read()->do_auxPower>0) return true; return false; } //static uint8_t do_coinShutter; void gpi_storeDO_coinShutter(uint8_t state) { SharedMem::write()->do_coinShutter=state; } bool epi_getDO_coinShutterOpen(void) { // bit0: Coin shutter output, bit1: input-test-output if (SharedMem::read()->do_coinShutter & 1) return true; return false; } bool epi_getDO_coinShutterTest(void) { // bit0: Coin shutter output, bit1: input-test-output if (SharedMem::read()->do_coinShutter & 2) return true; return false; } //static uint8_t do_coinEscrow; void gpi_storeDO_coinEscrow(uint8_t state) { SharedMem::write()->do_coinEscrow=state; } uint8_t epi_getDO_coinEscrow(void) { // retval: 1:return flap is open 2:take flap is open 0:closed if (SharedMem::read()->do_coinEscrow &1) return 1; // return flap is open if (SharedMem::read()->do_coinEscrow &2) return 2; // take flap is open return 0; } //static uint8_t do_printerPower; void gpi_storeDO_printerPwrOn(uint8_t state) { SharedMem::write()->do_printerPower=state; } uint8_t epi_getDO_printerPwr(void) { return SharedMem::read()->do_printerPower; } //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //----------------------------- Mifare Card Reader ----------------------------------- //#define NROFMIFSTATEBYTES 40 //static uint8_t Sdata_MIF_STATE[NROFMIFSTATEBYTES]; void gpi_clearMifHwData(void) { for (uint8_t nn=0; nn<64; nn++) SharedMem::write()->Sdata_MIF_DATA[nn]=0; } void gpi_storeMifHwData(uint8_t *receivedData) { for (uint8_t nn=0; nn<64; nn++) SharedMem::write()->Sdata_MIF_DATA[nn]=receivedData[nn]; } uint8_t epi_restoreMifHwData(uint8_t *buf, uint8_t maxBufferSize) { if (maxBufferSize<64) return 1; // error for (uint8_t nn=0; nn<64; nn++) buf[nn]=SharedMem::read()->Sdata_MIF_DATA[nn]; return 0; // ois OK } void gpi_clearMifAtbData(void) { for (uint8_t nn=0; nn<64; nn++) SharedMem::write()->Sdata_MIF_ATB[nn]=0; } void gpi_storeMifAtbData(uint8_t *receivedData) { for (uint8_t nn=0; nn<64; nn++) SharedMem::write()->Sdata_MIF_ATB[nn]=receivedData[nn]; } uint8_t epi_restoreMifAtbData( uint8_t *buf, uint8_t maxBufferSize) { if ( maxBufferSize<64) return 1; // error for (uint8_t nn=0; nn<64; nn++) buf[nn]=SharedMem::read()->Sdata_MIF_ATB[nn]; return 0; // ois OK } // not used //void gpi_storeNewMifareCard(uint8_t typ, uint8_t *holder ) //{ // SharedMem::write()->mif_cardType=typ; // uint8_t nn; // //tslib_strcpy(holder, SharedMem::write()->mif_cardHolder, 7); // for (nn=0; nn<7; nn++) // SharedMem::write()->mif_cardHolder[nn] = holder[nn]; // SharedMem::write()->mif_cardHolder[7]=0; //} // not used //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 //tslib_strcpy(SharedMem::read()->mif_cardHolder, holder, 7); // uint8_t nn; // for (nn=0; nn<7; nn++) // holder[nn]= SharedMem::read()->mif_cardHolder[nn]; // holder[7]=0; // return SharedMem::read()->mif_cardType; // return 0; //} //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //static uint8_t Sdata_PRN_STATE[pi_prnStateArraySize]; void epi_restorePrinterState(uint8_t *buf) { uint8_t nn; for (nn=0; nnSdata_PRN_STATE[nn]; } void gpi_storePrinterState(uint8_t *buf) { uint8_t nn; for (nn=0; nnSdata_PRN_STATE[nn]=buf[nn]; } //static uint8_t Sdata_PRN_FONTS[pi_prnFontArraySize]; void epi_restorePrinterFonts(uint8_t *buf) { uint8_t nn; for (nn=0; nnSdata_PRN_FONTS[nn]; } void gpi_storePrinterFonts(uint8_t *buf) { uint8_t nn; for (nn=0; nnSdata_PRN_FONTS[nn]=buf[nn]; /* qDebug()<<"printer fonts stored " <Sdata_mdb_busRdy=bool(busReady); SharedMem::write()->Sdata_mdb_V12on=bool(V12on); SharedMem::write()->Sdata_mdb_V5on=bool(V5on); } bool epi_restoreMdbBusReady(void) { return SharedMem::read()->Sdata_mdb_busRdy; } bool epi_restoreMdbV12Ready(void) { return SharedMem::read()->Sdata_mdb_V12on; } bool epi_restoreMdbV5Ready(void) { return SharedMem::read()->Sdata_mdb_V5on; } //static uint8_t Sdata_mdbNrOfRecData; //static uint8_t Sdata_RecBuff[40]; // last received mdb answer (from mdb device) // only needed if a special command was sent directly // DB0: mdb Device-Nr // DB1: last sent mdb command // DB2: nr of received (payload) data bytes (apart from ACK, can be 0....34) // DB3...DB38: rec.data (payload) void gpi_storeMdbResponse(uint8_t leng, uint8_t *data) { uint8_t nn; if (leng>40) leng=40; tslib_strclr(SharedMem::write()->Sdata_RecBuff,0,40); SharedMem::write()->Sdata_mdbNrOfRecData=leng; //tslib_strcpy(data, SharedMem::write()->Sdata_RecBuff, uint16_t(Sdata_mdbNrOfRecData)); for (nn=0; nnSdata_RecBuff[nn] = data[nn]; } void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data) { uint8_t nn, LL; LL=SharedMem::read()->Sdata_mdbNrOfRecData; //tslib_strcpy(SharedMem::read()->Sdata_RecBuff, data, SharedMem::read()->Sdata_mdbNrOfRecData); for (nn=0; nnSdata_RecBuff[nn]; *leng = LL; } //static uint8_t Sdata_empNrOfsettings; //static uint8_t Sdata_emp_settingsBuff[66]; void gpi_storeEmpSettings(uint8_t leng, uint8_t *data) { uint8_t nn; if (leng>64) leng=64; SharedMem::write()->Sdata_empNrOfsettings=leng; //tslib_strcpy(data, SharedMem::write()->Sdata_emp_settingsBuff, leng); for (nn=0; nnSdata_emp_settingsBuff[nn] = data[nn]; } void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data) { uint8_t nn, LL; LL=SharedMem::read()->Sdata_empNrOfsettings; *leng=LL; //tslib_strcpy(SharedMem::read()->Sdata_emp_settingsBuff, data, SharedMem::read()->Sdata_empNrOfsettings); for (nn=0; nnSdata_emp_settingsBuff[nn]; } // ...................................................................... // Münzbuffer[10]: Münze für Münze auslesen (LIFO) // 4.5.21 /* struct T_coin { uint8_t valid; uint8_t signal; uint8_t error; uint8_t pad; uint16_t value; }; static struct T_coin gotCoin[MEMDEPTH_GOTCOINS]; static uint8_t ctr_gotCoin; */ void sub_enterData(uint8_t valid, uint8_t signal, uint8_t error, uint16_t value ) { uint8_t pGotCoin; pGotCoin=SharedMem::read()->ctr_gotCoin; if (pGotCoingotCoin[pGotCoin].valid=valid; SharedMem::write()->gotCoin[pGotCoin].signal=signal; SharedMem::write()->gotCoin[pGotCoin].error=error; SharedMem::write()->gotCoin[pGotCoin].value=value; } pGotCoin++; SharedMem::write()->ctr_gotCoin=pGotCoin; } void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data) { // leng is number of coin record with 5 bytes each uint8_t LL=leng; // nr of coin records uint16_t vv, pp=0; vv=uchar2uint(data[pp+4], data[pp+3]); sub_enterData(data[pp], data[pp+1], data[pp+2], vv ); pp+=5; LL--; } uint8_t epi_isNewCoinLeft(void) { // retval: 0...16 coins left in FIFO return SharedMem::read()->ctr_gotCoin; } void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) { uint8_t pGotCoin; pGotCoin=SharedMem::read()->ctr_gotCoin; pGotCoin--; if (pGotCoingotCoin[pGotCoin].valid; *signal=SharedMem::read()->gotCoin[pGotCoin].signal; *error=SharedMem::read()->gotCoin[pGotCoin].error; *value=SharedMem::read()->gotCoin[pGotCoin].value; } SharedMem::write()->ctr_gotCoin=pGotCoin; } //static uint8_t Sdata_NrOfDeviceSetting; //static uint8_t Sdata_DeviceSettingBuff[66]; void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t *data) // getestet am 12.4.23TS { uint8_t nn; if (leng>64) leng=64; SharedMem::write()->Sdata_NrOfDeviceSetting=leng; //tslib_strcpy(data, SharedMem::write()->Sdata_DeviceSettingBuff, leng); for (nn=0; nnSdata_DeviceSettingBuff[nn] = data[nn]; } void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data) // getestet am 12.4.23TS { uint8_t nn, LL; LL=SharedMem::read()->Sdata_NrOfDeviceSetting; *leng=LL; //tslib_strcpy(SharedMem::read()->Sdata_DeviceSettingBuff, data, SharedMem::read()->Sdata_NrOfDeviceSetting); for (nn=0; nnSdata_DeviceSettingBuff[nn]; } /* Beispiel: void gpi_storeUID(uint8_t const *buf8byteUid) { uint64_t udltmp=0; for (int ii=0; ii<8; ii++) { SharedMem::getData()->Sdata.UIDstr[ii] = buf8byteUid[ii]; udltmp |= buf8byteUid[ii]; udltmp <<= 8; } SharedMem::getData()->Sdata.slaveUID = udltmp; } void epi_getUIDdec(uint8_t *buf8byteUid) { for (int ii=0; ii<8; ii++) { buf8byteUid[ii] = SharedMem::getDataConst()->Sdata.UIDstr[ii]; } } */ //static uint8_t Sdata_NrOfMachineIDSetting; //static uint8_t Sdata_NrOfMachineIDBuff[66]; void gpi_storeMachineIDsettings(uint8_t leng, uint8_t *data) { uint8_t nn; if (leng>64) leng=64; //Sdata_NrOfMachineIDSetting=leng; //tslib_strcpy(data, Sdata_NrOfMachineIDBuff, leng); SharedMem::write()->SizeMachineIDBuff=leng; for (nn=0; nn<64; nn++) SharedMem::write()->MachineIDBuff[nn]=data[nn]; } void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data) { //*leng=Sdata_NrOfMachineIDSetting; //tslib_strcpy(Sdata_NrOfMachineIDBuff, data, Sdata_NrOfMachineIDSetting); uint8_t uctmp, nn; uctmp=SharedMem::read()->SizeMachineIDBuff; *leng=uctmp; for (nn=0; nn<64; nn++) data[nn]=SharedMem::read()->MachineIDBuff[nn]; } //static uint32_t store_insertedAmount; //static uint16_t store_lastCoinType[64]; //static uint16_t store_lastCoinValue[64]; //static uint8_t p_lastCoin; //static char store_curPayNewCoin; void epi_clearCurrentPayment(void) { // call at beginning of coin collection int nn; SharedMem::write()->store_insertedAmount=0; SharedMem::write()->p_lastCoin=0; // 17.5.23TS: ergänzt: for (nn=0; nn<64; nn++) { SharedMem::write()->store_lastCoinType[nn]=0; SharedMem::write()->store_lastCoinValue[nn]=0; } SharedMem::write()->store_curPayNewCoin=0; } void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue) { uint8_t pLC=SharedMem::read()->p_lastCoin; SharedMem::write()->store_insertedAmount=insertedAmount; SharedMem::write()->store_lastCoinType[pLC]=lastCoinType; SharedMem::write()->store_lastCoinValue[pLC]=lastCoinValue; pLC++; SharedMem::write()->p_lastCoin=pLC; SharedMem::write()->store_curPayNewCoin++; //qDebug()<<"gpi_storeCurrentPayment "<store_insertedAmount; } uint16_t epi_CurrentPaymentGetLastCoin(void) { uint8_t pp; pp=SharedMem::read()->p_lastCoin; if (pp==0) return 0; // noch keine Münze erhalten if (pp>0) pp--; //store_curPayNewCoin=0; // nur 1x melden return SharedMem::read()->store_lastCoinValue[pp]; } bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values) { // alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht uint8_t nn; uint8_t pp; pp=SharedMem::read()->p_lastCoin; if (pp==0) return false; for (nn=0; nn<64; nn++) { types[nn]= SharedMem::read()->store_lastCoinType[nn]; values[nn]=SharedMem::read()->store_lastCoinValue[nn]; } return true; } //uint64_t stor_wakSrc; //uint8_t stor_reason; void gpi_storeWakeSources(uint8_t *receivedData) { uint8_t uctmp; int nn; SharedMem::write()->stor_wakSrc=0; for (nn=5; nn>=0; nn--) { uctmp=receivedData[nn]; SharedMem::write()->stor_wakSrc |=uctmp; SharedMem::write()->stor_wakSrc<<=8; } SharedMem::write()->stor_reason=receivedData[6]; } uint64_t epi_getWakeSources(void) { return SharedMem::read()->stor_wakSrc; } uint8_t epi_getWakeReason(void) { return SharedMem::read()->stor_reason; } //static uint8_t store_rbDevParamLen; //static uint8_t store_rbDevParams[66]; void gpi_storeExtendedTime(uint8_t leng, uint8_t *data) { uint8_t nn; if (leng>64) leng=64; SharedMem::write()->store_rbDevParamLen=leng; //tslib_strcpy(data, SharedMem::write()->store_rbDevParams, leng); for (nn=0; nnstore_rbDevParams[nn] = data[nn]; } void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data) { uint8_t nn, LL; LL=SharedMem::read()->store_rbDevParamLen; *leng=LL; //tslib_strcpy(SharedMem::read()->store_rbDevParams, data, SharedMem::read()->store_rbDevParamLen); for (nn=0; nnstore_rbDevParams[nn]; } // store device conditions //static uint8_t store_deviceCondLen; //static uint8_t store_deviceCond[66]; void epi_clearDeviceConditions(void) { uint8_t nn; SharedMem::write()->store_deviceCondLen=0; for (nn=0; nn<64; nn++) SharedMem::write()->store_deviceCond[nn]=0; } void gpi_storeDeviceConditions(uint8_t leng, uint8_t *data) { uint8_t nn; if (leng>64) leng=64; SharedMem::write()->store_deviceCondLen=leng; //tslib_strcpy(data, SharedMem::write()->store_deviceCond, leng); for (nn=0; nnstore_deviceCond[nn]=data[nn]; } void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data) { uint8_t nn, LL; LL=SharedMem::read()->store_deviceCondLen; *leng=LL; //tslib_strcpy(SharedMem::read()->store_deviceCond, data, SharedMem::read()->store_deviceCondLen); for (nn=0; nnstore_deviceCond[nn]; } // store dynamic machine conditions //static uint8_t store_machCondLen; //static uint8_t store_machCond[66]; void epi_clearDynMachineConditions(void) { uint8_t nn; SharedMem::write()->store_machCondLen=0; for (nn=0; nn<64; nn++) SharedMem::write()->store_machCond[nn] = 0; } void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data) { uint8_t nn; if (leng>64) leng=64; SharedMem::write()->store_machCondLen=leng; // tslib_strcpy(data, SharedMem::write()->store_machCond, leng); for (nn=0; nnstore_machCond[nn] = data[nn]; } void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data) { uint8_t nn, LL; LL=SharedMem::read()->store_machCondLen; *leng=LL; //tslib_strcpy(SharedMem::read()->store_machCond, data, SharedMem::read()->store_machCondLen); for (nn=0; nnstore_machCond[nn]; } //static uint8_t store_DcBackupNrOfAccNr; //static uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8 void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data) { if (leng>32) leng=32; SharedMem::write()->store_DcBackupAccNr[0]=uchar2uint(data[1], data[0]); SharedMem::write()->store_DcBackupAccNr[1]=uchar2uint(data[3], data[2]); SharedMem::write()->store_DcBackupAccNr[2]=uchar2uint(data[5], data[4]); SharedMem::write()->store_DcBackupAccNr[3]=uchar2uint(data[7], data[6]); SharedMem::write()->store_DcBackupAccNr[4]=uchar2uint(data[9], data[8]); SharedMem::write()->store_DcBackupAccNr[5]=uchar2uint(data[11], data[10]); SharedMem::write()->store_DcBackupAccNr[6]=uchar2uint(data[13], data[12]); SharedMem::write()->store_DcBackupAccNr[7]=uchar2uint(data[15], data[14]); SharedMem::write()->store_DcBackupNrOfAccNr=8; } void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs) { // return accNrs[0..7] uint8_t nn; *leng=SharedMem::read()->store_DcBackupNrOfAccNr; for (nn=0; nn<8; nn++) accNrs[nn]=SharedMem::read()->store_DcBackupAccNr[nn]; } void epi_iniVRstorage(void) { tslib_strclr(SharedMem::write()->store_vaultrecord, 0, PI_SIZOFVAULTRECORD); SharedMem::write()->store_gotNrBlocksOfVaultRec=0; } void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data ) { uint16_t start=blkNr, ii; qDebug()<<"storing vault data "<store_gotNrBlocksOfVaultRec |= (1< PI_SIZOFVAULTRECORD) start=320; // beginning of 6.block for (ii=0; ii<64; ii++) SharedMem::write()->store_vaultrecord[start+ii]=data[ii]; } bool epi_checkIfVaultRecordAvailable(void) { uint8_t data; data=SharedMem::read()->store_gotNrBlocksOfVaultRec; // qDebug()<<"epi_checkIfVaultRecordAvailable: "<store_gotNrBlocksOfVaultRec; return data; } bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf ) { uint16_t nn; uint8_t dat; *length=384; //genau: 340; for (nn=0; nn<384; nn++) { dat = SharedMem::read()->store_vaultrecord[nn]; buf[nn]=dat; } return true; } //static uint32_t store_amount; //static uint16_t store_nrOfCoins; void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins ) { SharedMem::write()->store_amount=amount; SharedMem::write()->store_nrOfCoins=nrOfCoins; } uint32_t epi_getCashBoxContent(void) { return SharedMem::read()->store_amount; } uint16_t epi_getNrOfCoinsInCashBox(void) { return SharedMem::read()->store_nrOfCoins; } //static bool store_DcDataAreValid; void gpi_storeDcDataValid(bool isVal) { SharedMem::write()->store_DcDataAreValid = isVal; } bool epi_areDcDataValid() { return SharedMem::read()->store_DcDataAreValid; } // .................................................................................... // 24.5.2023 //static uint8_t storeDCdynPrinterData[64]; //static uint8_t DCdynPrinterDataActual; /* uint8_t nn, LL; LL=SharedMem::read()->Sdata_mdbNrOfRecData; //tslib_strcpy(SharedMem::read()->Sdata_RecBuff, data, SharedMem::read()->Sdata_mdbNrOfRecData); for (nn=0; nnSdata_RecBuff[nn]; */ void epi_clearDynData(void) { uint8_t nn; SharedMem::write()->DCdynPrinterDataActual=0; //memset(SharedMem::write()->storeDCdynPrinterData,0, sizeof(storeDCdynPrinterData)); for (nn=0; nn<64; nn++) SharedMem::write()->storeDCdynPrinterData[nn]=0; } void gpi_storeDynData(uint8_t *DCdynDat) { uint8_t nn; // buffer size: 64 byte //memcpy(SharedMem::write()->storeDCdynPrinterData, DCdynDat, 64); SharedMem::write()->DCdynPrinterDataActual=1; for (nn=0; nn<64; nn++) SharedMem::write()->storeDCdynPrinterData[nn] = DCdynDat[nn]; } bool epi_getDynPrnData(uint8_t *DCdynDat) { // buffer size: 64 byte // return true if data are new and valid uint8_t nn; if (SharedMem::read()->DCdynPrinterDataActual) { //memcpy(DCdynDat, SharedMem::read()->storeDCdynPrinterData, 64); for (nn=0; nn<64; nn++) DCdynDat[nn] = SharedMem::read()->storeDCdynPrinterData[nn]; return true; } else { return false; } } void gpi_storeNextDCaccNr(uint16_t nxtDcAccNr) { SharedMem::write()->store_DCNextAccountNumber = nxtDcAccNr; } uint16_t epi_getNextDCaccNr(void ) { return SharedMem::read()->store_DCNextAccountNumber; } void gpi_storeMifCardType(uint16_t length, uint8_t *data) { SharedMem::write()->storeMifCardTypDataLen = length; for (uint8_t ii=0; ii<64; ii++) SharedMem::write()->storeMcardTypData[ii] = data[ii]; } void epi_restoreMifCardType(uint16_t *length, uint8_t *data) { *length = SharedMem::read()->storeMifCardTypDataLen; for (uint8_t ii=0; ii<64; ii++) data[ii] = SharedMem::read()->storeMcardTypData[ii]; } // before with local memory: //static uint8_t Sdata_rawData[RAW_BL_DATALEN]; //static uint8_t Sdata_LengthRawData; void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData) { uint8_t nn, lrd; lrd=RdDlen; if (lrd>RAW_BL_DATALEN) lrd=RAW_BL_DATALEN; SharedMem::write()->Sdata_LengthRawData=lrd; for (nn=0; nnSdata_rawData[nn]=receivedData[nn]; //qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)"; } uint8_t epi_getRawReceivedData(uint8_t *receivedData) { uint8_t nn, lrd; lrd=SharedMem::read()->Sdata_LengthRawData; for (nn=0; nnSdata_rawData[nn]; SharedMem::write()->Sdata_LengthRawData=0; // nur 1x gueltig return lrd; } uint8_t epi_getRawRecLength(void) { // retval=length return SharedMem::read()->Sdata_LengthRawData; } /* QString epi_getRawReceivedString() { uint8_t nn; //, ret; QString myString=nullptr, tmpStr=nullptr; myString.clear(); if (Sdata_LengthRawData==0) return myString; for (nn=0; nn0x80 dann wird EIN Byte 16 stellig angezeigt int ll=tmpStr.length(); if (ll>2) { myString.append(tmpStr[ll-2]); myString.append(tmpStr[ll-1]); } else { myString.append(tmpStr); } myString.append(" "); } //ret=Sdata_LengthRawData; //Sdata_LengthRawData=0; return myString; }*/ void epi_clrRawReceivedString() { SharedMem::write()->Sdata_LengthRawData=0; } // Mitteilung von Hwapi zu Datif (request coin type) void epi_setNowCoinPay(bool on_off) { SharedMem::write()->Sdata_coinPaymentNow=on_off; } bool gpi_getNowCoinPay (void) { return SharedMem::read()->Sdata_coinPaymentNow; } // Mitteilung von Hwapi zu Datif: using BL now void epi_setNowIsBootload(bool on_off) { SharedMem::write()->Sdata_bootloadingNow=on_off; } bool gpi_getNowIsBootload(void) { return SharedMem::read()->Sdata_bootloadingNow; } // 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 uint8_t nn, lrd; char einZeichen; lrd=jsonNr; if (lrd>0 && lrd<=numberOfJsons) { lrd--; for (nn=0; nnstore_jsonVersion[nn][lrd]=einZeichen; } } } 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 uint8_t nn, lrd; lrd=jsonNr; if (lrd>0 && lrd<=numberOfJsons) { lrd--; for (nn=0; nnstore_jsonVersion[nn][lrd]; } } void gpi_storeChangerResult(uint8_t result, uint32_t amount) { SharedMem::write()->Sdata_changeResult=result; SharedMem::write()->Sdata_changedAmount=amount; } uint8_t epi_getChangerResult(uint32_t *returnedAmount) { *returnedAmount=SharedMem::read()->Sdata_changedAmount; return SharedMem::read()->Sdata_changeResult; } void gpi_storeTubeLevel(uint8_t *data) { int nn; for (nn=0; nn<64; nn++) { SharedMem::write()->store_tubeLev[nn]=data[nn]; } } void epi_restoreTubeLevel(uint8_t *data) { int nn; for (nn=0; nn<64; nn++) { data[nn]=SharedMem::read()->store_tubeLev[nn]; } }