Added/merged from sources of Thomas (version CashAgentLib 3.3, 12.04.2023)
This commit is contained in:
330
include/hwapi.h
330
include/hwapi.h
@@ -1,4 +1,23 @@
|
||||
/*
|
||||
matching interfaces.h:
|
||||
|
||||
// History
|
||||
// 11.10.2021: V1.0 222 functions
|
||||
// 23.12.2021: V1.1 added block-parameter to function "read mifare data"
|
||||
// 30.12.2021: V1.2 added function: mif_clearDataBuffer(), mif_isBlockAvailable(uint8_t blkNr) and mif_getAvailableDataBlocks()
|
||||
// 1.1.2022: V1.3 Mifare extended. ( background: read 16 x 48byte from card to DC, read 12 x 64byte from DC to CA)
|
||||
// new: read full card with 768bytes from HWapi without block borders
|
||||
// added: mif_getNrOfAvailableDataBytes mif_getCardData768byteDec(uint8_t *buf, uint16_t bufferSize)
|
||||
// mif_getCardDataDec(uint16_t fromAddr, uint16_t toAddr, uint8_t *buf, uint16_t bufferSize)
|
||||
// mif_getCardDataStr(bool useHexFormat, char seperator)
|
||||
// 29.03.2023: V3.1 some extensions for PSA1256_ptu5,
|
||||
// V3.2 Bootloader improvement
|
||||
// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging
|
||||
|
||||
//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1"
|
||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.1"
|
||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
||||
|
||||
|
||||
PSA1259 hardware control using the DeviceController DC2
|
||||
|
||||
@@ -37,7 +56,7 @@ Level 3:
|
||||
start/stop complete processes.
|
||||
Example: 1) print (predefined) document nr 3 with Text, letter size, font set, cut.
|
||||
Also power up/down the printer, check if paper ok and so on.
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
Another access example: control the coin unit
|
||||
@@ -71,93 +90,11 @@ Level 3): send command: "start payment process"
|
||||
#include <QTabWidget>
|
||||
#include <QtPlugin>
|
||||
#include <QObject>
|
||||
#include <../plugins/interfaces.h>
|
||||
#include "interfaces.h"
|
||||
#include "datIf.h"
|
||||
|
||||
|
||||
|
||||
//public QWidget,
|
||||
|
||||
/*
|
||||
struct Tprn_hw_state
|
||||
{
|
||||
// hardware (IO's)
|
||||
bool powerRdBk; // prn pwr is on
|
||||
bool rsSwOk; // serial switch (printer or modem) is set to printer
|
||||
bool rsDrvOk; // RS232 converter for PTU, Printer and Modem in on
|
||||
|
||||
bool ReadyLine; // HW signal from printer showing ready
|
||||
bool inIdle; // powered and free from errors
|
||||
bool paperNearEnd; // paper roll runs out
|
||||
bool noPaper;
|
||||
bool ErrorTemp;
|
||||
bool HeadOpen;
|
||||
bool cutterJam;
|
||||
bool noResponse; // printer is not connected, cable broken, wrong baudrate
|
||||
bool badResponse;
|
||||
};
|
||||
|
||||
struct Tprn_currentSettings
|
||||
{
|
||||
uint8_t currFont;
|
||||
uint8_t currSize;
|
||||
uint8_t currHeigth;
|
||||
uint8_t currWidth;
|
||||
bool nowBold;
|
||||
bool nowInvers;
|
||||
bool nowUnderlined;
|
||||
uint8_t currDensity;
|
||||
uint8_t currSpeed;
|
||||
bool nowAligned;
|
||||
};
|
||||
|
||||
struct T_dynDat
|
||||
{
|
||||
uint8_t licensePlate[8];
|
||||
uint8_t vendingPrice[8];
|
||||
uint8_t parkingEnd[8];
|
||||
uint8_t currentTime[8];
|
||||
uint8_t currentDate[8];
|
||||
uint8_t dynDat5[8];
|
||||
uint8_t dynDat6[8];
|
||||
uint8_t dynDat7[8];
|
||||
};
|
||||
|
||||
|
||||
struct T_emp
|
||||
{
|
||||
|
||||
// Fixdata from EMP:
|
||||
uint8_t shaft; // = changer level
|
||||
uint16_t countryCode;
|
||||
uint8_t scale;
|
||||
uint8_t decimals;
|
||||
uint8_t coinValues[16];
|
||||
uint16_t routing;
|
||||
|
||||
// Master specs:
|
||||
uint8_t gotSetup; // 1: got specifications from master 0: no specs
|
||||
uint16_t coinAccept; // bit 0 = coin1 bit H=accept
|
||||
uint8_t tokenChannel;
|
||||
uint16_t denomination[16];
|
||||
|
||||
// dynamic:
|
||||
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
||||
// 0=Emp & Bus power off, 1=powered, poll off 2=polling on
|
||||
// 3=device responded, requesting status
|
||||
// 4=waiting for status 5=have status,
|
||||
// 6: IDLE, have paramters from master, polling running, ready for payment
|
||||
// Master can stop/start polling and acceptance
|
||||
// 7: end of transaction, polling on, accept off, reporting coins, (wait for last coin)
|
||||
// 8: transaction running, polling on, acceptance on, reporting coins,
|
||||
|
||||
uint8_t pollingRunning;
|
||||
uint8_t paymentRunning;
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
class hwapi : public QObject,
|
||||
public hwinf
|
||||
{
|
||||
@@ -182,6 +119,7 @@ public:
|
||||
|
||||
T_datif *myDatif;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 0 commands, interface
|
||||
// open, close, change serial interface
|
||||
@@ -258,7 +196,6 @@ public:
|
||||
|
||||
QString dc_getState(void) const override;
|
||||
|
||||
// neu, 25.8.21
|
||||
QString dc_getTxt4RsDiagWin(void) const override;
|
||||
void dc_clrTxt4RsDiagWin(void) const override;
|
||||
QString dc_get2ndTxt4RsDiagWin(void) const override;
|
||||
@@ -295,13 +232,6 @@ public:
|
||||
uint8_t bl_exitBL(uint8_t *sendData) const override;
|
||||
// minimum size of sendData-buffer: 5byte retval: length
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 2 DC2-onboard devices
|
||||
// WR: set time
|
||||
@@ -983,7 +913,7 @@ public:
|
||||
// return true is bl is up and running
|
||||
// also initializes "sendFile"
|
||||
|
||||
void bl_sendAddress(u_int16_t blockNumber) const override;
|
||||
void bl_sendAddress(uint16_t blockNumber) const override;
|
||||
// send start address, nr of 64byte-block, start with 0
|
||||
// will be sent only for folling block-numbers:
|
||||
// 0, 1024, 2048, 3072 and 4096, so basically every 64kByte
|
||||
@@ -993,7 +923,7 @@ public:
|
||||
|
||||
void bl_openBinary(void) const override;
|
||||
|
||||
void bl_sendDataBlock(uint8_t length, u_int8_t *buffer) const override;
|
||||
void bl_sendDataBlock(uint8_t length, uint8_t *buffer) const override;
|
||||
// send 64 byte from bin file
|
||||
|
||||
void bl_sendLastBlock(void) const override;
|
||||
@@ -1003,61 +933,52 @@ public:
|
||||
|
||||
void bl_stopBL(void) const override;
|
||||
|
||||
|
||||
// Bootlader, not used or obsolete
|
||||
//bool bl_isDiagAvailable(void) const override;
|
||||
|
||||
//QString dc_getDiagText(void) const override;
|
||||
|
||||
|
||||
|
||||
|
||||
// Komplett-schreib Funktion, noch nicht getestet
|
||||
// Nachteil: keine Rückmeldung wie lang's noch dauert
|
||||
|
||||
//void bl_startSending(void) const override;
|
||||
|
||||
//void bl_sendFile(void) const override;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// neu, ab 6.4.23
|
||||
// bereits vorhanden, nochmal getestet/verbessert:
|
||||
// void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const override;
|
||||
// void alarm_switchSiren(bool on) const override;
|
||||
|
||||
// neu, 25.8.21
|
||||
QString dc_getTxt4RsDiagWin(void) const override;
|
||||
void dc_clrTxt4RsDiagWin(void) const override;
|
||||
QString dc_get2ndTxt4RsDiagWin(void) const override;
|
||||
void dc_clr2ndTxt4RsDiagWin(void) const override;
|
||||
QString dc_getTxt4HsStateLine(void) const override;
|
||||
void dc_clrTxt4HsStateLine(void) const override;
|
||||
QString dc_getTxt4masterStateLine(void) const override;
|
||||
void dc_clrTxt4masterStateLine(void) const override;
|
||||
QString dc_getTxt4resultStateLine(void) const override;
|
||||
void dc_clrTxt4resultStateLine(void) const override;
|
||||
QString dc_getdataStateLine(void) const override;
|
||||
void dc_clrTxt4dataStateLine(void) const override;
|
||||
QString dc_getdatifLine(void) const override;
|
||||
void dc_clrTxt4datifLine(void) const override;
|
||||
// void mif_readerOn(bool on) const override;
|
||||
// bool mif_cardIsAttached(void) const override;
|
||||
|
||||
// using DC2 Bootloader
|
||||
void bl_iniChain(void) const override;
|
||||
bool bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const override;
|
||||
uint8_t bl_activatBootloader(uint8_t *sendData) const override;
|
||||
uint8_t bl_startChain(void) const override;
|
||||
uint8_t bl_readBLversion(uint8_t *sendData) const override;
|
||||
// minimum size of sendData-buffer: 5byte retval: length
|
||||
uint8_t bl_readFWversion(uint8_t *sendData) const override;
|
||||
// minimum size of sendData-buffer: 5byte retval: length
|
||||
// void shut_move(bool open) const override;
|
||||
// void esc_moveFlaps(uint8_t flap ) const override;
|
||||
// 0: close both 1: open take-flap 2: open return
|
||||
// void shut_openOnce(void) const override;
|
||||
// and close automatic after shutter time
|
||||
// void shut_openForCoin(bool start) const override;
|
||||
// open flap if coin is attached
|
||||
// once process is started it runs until stop command
|
||||
// void shut_sendOpeningTime(uint16_t timeIn_ms ) const override;
|
||||
// after this time without retrigger the flap is closed
|
||||
// void esc_takeMoney(void) const override;
|
||||
// and close automatically after escrow time (1s)
|
||||
// void esc_returnMoney(void) const override;
|
||||
// and close automatically after escrow time (1s)
|
||||
|
||||
uint8_t bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const override;
|
||||
// make BL protocol, retval = outbuf length (5...133)
|
||||
// bring data in correct form: start always with 0x02 finish with 0x03 and append checksum
|
||||
// 0x02 Cmd < ...sendData ..> CRC CRC 0x03
|
||||
// Data length = 0...64
|
||||
// special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80
|
||||
// so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64
|
||||
// void prn_switchPower(bool on) const override;
|
||||
// void prn_sendText(QByteArray *buf) const override;
|
||||
// up to 1280 bytes
|
||||
|
||||
uint8_t bl_exitBL(uint8_t *sendData) const override;
|
||||
// minimum size of sendData-buffer: 5byte retval: length
|
||||
*/
|
||||
// uint8_t rtc_setDateTime(void) const override;
|
||||
// send system time
|
||||
|
||||
//void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker,
|
||||
// uint8_t kindOfMifareReader, uint8_t suppressSleep,
|
||||
// uint8_t kindOfModem, uint8_t kindOfCredit ) const override;
|
||||
|
||||
//void sendMachineID(uint16_t customerNr, uint16_t machineNr,
|
||||
// uint16_t borough, uint16_t zone,
|
||||
// uint16_t alias, char *location) const override;
|
||||
|
||||
/*
|
||||
uint8_t emp_getInsertedCoinSignal(void) const override;
|
||||
@@ -1073,6 +994,96 @@ public:
|
||||
// emp_chkIfCoinInserted() must be called before!
|
||||
*/
|
||||
|
||||
bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const override;
|
||||
// return true if successful. could fail if more the 8 commands are waiting
|
||||
|
||||
bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const override;
|
||||
|
||||
bool sys_runCompleteTest(void) const override;
|
||||
// warning: lasts 20s in one pace
|
||||
|
||||
bool sys_ready4sending(void) const override;
|
||||
// return true if a Json-file can be sent
|
||||
|
||||
bool sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8_t *content ) const override;
|
||||
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
|
||||
// nrOfTemplate=1...32 if kindOfFile==6
|
||||
// content = content of the Json file, max 800byte ascii signs
|
||||
// file is 0-terminated!
|
||||
// return false if sending is not possible, wait a second
|
||||
|
||||
bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const override;
|
||||
// dynPrnVal = array of 8 Variables with 8 byte each, come as ascii string
|
||||
// like: char prn_dynPrnVal[8][8];
|
||||
// return true if sending, false if cmd-stack is full
|
||||
|
||||
bool prn_printTemplate(uint8_t nrOftemplate) const override;
|
||||
// print one of the templates loaded by Json prior
|
||||
// nr = 1..32
|
||||
// return true if sending, false if cmd-stack is full
|
||||
|
||||
void log_getHoldAccountNumbers(uint32_t *accNr ) const override;
|
||||
// returns all acc nrs of the backuped vault records
|
||||
// use: uint32_t backupedAccNumbers[8]
|
||||
|
||||
bool log_selectVaultRecord(uint16_t accountNr ) const override;
|
||||
// return true if sending, false if cmd-stack is full
|
||||
|
||||
//request, isAvailable
|
||||
void log_getVaultRecord(struct T_vaultRecord *retVR) const override;
|
||||
// which was selected by: log_selectVaultRecord()
|
||||
// to be forwarded to Ismas
|
||||
|
||||
bool prn_printAccountReceipt(void) const override;
|
||||
// return true if sending to DC OK, false if cmd-stack is full
|
||||
|
||||
bool prn_printTestTicket(void) const override;
|
||||
// return true if sending to DC OK, false if cmd-stack is full
|
||||
|
||||
bool cash_startPayment(uint16_t amount) const override;
|
||||
|
||||
bool cash_cancelPayment(void) const override;
|
||||
// and return coins
|
||||
|
||||
bool cash_stopPayment(void) const override;
|
||||
// and keep coins in escrow
|
||||
|
||||
uint32_t getInsertedAmount(void) const override;
|
||||
|
||||
uint16_t getLastInsertedCoin(void) const override;
|
||||
|
||||
bool getAllInsertedCoins(uint16_t *types, uint16_t *values) const override;
|
||||
// alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert, max 64
|
||||
|
||||
|
||||
// after ticket/goods issue:
|
||||
bool vend_success(void) const override;
|
||||
// conclude payment process, encash all inserted coins to vault. Printing was successful
|
||||
// if possible return change
|
||||
|
||||
bool vend_failed(void) const override;
|
||||
// conclude payment process and return all inserted coins
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t mif_getCardType(QString cardholder) const override;
|
||||
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
||||
// cardholder: 7byte Name-String
|
||||
|
||||
uint64_t sys_getWakeSource(void) const override;
|
||||
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
||||
|
||||
//void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override;
|
||||
void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const override;
|
||||
|
||||
//void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
|
||||
void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void sub_storeSendingText(QByteArray *buf) const;
|
||||
@@ -1081,27 +1092,6 @@ private:
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// Modem:
|
||||
|
||||
uint8_t mod_power(bool on) const override;
|
||||
uint8_t mod_getHwState(struct Tmod_hw_state *mod_hw_state) const override;
|
||||
uint8_t mod_setCondition(uint16_t chgCmd) const override; // e.g. change to state registered, sleep, open, off....
|
||||
uint16_t mod_getCondition(void) const override; // e.g. now socket open
|
||||
bool mod_sendBufferFree(void) const override; // sending allowed (before writing) and sending finished (after writing)
|
||||
uint8_t mod_sendDataBlk(uint16_t len, uint8_t *buf) const override;
|
||||
void mod_wantReadData(uint16_t nrOfData) const override; // start reading
|
||||
uint16_t mod_gotData(void) const override; // return nr of received bytes
|
||||
uint8_t mod_loadDataBlk(uint16_t len, uint8_t *buf) const override;
|
||||
uint8_t mod_setupSerial(struct TserialParams serialParameter) const override;
|
||||
uint8_t mod_getCurrentSerialSettings(struct TserialParams *serialParameter) const override;
|
||||
|
||||
// Credit Card Terminal:
|
||||
|
||||
uint8_t cc_power(bool on) const override;
|
||||
uint8_t cc_getHwState(struct Tcc_hw_state *cc_hw_state) const override;
|
||||
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
@@ -1110,8 +1100,6 @@ private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// Coin checker and changer mdb4.2 / section 5
|
||||
// Level 2 Commands (predefined device msg acc. mdb manual and auto-poll)
|
||||
@@ -1229,3 +1217,23 @@ struct Tcc_hw_state
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// not yet implemented
|
||||
uint8_t mod_power(bool on) const override;
|
||||
uint8_t mod_getHwState(struct Tmod_hw_state *mod_hw_state) const override;
|
||||
uint8_t mod_setCondition(uint16_t chgCmd) const override; // e.g. change to state registered, sleep, open, off....
|
||||
uint16_t mod_getCondition(void) const override; // e.g. now socket open
|
||||
bool mod_sendBufferFree(void) const override; // sending allowed (before writing) and sending finished (after writing)
|
||||
uint8_t mod_sendDataBlk(uint16_t len, uint8_t *buf) const override;
|
||||
void mod_wantReadData(uint16_t nrOfData) const override; // start reading
|
||||
uint16_t mod_gotData(void) const override; // return nr of received bytes
|
||||
uint8_t mod_loadDataBlk(uint16_t len, uint8_t *buf) const override;
|
||||
uint8_t mod_setupSerial(struct TserialParams serialParameter) const override;
|
||||
uint8_t mod_getCurrentSerialSettings(struct TserialParams *serialParameter) const override;
|
||||
|
||||
// Credit Card Terminal:
|
||||
uint8_t cc_power(bool on) const override;
|
||||
uint8_t cc_getHwState(struct Tcc_hw_state *cc_hw_state) const override;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user