diff --git a/src/hwapi.cpp b/src/hwapi.cpp index 3d5862d..431579a 100644 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -501,6 +501,8 @@ uint8_t hwapi::rtc_setDateTime(void) const } + + void hwapi::rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const { epi_getTime(hh, mm, ss); @@ -2968,7 +2970,7 @@ bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const // 14.9.23 neu: Datensatz erst pruefen, [0..3] enthaelt "Psa>" und [4,5 =Abr.Nr] uint16_t ds_acc_nr=uchar2uint(buf[5], buf[4]); - if (buf[0]=='P' && buf[1]=='S' && buf[2]=='A' && buf[3]=='>' && ds_acc_nr<60000) + if (buf[0]=='P' && buf[1]=='s' && buf[2]=='a' && buf[3]=='>' && ds_acc_nr<60000) { // valid data, copy data to struct do @@ -4176,22 +4178,55 @@ void hwapi::bna_sendSettings(uint16_t notesToAccept, uint16_t parameters, // acceptanceLimit: device will stop acceptance once this amount is reached and // optionally keep last bill in escrow until vend_success() // is called (put bill to stacker) or vend_failed() is called (return bill) - Q_UNUSED(notesToAccept); - Q_UNUSED(parameters); - Q_UNUSED(billDenomination); - Q_UNUSED(acceptanceLimit); + + uint16_t noteAcc=notesToAccept; + uint16_t para=parameters; + uint16_t denom[16]; + uint32_t limit=acceptanceLimit; + uint8_t buf[64], nn, pp; + + for (nn=0; nn<16; nn++) + denom[nn]=billDenomination[nn]; + + + buf[0]=uint2uchar(noteAcc, LOWBYTE); + buf[1]=uint2uchar(noteAcc, HIGHBYTE); + buf[2]=uint2uchar(para, LOWBYTE); + buf[3]=uint2uchar(para, HIGHBYTE); + pp=4; + for (nn=0; nn<16; nn++) + { + buf[pp++]=uint2uchar(denom[nn], LOWBYTE); + buf[pp++]=uint2uchar(denom[nn], HIGHBYTE); + } + + buf[pp++]=ulong2uchar(limit, 0); + buf[pp++]=ulong2uchar(limit, 1); + buf[pp++]=ulong2uchar(limit, 2); + buf[pp++]=ulong2uchar(limit, 3); + + longFDcmd_set(35, 41, 0, pp, buf); + } void hwapi::bna_setCurrentAcceptance(uint16_t notesToAccept) const { // can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid) - Q_UNUSED(notesToAccept); + uint8_t LB, HB; + uint16_t val=notesToAccept; + + LB=uint2uchar(val, LOWBYTE); + HB=uint2uchar(val, HIGHBYTE); + + sendFDcmd_set(170, 0, 0, LB, HB, LB, HB); } void hwapi::bna_requestParameters(void) const { // send command to DC in order to get static invariable device parameters like currency // device must be powered and polled to get these + + sendFDcmd_set(0, 41, 0, 0, 0, 0, 0); } bool hwapi::bna_getAllParameters(struct T_bna *bna) const @@ -4199,38 +4234,128 @@ bool hwapi::bna_getAllParameters(struct T_bna *bna) const // get all constant data from reader (e.g. currency) // and actual Host-Settings (sent with bna_sendSettings() or json) // retval = true if data are valid - Q_UNUSED(bna); - return false; + uint8_t buf[66], nn, pp; + + epi_restoreBnaParams(buf); + bna->setup=buf[0]; + bna->FeatureLevel=buf[1]; + bna->countryCode=uchar2uint(buf[3], buf[2]); + bna->scalingFactor=uchar2uint(buf[5], buf[4]); + bna->decimalPlace=buf[6]; + bna->pad1=0; + bna->stackerCap=uchar2uint(buf[8], buf[7]); + bna->billSecureLevel=uchar2uint(buf[10], buf[9]); + bna->hasEscrow=buf[11]; + + for (nn=0; nn<16; nn++) + bna->accBillTypes[nn] = buf[nn+12]; + + bna->currentStackerLevel = uchar2uint(buf[29], buf[28]); + bna->intendedAccept = uchar2uint(buf[31], buf[30]); + bna->pad2=0; + pp=32; + for (nn=0; nn<16; nn++) + { + bna->billDenomination[nn] = uchar2uint(buf[pp+1], buf[pp]); + pp+=2; + } + if (bna->setup) + return true; + else + return false; } void hwapi::bna_requestCurrentNotes(void) const { // send command to DC in order to get transaction data + sendFDcmd_set(0, 116, 0, 0, 0, 0, 0); } uint8_t hwapi::bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const { // returns number of collected bank notes since start-command (current transaction) - // latestBill: last accepted bank note, value in cent - // currentNotes an array with up to 16 (further) notes collected - Q_UNUSED(latestBill); - Q_UNUSED(currentNotes); - return 0; + // latestBill: not used + // currentNotes[0] = last bill value + // currentNotes[1] = 0/1 1 if bill in escrow 0 if bill in cash box (stacker) + // currentNotes[2,3] = total sum of collected bills within this transaction + + // incoming data: + //DB1: nr of bills (this transaction) + //DB2: 1 if bill in escrow + //DB3..6: collected amount + //DB7,8: denomination of last bill + + uint8_t buf[10], haveBilInEscrow, haveNrOfBills; + uint16_t lastBillVal; + uint32_t collAmountThisTrans; + + epi_restoreBnaCollection(buf); + haveNrOfBills=buf[0]; + haveBilInEscrow=buf[1]; + collAmountThisTrans = uchar2ulong(buf[5],buf[4],buf[3],buf[2]); + lastBillVal = uchar2uint(buf[7],buf[6]); + + currentNotes[0]=latestBill; // just to get rid of compiler warning + currentNotes[0]=lastBillVal; + currentNotes[1]=haveBilInEscrow; + currentNotes[2]=uint16_t(collAmountThisTrans); + collAmountThisTrans>>=16; + currentNotes[3]=uint16_t(collAmountThisTrans); + + return haveNrOfBills; } void hwapi::bna_requestStackerLevel(void) const { - + sendFDcmd_set(0, 42, 0, 0, 0, 0, 0); } uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOfBills) const { // return val: nr of bills in stacker - // countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker - // countOfBills[1] for 10€ and so on - Q_UNUSED(amountInStacker); - Q_UNUSED(countOfBills); - return 0; + // countOfBills[0..7] = count of bills of bill-type 0..7 (e.g. countOfBills[0]=nr of 5€-bills in stacker) + // countOfBills[8..15] = value of bill-type 0...7 + + // receive data: + //je zwei Byte pro Wert, + //1…16: Anzahl Scheine pro Typ + //33…48: Wertigkeit der Typen + uint8_t buf[66], nn, pp, qq; + uint16_t nrOfBills[16], valueOfBills[16], anzahl=0; + uint32_t totalSum=0; + + epi_restoreBnaContent(buf); + + pp=0; qq=32; + for (nn=0; nn<16; nn++) + { + nrOfBills[nn]=uchar2uint(buf[pp+1],buf[pp]); + pp+=2; + valueOfBills[nn]=uchar2uint(buf[qq+1],buf[qq]); + qq+=2; + } + + //qDebug()<< "CAmaster hwapi::bna_getStackerLevel " << nrOfBills[0] <<" "<< nrOfBills[1] + // <<" "<