From b0e55d8ea40f48eb547c38c135056a542a9585d2 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 4 Jul 2024 14:01:43 +0200 Subject: [PATCH] Add collected changes from T.Sax --- include/dump.txt | 92 ++ include/hwapi.h | 60 +- include/interfaces.h | 191 ++-- include/runProc.h | 56 +- include/sendWRcmd.h | 2 + include/shared_mem_buffer.h | 5 +- include/storeINdata.h | 8 +- include/tslib.h | 33 +- lib_ca_master/lib_ca_master.pro | 3 + src/datIf.cpp | 148 ++- src/hwapi.cpp | 182 ++-- src/prot.cpp | 10 +- src/runProc.cpp | 1727 +++++++++++++++++++++++++++++-- src/sendWRcmd.cpp | 6 +- src/storeINdata.cpp | 67 +- src/tslib.cpp | 371 +++++++ 16 files changed, 2623 insertions(+), 338 deletions(-) create mode 100755 include/dump.txt mode change 100644 => 100755 include/sendWRcmd.h mode change 100644 => 100755 include/shared_mem_buffer.h mode change 100644 => 100755 include/storeINdata.h mode change 100644 => 100755 include/tslib.h mode change 100644 => 100755 src/datIf.cpp mode change 100644 => 100755 src/hwapi.cpp mode change 100644 => 100755 src/prot.cpp mode change 100644 => 100755 src/runProc.cpp mode change 100644 => 100755 src/sendWRcmd.cpp mode change 100644 => 100755 src/storeINdata.cpp mode change 100644 => 100755 src/tslib.cpp diff --git a/include/dump.txt b/include/dump.txt new file mode 100755 index 0000000..f744aff --- /dev/null +++ b/include/dump.txt @@ -0,0 +1,92 @@ +/* +void incTextBuffer(void) +{ + runProc_prnSeqNr++; + runProc_pointPrnTxt=0; + if (runProc_prnSeqNr>127) + runProc_prnSeqNr=127; + runProc_prnCmdSeq[runProc_pointPrnCmd]=1; + runProc_prnCmdPara[runProc_pointPrnCmd++]=runProc_prnSeqNr; +}*/ +/* +void T_runProc::subAppendNxtTxt(char *textLine) +{ + // append given text to current sequence, respect max. sequ.length + + // also send a command "print text buffer nn" ==1 once for each buffer + //static uint8_t runProc_prnCmdSeq[512]; + //static uint8_t runProc_prnCmdPara[512]; + //static uint16_t runProc_pointPrnCmd; + + int sl=strlen(textLine); + if (sl>1024) sl=1024; + textLine[sl]=0; + if (runProc_prnSeqNr==0 && runProc_pointPrnTxt<3) + { + // then this is the very first text entry + // store command to print this buffer + runProc_prnCmdSeq[runProc_pointPrnCmd]=1; + runProc_prnCmdPara[runProc_pointPrnCmd++]=runProc_prnSeqNr; + } + if ( (runProc_pointPrnTxt + sl) > 1023) + { + incTextBuffer(); + + } + runProc_prnTextSeq[runProc_prnSeqNr].append(textLine); + + //for (nn=0; nn + alle Mifare-Funktionen ueberprueft und ggf verbessert + 18.09.2023: Signal "Kasse entnommen" und Signale "Tuer auf/zu" ueberprueft + +20.9.2023: in datif die Abfrage der DynMachineData massiv beschleunigt + und hier in hwapi die entprellten Werte fuer Tueren und Kasse verwenden. + Problem war: Signal "Kasse entnommen" war zu langsam -> manchmal abr nicht gesendet + +14.3.24 new function bool hwapi::cash_isCollectionStarted(void) const + padding three struct to 64 byte to avoid stack overflow when using + //#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1" //#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.1" #define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3" V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM) +23.5.2024: prn_getHwState() fixed and moved down to runProc with a wrapper in hwapi, current version: 5.5 + several new functions for "direct ticket print", without the dueway loading jsons to DC and cmd DC to print + The same rules as before apply to the json, but it can have any arbitrary length + */ @@ -569,12 +590,10 @@ public: // read printer condition and settings uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const override; - // retval: status byte - // byte 0 = 0: prnter OK, >0: error - // bit0: paper low 1: no paper 2: temperature error - // 3: head open 4: paper jam in cutter - // 6: no response 7: bad response from printer - // and return struct "Tprn_hw_state" + // return value: =prn_hw_state[0] + // 0:unknown 1: printer OK 100: printer OK but paper near end + // 200: not connected 201: printer on error 202: no paper + bool prn_isUpAndReady(void) const override; // true: printer is powered, serial is ok, no error, printer is connected and resonding @@ -603,7 +622,7 @@ public: void prn_movePaper(uint8_t wayInMm, uint8_t direction) const override; //direction: 1=forward 2=backward - // + void prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const override; // font = kind of font 5...11 (0..22) // size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge @@ -1037,7 +1056,6 @@ public: void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override; - uint32_t cash_getAmountInVault(void) const override; uint16_t cash_getNrCoinsInVault(void) const override; @@ -1358,6 +1376,30 @@ public: virtual QObject const *getAPI() override; + void mod_switchResetline(void) override; + + + + + // 22.5.2024 direct ticket printing + + void prn_translateLocalPrinterJson(QByteArray jsonFile2print) const override; + // load, parse, translate and save the file + + void prnStoreDynamics(char *bufferDynPrintVars[], uint8_t nrOfDyns) const override; + // store nrOfDyns (up to 16) dynamics before printing + // max length = 16 byte per dynamic + // 16 strings with up to 16bytes each + + void prn_printTranslatedTicket(void) const override; + + uint8_t prn_waitForDirectTicket(void) const override; + + + + + + signals: void hwapi_reportDCDownloadStatus(QString const&) const override; void hwapi_reportDCDownloadSuccess(QString const&) const override; @@ -1389,6 +1431,8 @@ signals: void hwapi_coinAttached() const override; + + private slots: //void hwapi_slotPrintFinished_OK(void); //void hwapi_slotPrintFinished_Err(void); diff --git a/include/interfaces.h b/include/interfaces.h index cd2026b..f2fb3f4 100755 --- a/include/interfaces.h +++ b/include/interfaces.h @@ -179,57 +179,64 @@ struct T_moduleCondition // 50..99 = HINT / Notification // 100..150 = WARNING // 200..250 = ERROR - uint8_t ram; uint8_t intEe; uint8_t extEe; uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error + uint8_t boardHw; uint8_t printer; uint8_t modem; uint8_t signal; // 1...99 + uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime uint8_t mdbBus; - // 10 uint8_t coinChecker; // EMP, OMP or mei-cashflow uint8_t coinEscrow; + uint8_t mifareReader; // 0: unknown 1=OK 200=no response 201=wrong response 202: Reader reports HW-error uint8_t creditTerm; uint8_t coinReject; uint8_t coinSafe; + uint8_t billSafe; uint8_t voltage; // 1:11..14V uint8_t temper; uint8_t poweronTest; - // 20 + uint8_t doorState; // 1: alles zu 200: tuer offen + bit1(S) +bit2(CB) + bit3(CB) - uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened - uint8_t changer; // can only be tested by usage - uint8_t coinBlocker; // can only be tested by usage - uint8_t billReader; // can only be tested by usage + uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened + uint8_t changer; + uint8_t coinBlocker; + + uint8_t billReader; uint8_t ResetReason; uint8_t allModulesChecked; uint8_t alarmState; + + uint8_t fuses; uint8_t res11; uint8_t res12; - // 30 uint8_t res13; + // 32 + + uint8_t padd00; uint8_t padd01; uint8_t padd02; uint8_t padd03; + //36 uint32_t padd04; uint32_t padd05; uint32_t padd06; uint32_t padd07; - // 50 + // 52 uint32_t padd08; uint32_t padd09; uint32_t padd10; - uint16_t padd11; // 64 }; -// ATTENTION: struct length must be 64 exactly!!! + struct T_dynamicCondition { char allDoorsDebounced; @@ -248,7 +255,7 @@ struct T_dynamicCondition char lastMifCardType; uint8_t lastSDoorState; uint8_t lastVDoorState; - uint8_t lastCBstate; + uint8_t lastCBstate; // =0, not used char paymentInProgress; // Version Szeged: aug2023 // 0: stopped by timeout @@ -291,7 +298,10 @@ struct T_dynamicCondition char jsonValid_serial; char jsonValid_time; char lastFileType; + uint8_t MifCardHolder[8]; + // 51 + uint8_t resultOfLastTemplPrint; // 0: unknown or printing in progress // 1: OK, doc was printed 2: error, doc was not printed @@ -302,17 +312,36 @@ struct T_dynamicCondition // bit4: paper jam in cutter // bit6: no response bit7: serial rec. error // bit5: printer not ready - uint8_t startupTestIsRunning; + uint8_t startupTestIsRunning; // =0, not used + uint16_t empty; // neu 3.7.24, dieser Platz wird vom Compiler im Ram + // freigehalten weil naechster Wert ein Long ist + // 56 + // new since 7.5.24 + uint32_t totalNrOfCuts; + uint16_t nextAccountNumber; + uint16_t nrOfBillsInBox; + //uint16_t padd07; // raus am 3.7.24 + // 64 + + // rest comes with new cmd: + uint32_t amountInBillbox; + uint16_t UbatAtLastPrint; + uint16_t pad01; + uint32_t reserve01; + uint32_t reserve02; + uint32_t reserve03; + uint32_t reserve04; + uint32_t reserve05; + uint32_t reserve06; + uint32_t reserve07; + uint32_t reserve08; + uint32_t reserve09; + uint32_t reserve10; + uint32_t reserve11; + uint32_t reserve12; + uint32_t reserve13; + uint32_t reserve14; - uint8_t padd01; - uint8_t padd02; - uint8_t padd03; - //50 - uint32_t padd04; - uint32_t padd05; - uint32_t padd06; - uint16_t padd07; - // 64 }; struct T_extTime @@ -358,24 +387,37 @@ struct T_devices UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza Csquare (MW) UCHAR kindOfMifareReader; // by now only stronglink SL025 =1 UCHAR solarPower; // 1:sleep allowed 0: no sleep + UCHAR kindOfModem; // 0:off 1:Sunlink UCHAR kindOfCreditcard; // 0:off 1:Feig NFC UCHAR CoinEscrow; UCHAR CoinRejectUnit; + UCHAR CoinShutter; UCHAR BillAcceptor; // 10 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; - // 30 + // 20 UINT BattEmptyWarnLevel; UINT BattEmptyErrorLevel; + + UCHAR useForeignCharacters; + UCHAR printRefundReceipt; + UINT BillFullWarnLevel; + UINT BillFullErrorLevel; + + UCHAR housing; + UCHAR resUc1; + // 32 uint32_t padd01; uint32_t padd02; uint32_t padd03; @@ -383,7 +425,7 @@ struct T_devices uint32_t padd05; uint32_t padd06; uint32_t padd07; - uint16_t padd08; + uint32_t padd08; // 64 }; @@ -417,6 +459,8 @@ struct T_changer uint8_t paymentRunning; // 1: coins are accepted uint16_t denomination[16]; uint16_t availableTubes; //bitwise 0,1 1=av. bit0 = lowest coin value + uint16_t pad; + // 64byte }; struct T_bna @@ -425,19 +469,29 @@ struct T_bna uint8_t setup; // 0: not 1: got valid parameters from device uint8_t FeatureLevel; uint16_t countryCode; // programmed in EMP + uint16_t scalingFactor; // z.B. 5 uint8_t decimalPlace; uint8_t pad1; + uint16_t stackerCap; uint16_t billSecureLevel; +// 12 uint8_t hasEscrow; uint8_t accBillTypes[16]; // programmed in EMP z.B. (bit 0..7): 1 2 4 10 20 40 0 0 uint16_t currentStackerLevel; // requested number of notes in billbox - +// 31 // settings from Master uint16_t intendedAccept; // bit 0 =5€ uint16_t pad2; - uint16_t billDenomination[16]; + // 35 + uint16_t billDenomination[8]; +// 51 + uint8_t pad3; + uint32_t pad4; + uint32_t pad5; + uint32_t pad6; + // 8.5.24 reduced, 3 bytes too much. }; @@ -1279,16 +1333,17 @@ public: // read printer condition and settings - virtual uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const { + virtual uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const + { Q_UNUSED(prn_hw_state); return 0; } - // retval: status byte - // byte 0 = 0: prnter OK, >0: error - // bit0: paper low 1: no paper 2: temperature error - // 3: head open 4: paper jam in cutter - // 6: no response 7: bad response from printer - // and return struct "Tprn_hw_state" + // return value: =prn_hw_state[0] + // 0:unknown 1: printer OK 100: printer OK but paper near end + // 200: not connected 201: printer on error 202: no paper + + + virtual bool prn_isUpAndReady(void) const { return false; @@ -2380,6 +2435,40 @@ public: virtual QObject const *getAPI() { return nullptr; } + virtual void mod_switchResetline() { } + + + // direct ticket printing + // new from 22.5.2024, print Json-Printer-Template which + // is stored locally here in PTU memory, + // rather then loading several jsons to DC and tell it to print (until now) + // the local printer-json can have any length using predefined commands + // printing a local printer-json happens like this: + // 1) select a file to be printed from memory + // 2) load, parse, translate and save the file with following function + // 3) set dynamics (values from current transaction) + // 4) send saved file to printer one or several times + // hint: dynamics can be changed at any time without reloading the ticket, just repeat 3) and 4) + + virtual void prn_translateLocalPrinterJson(QByteArray jsonFile2print) const + { Q_UNUSED(jsonFile2print) } + // load, parse, translate and save the file + + virtual void prnStoreDynamics(char *bufferDynPrintVars[], uint8_t nrOfDyns) const + { Q_UNUSED(bufferDynPrintVars); Q_UNUSED(nrOfDyns) } + // store nrOfDyns (up to 16) dynamics before printing + // max length = 16 byte per dynamic + // 16 strings with up to 16bytes each + + virtual void prn_printTranslatedTicket(void) const { } + + virtual uint8_t prn_waitForDirectTicket(void) const { return 0; } + // return: 0: just printing, wait + // 1: OK - last print was succesful + // 2: error - not printed + // 2: printer error 3: no connection to DC + + signals: /* @@ -2422,31 +2511,7 @@ signals: virtual void hwapi_coinAttached() const = 0; - // NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid. - /* GH Version, bringt Fehler - void hwapi_templatePrintFinished_OK() const; - void hwapi_templatePrintFinished_Err() const; - void hwapi_coinCollectionJustStarted() const; - void hwapi_coinCollectionAborted() const; - - void hwapi_gotNewCoin() const; - void hwapi_payStopByMax() const; - void hwapi_payStopByPushbutton() const; - - void hwapi_payStopByEscrow() const; - void hwapi_payStopByError() const; - void hwapi_payStopByTimeout() const; - void hwapi_payCancelled() const; - void hwapi_coinProcessJustStopped() const; - - void hwapi_doorServiceDoorOpened() const; - void hwapi_doorVaultDoorOpened() const; - void hwapi_doorCoinBoxRemoved() const; - void hwapi_doorCoinBoxInserted() const; - void hwapi_doorCBinAndAllDoorsClosed() const; - void hwapi_doorAllDoorsClosed() const; - */ }; @@ -2511,11 +2576,21 @@ signals: // hier von =0 auf {} durch Gerhard //#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.2" // 7.11.2023: bna functions activated -#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.3" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.3" // 14.3.24:new function bool hwapi::cash_isCollectionStarted(void) const // padding three struct to 64 byte to avoid stack overflow when using // signal coin attached is much faster now +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.4" + // 7.may.2024, matches to DC V6, some structs extended + // new function: modem reset, dyn. data come with two commands now + // released 17.may.2024 + +#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.5" + // started at 21.5.24, integration of ticket interpreter + // see change log in hwapi.h + + Q_DECLARE_INTERFACE(hwinf, HWINF_iid) diff --git a/include/runProc.h b/include/runProc.h index a9d8b97..626cf8e 100755 --- a/include/runProc.h +++ b/include/runProc.h @@ -23,7 +23,6 @@ #include "shared_mem_buffer.h" - class T_runProc : public QObject { Q_OBJECT @@ -36,6 +35,16 @@ class T_runProc : public QObject void restoreDeviceParameter(struct T_devices *deviceSettings); + void clearPrnFile(void); + char subFeedPaper(char *valueStr); + bool subGetVariStr(char *valueStr, char *returnStr); + //void subAppendNxtTxt(char *textLine); + void sub_changeStyle(char *valueStr); + void subPrintGrafics(char *valueStr); + char prn_directTicket_cycle(void); + void runProc_subPerformPrintCmds(uint8_t nextCmd, uint8_t nextPara); + uint16_t subStoreTicketText(char *textLine); + #ifndef THIS_IS_CA_MASTER std::atomic_bool m_coinAttached{false}; #endif @@ -53,6 +62,9 @@ public: 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); + // byte 0: 0:unknown 1: printer OK 100: printer OK but paper near end + // 200: not connected 201: printer on error 202: no paper + void bl_completeStart(void); void dc_autoRequest(bool on); void bl_rebootDC(void); @@ -60,6 +72,48 @@ public: void bl_checkBL(void); bool bl_isUp(void); + // new from 21.5.24 .................................................................. + + uint16_t sys_getCustomerNumber(void); + uint16_t sys_getMachineNumber(void); + uint16_t sys_getBoroughNumber(void); + uint16_t sys_getZoneNumber(void); + uint16_t sys_getMachineAlias(void); + void sys_getLocation(char *locStr); + void prn_sendText(QByteArray *buf); + void prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3); + void prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data); + bool sys_parseFile(QByteArray jsonFile2print); + // and copy all keys and values to arrays + + bool sys_translateKeys(void); + + bool sys_interpretPrnCmds(void); + + + void prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation); + // send 5 byte: byte 0,1: speed 5...250 mm/s + // byte2: density 0....(25)....50 + // byte3: alignment 'l', 'c', 'r' = left, center, right + // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) + + void prnStoreDynamics(char *bufferDynPrintVars[], uint8_t nrOfDyns); + // store nrOfDyns (up to 16) dynamics before printing + // max length = 16 byte per dynamic + + bool prnRestoreDynamic(uint8_t nrOfDyn, char *bufferOneDyn); + // nrOfDyn = 0...15 + // buffer bufferOneDyn[16] needs length of at least 16 byte + + bool prn_isUpAndReady(void); + + void prnStartDirectPrinting(void); + + uint8_t prn_getDirectPrintResult(void); + // return: 0: just printing, wait + // 1: OK - last print was succesful + // 2: error - not printed + // 2: printer error 3: no connection to DC signals: //void runProc_templatePrintFinished_OK(void) const override; diff --git a/include/sendWRcmd.h b/include/sendWRcmd.h old mode 100644 new mode 100755 index 2620428..7afac90 --- a/include/sendWRcmd.h +++ b/include/sendWRcmd.h @@ -14,6 +14,8 @@ uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf); void sendWRcmd_INI(void); +uint8_t sendWRcmd_getStackSize(void); + // #define FDCMD_STACKDEPTH 16 / 32 // short and long commands are queued into the same stack to guaranty right order void sendFDcmd_clrStack(void); diff --git a/include/shared_mem_buffer.h b/include/shared_mem_buffer.h old mode 100644 new mode 100755 index 6b0130e..620de4b --- a/include/shared_mem_buffer.h +++ b/include/shared_mem_buffer.h @@ -230,6 +230,9 @@ struct SharedMem uint8_t store_bnaCollect[8]; uint8_t store_bnaContent[64]; + // new, 8.5.24 + uint8_t store_machCon2len; + uint8_t store_machCon2[66]; @@ -242,7 +245,7 @@ struct SharedMem // ------------------ Data OUTPUT -------------------------------- // sendWRcmd.cpp - #define CMDSTACKDEPTH 16 + #define CMDSTACKDEPTH 32 uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH]; uint8_t nrOfCmdsInQueue; diff --git a/include/storeINdata.h b/include/storeINdata.h old mode 100644 new mode 100755 index ec4ef2d..1cea1f5 --- a/include/storeINdata.h +++ b/include/storeINdata.h @@ -529,7 +529,7 @@ bool epi_areDcDataValid(); void epi_setDcDataValid(void); -void epi_resetDcDataValid(void); +void epi_resetDcDataValid(char reason); void epi_clearDynData(void); @@ -626,6 +626,12 @@ void epi_restoreBnaContent(uint8_t *data); +void epi_clearDynMachCond2(void); + +void gpi_storeDynMachCond2(uint8_t leng, uint8_t *data); + +void epi_restoreDynMachCond2(uint8_t *leng, uint8_t *data); + diff --git a/include/tslib.h b/include/tslib.h old mode 100644 new mode 100755 index 114c9f4..3db56ab --- a/include/tslib.h +++ b/include/tslib.h @@ -1,7 +1,7 @@ #ifndef TSLIB_H #define TSLIB_H #include - +#include "stdint.h" #define LOWBYTE false #define HIGHBYTE true @@ -87,6 +87,37 @@ void biox_CopyBlock(uint8_t *src, uint16_t srcPos, uint8_t *dest, uint16_t destP bool tslib_strComp(uint8_t *buf, char *compStr); + + + + + +uint16_t tslib_StrLen(char *str); + + + +void tslib_itoa(int n, char *str); + // -23456 -> str[0]='-' str[1]='2' ...[5]='6' str[6]=0 + // 5 -> str[0]='5' str[1..6]=0 + +void tslib_uitoa(unsigned int n, char *str); + +void tslib_ltoa(long n, char *str); + // -2147483647 -> str[0]='-' str[1]='2' ...[10]='6' str[11]=0 + +void tslib_ultoa( long n, char *str); + // 0... ->4294967296 str[0]='4' str[1]='2' ...[9]='6' str[10]=0 str[11]=0 + +void tslib_uitobin( int decval, char *str); + +long tslib_atol( char *AscString); + // change ascii string ( of ascii numbers '0'..'9') to number + // AscString must be 0-terminated! + // a leading '-' is ignored, a'.' or a ',' stops calculation + + + + #endif // TSLIB_H diff --git a/lib_ca_master/lib_ca_master.pro b/lib_ca_master/lib_ca_master.pro index e6c8f87..aba9189 100644 --- a/lib_ca_master/lib_ca_master.pro +++ b/lib_ca_master/lib_ca_master.pro @@ -41,3 +41,6 @@ unix { system("mkdir -p $${DESTDIR}") system("cp ../include/interfaces.h $${DESTDIR}") } + +DISTFILES += \ + ../include/dump.txt diff --git a/src/datIf.cpp b/src/datIf.cpp old mode 100644 new mode 100755 index 8496dfa..26ccdd2 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -88,7 +88,7 @@ T_datif::T_datif(QObject *parent) : QObject(parent) dif_scanStep=0; selectedSlaveAddr=FIX_SLAVE_ADDR; cycl_running=0; - epi_resetDcDataValid(); // data are not yet valid, no response from DC by now + epi_resetDcDataValid(1); // data are not yet valid, no response from DC by now datif_noResponseCtr=0; @@ -129,6 +129,11 @@ void T_datif::resetChain(void) dif_scanStep=0; } +#define RESPONSEWAITTIME 10 + // ab 5 keine timeouts mehr +#define GOTRESP_SENDGAP 20 + // Wert egal, muss nur > RESPONSEWAITTIME und <255 sein + char T_datif::datif_cycleSend() { // cyclic transmission of INPUT-Requests @@ -145,14 +150,14 @@ char T_datif::datif_cycleSend() if ( !myDCIF->isPortOpen()) { //qDebug() << "com port not available"; // wird ununterbrochen ausgegeben - epi_resetDcDataValid(); // DC data not valid + epi_resetDcDataValid(2); // DC data not valid return 0; } // supervise if DC data are valid datif_noResponseCtr++; // inc every 20ms if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s - epi_resetDcDataValid(); // DC data has not updated for >=5s -> no longer valid! + epi_resetDcDataValid(3); // DC data has not updated for >=5s -> no longer valid! // Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren if (gpi_wantToResetSupervision()) @@ -171,8 +176,7 @@ char T_datif::datif_cycleSend() // c) gar keine Antwort, Timeout nach 100ms -> 2x wiederholen (nach einer Luecke von 10ms ) // cycl_running=0: nichts zu tun 1: Mitteilung: Kommando wurde soeben abgesendet, 2,3,4 = Wiederholung - if (cycl_running) // 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL) - // if (cycl_running && doRepeat) + if (cycl_running) { // request is still running, wait for response before next sending //qDebug()<< "datif wait for response"; @@ -180,28 +184,35 @@ char T_datif::datif_cycleSend() datif_trigger->start(20); // ruft "this" (datif_cycleSend) erneut in 20ms auf // mit 10 kein Unterscheid weil Zykluszeit grösser - cycl_running++; // inc every 20...30ms // warte max 100ms auf Antwort - if (cycl_running >80 && cycl_running <95) // neu 13.9.23 mind. 40 damit Templates - // in Folge gedruckt werden koennen - // 95: muss nur kleiner sein als die 100 fuer die Luecke - // 17.10.23: 50--> 80 + cycl_running++; // inc every 20ms, warte auf Antwort + + if (cycl_running >= GOTRESP_SENDGAP) { - // 100ms vergangen, bisher keine Antwort, also Kommando wiederholen - qDebug()<< "datif timeout no response for wr/rd cmd "<< keepLastWrCmd << " " << keepLastRdCmd; + // got response, wait just one (this) cycle before next sending + cycl_running=0; + return 0; + } + + + if (cycl_running >=RESPONSEWAITTIME ) + { + // bisher keine Antwort, also Kommando wiederholen + qDebug()<< "datif timeout no response for wr/rd cmd "<< keepLastWrCmd << " " << keepLastRdCmd; cycl_running = 0; // gleich wiederholen weil ja schon ewig nichts mehr reinkam datif_cmdWasPerformed=2; // NO :(( gpi_storeLastResult(8); - + return 0; } - - if (cycl_running>=101) // 100 + 1 +/* + * Unsinn, wird nie durchlaufen + if (cycl_running>=(RESPONSEWAITTIME+6)) // 3.7.24: 101-->110 { // Antwort ist gekommen, also nach kurzer Luecke naechstes (datif_cmdWasPerformed==1) // oder nochmal gleiches (datif_cmdWasPerformed==2) Kommando senden //qDebug()<< "datif got any response"; cycl_running=0; } - +*/ // hier stoppen, weil Antwort des letzten Cmds noch nicht da return 0; } @@ -223,6 +234,7 @@ char T_datif::datif_cycleSend() datif_kindOfCmd=0; cycl_running=0; gpi_storeOverallResult(2); + qCritical()<<"datif, error no response to wr/rd "<setUserReadData(nextRdCmd); myDCIF->sendUserData(selectedSlaveAddr); - //qDebug()<<"Datif send long FD cmd (wr/rd): "<setUserReadData(nextRdCmd); myDCIF->sendUserData(selectedSlaveAddr); - //qDebug()<<"Datif send short FD cmd (wr/rd): "<0) // nur 1x bei neuer Münze 6.10.23 aendern: // beim Wechsler hat die kleinste Muenze immer coin type 0! if (uitmp>10000 || uit2>10000) @@ -999,7 +1001,7 @@ char T_datif::loadRecDataFromFrame() uitmp=0; uit2=0; } - if ((newInsertedAmount != lastInsertedAmount) || uit2>0) // 22.5.2024 + if ((newInsertedAmount != lastInsertedAmount) || uit2>0 ) { gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2); emit datif_gotNewCoin(); // OR BILL if (uitmp & 0x8000)>0 @@ -1037,7 +1039,9 @@ char T_datif::loadRecDataFromFrame() break; case 31: // Get dynamic machine conditions (doors, voltage, alarm….) - if (RdDleng>50) + // first 64 bytes, rest comes with cmd 34 + + if (RdDleng>60) { epi_setDcDataValid(); // DC-Data are valid as DC responded. // Could be set to every response but this (31) @@ -1046,23 +1050,8 @@ char T_datif::loadRecDataFromFrame() gpi_storeDI_CoinAttach(receivedData[6]); // new, 14.2.24 needed for direct coin insertion - } - /* funktioniert, ist aber nicht nötig. Signal wird nach dem shared memory erzeugt - prnResult=receivedData[52]; - if (prnResult != lastResult) - { - // new result - if (prnResult==1) - { - emit datif_templatePrintFinished_OK(); - } else - if (prnResult==2) - { - emit datif_templatePrintFinished_Err(); - } - - lastResult=prnResult; - }*/ + } else + qDebug()<<"datif received cmd31 with "<5) + { + gpi_storeDynMachCond2(RdDleng, receivedData); + //qDebug()<<"datif rec. cmd34: "; + //for (int nn=0; nn<64; nn++) + // qDebug() << nn << " : " << receivedData[nn] << " "; + + } + break; + case 35: gpi_storeMifCardType(RdDleng, receivedData); break; case 38: // Get stored account record backup - // readAddress, &RdDleng, receivedData - //if (RdDleng>50) // 1.8.23 nach Verlängerung des Datensatzes um 20byte falsch!!! - //{ gpi_storeVaultRecord(readAddress, receivedData ); // always/max 64byte -/* - qDebug()<<"datif cmd38 got vault data. blockNr: "< - alle Mifare-Funktionen ueberprueft und ggf verbessert - 18.09.2023: Signal "Kasse entnommen" und Signale "Tuer auf/zu" ueberprueft - -20.9.2023: in datif die Abfrage der DynMachineData massiv beschleunigt - und hier in hwapi die entprellten Werte fuer Tueren und Kasse verwenden. - Problem war: Signal "Kasse entnommen" war zu langsam -> manchmal abr nicht gesendet - -14.3.24 new function bool hwapi::cash_isCollectionStarted(void) const - padding three struct to 64 byte to avoid stack overflow when using - + see history in hwapi.h */ #include "hwapi.h" @@ -1770,8 +1756,10 @@ QString hwapi::mif_getCardDataStr(uint8_t blockNumber) const uint8_t hwapi::prn_getHwState(struct Tprn_hw_state *prn_hw_state) const { - // return printer hardware state: power is on? rs-driver on? rs_switch ok? hw-ready-line ok? - // printer on error or ok? + // return value: + // 0: unknown 1: printer OK + // 100: printer OK but paper near end + // 200: not connected 201: printer on error 202: no paper return runProcess->prn_getHwState(prn_hw_state); @@ -1779,13 +1767,8 @@ uint8_t hwapi::prn_getHwState(struct Tprn_hw_state *prn_hw_state) const bool hwapi::prn_isUpAndReady(void) const { - // 25.5.2023: geht nicht richtig :( bringt immer false obwohl Drucker OK - struct Tprn_hw_state prnHwNow; - - prn_getHwState(&prnHwNow); - if (prnHwNow.inIdle && prnHwNow.rsSwOk && prnHwNow.rsDrvOk && prnHwNow.powerRdBk ) - return true; - return false; + // gefixt am 24.5.2024 + return runProcess->prn_isUpAndReady(); } void hwapi::prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const @@ -1809,46 +1792,10 @@ void hwapi::prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) co void hwapi::prn_sendText(QByteArray *buf) const { - uint16_t nn, pp, mm, leng_byt, leng_blk, llb, freeStak; - uint8_t tmp66[66]; - - qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID"; - - epi_clearDynMachineConditions(); // 24.6.23 - gpi_storeDcDataValid(0); - - // komplett aendern 11.9.23 - memset(tmp66,0,66); - leng_byt=buf->size(); - freeStak=check4freeFDstack(); - freeStak<<=6; - if ( leng_byt > freeStak) - { - leng_byt=freeStak; // shorten the buffer as we cannot return an error (void function) - } - llb=leng_byt % 64; // length of last block, >0 if not dividable by 64 - leng_blk=leng_byt / 64; - - pp=0; - for (nn=0; nnat(pp++); - longFDcmd_set(CMD2DC_PRI_PRINT_TXT, 0,0,64, tmp66); - } - - if (llb>0) - { - - //leng_blk++; // z.B. 200 = 3 volle blocks und ein block mit nur 8byte - memset(tmp66,0,66); - for (mm=0; mmat(pp++); - for (mm=llb; mm<64; mm++) - tmp66[mm]=0; - longFDcmd_set(CMD2DC_PRI_PRINT_TXT, 0,0,64, tmp66); - } - + runProcess->prn_sendText(buf); + // 23.5.2024TS: moved function down to runProc in order to have it available there. + // here in hwapi only a wrapper left + // ( this also supports the idea to keep hwapi short :) } @@ -1857,6 +1804,8 @@ void hwapi::prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) cons // send three byte through to printer, see printers manual //sendWRcmd _setSendCommand8(SENDDIRCMD_PRN_SYS_CMD, para1, para2, 0, para3); hat gar nicht funktioniert + runProcess->prn_sendPrnSysCmd(para1, para2, para3); + /* uint8_t data[64]; uint32_t ultmp=para3; memset(data, 0,64); @@ -1870,6 +1819,7 @@ void hwapi::prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) cons data[7]=uint8_t(ultmp); longFDcmd_set(CMD2DC_PRI_SYS_CMD, 0, 0, 8, data); + */ // getestet auf richtige uebertragung am 11.9.23TS } @@ -1887,7 +1837,7 @@ void hwapi::prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alig // byte3: alignment 'l', 'c', 'r' = left, center, right // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) // not batched! don't use twice within 100ms - +/* uint8_t buf[10]; uint16_t uitmp; @@ -1900,7 +1850,8 @@ void hwapi::prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alig buf[4]=orientation; buf[5]=0; longFDcmd_set(CMD2DC_PRI_SETUP,0,0,5, buf); - +*/ + runProcess->prn_sendPrnSetup(paperSpeed, density, alignment, orientation); } void hwapi::prn_movePaper(uint8_t wayInMm, uint8_t direction) const @@ -2806,6 +2757,7 @@ bool hwapi::rtc_getExtendedTime(struct T_extTime *exTime) const epi_restoreExtendedTime(&len, buf); // Puffer in struct eintragen: LL=sizeof(struct T_extTime); + if (LL>64) LL=64; start = &(exTime->Hours); nn=0; do @@ -3186,10 +3138,11 @@ void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const uint8_t *start; uint8_t buf[70], leng; - epi_restoreDeviceConditions(&leng, buf); + epi_restoreDeviceConditions(&leng, buf); // leng is less then 64 // Puffer in struct eintragen: LL=sizeof(struct T_moduleCondition); + if (LL>64) LL=64; start = &devCond->ram; nn=0; do @@ -3231,26 +3184,27 @@ void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const void hwapi::sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const { + // not complete anymore epi_restoreDynMachineConditions(leng, data); } void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const { - - uint16_t LL, nn; - char *start; - uint8_t buf[70], leng; + uint8_t buf[130], leng; epi_restoreDynMachineConditions(&leng, buf); - // Puffer in struct eintragen: - LL=sizeof(struct T_dynamicCondition); - start = &dynMachCond->allDoorsDebounced; - nn=0; - do - { - *start = buf[nn]; - start++; - } while(++nntotalNrOfCuts = uchar2ulong(buf[57],buf[56],buf[55],buf[54]); + dynMachCond->nextAccountNumber = uchar2uint(buf[59], buf[58]); + dynMachCond->nrOfBillsInBox = uchar2uint(buf[61], buf[60]); + + // 8.5.24TS, as the DC struct is >64byte now, it comes in two parts: + epi_restoreDynMachCond2(&leng, buf); + dynMachCond->amountInBillbox = uchar2ulong(buf[3], buf[2],buf[1],buf[0]); + dynMachCond->UbatAtLastPrint = uchar2uint(buf[5], buf[4]); + memcpy(&dynMachCond->reserve01, &buf[8], 56); // rest reserve } @@ -3334,14 +3288,11 @@ void hwapi::sys_sendDeviceParameter(struct T_devices *deviceSettings) const void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const { - // attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before - // cannot be used to see settings programmed by JsonFile uint8_t buf[64]; uint8_t LL; tslib_strclr(buf,0,64); - //runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die??? - epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer + epi_restoreRbDeviceSettings(&LL, buf); Q_STATIC_ASSERT(sizeof(*deviceSettings) <= sizeof(buf)); @@ -3416,6 +3367,7 @@ void hwapi::prn_requestCurrentDynData(void) const { sendFDcmd_set(0,39,0,0,0,0,0); // rd data dynData epi_clearDynData(); + epi_clearDynMachCond2(); } bool hwapi::prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const @@ -4095,8 +4047,8 @@ int8_t hwapi::bl_blockAutoResponse(void) const void hwapi::sys_requestJsonVersions(uint8_t jsonNr) const { // send one request for every single version - // jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res. - // 5=printer template 1 ..... 36= template 32 + // jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4,5=empty + // 6=printer template 1 ..... 37= template 32 sendFDcmd_set(0, 21, jsonNr,0,0,0,0); } @@ -4301,7 +4253,7 @@ bool hwapi::bna_getAllParameters(struct T_bna *bna) const bna->intendedAccept = uchar2uint(buf[31], buf[30]); bna->pad2=0; pp=32; - for (nn=0; nn<16; nn++) + for (nn=0; nn<8; nn++) // was 16!!! // 8.5.24 reduced { bna->billDenomination[nn] = uchar2uint(buf[pp+1], buf[pp]); pp+=2; @@ -4672,7 +4624,61 @@ bool hwapi::dcDownloadGetRunning() const { return data ? data->m_downLoadDC.m_running.load() : 0; } -bool hwapi::dcDownloadGetFinished() const { +bool hwapi::dcDownloadGetFinished() const +{ SharedMem const *data = SharedMem::getDataConst(); return data ? data->m_downLoadDC.m_running.load() : 0; } + +//uint16_t dcDownloadGetTotalBlockNumber() const override; +//uint16_t dcDownloadGetCurrentBlockNumber() const override; +//virtual QObject const *getAPI() override; + + + +void hwapi::mod_switchResetline(void) +{ + sendFDcmd_set(171,0,0, 2,0,0,0); +} + + + +// new from 22.5.2024, print Json-Printer-Template which +// is stored locally here in PTU memory, +// rather then loading several jsons to DC and tell it to print (until now) +// the local printer-json can have any length using predefined commands +// printing a local printer-json happens like this: +// 1) select a file to be printed from memory +// 2) load, parse, translate and save the file with following function +// 3) set dynamics (values from current transaction) +// 4) send saved file to printer one or several times +// hint: dynamics can be changed at any time without reloading the ticket, just repeat 3) and 4) + +void hwapi::prn_translateLocalPrinterJson(QByteArray jsonFile2print) const +{ + runProcess->sys_parseFile( jsonFile2print); + runProcess->sys_translateKeys(); +} + +void hwapi::prnStoreDynamics(char *bufferDynPrintVars[], uint8_t nrOfDyns) const +{ + + runProcess->prnStoreDynamics(bufferDynPrintVars, nrOfDyns); + // store nrOfDyns (up to 16) dynamics before printing + // max length = 16 byte per dynamic +} + +void hwapi::prn_printTranslatedTicket(void) const +{ + runProcess->prnStartDirectPrinting(); +} + +uint8_t hwapi::prn_waitForDirectTicket(void) const +{ + return runProcess->prn_getDirectPrintResult(); + // return: 0: just printing, wait + // 1: OK - last print was succesful + // 2: error - not printed + // 2: printer error 3: no connection to DC + +} diff --git a/src/prot.cpp b/src/prot.cpp old mode 100644 new mode 100755 index 60b3e09..ca1e397 --- a/src/prot.cpp +++ b/src/prot.cpp @@ -97,14 +97,22 @@ void T_prot::setRecLen(uint16_t ReadCmd) void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, uint8_t *data) { + int nn; WriteCommand=WriteCmd; WriteAddr=WrAddr; WrDataLength=WrDatLen; if (WrDataLength>FRAME_DATALEN) WrDataLength=FRAME_DATALEN; - for (int nn=0; nnsetRecLen(100); // default: short response diff --git a/src/runProc.cpp b/src/runProc.cpp old mode 100644 new mode 100755 index a7783d8..cf395ee --- a/src/runProc.cpp +++ b/src/runProc.cpp @@ -33,11 +33,6 @@ T_runProc::T_runProc() hwapi_lastDoorState=0; // default: all doors (should be) closed, coin box inserted // bit0: upper door 1:middle 2:lower 3=cash-box out -// hwapi_triggerBL = new QTimer(); -// connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart())); -// hwapi_triggerBL->setSingleShot(false); -// hwapi_triggerBL->stop(); - myTO = new QTimer(); myTO->setSingleShot(true); myTO->start(200); @@ -62,6 +57,8 @@ void T_runProc::runProc_slotProcess(void) doors_supervise(); bl_performComplStart(); // neu 1.12.23 dcBL_cycle(); + prn_directTicket_cycle(); + #endif } @@ -92,11 +89,8 @@ bool T_runProc::cash_startPayment(uint32_t amount) uint8_t T_runProc::cash_paymentProcessing(void) { // run this function periodically while coin payment process to generate necessary signals: - // am 5.10.23 umgebaut, geht jetzt auch fuer MW. Für EMP und MW getestet - // 12.10.23: epi_store64BdevParameter() MUSS vorher aufgerufen werden zur Unterscheidung EMP / MW !!!!! - // return value: // 0: stopped 1: starting up 2: coin collection // 3: finished by User (Push button) 4: finished, Max-Value collected @@ -113,7 +107,7 @@ uint8_t T_runProc::cash_paymentProcessing(void) struct T_dynamicCondition myDynMachCond; struct T_devices devParameter; - uint8_t collActiv=0, payInProg, empState, kcc; + uint8_t collActiv=0, payInProg, kcc; // empState uint32_t newSum; if (hwapi_paymentStarted<1) @@ -151,11 +145,11 @@ uint8_t T_runProc::cash_paymentProcessing(void) if (kcc<3) { sub_emp_getAllParameters(&empStat); - empState=empStat.state; + //empState=empStat.state; } else { changer_getAllParameters(&chgrStat); - empState=chgrStat.state; + //empState=chgrStat.state; } // 0=start command @@ -201,23 +195,6 @@ uint8_t T_runProc::cash_paymentProcessing(void) //10= print refund receipt with "amountToReturn" -// qCritical() << "emitting signal payCancelled"; -// emit runProc_payCancelled(); - /* - // gabs bei Szeged, jetzt nicht mehr: - if (payInProg==8) - { - // coin checker faulty, cannot start - if (hwapi_paymentStarted==1) - { - hwapi_paymentStarted=90; // stop due to error - qCritical() << "emitting signal coinCollectionAborted 1"; - emit runProc_coinCollectionAborted(); - //sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment - } - return 10; // error cannot start - }*/ - // if (empState>=10 && empState<=12 && (payInProg==1 || payInProg==2) ) // Szeged if ( payInProg==2 ) //8.12.23 { @@ -252,7 +229,6 @@ uint8_t T_runProc::cash_paymentProcessing(void) } else - //if (payInProg==3) // user pressed "Next/Continue", keep coin if (payInProg==4) // user pressed "Next/Continue", keep coin since nov2023 { hwapi_paymentStarted++; @@ -261,7 +237,6 @@ uint8_t T_runProc::cash_paymentProcessing(void) emit runProc_payStopByPushbutton(); } else - //if (payInProg==4) // max achieved, keep coins if (payInProg==5) // max achieved, keep coins since nov2023 { hwapi_paymentStarted++; @@ -270,7 +245,6 @@ uint8_t T_runProc::cash_paymentProcessing(void) emit runProc_payStopByMax(); } else - //if (payInProg==5) // escrow full, keep coins if (payInProg==6) // escrow full, keep coins since nov2023 { hwapi_paymentStarted++; @@ -279,22 +253,12 @@ uint8_t T_runProc::cash_paymentProcessing(void) emit runProc_payStopByEscrow(); } - // 5.10.23 raus, geht auf 99 wenn Betrag erreicht, ist aber kein fehler - if ( (empState<10) || (empState>12)) // error - { - //collActiv=13; - //hwapi_paymentStarted=90; - //qCritical() << "emitting signal payStopByError" << empState; - //emit runProc_payStopByError(); - } - } if (hwapi_paymentStarted==3) { // coin collection finished, but coins kept until printing done collActiv=2; - //if (payInProg==6) // coins encashed if (payInProg==7) // coins encashed since nov2023 { collActiv=6; @@ -303,7 +267,6 @@ uint8_t T_runProc::cash_paymentProcessing(void) emit runProc_coinProcessJustStopped(); } else - //if (payInProg==7) // coins returned, printing failed if (payInProg==0) // coins returned, printing failed since nov2023 { collActiv=7; @@ -319,9 +282,6 @@ uint8_t T_runProc::cash_paymentProcessing(void) hwapi_paymentStarted=0; } - //if ( (empState<8) || (empState>12)) - // epi_clearCurrentPayment(); // to avoid wrong "got-coin" messages - if (hwapi_paymentStarted==90 ) { // EMP error, wait till process finished @@ -405,10 +365,13 @@ void T_runProc::sub_getDynMachineConditions(struct T_dynamicCondition *dynMachCo char *start; uint8_t buf[70], leng; + tslib_strclr(buf,0,70); epi_restoreDynMachineConditions(&leng, buf); // Puffer in struct eintragen: LL=sizeof(struct T_dynamicCondition); start = &dynMachCond->allDoorsDebounced; + if (LL>64) LL=64; + if (leng>64) leng=64; nn=0; do { @@ -421,45 +384,13 @@ void T_runProc::sub_getDynMachineConditions(struct T_dynamicCondition *dynMachCo -/* -static uint8_t Sdata_DeviceParameter[64]; -static uint8_t Sdata_DevParaLen; - -uint8_t T_runProc::epi_store64BdevParameter(uint8_t length, uint8_t *buf) -{ - // HWapi writes data to be stored - uint8_t nn; - for (nn=0; nnkindOfPrinter; @@ -472,9 +403,6 @@ void T_runProc::restoreDeviceParameter(struct T_devices *deviceSettings) } - - - bool T_runProc::doors_supervise(void) { // new from 2023.06.12, generate some signals: @@ -530,7 +458,7 @@ bool T_runProc::doors_supervise(void) uctmp=(hwapi_lastDoorState & 8); // 0: cash box was in if (uctmp==0 && myDynMachCond.CBinDebounced==0) // 0:fehlt 1:drin { - // wurde gerade entnommen + // Kasse wurde gerade entnommen hwapi_lastDoorState |= 8; qCritical()<<"hwapi emitting signal CoinBoxRemoved "; emit runProc_doorCoinBoxRemoved(); @@ -539,7 +467,7 @@ bool T_runProc::doors_supervise(void) uctmp=(hwapi_lastDoorState & 8); if (uctmp>0 && myDynMachCond.CBinDebounced>0) // 0:fehlt 1:drin { - // war draussen, ist wieder drin + // Kasse war draussen, ist wieder drin hwapi_lastDoorState &= ~0x08; qCritical()<<"hwapi emitting signal CoinBoxInserted"; emit runProc_doorCoinBoxInserted(); @@ -569,7 +497,6 @@ bool T_runProc::doors_supervise(void) } return true; - } @@ -580,58 +507,62 @@ uint8_t T_runProc::prn_getHwState(struct Tprn_hw_state *prn_hw_state) uint8_t prnHWstate[20]; epi_restorePrinterState(prnHWstate); - // byte 1...6 come right from printer, see printer manual - // byte 0 = all important infos: - // byte 0 = 0: prnter OK, >0: error + + // byte 0: 0:unknown 1: printer OK 100: printer OK but paper near end + // 200: not connected 201: printer on error 202: no paper + + // byte 1 = 0: prnter OK, >0: error // bit0: paper low 1: no paper 2: temperature error // 3: head open 4: paper jam in cutter // 6: no response 7: bad response from printer + // byte 2..6 come right from printer, by now always 0 prn_hw_state->powerRdBk = epi_getDI_printerPwr(); prn_hw_state->rsSwOk = epi_getDO_serialMux1isSetToPrinter(); // mux1 off: serial is switched to printer prn_hw_state->rsDrvOk = epi_getDO_serialDriverIsOn(); prn_hw_state->ReadyLine = epi_getDI_prnReady(); - if (prnHWstate[0]==0) + if (prnHWstate[1]<2) prn_hw_state->inIdle = true; // no errors else prn_hw_state->inIdle = false; // off or errors - if (prnHWstate[0] & 1) + if (prnHWstate[1] & 1) prn_hw_state->paperNearEnd=true; else prn_hw_state->paperNearEnd = false; - if (prnHWstate[0] & 2) + if (prnHWstate[1] & 2) prn_hw_state->noPaper=true; else prn_hw_state->noPaper = false; - if (prnHWstate[0] & 4) + if (prnHWstate[1] & 4) prn_hw_state->ErrorTemp=true; else prn_hw_state->ErrorTemp = false; - if (prnHWstate[0] & 8) + if (prnHWstate[1] & 8) prn_hw_state->HeadOpen=true; else prn_hw_state->HeadOpen = false; - if (prnHWstate[0] & 16) + if (prnHWstate[1] & 16) prn_hw_state->cutterJam=true; else prn_hw_state->cutterJam = false; - if (prnHWstate[0] & 64) + if (prnHWstate[1] & 64) prn_hw_state->noResponse=true; else prn_hw_state->noResponse = false; - if (prnHWstate[0] & 128) + if (prnHWstate[1] & 128) prn_hw_state->badResponse=true; else prn_hw_state->badResponse = false; + return prnHWstate[0]; } @@ -707,7 +638,6 @@ bool T_runProc::bl_isUp(void) return false; } - void T_runProc::bl_completeStart(void) { bl_startupStep=1; @@ -796,3 +726,1610 @@ bool T_runProc::bl_performComplStart(void) return false; } + + + + +// new from 21.5.24 .................................................................. + +uint16_t T_runProc::sys_getCustomerNumber(void) +{ + uint8_t length, data[64]; + + epi_restoreMachineIDsettings(&length, data); +// state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number +// byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name +// byte[10...41]=location + + return uchar2uint(data[1], data[0]); +} + +uint16_t T_runProc::sys_getMachineNumber(void) +{ + uint8_t length, data[64]; + + epi_restoreMachineIDsettings(&length, data); +// state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number +// byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name +// byte[10...41]=location + + return uchar2uint(data[3], data[2]); +} + +uint16_t T_runProc::sys_getBoroughNumber(void) +{ + uint8_t length, data[64]; + + epi_restoreMachineIDsettings(&length, data); +// state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number +// byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name +// byte[10...41]=location + + return uchar2uint(data[5], data[4]); +} + +uint16_t T_runProc::sys_getZoneNumber(void) +{ + uint8_t length, data[64]; + + epi_restoreMachineIDsettings(&length, data); +// state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number +// byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name +// byte[10...41]=location + + return uchar2uint(data[7], data[6]); +} + +uint16_t T_runProc::sys_getMachineAlias(void) +{ + uint8_t length, data[64]; + + epi_restoreMachineIDsettings(&length, data); +// state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number +// byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name +// byte[10...41]=location + + return uchar2uint(data[9], data[8]); +} + +void T_runProc::sys_getLocation(char *locStr) +{ + // return location in "locStr[32]" + + uint8_t length, data[64]; + + epi_restoreMachineIDsettings(&length, data); +// state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number +// byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name +// byte[10...41]=location + + for (int nn=0; nn<32; nn++) + locStr[nn]=data[nn+10]; +} + +void T_runProc::prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) +{ + // send 5 byte: byte 0,1: speed 5...250 mm/s + // byte2: density 0....(25)....50 + // byte3: alignment 'l', 'c', 'r' = left, center, right + // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) + + uint8_t buf[10]; + uint16_t uitmp; + + uitmp=paperSpeed; + buf[0]=uint8_t(uitmp); + uitmp>>=8; + buf[1]=uint8_t(uitmp); + buf[2]=density; + buf[3]=alignment; + buf[4]=orientation; + buf[5]=0; + longFDcmd_set(CMD2DC_PRI_SETUP,0,0,5, buf); + +} + + +void T_runProc::prn_sendText(QByteArray *buf) +{ + uint16_t nn, pp, mm, leng_byt, llb, freeStak, anzahlFullBlocks; + uint8_t tmp66[66]; + + //qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID"; + + epi_clearDynMachineConditions(); // 24.6.23 + gpi_storeDcDataValid(0); + + memset(tmp66,0,66); + leng_byt=buf->size(); + freeStak=check4freeFDstack(); + freeStak<<=6; + if ( leng_byt > freeStak) + { + leng_byt=freeStak; // shorten the buffer as we cannot return an error (void function) + } + llb=leng_byt % 64; // length of last block, >0 if not dividable by 64 + anzahlFullBlocks=leng_byt / 64; + + pp=0; + for (nn=0; nnat(pp++); + longFDcmd_set(CMD2DC_PRI_PRINT_TXT, 0,0,64, tmp66); + } + + if (llb>0) + { + // last block is shorter, only llb bytes + memset(tmp66,0,66); + for (mm=0; mmat(pp++); + for (mm=llb; mm<64; mm++) + tmp66[mm]=0; + longFDcmd_set(CMD2DC_PRI_PRINT_TXT, 0,0,llb, tmp66); + // set real length, not 64 + } + +} + + +void T_runProc::prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) +{ + // send three byte through to printer, see printers manual + //sendWRcmd _setSendCommand8(SENDDIRCMD_PRN_SYS_CMD, para1, para2, 0, para3); hat gar nicht funktioniert + + uint8_t data[64]; + uint32_t ultmp=para3; + memset(data, 0,64); + data[0]=para1; + data[1]=para2; + data[2]=0; + data[3]=0; + data[4]=uint8_t(ultmp); ultmp>>=8; + data[5]=uint8_t(ultmp); ultmp>>=8; + data[6]=uint8_t(ultmp); ultmp>>=8; + data[7]=uint8_t(ultmp); + + longFDcmd_set(CMD2DC_PRI_SYS_CMD, 0, 0, 8, data); +// getestet auf richtige uebertragung am 11.9.23TS + +} + +void T_runProc::prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) +{ + uint8_t buf[66], nn; + + if (dataLeng>58) + dataLeng=58; + + buf[0]=kindOf; + buf[1]=withText; + buf[2]=offset; + buf[3]=rotation; + buf[4]=dataLeng; + // rest: Barcode-data: + for (nn=0; nn= fileLength) + break; + + // search for ":" (quote comma quote) + // copy content to array keyStr up to there + ps=0; + do + { + oneSign=localCopy.at(filePointer++); + runProc_prnFile[LL].keyStr[ps++]=oneSign; + } while(oneSign!=':' && filePointer= fileLength) + break; + + // found : + // search for ", or " NL=10 or 13 or both (quote and new line) + // copy content to array valStr up to there + // skip ",": + if (filePointer < (fileLength-1)) + { + filePointer++; + } + if (filePointer >= fileLength) + break; + + ps=0; + do + { + oneSign=localCopy.at(filePointer++); + runProc_prnFile[LL].valStr[ps++]=oneSign; + } while( (oneSign!='"' && oneSign!=10 && oneSign!=13) && filePointer16) + runProc_nrOfPrnDyns=16; + + for (pp=0; pp=runProc_nrOfPrnDyns || pp>15) + return false; + + for (nn=0; nn1024) sl=1024; + textLine[sl]=0; + uint16_t point; + + if (sl==0) + return 10000; + + point=runProc_prnSeqNr; + if (point>127) + { + runProc_prnSeqNr=0; + point=0; + } + runProc_prnTextSeq[runProc_prnSeqNr].clear(); + runProc_prnTextSeq[runProc_prnSeqNr++].append(textLine); + return point; // Text wurde an diese Stelle geschrieben +} + + + +void T_runProc::sub_changeStyle(char *valueStr) +{ + /* + "styl":"bold on", + "styl":"under off", + "styl":"latin on", + "styl":"font 12", // select Font-type for the following print, + / range: 1...99 + "styl":"size 01", // select Font size for the following print + // range: 00...99, depends on font-type, selects hight and width + // 10th:height 1th=width + "styl":"align c" // 'l' 'c' 'r' // left center right + "styl":"density25"; // 0....[25]...50 0=blass + */ + + uint8_t val; + + if (runProc_pointPrnCmd >= 510) + { + // do nothing, buffer is full + } else + if ( memcmp(valueStr, "bold on", 7) ==0 ) // ==0 means equal + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=10; // cmd 10 heisst "bold on" + + } else + if ( memcmp(valueStr, "bold off", 7) ==0 ) // ==0 means equal + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=11; // cmd 11 heisst "bold off" + + } else + if ( memcmp(valueStr, "under on", 8) ==0 ) // ==0 means equal + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=12; + + } else + if ( memcmp(valueStr, "under off", 8) ==0 ) // ==0 means equal + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=13; + + } else + if ( memcmp(valueStr, "latin on", 8) ==0 ) // ==0 means equal + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=14; + + } else + if ( memcmp(valueStr, "latin off", 8) ==0 ) // ==0 means equal + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=15; + + } else + + if ( memcmp(valueStr, "font ", 5) ==0 ) // font type + { + valueStr[7]=0; + val=uint8_t(tslib_atol(&valueStr[5])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=16; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + + } else + + if ( memcmp(valueStr, "size ", 5) ==0 ) + { + valueStr[7]=0; + val=uint8_t(tslib_atol(&valueStr[5])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=17; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + + } else + + if ( memcmp(valueStr, "align ", 6) ==0 ) + { + runProc_prnCmdSeq[runProc_pointPrnCmd]=18; + runProc_prnCmdPara[runProc_pointPrnCmd++]=valueStr[6]; + } else + + if ( memcmp(valueStr, "density", 7) ==0 ) + { + valueStr[9]=0; + val=uint8_t(tslib_atol(&valueStr[7])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=19; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } + // "prn_papSped" comes with feed-cmd, not with "styl" !! + +} + +char T_runProc::subFeedPaper(char *valueStr) +{ + uint16_t val; +/* +"feed":"cut", +"feed":"part", +"feed":"eject", // 5 line forward and cut +"feed":"line3", // 3 line forward (1..9) +"feed":"back1", // 1 line back (1..9) +"feed":"BM", // Blackmark +"feed":"nl", // NewLine LF & CR (1..9) +"feed":"margin05", // left border in mm +"feed":"rim05", // right border in mm +"feed":"speed10", // printer speed *10mm/s +*/ + + if (runProc_pointPrnCmd >= 510) + { + // do nothing, buffer is full + } else + if ( memcmp(valueStr, "cut", 3) ==0 ) + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=30; + } else + + if ( memcmp(valueStr, "part", 4) ==0 ) + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=31; + } else + + if ( memcmp(valueStr, "eject", 5) ==0 ) + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=32; + } else + + if ( memcmp(valueStr, "line", 4) ==0 ) + { + valueStr[5]=0; + val=uint8_t(tslib_atol(&valueStr[4])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=33; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } else + + if ( memcmp(valueStr, "back", 4) ==0 ) + { + valueStr[5]=0; + val=uint8_t(tslib_atol(&valueStr[4])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=34; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } else + + if ( memcmp(valueStr, "BM", 2) ==0 ) + { + runProc_prnCmdSeq[runProc_pointPrnCmd++]=35; + } else + + if ( memcmp(valueStr, "nl", 2) ==0 ) + { + // immer eine Zeile vor, Para=1!!! + runProc_prnCmdSeq[runProc_pointPrnCmd]=36; + runProc_prnCmdPara[runProc_pointPrnCmd++]=1; + + //return 'n'; + } else + + if ( memcmp(valueStr, "margin", 6) ==0 ) + { + valueStr[8]=0; + val=uint8_t(tslib_atol(&valueStr[6])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=37; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } else + + if ( memcmp(valueStr, "rim", 3) ==0 ) + { + valueStr[5]=0; + val=uint8_t(tslib_atol(&valueStr[3])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=38; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } else + + if ( memcmp(valueStr, "speed", 5) ==0 ) + { + valueStr[7]=0; + val=uint8_t(tslib_atol(&valueStr[5])); + val*=10; + runProc_prnCmdSeq[runProc_pointPrnCmd]=39; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } + return 0; +} + +void T_runProc::subPrintGrafics(char *valueStr) +{ + uint16_t val; +/* +graf":"barc8", // kind and content is fixed programmed, 1..9 +"graf":"logo2", // programmed in printer, 1...9 +"graf":"q.r.1", // content is fixed programmed 1..9 + +*/ + if (runProc_pointPrnCmd >= 510) + { + // do nothing, buffer is full + } else + if ( memcmp(valueStr, "barc", 4) ==0 ) + { + valueStr[5]=0; + val=uint8_t(tslib_atol(&valueStr[4])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=50; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } else + if ( memcmp(valueStr, "logo", 4) ==0 ) + { + valueStr[5]=0; + val=uint8_t(tslib_atol(&valueStr[4])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=51; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } else + if ( memcmp(valueStr, "q.r.", 4) ==0 ) + { + valueStr[5]=0; + val=uint8_t(tslib_atol(&valueStr[4])); + runProc_prnCmdSeq[runProc_pointPrnCmd]=52; + runProc_prnCmdPara[runProc_pointPrnCmd++]=val; + } + +} + +bool T_runProc::subGetVariStr(char *valueStr, char *returnStr) +{ + // return appropriate value as string in returnStr[32] + uint16_t val; + uint8_t ddnum; + uint8_t hh, min, ss, yy, mon, dd; + uint8_t dow, datebuf[16]; + uint16_t minOfToday; + uint32_t secOfToday; + + for (int nn=0; nn<32; nn++) + returnStr[nn]=0; + for (int nn=0; nn<16; nn++) + datebuf[nn]=0; + // 1) fix data + + if ( memcmp(valueStr, "cunu", 4) ==0 ) // ==0 means equal + { + val=sys_getCustomerNumber(); + tslib_uitoa(val,returnStr); + return true; + } + if ( memcmp(valueStr, "manu", 4) ==0 ) // ==0 means equal + { + val=sys_getMachineNumber(); + tslib_uitoa(val,returnStr); + return true; + } + if ( memcmp(valueStr, "group", 5) ==0 ) // ==0 means equal + { + val=sys_getBoroughNumber(); + tslib_uitoa(val,returnStr); + return true; + } + if ( memcmp(valueStr, "zone", 4) ==0 ) // ==0 means equal + { + val=sys_getZoneNumber(); + tslib_uitoa(val,returnStr); + return true; + } + if ( memcmp(valueStr, "alias", 5) ==0 ) // ==0 means equal + { + val=sys_getMachineAlias(); + tslib_uitoa(val,returnStr); + return true; + } + if ( memcmp(valueStr, "location", 8) ==0 ) + { + sys_getLocation(returnStr); + return true; + } + + // 2) time and date + epi_getTime(&hh, &min, &ss); + epi_getDate(&yy, &mon, &dd); + epi_getToday(&dow, &minOfToday, &secOfToday); + + if ( memcmp(valueStr, "date ge", 7) ==0 ) + { + GetDateString(dd, mon, 0x20, yy, 0, 0, datebuf); + for (int nn=0; nn<16; nn++) + returnStr[nn] = datebuf[nn]; + return true; + } + if ( memcmp(valueStr, "date us", 7) ==0 ) + { + GetDateString(dd, mon, 0x20, yy, 2, 1, datebuf); + for (int nn=0; nn<16; nn++) + returnStr[nn] = datebuf[nn]; + return true; + } + if ( memcmp(valueStr, "time long", 9) ==0 ) // erstmal nur 24h system + { + GetTimeString(hh, min, ss, 0, 1, datebuf); + for (int nn=0; nn<16; nn++) + returnStr[nn] = datebuf[nn]; + return true; + } + if ( memcmp(valueStr, "time shor", 9) ==0 ) + { + GetTimeString(hh, min, ss, 0, 0, datebuf); + for (int nn=0; nn<16; nn++) + returnStr[nn] = datebuf[nn]; + return true; + } + + if ( memcmp(valueStr, "wday eng shor", 13) ==0 ) + { + switch (dow) + { + + case 1: + returnStr[0]='m'; returnStr[1]='o'; + break; + case 2: + returnStr[0]='t'; returnStr[1]='u'; + break; + case 3: + returnStr[0]='w'; returnStr[1]='e'; + break; + case 4: + returnStr[0]='t'; returnStr[1]='h'; + break; + case 5: + returnStr[0]='f'; returnStr[1]='r'; + break; + case 6: + returnStr[0]='s'; returnStr[1]='a'; + break; + case 7: + returnStr[0]='s'; returnStr[1]='u'; + break; + default: + returnStr[0]='-'; returnStr[1]='-'; + break; + } + returnStr[2]=0; + return true; + } + if ( memcmp(valueStr, "wday eng long", 13) ==0 ) + { + + return true; + } + if ( memcmp(valueStr, "wday deu shor", 13) ==0 ) + { + + return true; + } + + if ( memcmp(valueStr, "wday deu long", 13) ==0 ) + { + + return true; + } + + // 3.) dynamics + // char runProc_dynPrnVars[16][16]; + // example: "vari","Dynamic02"; + if ( memcmp(valueStr, "Dynamic", 7) ==0 ) + { + ddnum = ((valueStr[7]-0x30)*10 + (valueStr[8]-0x30)); + if (ddnum>15) + return false; + prnRestoreDynamic( ddnum, returnStr); + return true; + } + + + return false; +} + + + +bool T_runProc::sys_translateKeys(void) +{ + // 2) use key-value pairs from printer-Json-File and interpret them + + // store printer commands in chronologic order (will be printed in this order 0 1 2 3....) + // to runProc_prnCmdSeq[512] and runProc_prnCmdPara[512]. nr of commands in total in "runProc_pointPrnCmd" + + // command 1=print text from textbuffer[nn] where nn is stored in runProc_prnCmdPara + + // number of key-value pairs: + // runProc_nrOfLinesPrnFile + // runProc_prnFile[LL].keyStr[] + // runProc_prnFile[LL].valStr[] + + + // header keys: "title", "project", "Version" - no action by now + + // Following keys are used: save as cmd: + // text // drucke Text direkt -> t + // styl // wie soll der Text aussehen -> s + // feed // Papier bewegen -> f + // vari // Werte aus Speicher drucken -> v + // graf // drucke Log, QRcode oder Barcode -> g + uint16_t pairNr=0, nn, pTxt; + char keyCmd; + char variStr[32]; + + runProc_prnSeqNr=0; + runProc_pointPrnTxt=0; + runProc_pointPrnCmd=0; + + for (nn=0; nn<128; nn++) + runProc_prnTextSeq[nn].clear(); + + for (nn=0; nn<512; nn++) + { + runProc_prnCmdSeq[nn]=0; + runProc_prnCmdPara [nn]=0; + } + runProc_pointPrnCmd=0; + runProc_nrOfPrnDyns=0; // delete one time here + do + { + keyCmd=sub_findKey(runProc_prnFile[pairNr].keyStr); + switch(keyCmd) + { + case 't': + pTxt=subStoreTicketText(runProc_prnFile[pairNr].valStr); + runProc_prnCmdSeq[runProc_pointPrnCmd]=1; + runProc_prnCmdPara[runProc_pointPrnCmd++]=pTxt; + break; + case 's': + sub_changeStyle(runProc_prnFile[pairNr].valStr); + break; + case 'f': + // new line nicht als Kommando senden sondern mit in den Textpuffer, geht schneller + subFeedPaper(runProc_prnFile[pairNr].valStr); + break; + case 'v': + memset(variStr,0,32); + subGetVariStr(runProc_prnFile[pairNr].valStr, variStr); + //subAppendNxtTxt(variStr); + pTxt=subStoreTicketText(variStr); + runProc_prnCmdSeq[runProc_pointPrnCmd]=1; + runProc_prnCmdPara[runProc_pointPrnCmd++]=pTxt; + + + break; + case 'g': + subPrintGrafics(runProc_prnFile[pairNr].valStr); + break; + + // Header: + case 'T': + break; + case 'P': + break; + case 'V': + break; + + default: + // irgendwas anderes, Kommentar oder Leerzeile. Tolerieren, einfach weiter + break; + } + + //qDebug()<<"runProc sys_translateKeys "<50) + return 0; + + bool printerOK=prn_isUpAndReady(); + + + // Printer Start =============================================== + if (runProc_stepChainPrintDirect==1) + { + qDebug()<<"runProc start quick print"; + if (printerOK) + { + runProc_stepChainPrintDirect=10; + } else + { + // printer off-on for 100ms + qDebug()<<"runProc quick print proff"; + sendFDcmd_set(CMD2DC_PRINTERON,0,0, false,0,0,0); + runProc_stepChainDelay=0; + runProc_stepChainPrintDirect++; + } + + + } else + + if (runProc_stepChainPrintDirect==2) + { + if (++runProc_stepChainDelay>30) // 30 + { + qDebug()<<"runProc quick print pron"; + sendFDcmd_set(CMD2DC_PRINTERON,0,0, true,0,0,0); + runProc_stepChainDelay=0; + runProc_stepChainPrintDirect++; + } + } else + + if (runProc_stepChainPrintDirect==3) + { + // waiting for printer getting ready + if (++runProc_stepChainDelay>300) + { + // timeout 3s + runProc_stepChainResult=2; // printer not ready + runProc_stepChainPrintDirect= 99; // finish + printerOK=prn_isUpAndReady(); // double, just for test + qDebug()<<"runProc quick print TO pr not rdy"; + } + + if (printerOK) + { + qDebug()<<"runProc quick print pr is ready"; + + runProc_stepChainPrintDirect=10; + runProc_stepChainDelay=0; + } + } else + + // Printer Default Settings =============================================== + + if (runProc_stepChainPrintDirect==10) + { + // printer is ready now + // default settings: + + if (++runProc_stepChainDelay>runProc_dirPrnCmdDelay) + { + qDebug()<<"runProc quick print send ini1"; + prn_papSped=100; // 5...250 mm/s + prn_density=25; // 0....(25)....50 + prn_alignment='l'; // 'l', 'c', 'r' = left, center, right + prn_orient=0; // 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) + //prn_sendPrnSetup(prn_papSped, prn_density, prn_alignment, prn_orient); + runProc_stepChainDelay=0; + runProc_stepChainPrintDirect++; + } + } else + + if (runProc_stepChainPrintDirect==11) + { + if (++runProc_stepChainDelay>runProc_dirPrnCmdDelay) + { + qDebug()<<"runProc quick print send ini2"; + prn_fontTyp=8; // kind of font 5...11 (0..22) + prn_fontSiz=12; // 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge + prn_width=0; // 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) + prn_hei=0; // 0...7 = 1x...8x only 0,1,2,(3) make sense + //sendFDcmd_set(CMD2DC_PRI_SETFONT, 0,0, prn_fontTyp, prn_fontSiz, prn_width, prn_hei); + runProc_stepChainDelay=0; + runProc_stepChainPrintDirect++; + } + } else + + if (runProc_stepChainPrintDirect==12) + { + if (++runProc_stepChainDelay>runProc_dirPrnCmdDelay) + { + qDebug()<<"runProc quick print send ini3"; + prn_fontBold=0; // 0=off 1=on + prn_fontInv=0; // 0=off 1=on + prn_underLine=0; // 0=off 1=on + //sendFDcmd_set(CMD2DC_PRI_SETLETTER, 0, 0, prn_fontBold, prn_fontInv, prn_underLine, 0); + runProc_stepChainDelay=0; + runProc_stepChainPrintDirect++; + } + } else + + if (runProc_stepChainPrintDirect==13) + { + if (++runProc_stepChainDelay>runProc_dirPrnCmdDelay) + { + if (printerOK) + { + qDebug()<<"runProc quick print step13: pr is rdy"; + runProc_stepChainPrintDirect=20; + runProc_TOcnt=0; + } // else stay here + + if (++runProc_TOcnt>30) + { + qDebug()<<"runProc quick print step13: TO"; + // printer is not ready after 3s, stop chain + runProc_stepChainResult=2; // printer not ready + runProc_stepChainPrintDirect= 99; // finish + } + runProc_pointPrnCmd=0; + runProc_stepChainDelay=0; + } + + } else + + // Print Saved Ticketdata =============================================== + //static char runProc_prnTextSeq[128][1024]; + //static uint8_t runProc_prnCmdSeq[512]; + //static uint8_t runProc_prnCmdPara[512]; + //static uint16_t runProc_pointPrnCmd; + if (runProc_stepChainPrintDirect==20) + { + if (++runProc_stepChainDelay>runProc_dirPrnCmdDelay) + { + freeStak=check4freeFDstack(); // returns nr of free places in command stack + if (freeStak<=1) + { + // cmd stack is full, wait 1s + qDebug()<<"runProc quick print step20: cmdStack is full"; + + if (++runProc_TOcnt>30) + { + // still full after 3s + qDebug()<<"runProc quick print step20 stop bec. 30xTO"; + + runProc_stepChainResult=3; // transmission disturbed + runProc_stepChainPrintDirect= 99; // finish + } else + { + runProc_stepChainPrintDirect++; + runProc_stepChainDelay=0; + } + } else + + if (!printerOK) + { + if (++runProc_TOcnt>30) + { + // still not OK after 3s + qDebug()<<"runProc quick print step20 stop bec. 30x pr not rdy"; + runProc_stepChainResult=2; + runProc_stepChainPrintDirect= 99; // finish + } else + { + // wait a s + runProc_stepChainPrintDirect++; + runProc_stepChainDelay=0; + } + + } else + { + // printer is OK, cmd-stack is OK, so send next command: + + runProc_TOcnt=0; + nextCmd = runProc_prnCmdSeq[runProc_pointPrnCmd]; + nextPara = runProc_prnCmdPara[runProc_pointPrnCmd]; + + + if (nextCmd==0 || runProc_pointPrnCmd > 510) + { + // we're done + qDebug()<<"runProc quick print step20: successful finished"; + runProc_stepChainResult=1; + runProc_stepChainPrintDirect=99; + } else + if (nextCmd==1 ) + { + // send text buffer + qDebug()<<"runProc quick print step20 send TEXT " + << nextCmd << " / " << nextPara; + + if (nextPara<128) + prn_sendText(&runProc_prnTextSeq[nextPara]); + + qDebug()<100) + { + runProc_stepChainPrintDirect=20; + runProc_stepChainDelay=0; + } + } else + + if (runProc_stepChainPrintDirect==99) + { + // do nothing + } + + return 0; +} + + diff --git a/src/sendWRcmd.cpp b/src/sendWRcmd.cpp old mode 100644 new mode 100755 index 0f3cec1..85f82aa --- a/src/sendWRcmd.cpp +++ b/src/sendWRcmd.cpp @@ -19,7 +19,11 @@ void sendWRcmd_INI(void) } -// Command Stack for commands without parameters +uint8_t sendWRcmd_getStackSize(void) +{ + return CMDSTACKDEPTH; // defined in shared_mem_buffer.h +} + //static uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH]; diff --git a/src/storeINdata.cpp b/src/storeINdata.cpp old mode 100644 new mode 100755 index 65e1ec9..50b6094 --- a/src/storeINdata.cpp +++ b/src/storeINdata.cpp @@ -9,7 +9,7 @@ // 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) - +// Change log: 8.5.24TS: clear all oversize buffers (if only 32 of 64bytes are used then fill the rest with 0) @@ -1002,6 +1002,8 @@ bool epi_getDI_auxPwr(void) void gpi_storeDI_GsmPowerIsOn(bool di_gsm_PwrOn) { SharedMem::write()->di_gsmPwrOn=di_gsm_PwrOn; + //qDebug()<<"store In Data Gsm Pwr = "<< di_gsm_PwrOn; + } bool epi_getDI_gsmPwr(void) @@ -1541,6 +1543,8 @@ void gpi_storeMdbResponse(uint8_t leng, uint8_t *data) //tslib_strcpy(data, SharedMem::write()->Sdata_RecBuff, uint16_t(Sdata_mdbNrOfRecData)); for (nn=0; nnSdata_RecBuff[nn] = data[nn]; + for (nn=leng; nn<40; nn++) + SharedMem::write()->Sdata_RecBuff[nn] = 0; } @@ -1567,6 +1571,8 @@ void gpi_storeEmpSettings(uint8_t leng, uint8_t *data) //tslib_strcpy(data, SharedMem::write()->Sdata_emp_settingsBuff, leng); for (nn=0; nnSdata_emp_settingsBuff[nn] = data[nn]; + for (nn=leng; nn<64; nn++) + SharedMem::write()->Sdata_emp_settingsBuff[nn] = 0; } @@ -1672,6 +1678,9 @@ void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t *data) // getestet am //tslib_strcpy(data, SharedMem::write()->Sdata_DeviceSettingBuff, leng); for (nn=0; nnSdata_DeviceSettingBuff[nn] = data[nn]; + for (nn=leng; nn<64; nn++) + SharedMem::write()->Sdata_DeviceSettingBuff[nn] = 0; + } @@ -1912,6 +1921,10 @@ void gpi_storeDeviceConditions(uint8_t leng, uint8_t *data) //tslib_strcpy(data, SharedMem::write()->store_deviceCond, leng); for (nn=0; nnstore_deviceCond[nn]=data[nn]; + // clear the rest + for (nn=leng; nn<64; nn++) + SharedMem::write()->store_deviceCond[nn]=0; + } void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data) @@ -1947,6 +1960,8 @@ void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data) // tslib_strcpy(data, SharedMem::write()->store_machCond, leng); for (nn=0; nnstore_machCond[nn] = data[nn]; + for (nn=leng; nn<64; nn++) + SharedMem::write()->store_machCond[nn] = 0; } @@ -2098,16 +2113,26 @@ void epi_setDcDataValid(void) } } -void epi_resetDcDataValid(void) +void epi_resetDcDataValid(char reason) { bool now=SharedMem::read()->store_DcDataAreValid; if (now==true) { SharedMem::write()->store_DcDataAreValid = false; #ifdef THIS_IS_CA_MASTER - qDebug()<<"master lib RESET DcDataValid"; + switch (reason) + { + case 1: qDebug()<<"master lib RESET DcDataValid startup"; break; + case 2: qDebug()<<"master lib RESET DcDataValid port closed"; break; + case 3: qDebug()<<"master lib RESET DcDataValid no more data"; break; + case 4: qDebug()<<"master lib RESET DcDataValid manuell"; break; + default: qDebug()<<"master lib RESET DcDataValid ---"; break; + } + + #else qDebug()<<"slave lib RESET DcDataValid"; + Q_UNUSED(reason); #endif } } @@ -2346,6 +2371,7 @@ void epi_getJsonVersion(uint8_t jsonNr, char *versionString) versionString[nn] = SharedMem::read()->store_jsonVersion[nn][lrd]; } + // korrektur 8.5.24: printer versionen auf 6...37 (nicht 5..36) } @@ -2452,7 +2478,40 @@ void epi_restoreBnaContent(uint8_t *data) - +// new, 8.5.24 +//uint8_t store_machCon2len; +//uint8_t store_machCon2[66]; + +void epi_clearDynMachCond2(void) +{ + uint8_t nn; + SharedMem::write()->store_machCon2len=0; + for (nn=0; nn<64; nn++) + SharedMem::write()->store_machCon2[nn] = 0; +} + + +void gpi_storeDynMachCond2(uint8_t leng, uint8_t *data) +{ + uint8_t nn; + if (leng>64) leng=64; + SharedMem::write()->store_machCon2len=leng; + for (nn=0; nnstore_machCon2[nn] = data[nn]; + for (nn=leng; nn<64; nn++) + SharedMem::write()->store_machCon2[nn] = 0; + + } + +void epi_restoreDynMachCond2(uint8_t *leng, uint8_t *data) +{ + uint8_t nn, LL; + LL=SharedMem::read()->store_machCon2len; + *leng=LL; + + for (nn=0; nnstore_machCon2[nn]; +} diff --git a/src/tslib.cpp b/src/tslib.cpp old mode 100644 new mode 100755 index c5a3002..3fc3b6d --- a/src/tslib.cpp +++ b/src/tslib.cpp @@ -610,3 +610,374 @@ bool tslib_strComp(uint8_t *buf, char *compStr) return true; } + + + + + +char biox_StrComp(char *S1, char *S2, int len) +{ + // retval=1 wenn gleich; ? in S2 =Jokerzeichen + + int ii; + + for (ii=0; ii0) + { + dest[zz]=src[zz]; + zz++; + } + dest[zz]=0; // termination + } else + { + // Len>0 --> copy "Len" bytes + for (zz=0; zz str[0]='-' str[1]='2' ...[5]='6' str[6]=0 + // 5 -> str[0]='5' str[1..6]=0 + + uint8_t pp, zi[7]; + int itmp, pi=0; + + for (pp=0;pp<7;pp++) + { + str[pp]=0; + zi[pp]=0; + } + + itmp=n; + pp=0; + + if (itmp==0) + str[pp++]=0x30; + + if (itmp<0) + { + str[pp++]='-'; + itmp*=-1; + } + + while(itmp>0) + { + zi[pi++]=itmp%10; + itmp/=10; + } + // now: zi[0]=6 zi[1]=5 zi[2]=4 zi[3]=3 zi[4]=2 zi[5]=0 zi[6]=0 pi=4 + while (pi>0) + str[pp++]=zi[--pi]+0x30; + + //str[0]='-'; str[1]='1'; str[3]='3'; // Test + } + +// *********************************************************************************************** + +void tslib_uitoa(unsigned int n, char *str) +{ + + uint8_t pp, zi[6]; + unsigned int itmp; + int pi=0; + + for (pp=0;pp<6;pp++) + { + str[pp]=0; + zi[pp]=0; + } + + itmp=n; + pp=0; + + if (itmp==0) + str[pp++]=0x30; + + while(itmp>0) + { + zi[pi++]=itmp%10; + itmp/=10; + } + // now: zi[0]=6 zi[1]=5 zi[2]=4 zi[3]=3 zi[4]=2 zi[5]=0 pi=4 + while (pi>0) + str[pp++]=zi[--pi]+0x30; + + //str[0]='-'; str[1]='1'; str[3]='3'; // Test + } + +// *********************************************************************************************** + +void tslib_ltoa(long n, char *str) +{ + // -2147483647 -> str[0]='-' str[1]='2' ...[10]='6' str[11]=0 + + uint8_t pp, zi[12]; + int pi=0; + long ltmp; + + for (pp=0;pp<12;pp++) + { + str[pp]=0; + zi[pp]=0; + } + + ltmp=n; + pp=0; + + if (ltmp==0) + str[pp++]=0x30; + + if (ltmp<0) + { + str[pp++]='-'; + ltmp*=-1; + } + + while(ltmp>0) + { + zi[pi++]=ltmp%10; + ltmp/=10; + } + + while (pi>0) + str[pp++]=zi[--pi]+0x30; + + +} + +// *********************************************************************************************** + +void tslib_ultoa(unsigned long n, char *str) +{ + // 0... ->4294967296 str[0]='4' str[1]='2' ...[9]='6' str[10]=0 str[11]=0 + + uint8_t pp, zi[12]; + int pi=0; + unsigned long ltmp; + + for (pp=0;pp<12;pp++) + { + str[pp]=0; + zi[pp]=0; + } + + ltmp=n; + pp=0; + + if (ltmp==0) + str[pp++]=0x30; + + while(ltmp>0) + { + zi[pi++]=ltmp%10; + ltmp/=10; + } + + while (pi>0) + str[pp++]=zi[--pi]+0x30; +} + +// *********************************************************************************************** + +void tslib_uitobin(unsigned int decval, char *str) +{ + uint16_t dv, bb; + int ll; + + dv=decval; + ll=8; // show 8 bit + if (dv>255) ll=16; // show 16 bit + str[ll--]=0; // terminierung + + bb=0; + do + { + if (dv & (1<=0); + + + +} + +// *********************************************************************************************** + +long tslib_atol( char *AscString) +{ + // change ascii string ( of ascii numbers '0'..'9') to number + // AscString must be 0-terminated! + // a leading '-' is ignored, a'.' or a ',' stops calculation + + //aufruf mit ("1234") + // aus IDE: ucatmp[0]='1' ucatmp[3]='4' ucatmp[4]='0' sl=4 + + unsigned long ultmp; + unsigned char uctmp1, minus=0; + unsigned int sl, zz; + + sl=tslib_StrLen(AscString); + if (sl>10) sl=10; // mehr passt im ULONG nicht rein! + + ultmp=0; + for (zz=0; zz0x2F && uctmp1<0x3A) + { + ultmp*=10; // nur wenn eine neue Ziffer dazukommt und vor der addition! + uctmp1-=0x30; + ultmp+=(uint32_t)uctmp1; + + } else + if (uctmp1=='.' || uctmp1==',' || uctmp1==0 ) + { + if (minus) + ultmp*=(-1); + return(ultmp); + } + } + + if (minus) + ultmp*=(-1); + return(ultmp); + +} + +// ***************************************************************************************** + +unsigned long tslib_atoul( char *AscString) +{ + // change ascii string ( of ascii numbers '0'..'9') to number + // AscString must be 0-terminated! + // a leading '-' is ignored, a'.' or a ',' stops calculation + + //aufruf mit ("1234") + // aus IDE: ucatmp[0]='1' ucatmp[3]='4' ucatmp[4]='0' sl=4 + + unsigned long ultmp; + unsigned char uctmp1; + unsigned int sl, zz; + + sl=tslib_StrLen(AscString); + if (sl>10) sl=10; // mehr passt im ULONG nicht rein! + + ultmp=0; + for (zz=0; zz0x2F && uctmp1<0x3A) + { + ultmp*=10; // nur wenn eine neue Ziffer dazukommt und vor der addition! + uctmp1-=0x30; + ultmp+=(uint32_t)uctmp1; + + } else + if (uctmp1=='.' || uctmp1==',' || uctmp1==0 ) + return(ultmp); + } + + return(ultmp); + +} + +// ***************************************************************************************** + +unsigned int tslib_ah2ui( char *AscString) +{ + // change hex ascii string ( of ascii numbers '0'..'9', 'A' or 'a' ...'F','f') to number + // AscString must be 0-terminated! + // Example: "1A0C" = 6668 + + //unsigned long ultmp; + unsigned char uctmp1; + unsigned int sl, zz, uitmp; + + sl=tslib_StrLen(AscString); + if (sl>4) sl=4; + + uitmp=0; + for (zz=0; zz=0x30 && uctmp1<=0x39) + { + uitmp<<=4; // nur wenn eine neue Ziffer dazukommt und vor der addition! + uctmp1-=0x30; + uitmp+=(uint16_t)uctmp1; + } else + + if (uctmp1>='A' && uctmp1<='F') + { + uitmp<<=4; + uctmp1-=0x37; + uitmp+=(uint16_t)uctmp1; + } else + + if (uctmp1>='a' && uctmp1<='f') + { + uitmp<<=4; + uctmp1-=0x57; + uitmp+=(uint16_t)uctmp1; + } + + } + + return(uitmp); + +}