Compare commits
36 Commits
37f0012ce9
...
changes-fo
Author | SHA1 | Date | |
---|---|---|---|
fb75074955 | |||
d992ee3fad | |||
b7d8fabfd0 | |||
7129805f4e | |||
01140c523b | |||
c99d0730ce | |||
81c610c48b | |||
6ae7c06d42 | |||
1eb2ac3a1d | |||
f3adba2f0f | |||
652ad9b43d | |||
c85b090306 | |||
87a6ed0795 | |||
99c88c7825 | |||
712ea0fc6e | |||
86311de486 | |||
cb4412779f | |||
a95e174356 | |||
c724b5b9fb | |||
ef7932102f | |||
a7aa75ae5f | |||
dc00c69b82 | |||
eeb35190e1 | |||
30338e24cc | |||
58fdea45f0 | |||
df760f1a52 | |||
3e3e1efe7d | |||
e5a8cfd1cd | |||
5e6e6017b3 | |||
f3d9c690b7 | |||
3f10469b8f | |||
d92bdbfb3e | |||
60c48588b0 | |||
ef48301dad | |||
5f7d34ef12 | |||
863e4b23a9 |
10
DCPlugin.pri
10
DCPlugin.pri
@@ -10,7 +10,10 @@ HEADERS += $${PWD}/include/com.h \
|
||||
$${PWD}/include/prot.h \
|
||||
$${PWD}/include/sendWRcmd.h \
|
||||
$${PWD}/include/storeINdata.h \
|
||||
$${PWD}/include/tslib.h
|
||||
$${PWD}/include/tslib.h \
|
||||
$${PWD}/include/shared_mem_buffer.h \
|
||||
$${PWD}/include/serial_port_thread.h \
|
||||
$${PWD}/include/serial_port_worker.h
|
||||
|
||||
SOURCES += $${PWD}/src/com.cpp \
|
||||
$${PWD}/src/controlBus.cpp \
|
||||
@@ -20,4 +23,7 @@ SOURCES += $${PWD}/src/com.cpp \
|
||||
$${PWD}/src/prot.cpp \
|
||||
$${PWD}/src/sendWRcmd.cpp \
|
||||
$${PWD}/src/storeINdata.cpp \
|
||||
$${PWD}/src/tslib.cpp
|
||||
$${PWD}/src/tslib.cpp \
|
||||
$${PWD}/src/shared_mem_buffer.cpp \
|
||||
$${PWD}/src/serial_port_thread.cpp \
|
||||
$${PWD}/src/serial_port_worker.cpp
|
||||
|
@@ -170,7 +170,7 @@ uint8_t epi_getResultOfLastRequest();
|
||||
// retval: 0: in progress 1: OK 2: error
|
||||
|
||||
|
||||
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t *receivedData);
|
||||
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData);
|
||||
// stored by Datif
|
||||
|
||||
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad);
|
||||
|
@@ -330,6 +330,11 @@ signals:
|
||||
//the requested data are stored in peripheral image
|
||||
// can be loaded with epi
|
||||
|
||||
void datif_templatePrintFinished_OK();
|
||||
void datif_templatePrintFinished_Err();
|
||||
|
||||
void datif_gotNewCoin();
|
||||
|
||||
};
|
||||
|
||||
#endif // CI_H
|
||||
|
@@ -78,7 +78,7 @@ uint8_t dcBL_getResult(void);
|
||||
|
||||
|
||||
#define RAW_BL_DATALEN 150
|
||||
void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData);
|
||||
void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t const *receivedData);
|
||||
|
||||
uint8_t epi_getRawReceivedData(uint8_t *receivedData);
|
||||
// retval=length, will be zeroed after first reading
|
||||
|
@@ -93,14 +93,15 @@ Level 3): send command: "start payment process"
|
||||
#include "interfaces.h"
|
||||
#include "datIf.h"
|
||||
|
||||
|
||||
|
||||
class QSharedMemory;
|
||||
class hwapi : public QObject,
|
||||
public hwinf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" ) //FILE "HWapi.json")
|
||||
Q_INTERFACES(hwinf)
|
||||
private:
|
||||
void sub_storeSendingText(QByteArray *buf) const;
|
||||
|
||||
DownloadResult sendNextAddress(int bNum) const;
|
||||
DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const;
|
||||
@@ -114,12 +115,17 @@ class hwapi : public QObject,
|
||||
bool resetDeviceController() const;
|
||||
QByteArray loadBinaryDCFile(QString filename) const;
|
||||
bool downloadBinaryToDC(QString const &bFile) const;
|
||||
|
||||
QSharedMemory *m_sharedMem;
|
||||
public:
|
||||
explicit hwapi(QWidget *parent = nullptr);
|
||||
virtual ~hwapi();
|
||||
|
||||
T_datif *myDatif;
|
||||
|
||||
|
||||
virtual QStringList dc_getStatus() const;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 0 commands, interface
|
||||
// open, close, change serial interface
|
||||
@@ -144,6 +150,16 @@ public:
|
||||
bool dc_updateDC(QString binFileName, QString baudrate,
|
||||
QString comPort) const override;
|
||||
|
||||
bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||
QVector<int> templateIdx,
|
||||
QVector<QString> fnames,
|
||||
QString br,
|
||||
QString serial = QString()) const override;
|
||||
|
||||
bool dc_printTemplate(enum FileTypeJson type,
|
||||
QVector<int> templateIdx,
|
||||
QString br,
|
||||
QString serial = QString()) const override;
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 1, control device-controller (functions of µC)
|
||||
// check serial connection to deviceController
|
||||
@@ -980,24 +996,12 @@ public:
|
||||
// uint16_t borough, uint16_t zone,
|
||||
// uint16_t alias, char *location) const override;
|
||||
|
||||
/*
|
||||
uint8_t emp_getInsertedCoinSignal(void) const override;
|
||||
// can be called one time after each coin
|
||||
// emp_chkIfCoinInserted() must be called before!
|
||||
|
||||
uint16_t emp_getInsertedCoinValue(void) const override;
|
||||
// can be called one time after each coin
|
||||
// emp_chkIfCoinInserted() must be called before!
|
||||
|
||||
uint8_t emp_getCoinError(void) const override;
|
||||
// can be called one time after each coin
|
||||
// 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 rtc_getExtendedTime(struct T_extTime *exTime) const override;
|
||||
|
||||
bool sys_runCompleteTest(void) const override;
|
||||
// warning: lasts 20s in one pace
|
||||
@@ -1022,15 +1026,18 @@ public:
|
||||
// nr = 1..32
|
||||
// return true if sending, false if cmd-stack is full
|
||||
|
||||
void log_getHoldAccountNumbers(uint32_t *accNr ) const override;
|
||||
void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const override;
|
||||
// returns all acc nrs of the backuped vault records
|
||||
// use: uint32_t backupedAccNumbers[8]
|
||||
// use: uint16_t backupedAccNumbers[8]
|
||||
|
||||
bool log_selectVaultRecord(uint16_t accountNr ) const override;
|
||||
// return true if sending, false if cmd-stack is full
|
||||
// and trigger transfer
|
||||
|
||||
//request, isAvailable
|
||||
void log_getVaultRecord(struct T_vaultRecord *retVR) const override;
|
||||
bool log_chkIfVaultRecordAvailable(void) const override;
|
||||
// return true if completly received
|
||||
|
||||
bool log_getVaultRecord(struct T_vaultRecord *retVR) const override;
|
||||
// which was selected by: log_selectVaultRecord()
|
||||
// to be forwarded to Ismas
|
||||
|
||||
@@ -1040,7 +1047,8 @@ public:
|
||||
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_startPayment(uint32_t amount) const override;
|
||||
// 17.4.23TS: extended to 32bit
|
||||
|
||||
bool cash_cancelPayment(void) const override;
|
||||
// and return coins
|
||||
@@ -1068,30 +1076,47 @@ public:
|
||||
|
||||
|
||||
|
||||
uint8_t mif_getCardType(QString cardholder) const override;
|
||||
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_getDeviceConditions(struct T_moduleCondition *devCond) const override;
|
||||
|
||||
void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override;
|
||||
void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
|
||||
|
||||
|
||||
uint32_t cash_getAmountInVault(void) const override;
|
||||
|
||||
uint16_t cash_getNrCoinsInVault(void) const override;
|
||||
|
||||
uint8_t prn_getPrintResult() const override;
|
||||
|
||||
uint8_t prn_getCurrentPrinterState() const override;
|
||||
// 0: printer OK
|
||||
// bit0: near paper end bit1: no paper
|
||||
// bit2: temperature error bit3: error head open
|
||||
// bit4: paper jam in cutter
|
||||
// bit6: no response bit7: serial rec. error
|
||||
// bit5: printer not ready
|
||||
|
||||
|
||||
signals:
|
||||
void hwapi_templatePrintFinished_OK(void) const override;
|
||||
void hwapi_templatePrintFinished_Err(void) const override;
|
||||
void hwapi_gotNewCoin(void) const override;
|
||||
void hwapi_vendStopByMax(void) const override;
|
||||
void hwapi_vendStopByPushbutton(void) const override;
|
||||
|
||||
private:
|
||||
void sub_storeSendingText(QByteArray *buf) const;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void hwapi_slotPrintFinished_OK(void);
|
||||
void hwapi_slotPrintFinished_Err(void);
|
||||
void hwapi_slotGotCoin(void);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -2,12 +2,9 @@
|
||||
#define INTERFACE_H
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
|
||||
struct T_emp
|
||||
{
|
||||
|
||||
struct T_emp {
|
||||
// Fixdata from EMP:
|
||||
uint8_t shaft; // = changer level
|
||||
uint16_t countryCode;
|
||||
@@ -34,11 +31,9 @@ struct T_emp
|
||||
|
||||
uint8_t pollingRunning;
|
||||
uint8_t paymentRunning;
|
||||
|
||||
};
|
||||
|
||||
struct Trtc_DateTime
|
||||
{
|
||||
struct Trtc_DateTime {
|
||||
uint8_t rtc_hour;
|
||||
uint8_t rtc_min;
|
||||
uint8_t rtc_sec;
|
||||
@@ -48,8 +43,7 @@ struct Trtc_DateTime
|
||||
uint8_t rtc_dayOfWeek;
|
||||
};
|
||||
|
||||
struct Tprn_hw_state
|
||||
{
|
||||
struct Tprn_hw_state {
|
||||
// hardware (IO's)
|
||||
bool powerRdBk; // prn pwr is on
|
||||
bool rsSwOk; // serial switch (printer or modem) is set to printer
|
||||
@@ -66,8 +60,7 @@ struct Tprn_hw_state
|
||||
bool badResponse;
|
||||
};
|
||||
|
||||
struct Tprn_currentSettings
|
||||
{
|
||||
struct Tprn_currentSettings {
|
||||
uint8_t currFont;
|
||||
uint8_t currSize;
|
||||
uint8_t currHeigth;
|
||||
@@ -80,8 +73,7 @@ struct Tprn_hw_state
|
||||
bool nowAligned;
|
||||
};
|
||||
|
||||
struct T_dynDat
|
||||
{
|
||||
struct T_dynDat {
|
||||
uint8_t licensePlate[8];
|
||||
uint8_t vendingPrice[8];
|
||||
uint8_t parkingEnd[8];
|
||||
@@ -92,10 +84,7 @@ struct Tprn_hw_state
|
||||
uint8_t dynDat7[8];
|
||||
};
|
||||
|
||||
|
||||
struct T_vaultRecord
|
||||
{
|
||||
|
||||
struct T_vaultRecord {
|
||||
// Kassenbeleg (Abrechnungsdatensatz = Kassenwechsel-Datensatz)
|
||||
char startbuffer[4]; // Psa> // never move or change this 1st entry
|
||||
uint16_t AccountingNumber;
|
||||
@@ -126,7 +115,6 @@ struct T_vaultRecord
|
||||
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||
//88
|
||||
|
||||
// Service, Tür offen:
|
||||
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||
@@ -136,12 +124,10 @@ struct T_vaultRecord
|
||||
uint16_t resint5;
|
||||
uint16_t resint6;
|
||||
// 56
|
||||
|
||||
char label4buffer[4]; // box>
|
||||
uint16_t coinsInVault[16];
|
||||
uint16_t billsInStacker[8];
|
||||
// 48
|
||||
|
||||
char label5buffer[4]; // val>
|
||||
// actually constant unless exchange rate is changed
|
||||
uint16_t coinDenomination[16]; // 5..50000 (z.B. 2? sind in Ungarn 760Ft)
|
||||
@@ -149,17 +135,12 @@ struct T_vaultRecord
|
||||
uint16_t tubeDenom[6];
|
||||
uint16_t exchangeRate;
|
||||
uint16_t resint9;
|
||||
|
||||
// 64
|
||||
|
||||
char endofblock[4]; // end>
|
||||
|
||||
// 316 byte Block im Speicher
|
||||
|
||||
};
|
||||
|
||||
struct T_moduleCondition
|
||||
{
|
||||
struct T_moduleCondition {
|
||||
// store conditon of all system components, hold in RAM
|
||||
// 0 means unknown, not yet tested/used
|
||||
// 1 means OK
|
||||
@@ -167,30 +148,29 @@ struct T_moduleCondition
|
||||
// 100..150 = WARNING
|
||||
// 200..250 = ERROR
|
||||
|
||||
uint8_t structStart; // always first!!!
|
||||
uint8_t ram; // v
|
||||
uint8_t intEe; // v
|
||||
uint8_t extEe; // v
|
||||
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; // v
|
||||
uint8_t printer; // v
|
||||
uint8_t modem; // v
|
||||
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;
|
||||
uint8_t coinChecker; // EMP, OMP or mei-cashflow
|
||||
|
||||
uint8_t coinEscrow; // v
|
||||
uint8_t mifareReader; // v
|
||||
uint8_t creditTerm; // not available
|
||||
uint8_t coinReject; // v
|
||||
uint8_t coinEscrow;
|
||||
uint8_t mifareReader;
|
||||
uint8_t creditTerm;
|
||||
uint8_t coinReject;
|
||||
|
||||
uint8_t coinSafe; // v
|
||||
uint8_t billSafe; // v
|
||||
uint8_t voltage; // v // 1:11..14V
|
||||
uint8_t temper; // v
|
||||
uint8_t coinSafe;
|
||||
uint8_t billSafe;
|
||||
uint8_t voltage; // 1:11..14V
|
||||
uint8_t temper;
|
||||
|
||||
uint8_t poweronTest;
|
||||
uint8_t doorState; // 1: alles zu 200: t?r offen + bit1(S) +bit2(CB) + bit3(CB)
|
||||
@@ -206,70 +186,91 @@ struct T_moduleCondition
|
||||
uint8_t res11;
|
||||
uint8_t res12;
|
||||
uint8_t res13;
|
||||
|
||||
};
|
||||
|
||||
struct T_dynamicCondition
|
||||
{
|
||||
// dynamic conditions, change rapidly and frequently
|
||||
// these are values for the Heartbeat
|
||||
|
||||
// T?rschalter entprellt:
|
||||
struct T_dynamicCondition {
|
||||
char allDoorsDebounced;
|
||||
char openedAuthorized;
|
||||
uint8_t CBinDebounced;
|
||||
char upperDoor; // 0:fehlt 1:drin
|
||||
char middleDoor;
|
||||
char lowerDoor;
|
||||
char coinBox;
|
||||
|
||||
char billBox;
|
||||
char modeAbrech;
|
||||
char onAlarm;
|
||||
char nowCardTest;
|
||||
|
||||
char nowPayment;
|
||||
char lastMifCardType;
|
||||
char openedAuthorized;
|
||||
char allDoorsDebounced;
|
||||
|
||||
uint8_t lastSDoorState;
|
||||
uint8_t lastVDoorState;
|
||||
uint8_t CBinDebounced;
|
||||
uint8_t lastCBstate;
|
||||
|
||||
char paymentInProgress;
|
||||
char res1;
|
||||
char res2;
|
||||
char res3;
|
||||
|
||||
uint16_t U_Batt;
|
||||
uint16_t Temperatur;
|
||||
|
||||
uint16_t cash_storedaccNumbers[8]; // List all stored accounting numbers in ext. eeprom
|
||||
|
||||
uint16_t nrCoinsInBox;
|
||||
uint16_t resui1;
|
||||
|
||||
uint32_t amountInBox;
|
||||
uint32_t amountJustPaid;
|
||||
|
||||
uint16_t lastInsCoinType; // wahrscheinlich uchar
|
||||
uint16_t resui2;
|
||||
|
||||
uint32_t totalTransVolume;
|
||||
uint32_t totalNrOfVends;
|
||||
|
||||
char jsonValid_config;
|
||||
char jsonValid_device;
|
||||
char jsonValid_cash;
|
||||
char jsonValid_print;
|
||||
char jsonValid_serial;
|
||||
char jsonValid_time;
|
||||
char lastFileType;
|
||||
// 44
|
||||
uint8_t MifCardHolder[8];
|
||||
uint8_t resultOfLastTemplPrint;
|
||||
// 0: unknown or printing in progress
|
||||
// 1: OK, doc was printed 2: error, doc was not printed
|
||||
uint8_t lastPrinterStatus;
|
||||
// 0: printer OK
|
||||
// bit0: near paper end bit1: no paper
|
||||
// bit2: temperature error bit3: error head open
|
||||
// bit4: paper jam in cutter
|
||||
// bit6: no response bit7: serial rec. error
|
||||
// bit5: printer not ready
|
||||
//54
|
||||
};
|
||||
|
||||
struct T_extTime {
|
||||
uint8_t Hours;
|
||||
uint8_t Min;
|
||||
uint8_t Sec;
|
||||
uint8_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t Day;
|
||||
uint8_t DOW;
|
||||
uint8_t res1;
|
||||
uint16_t MinOfDay;
|
||||
uint16_t res2;
|
||||
uint32_t SecOfDay;
|
||||
uint8_t isLeapYear;
|
||||
uint8_t nxtLeapYear;
|
||||
uint8_t lastLeapYear;
|
||||
uint8_t hoursOfThisWeek;
|
||||
uint16_t minutesOfThisWeek;
|
||||
uint16_t hoursOfThisMonth;
|
||||
uint16_t daysOfThisYear;
|
||||
uint16_t GetHoursOfYear;
|
||||
uint16_t res3;
|
||||
uint32_t GetMinutesOfYear;
|
||||
uint8_t getWakeIntvSec;
|
||||
uint8_t res4;
|
||||
uint16_t res5;
|
||||
uint32_t MinutesOfMillenium;
|
||||
};
|
||||
|
||||
class hwinf
|
||||
{
|
||||
|
||||
class hwinf {
|
||||
public:
|
||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||
enum class FileTypeJson {CONFIG=1, DEVICE, CASH, SERIAL, TIME, PRINTER};
|
||||
|
||||
virtual ~hwinf() {}
|
||||
|
||||
|
||||
virtual QStringList dc_getStatus() const = 0;
|
||||
|
||||
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||
// Use serial interface and protocol stack in Cashagent-Library
|
||||
@@ -306,6 +307,17 @@ public:
|
||||
QString comPort) const = 0;
|
||||
// download binary file down into device controller
|
||||
|
||||
virtual bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||
QVector<int> templateIdx,
|
||||
QVector<QString> fnames,
|
||||
QString br,
|
||||
QString serial = QString()) const = 0;
|
||||
|
||||
virtual bool dc_printTemplate(enum FileTypeJson type,
|
||||
QVector<int> templateIdx,
|
||||
QString br,
|
||||
QString serial = QString()) const = 0;
|
||||
|
||||
virtual void dc_autoRequest(bool on) const =0;
|
||||
// on = true: select that all READ-Requests are sent automatically
|
||||
// on = false: select that all READ-Requests are sent manually one by one
|
||||
@@ -1360,6 +1372,8 @@ public:
|
||||
|
||||
*/
|
||||
|
||||
virtual bool rtc_getExtendedTime(struct T_extTime *exTime) const=0;
|
||||
|
||||
virtual bool sys_runCompleteTest(void) const=0;
|
||||
// warning: lasts 20s in one pace
|
||||
// return true if sending, false if cmd-stack is full
|
||||
@@ -1384,15 +1398,18 @@ public:
|
||||
// nr = 1..32
|
||||
// return true if sending, false if cmd-stack is full
|
||||
|
||||
virtual void log_getHoldAccountNumbers(uint32_t *accNr ) const=0;
|
||||
virtual void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const=0;
|
||||
// returns all acc nrs of the backuped vault records
|
||||
// use: uint32_t backupedAccNumbers[8]
|
||||
// use: uint16_t backupedAccNumbers[8]
|
||||
|
||||
virtual bool log_selectVaultRecord(uint16_t accountNr ) const=0;
|
||||
// return true if sending, false if cmd-stack is full
|
||||
// and trigger transfer
|
||||
|
||||
//request, isAvailable
|
||||
virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||
virtual bool log_chkIfVaultRecordAvailable(void) const=0;
|
||||
// return true if completly received
|
||||
|
||||
virtual bool log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||
// which was selected by: log_selectVaultRecord()
|
||||
// to be forwarded to Ismas
|
||||
|
||||
@@ -1402,7 +1419,8 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||
virtual bool prn_printTestTicket(void) const=0;
|
||||
// return true if sending to DC OK, false if cmd-stack is full
|
||||
|
||||
virtual bool cash_startPayment(uint16_t amount) const=0;
|
||||
virtual bool cash_startPayment(uint32_t amount) const=0;
|
||||
// 17.4.23TS: extended to 32bit
|
||||
|
||||
virtual uint32_t getInsertedAmount(void) const=0;
|
||||
|
||||
@@ -1426,18 +1444,13 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||
// conclude payment process and return all inserted coins
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual uint8_t mif_getCardType(QString cardholder) const=0;
|
||||
virtual uint8_t mif_getCardType(QString *cardholder) const=0;
|
||||
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
||||
// cardholder: 7byte Name-String
|
||||
|
||||
virtual uint64_t sys_getWakeSource(void) const =0;
|
||||
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
||||
|
||||
//virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0;
|
||||
virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const=0;
|
||||
/*
|
||||
|
||||
@@ -1474,8 +1487,7 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0;
|
||||
virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0;
|
||||
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0;
|
||||
/*
|
||||
|
||||
@@ -1541,6 +1553,31 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||
|
||||
*/
|
||||
|
||||
virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0;
|
||||
|
||||
// content of Cashbox
|
||||
virtual uint32_t cash_getAmountInVault(void) const=0;
|
||||
|
||||
virtual uint16_t cash_getNrCoinsInVault(void) const=0;
|
||||
|
||||
|
||||
virtual uint8_t prn_getPrintResult() const=0;
|
||||
|
||||
// in case of print-error get detailed error:
|
||||
virtual uint8_t prn_getCurrentPrinterState() const=0;
|
||||
// 0: printer OK
|
||||
// bit0: near paper end bit1: no paper
|
||||
// bit2: temperature error bit3: error head open
|
||||
// bit4: paper jam in cutter
|
||||
// bit6: no response bit7: serial rec. error
|
||||
// bit5: printer not ready
|
||||
|
||||
signals:
|
||||
virtual void hwapi_templatePrintFinished_OK(void) const=0;
|
||||
virtual void hwapi_templatePrintFinished_Err(void) const=0;
|
||||
virtual void hwapi_gotNewCoin(void) const=0;
|
||||
virtual void hwapi_vendStopByMax(void) const=0;
|
||||
virtual void hwapi_vendStopByPushbutton(void) const=0;
|
||||
|
||||
};
|
||||
|
||||
@@ -1558,10 +1595,15 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||
// 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
|
||||
// 14.04.2023: V3.4 new features extended: sys_getDynMachineConditions, sys_getDeviceConditions and
|
||||
// rtc_getExtendedTime return struct in addition. New function to select and get VaultRecord
|
||||
//
|
||||
|
||||
//#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"
|
||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.4"
|
||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.5"
|
||||
|
||||
|
||||
|
||||
|
@@ -148,21 +148,23 @@
|
||||
|
||||
|
||||
// highest priority
|
||||
#define CMDSTACKDEPTH 16
|
||||
// #define CMDSTACKDEPTH 16
|
||||
// means: up to 16 cmd can be stored. They are issued one by one every 100ms
|
||||
void sendWRcmd_clrCmdStack(void);
|
||||
bool sendWRcmd_setSendCommand0(uint16_t nextCmd);
|
||||
bool sendWRcmd_setSendCommand0(uint16_t nextCmd, uint8_t dat1=0, uint8_t dat2=0,
|
||||
uint8_t dat3=0, uint8_t dat4=0);
|
||||
// GUI or app sends a command to DC transfered by serial
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand0(void);
|
||||
uint16_t sendWRcmd_getSendCommand0(uint8_t *dat1=0, uint8_t *dat2=0,
|
||||
uint8_t *dat3=0, uint8_t *dat4=0);
|
||||
|
||||
// lower priority
|
||||
#define CMD4STACKDEPTH 8
|
||||
// #define CMD4STACKDEPTH 8
|
||||
void sendWRcmd_clrCmd4Stack(void);
|
||||
bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
||||
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
||||
|
||||
#define CMD8STACKDEPTH 4
|
||||
// #define CMD8STACKDEPTH 4
|
||||
void sendWRcmd_clrCmd8Stack(void);
|
||||
bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint16_t dat3, uint32_t dat4);
|
||||
uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4);
|
||||
@@ -171,7 +173,7 @@ uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3,
|
||||
|
||||
// lowest priority
|
||||
// wait for resonse before send next!
|
||||
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf);
|
||||
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t const *buf);
|
||||
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf);
|
||||
// retval = *leng
|
||||
|
||||
@@ -179,7 +181,7 @@ void sendWRcmd_INI(void);
|
||||
|
||||
|
||||
|
||||
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf);
|
||||
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t const *buf);
|
||||
// HWapi writes data to be forwarded to DC and further to mdb-device
|
||||
// not batched! don't use twice within 100ms
|
||||
|
||||
@@ -211,18 +213,21 @@ uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *
|
||||
// user=1: Text-Print is using this buffer
|
||||
// 2: QR-code-Printer is using this buffer
|
||||
|
||||
#define FDCMD_STACKDEPTH 16
|
||||
//#define FDCMD_STACKDEPTH 16
|
||||
void sendFDcmd_clrStack(void);
|
||||
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
||||
// write Command to memory, wait for transport
|
||||
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
||||
|
||||
uint8_t check4FDshortCmd(void);
|
||||
// returns number of waiting command
|
||||
// returns number of waiting command, maxFDCMD_STACKDEPTH
|
||||
|
||||
#define FDLONG_STACKDEPTH 16
|
||||
uint8_t check4freeFDshortCmd(void);
|
||||
// returns number of free places in short-command stack
|
||||
|
||||
//#define FDLONG_STACKDEPTH 16
|
||||
void longFDcmd_clrStack(void);
|
||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data);
|
||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t const *data);
|
||||
// write Command to memory, wait for transport
|
||||
// data buffer size always 64! data[64], padded with 0
|
||||
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
||||
@@ -230,6 +235,9 @@ bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, ui
|
||||
uint8_t check4FDlongCmd(void);
|
||||
// returns number of waiting command
|
||||
|
||||
uint8_t check4freeFDlongCmd(void);
|
||||
// returns number of free places in long-command stack
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
22
include/serial_port_thread.h
Normal file
22
include/serial_port_thread.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef SERIAL_PORT_THREAD_H_INCLUDED
|
||||
#define SERIAL_PORT_THREAD_H_INCLUDED
|
||||
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
#include <QEventLoop>
|
||||
|
||||
class SerialPortThread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
QEventLoop m_loop;
|
||||
public:
|
||||
SerialPortThread(QObject *parent = nullptr);
|
||||
virtual ~SerialPortThread();
|
||||
|
||||
virtual void run() override;
|
||||
|
||||
QEventLoop &getEventLoop() { return m_loop; }
|
||||
};
|
||||
|
||||
|
||||
#endif // SERIAL_PORT_THREAD_H_INCLUDED
|
121
include/serial_port_worker.h
Normal file
121
include/serial_port_worker.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#ifndef SERIAL_PORT_WORKER_H_INCLUDED
|
||||
#define SERIAL_PORT_WORKER_H_INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <QSerialPort>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QThread>
|
||||
|
||||
#include <assert.h>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
|
||||
struct Command {
|
||||
enum : uint16_t {PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4, END_MARK};
|
||||
enum : uint16_t {QUIT_SENTINEL = 0x1000, SEND_BLOCK_SIZE = 160};
|
||||
uint32_t m_priority;
|
||||
uint16_t m_priorityClass;
|
||||
uint16_t m_cmdId;
|
||||
char *m_sendBuffer;
|
||||
char *m_recvBuffer;
|
||||
uint8_t m_sendBufferLength;
|
||||
uint8_t m_recvBufferLength; // expected result length
|
||||
|
||||
static std::atomic<uint8_t> m_nextSendBufferIndex;
|
||||
static std::atomic<uint8_t> m_nextRecvBufferIndex;
|
||||
static char m_sendBuffers[256][SEND_BLOCK_SIZE];
|
||||
static char m_recvBuffers[256][SEND_BLOCK_SIZE];
|
||||
|
||||
static uint32_t getNextCommandPriority(uint8_t cmdType);
|
||||
static char *getNextSendBuffer();
|
||||
static char *getNextRecvBuffer();
|
||||
|
||||
public:
|
||||
Command(uint16_t cmdId, uint8_t sendBufferLength, uint8_t recvBufferLength, uint8_t priorityClass);
|
||||
Command();
|
||||
|
||||
friend bool operator< (Command const& lhs, Command const& rhs) {
|
||||
return lhs.m_priority < rhs.m_priority;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& os, Command const& cmd) {
|
||||
return os << "{ " << cmd.m_priority << ", '" << cmd.m_priority << "' } ";
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief SerialPortWorker
|
||||
///
|
||||
/// SerialPortWorker sends and receives data from serial port
|
||||
///
|
||||
class SerialPortWorker : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
/// \brief Internal serial port.
|
||||
QSerialPort m_serialPort;
|
||||
|
||||
/// \brief Internal serial port info.
|
||||
QSerialPortInfo m_serialPortInfo;
|
||||
|
||||
/// \brief Flag indicating if serial port is opened.
|
||||
bool m_serialPortOpened;
|
||||
|
||||
/// \brief Port name of serial port.
|
||||
QString m_portName;
|
||||
|
||||
/// \brief Baudrate of internal serial port.
|
||||
enum QSerialPort::BaudRate m_baudRate;
|
||||
|
||||
std::priority_queue<Command, std::deque<Command>> m_sendQueue;
|
||||
std::deque<Command> m_recvQueue;
|
||||
std::mutex m_sendQueueMutex;
|
||||
std::mutex m_recvQueueMutex;
|
||||
std::condition_variable m_sendQueueCondVar;
|
||||
std::condition_variable m_recvQueueCondVar;
|
||||
|
||||
std::atomic<uint32_t> m_bytesWritten;
|
||||
std::atomic<uint32_t> m_bytesAvailable;
|
||||
|
||||
SerialPortWorker(QString portName, QSerialPort::BaudRate baudRate, QObject *parent = nullptr);
|
||||
|
||||
Command getNextCommand();
|
||||
void insertResult(Command const &result);
|
||||
|
||||
enum : uint16_t {TIMEOUT = 100, WAIT_TIME_MAX = 1000};
|
||||
|
||||
public:
|
||||
~SerialPortWorker();
|
||||
|
||||
SerialPortWorker(SerialPortWorker const &) = delete;
|
||||
void operator=(SerialPortWorker const &) = delete;
|
||||
|
||||
// serial port im plugin anlegen. erst dann kann getInstance() benutzt werden
|
||||
static SerialPortWorker &getInstance(QString portName, QSerialPort::BaudRate baudRate, QObject *parent = nullptr) {
|
||||
static SerialPortWorker serialPortWorker(portName, baudRate, parent);
|
||||
return serialPortWorker;
|
||||
}
|
||||
|
||||
bool openSerialPort();
|
||||
void closeSerialPort();
|
||||
|
||||
bool isPortOpen() const { return m_serialPortOpened; }
|
||||
|
||||
void insertCommand(Command const &cmd);
|
||||
bool getNextResult(Command &result, int timeout = 1000);
|
||||
|
||||
virtual void run() override;
|
||||
|
||||
void quit();
|
||||
|
||||
private slots:
|
||||
void getBytesAvailable();
|
||||
bool getNumberOfBytesWritten(qint64);
|
||||
};
|
||||
|
||||
#endif // SERIAL_PORT_WORKER_H_INCLUDED
|
347
include/shared_mem_buffer.h
Normal file
347
include/shared_mem_buffer.h
Normal file
@@ -0,0 +1,347 @@
|
||||
#ifndef SHARED_MEM_BUFFER_INCLUDED_H
|
||||
#define SHARED_MEM_BUFFER_INCLUDED_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <atomic>
|
||||
|
||||
#include <QSharedMemory>
|
||||
|
||||
// TODO: pid eintragen und convars/mutexe eintragen
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
// PTHREAD_PROCESS_SHARED
|
||||
|
||||
#else
|
||||
// WIN32
|
||||
#endif
|
||||
|
||||
struct SharedMemBuffer {
|
||||
int init;
|
||||
char appName[32];
|
||||
pid_t pid;
|
||||
pthread_condattr_t sndCndA;
|
||||
pthread_cond_t sndCndV;
|
||||
pthread_mutexattr_t sndMtxA;
|
||||
pthread_mutex_t sndMtx;
|
||||
|
||||
pthread_condattr_t rcvCndA;
|
||||
pthread_cond_t rcvCndV;
|
||||
pthread_mutexattr_t rcvMtxA;
|
||||
pthread_mutex_t rcvMtx;
|
||||
|
||||
struct rs {
|
||||
char comportName[16]; // z.B. "COM48"
|
||||
char baudStr[16]; // z.B. "19200"
|
||||
int baudNr; // 0...5 oder -1
|
||||
uint8_t connect; // 0,1
|
||||
bool portIsOpen;
|
||||
} rs;
|
||||
|
||||
char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
||||
|
||||
struct datif {
|
||||
#define DATIF_MAXCMDS 16
|
||||
uint16_t sendingPeriod;
|
||||
bool sendingPer_changed;
|
||||
uint8_t OutCmdpara1;
|
||||
uint8_t OutCmdpara2;
|
||||
uint8_t OutCmdpara3;
|
||||
uint8_t OutCmdpara4;
|
||||
uint16_t OutCmdpara5;
|
||||
uint32_t OutCmdpara6;
|
||||
uint8_t dataStep;
|
||||
uint8_t scanStep;
|
||||
uint8_t RDBLKNR;
|
||||
uint8_t cycl_running;
|
||||
} datif;
|
||||
|
||||
struct txt4 {
|
||||
char comStateLine[32];
|
||||
char HsStateLine[32];
|
||||
char masterStateLine[32];
|
||||
char resultStateLine[32];
|
||||
char dataLine[32];
|
||||
char datifReceive[32];
|
||||
char diagWindow[32];
|
||||
char sndDiagWindow[32];
|
||||
} txt4;
|
||||
|
||||
struct dcBL {
|
||||
#define SIZEBLRESP 50
|
||||
#define RAW_BL_DATALEN 150
|
||||
uint8_t LastBLcmd; // stored the last sent cmd in order to analys response
|
||||
uint8_t AtbBinFile[300000];
|
||||
uint32_t fileSize;
|
||||
uint16_t nrOfBlocks;
|
||||
uint16_t fileCrc;
|
||||
uint8_t myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise
|
||||
char Resp[SIZEBLRESP][32];
|
||||
int pResp;
|
||||
uint8_t step;
|
||||
uint8_t state;
|
||||
uint16_t BlkCtr;
|
||||
uint16_t cyclCtr;
|
||||
uint16_t repeatCtr;
|
||||
} dcBL;
|
||||
|
||||
struct {
|
||||
uint16_t shutterTime;
|
||||
char ticketTemplate[1024];
|
||||
} hwapi;
|
||||
|
||||
struct {
|
||||
uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer
|
||||
uint8_t sendAsyDatLen;
|
||||
} next;
|
||||
|
||||
struct { // highest priority
|
||||
#define CMDSTACKDEPTH 16
|
||||
// up to 16 cmd can be stored. They are issued one by one every 100ms
|
||||
uint16_t AsynchSend[CMDSTACKDEPTH];
|
||||
uint8_t para1[CMDSTACKDEPTH]; /* used to streamline source */
|
||||
uint8_t para2[CMDSTACKDEPTH]; /* used to streamline source */
|
||||
uint8_t para3[CMDSTACKDEPTH]; /* used to streamline source */
|
||||
uint8_t para4[CMDSTACKDEPTH]; /* used to streamline source */
|
||||
uint8_t nrOfCmdsInQueue;
|
||||
} Cmd0;
|
||||
|
||||
struct { // lower priority
|
||||
// Command Stack for commands with 4 parameters
|
||||
#define CMD4STACKDEPTH 8
|
||||
uint16_t AsynchSend[CMD4STACKDEPTH];
|
||||
uint8_t para1[CMD4STACKDEPTH];
|
||||
uint8_t para2[CMD4STACKDEPTH];
|
||||
uint8_t para3[CMD4STACKDEPTH];
|
||||
uint8_t para4[CMD4STACKDEPTH];
|
||||
uint8_t nrOfCmdsInQueue;
|
||||
} Cmd4;
|
||||
|
||||
struct {
|
||||
#define CMD8STACKDEPTH 4
|
||||
uint16_t AsynchSend[CMD8STACKDEPTH];
|
||||
uint8_t para1[CMD8STACKDEPTH];
|
||||
uint8_t para2[CMD8STACKDEPTH];
|
||||
uint16_t para3[CMD8STACKDEPTH];
|
||||
uint32_t para4[CMD8STACKDEPTH];
|
||||
uint8_t nrOfCmdsInQueue;
|
||||
} Cmd8;
|
||||
|
||||
struct { // short command, 4 data bytes
|
||||
#define FDCMD_STACKDEPTH 16
|
||||
uint8_t wrCmd[FDCMD_STACKDEPTH];
|
||||
uint8_t rdCmd[FDCMD_STACKDEPTH];
|
||||
uint8_t blkNr[FDCMD_STACKDEPTH];
|
||||
uint8_t para1[FDCMD_STACKDEPTH];
|
||||
uint8_t para2[FDCMD_STACKDEPTH];
|
||||
uint8_t para3[FDCMD_STACKDEPTH];
|
||||
uint8_t para4[FDCMD_STACKDEPTH];
|
||||
uint8_t cmdsInQueue;
|
||||
} FDShort;
|
||||
|
||||
struct { // long command, 64 data bytes
|
||||
#define FDLONG_STACKDEPTH 16
|
||||
uint8_t wrCmd[FDLONG_STACKDEPTH];
|
||||
uint8_t rdCmd[FDLONG_STACKDEPTH];
|
||||
uint8_t blkNr[FDLONG_STACKDEPTH];
|
||||
uint8_t length[FDLONG_STACKDEPTH];
|
||||
uint8_t para[FDLONG_STACKDEPTH][64];
|
||||
uint8_t cmdsInQueue;
|
||||
} FDLong;
|
||||
|
||||
struct {
|
||||
uint8_t DataParameters[4];
|
||||
uint8_t DataBufferUser;
|
||||
uint8_t pDataBuff; // points to next PRINTER_BLOCK
|
||||
} prn;
|
||||
|
||||
struct {
|
||||
bool savePrnPwr;
|
||||
bool saveMifPwr;
|
||||
bool MdbIsOn;
|
||||
} indat;
|
||||
|
||||
uint8_t ndbs;
|
||||
uint8_t pari;
|
||||
uint8_t nsb;
|
||||
uint8_t br;
|
||||
|
||||
#define MAXNROF_GENSTR 16
|
||||
char genStrings[MAXNROF_GENSTR][64];
|
||||
|
||||
#define MAXNROF_AI 4
|
||||
uint16_t AI_val[MAXNROF_AI];
|
||||
|
||||
struct DigitalInputs {
|
||||
uint8_t doorSwitch;
|
||||
uint8_t vaultSwitch;
|
||||
uint8_t lockSwitch;
|
||||
uint8_t opto;
|
||||
uint8_t aux;
|
||||
bool wakeFromPtu;
|
||||
bool wakeFromMdb;
|
||||
bool wakeFromModem;
|
||||
bool PrnReady;
|
||||
bool CoinAttach;
|
||||
bool CoinEscrowOpen;
|
||||
bool mifCardTap;
|
||||
bool contactPwrOn;
|
||||
bool mifarePwrOn;
|
||||
bool rdbk_mdbTxd;
|
||||
bool AuxPwrOn;
|
||||
bool gsmPwrOn;
|
||||
bool creditPwrOn;
|
||||
bool printerPwrOn;
|
||||
bool mdbPwrOn;
|
||||
bool rejMot_home;
|
||||
uint8_t npe_sensor;
|
||||
} din;
|
||||
|
||||
struct DigitalOutputs {
|
||||
uint8_t mbdRxTst;
|
||||
uint8_t motorBits;
|
||||
uint8_t serialSwitch; // serial drv on/off, Serial mux1, Serial mux2
|
||||
uint8_t ledsAndFan;
|
||||
uint8_t laermUndRelay;
|
||||
uint8_t ptuWake;
|
||||
uint8_t auxPower;
|
||||
uint8_t coinShutter;
|
||||
uint8_t coinEscrow;
|
||||
uint8_t printerPower;
|
||||
} dout;
|
||||
|
||||
struct Sdata {
|
||||
#define NROFMIFSTATEBYTES 40
|
||||
#define PRN_STATE_ARRAY_SIZE 20
|
||||
#define PRN_STATE_FONT_SIZE 20
|
||||
#define MAXNROF_PRNBYTES 64
|
||||
#define MAXNROF_PRNBLOCKS 20
|
||||
uint8_t MIF_STATE[NROFMIFSTATEBYTES];
|
||||
uint8_t MIF_DATA[12][64];
|
||||
uint8_t PRN_STATE[PRN_STATE_ARRAY_SIZE];
|
||||
uint8_t PRN_FONTS[PRN_STATE_FONT_SIZE];
|
||||
char PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
|
||||
bool mdb_busRdy;
|
||||
bool mdb_V12on;
|
||||
bool mdb_V5on;
|
||||
uint8_t mdbNrOfRecData;
|
||||
uint8_t RecBuff[40];
|
||||
uint8_t empNrOfsettings;
|
||||
uint8_t emp_settingsBuff[66];
|
||||
uint8_t NrOfDeviceSetting;
|
||||
uint8_t DeviceSettingBuff[66];
|
||||
uint8_t NrOfMachineIDSetting;
|
||||
uint8_t NrOfMachineIDBuff[66];
|
||||
uint64_t slaveUID;
|
||||
uint8_t UIDstr[8];
|
||||
#define MAXNROF_MEASURE 4
|
||||
uint32_t measurement[MAXNROF_MEASURE];
|
||||
bool serialTestResult;
|
||||
uint8_t pProtResultOk;
|
||||
uint16_t receivedDataLength;
|
||||
uint8_t receivedDataBlock[64];
|
||||
uint8_t rawData[150];
|
||||
uint8_t LengthRawData;
|
||||
uint8_t mdbSendBuffer[64];
|
||||
uint8_t mdbSendLen;
|
||||
} Sdata;
|
||||
|
||||
uint8_t mif_cardType;
|
||||
uint8_t mif_cardHolder[8];
|
||||
|
||||
#define MEMDEPTH_GOTCOINS (16)
|
||||
struct T_coin {
|
||||
uint8_t valid;
|
||||
uint8_t signal;
|
||||
uint8_t error;
|
||||
uint8_t pad;
|
||||
uint16_t value;
|
||||
} gotCoin[MEMDEPTH_GOTCOINS];
|
||||
uint8_t ctr_gotCoin;
|
||||
|
||||
struct store {
|
||||
uint32_t insertedAmount;
|
||||
uint16_t lastCoinType[64];
|
||||
uint16_t lastCoinValue[64];
|
||||
uint64_t wakeSrc;
|
||||
uint8_t rbDevParamLen;
|
||||
uint8_t rbDevParams[66];
|
||||
uint8_t deviceCondLen;
|
||||
uint8_t deviceCond[66];
|
||||
uint8_t machCondLen;
|
||||
uint8_t machCond[66];
|
||||
uint8_t DcBackupNrOfAccNr;
|
||||
uint16_t DcBackupAccNr[16]; // z.Z. nur 8
|
||||
uint8_t gotNrBlocksOfVaultRec;
|
||||
uint8_t vaultrecord[360];
|
||||
uint32_t amount;
|
||||
uint16_t nrOfCoins;
|
||||
} store;
|
||||
|
||||
struct T_globTime {
|
||||
// Reihenfolge nicht vertauschen!!!!!
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
uint8_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t DayOfMonth;
|
||||
uint8_t DayOfWeek; // 1=monday...7
|
||||
uint8_t reserve1;
|
||||
|
||||
uint16_t MinutesOfToday;
|
||||
uint16_t reserve2;
|
||||
|
||||
uint32_t SecondsOfToday;
|
||||
|
||||
uint8_t IsLeapyear;
|
||||
uint8_t nextLeap;
|
||||
uint8_t lastLeap;
|
||||
uint8_t hoursOfWeek;
|
||||
|
||||
uint16_t minOfWeek;
|
||||
uint16_t hoursOfMonth;
|
||||
uint16_t minOfMonth;
|
||||
uint16_t dayOfYear;
|
||||
uint16_t hoursOfYear;
|
||||
uint16_t reserve3;
|
||||
|
||||
uint32_t minOfYear;
|
||||
|
||||
uint8_t squareOutMode;
|
||||
uint8_t free1;
|
||||
uint16_t reserve4;
|
||||
uint32_t minOfMillenium;
|
||||
// bis hierher 44byts
|
||||
uint32_t free2;
|
||||
uint32_t free3;
|
||||
uint32_t free4;
|
||||
} getGlobalTime;
|
||||
|
||||
static QSharedMemory *getShm(std::size_t s = 0);
|
||||
static SharedMemBuffer *getData() {
|
||||
return (SharedMemBuffer *)getShm()->data();
|
||||
}
|
||||
static SharedMemBuffer const *getDataConst() {
|
||||
return (SharedMemBuffer const *)getShm()->data();
|
||||
}
|
||||
|
||||
#if 0
|
||||
static std::atomic<bool> __sharedMemLocked;
|
||||
|
||||
static bool sharedMemLocked() {
|
||||
return __sharedMemLocked;
|
||||
}
|
||||
static void setSharedMemLocked() {
|
||||
__sharedMemLocked = true;
|
||||
}
|
||||
static void setSharedMemUnlocked() {
|
||||
__sharedMemLocked = false;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // SHARED_MEM_BUFFER_INCLUDED_H
|
@@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
#define MAXNROF_AO 3
|
||||
#define MAXNROF_GENSTR 16
|
||||
//#define MAXNROF_GENSTR 16
|
||||
#define MAXNROF_CONTR_PORTS 11
|
||||
#define MAXNROF_DIports 2
|
||||
#define MAXNROF_DOports 2
|
||||
@@ -32,9 +32,6 @@ bool indat_isMifareOn();
|
||||
void indat_storeMDBisOn(bool isOn);
|
||||
bool indat_isMdbOn();
|
||||
|
||||
|
||||
|
||||
|
||||
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
||||
uint8_t parity, uint8_t NrStopBits);
|
||||
|
||||
@@ -43,23 +40,16 @@ void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
||||
|
||||
QString epi_getSlaveParamSTR();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void gpi_storeGenerals(uint8_t genNr, QString text);
|
||||
// 0=HW 1=SW 2=State
|
||||
|
||||
QString epi_loadGenerals(uint8_t genNr);
|
||||
// genNr=0=HW 1=SW 2=State
|
||||
|
||||
|
||||
void gpi_storeUID(uint8_t *buf8byteUid);
|
||||
void gpi_storeUID(uint8_t const *buf8byteUid);
|
||||
// buffer size: 8 byte
|
||||
|
||||
void epi_getUIDdec(uint8_t *buf8byteUid);
|
||||
// buffer size: 8 byte
|
||||
|
||||
QString epi_getUIDstr();
|
||||
|
||||
|
||||
@@ -89,7 +79,7 @@ void epi_getSpecialYearTimeDate(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define MAXNROF_AI 4
|
||||
// #define MAXNROF_AI 4
|
||||
|
||||
void gpi_storeAIs(uint8_t aiNr, uint16_t val); // rs -> Sdata
|
||||
|
||||
@@ -138,185 +128,119 @@ void gpi_storeDI_optos(uint8_t indatOpto);
|
||||
uint8_t epi_getDI_optos(void);
|
||||
// bit0: opto in 1 1: opto in 2
|
||||
|
||||
void gpi_storeDI_auxIn(uint8_t indatAuxIn);
|
||||
// Aux0...5
|
||||
|
||||
uint8_t epi_getDI_auxIn(void);
|
||||
// bit0: auxin 1 ... 5: auxin 6
|
||||
|
||||
void gpi_storeDI_ptuWake(uint8_t indat);
|
||||
uint8_t gpi_storeDI_auxIn(uint8_t indatAuxIn); // Aux0...5
|
||||
uint8_t epi_getDI_auxIn(void); // bit0: auxin 1 ... 5: auxin 6
|
||||
|
||||
bool gpi_storeDI_ptuWake(bool w);
|
||||
bool epi_getDI_ptuWake(void);
|
||||
|
||||
void gpi_storeDI_mbdWake(uint8_t indat);
|
||||
|
||||
bool gpi_storeDI_mbdWake(bool w);
|
||||
bool epi_getDI_mdbWake(void);
|
||||
|
||||
void gpi_storeDI_prnReady(uint8_t indat);
|
||||
|
||||
bool gpi_storeDI_prnReady(bool ready);
|
||||
bool epi_getDI_prnReady(void);
|
||||
|
||||
void gpi_storeDI_CoinAttach(uint8_t indat);
|
||||
|
||||
bool gpi_storeDI_CoinAttach(bool attach);
|
||||
bool epi_getDI_CoinAttach(void);
|
||||
|
||||
void gpi_storeDI_CoinEscrow(uint8_t indat);
|
||||
|
||||
bool gpi_storeDI_CoinEscrow(bool ce);
|
||||
bool epi_getDI_CoinEscrow(void);
|
||||
|
||||
void gpi_storeDI_mifareCardTapped(uint8_t indat);
|
||||
|
||||
bool gpi_storeDI_mifareCardTapped(bool tapped);
|
||||
bool epi_getDI_mifareCardTapped(void);
|
||||
|
||||
void gpi_storeDI_modemWake(uint8_t indat);
|
||||
|
||||
bool gpi_storeDI_modemWake(bool w);
|
||||
bool epi_getDI_modemWake(void);
|
||||
|
||||
|
||||
void gpi_storeDI_contactPowerIsOn(bool di_contact_PwrOn);
|
||||
|
||||
bool gpi_storeDI_contactPowerIsOn(bool on);
|
||||
bool epi_getDI_contactPwr(void);
|
||||
|
||||
void gpi_storeDI_MifarePowerIsOn(bool di_mifare_PwrOn);
|
||||
|
||||
bool gpi_storeDI_MifarePowerIsOn(bool on);
|
||||
bool epi_getDI_mifarePwr(void);
|
||||
|
||||
void gpi_storeDI_readbackMdbTxD(bool di_rdbkMdbTxd);
|
||||
|
||||
bool gpi_storeDI_readbackMdbTxD(bool rdbkMdbTxd);
|
||||
bool epi_getDI_mdbTxd(void);
|
||||
|
||||
void gpi_storeDI_AuxPowerIsOn(bool di_Aux_PwrOn);
|
||||
|
||||
bool gpi_storeDI_AuxPowerIsOn(bool on);
|
||||
bool epi_getDI_auxPwr(void);
|
||||
|
||||
void gpi_storeDI_GsmPowerIsOn(bool di_gsm_PwrOn);
|
||||
|
||||
bool gpi_storeDI_GsmPowerIsOn(bool on);
|
||||
bool epi_getDI_gsmPwr(void);
|
||||
|
||||
void gpi_storeDI_CreditPowerIsOn(bool di_credit_PwrOn);
|
||||
|
||||
bool gpi_storeDI_CreditPowerIsOn(bool on);
|
||||
bool epi_getDI_creditPwr(void);
|
||||
|
||||
void gpi_storeDI_PrinterPowerIsOn(bool di_printer_PwrOn);
|
||||
|
||||
bool gpi_storeDI_PrinterPowerIsOn(bool on);
|
||||
bool epi_getDI_printerPwr(void);
|
||||
|
||||
void gpi_storeDI_MdbPowerIsOn(bool di_mdb_PwrOn);
|
||||
|
||||
bool gpi_storeDI_MdbPowerIsOn(bool on);
|
||||
bool epi_getDI_mdbPwr(void);
|
||||
|
||||
|
||||
void gpi_storeDI_rejMot_home(bool di);
|
||||
|
||||
bool gpi_storeDI_rejMot_home(bool reject);
|
||||
bool epi_getDI_rejectMotor_homepos(void);
|
||||
|
||||
void gpi_storeDI_paperLow(uint8_t di);
|
||||
|
||||
uint8_t gpi_storeDI_paperLow(uint8_t di);
|
||||
uint8_t epi_getDI_npe_sensor(void);
|
||||
// 0: Sensor sees paper 1: no paper 99: off
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// readback digital outputs
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void gpi_storeDO_mdbRxTst(uint8_t do_mbdRxTst);
|
||||
|
||||
uint8_t gpi_storeDO_mdbRxTst(uint8_t do_mbdRxTst);
|
||||
bool epi_getDO_mdbRxTestOut(void);
|
||||
|
||||
|
||||
void gpi_storeDO_motorOutputs(uint8_t Pwr);
|
||||
|
||||
uint8_t gpi_storeDO_motorOutputs(uint8_t Pwr);
|
||||
uint8_t epi_getDO_motorOuts(void);
|
||||
// bit0: upper lock forward bit 1 backward
|
||||
// bit2: lower lock forward bit 3 backward
|
||||
|
||||
|
||||
void gpi_storeDO_serialSwitch(uint8_t state);
|
||||
uint8_t gpi_storeDO_serialSwitch(uint8_t state);
|
||||
// serial drv on/off, Serial mux1, Serial mux2
|
||||
|
||||
uint8_t epi_getDO_serialSwitch(void);
|
||||
// serial drv on/off, Serial mux1, Serial mux2
|
||||
|
||||
bool epi_getDO_serialDriverIsOn(void);
|
||||
|
||||
bool epi_getDO_serialMux1isSetToPrinter(void);
|
||||
// mux1 off: serial is switched to printer
|
||||
|
||||
bool epi_getDO_serialMux1isSetToModem(void);
|
||||
// mux1 on: serial is switched to modem
|
||||
|
||||
bool epi_getDO_serialMux2isSetToCredit(void);
|
||||
// mux2 off: serial is switched to credit card terminal
|
||||
|
||||
bool epi_getDO_serialMux2isSetToMifare(void);
|
||||
// mux2 on: serial is switched to mifare reader
|
||||
|
||||
|
||||
void gpi_storeDO_ledsAndFan(uint8_t ledState);
|
||||
|
||||
uint8_t gpi_storeDO_ledsAndFan(uint8_t ledState);
|
||||
bool epi_getDO_led_coin(void);
|
||||
|
||||
bool epi_getDO_led_front(void);
|
||||
|
||||
bool epi_getDO_led_ticket(void);
|
||||
|
||||
bool epi_getDO_led_pin(void);
|
||||
|
||||
bool epi_getDO_led_start(void);
|
||||
|
||||
bool epi_getDO_led_inside(void);
|
||||
|
||||
bool epi_getDO_fan(void);
|
||||
|
||||
void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay);
|
||||
|
||||
uint8_t gpi_storeDO_sirenAndRelay(uint8_t sirenRelay);
|
||||
bool epi_getDO_sirene(void);
|
||||
|
||||
bool epi_getDO_relay(void);
|
||||
|
||||
void gpi_storeDO_ptuWake(uint8_t state);
|
||||
|
||||
uint8_t gpi_storeDO_ptuWake(uint8_t state);
|
||||
bool epi_getDO_ptuWake(void);
|
||||
|
||||
void gpi_storeDO_auxPower(uint8_t pwr);
|
||||
|
||||
uint8_t gpi_storeDO_auxPower(uint8_t pwr);
|
||||
bool epi_getDO_auxPower(void);
|
||||
|
||||
|
||||
void gpi_storeDO_coinShutter(uint8_t state);
|
||||
|
||||
uint8_t gpi_storeDO_coinShutter(uint8_t state);
|
||||
bool epi_getDO_coinShutterOpen(void);
|
||||
|
||||
bool epi_getDO_coinShutterTest(void);
|
||||
|
||||
|
||||
void gpi_storeDO_coinEscrow(uint8_t state);
|
||||
|
||||
uint8_t gpi_storeDO_coinEscrow(uint8_t state);
|
||||
uint8_t epi_getDO_coinEscrow(void);
|
||||
// retval: 1:return flap is open 2:take flap is open 0:closed
|
||||
|
||||
|
||||
void gpi_storeDO_printerPwrOn(uint8_t state);
|
||||
|
||||
uint8_t gpi_storeDO_printerPwrOn(uint8_t state);
|
||||
uint8_t epi_getDO_printerPwr(void);
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// counterchecks, make sure that DC-outputs are correct
|
||||
|
||||
@@ -363,21 +287,14 @@ bool epi_cntchk_Mot2Fon(void);
|
||||
|
||||
uint8_t gpi_storeMdbRecData(uint8_t length, uint8_t *buf);
|
||||
// datif store received mdb data
|
||||
|
||||
uint8_t epi_getMdbResponse(void);
|
||||
// 0=no response 1=ACK 2=NAK 3=ACK with data
|
||||
|
||||
uint8_t epi_getMdbRecLength(void);
|
||||
// 0...31
|
||||
|
||||
uint8_t epi_restoreMdbRecData(uint8_t *buf);
|
||||
// hwapi reads received mdb data from PI
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t gpi_storeMifReaderStateAndCardType(uint8_t *buf);
|
||||
uint8_t gpi_storeMifReaderStateAndCardType(uint8_t const *buf);
|
||||
|
||||
/* data description:
|
||||
byte 0: current read state: 0=power off 1=reader-fault 2=ready
|
||||
@@ -401,41 +318,24 @@ byte 32: result, always 0
|
||||
|
||||
uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize);
|
||||
// retval 0=OK 1=error host buffer too small
|
||||
|
||||
void gpi_storeMifCardData(uint8_t blkNr, uint8_t *receivedData);
|
||||
bool gpi_storeMifCardData(uint8_t blkNr, uint8_t const *receivedData);
|
||||
// blkNr=0...11 receivedData[64]
|
||||
|
||||
uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize);
|
||||
// blkNr=0...11 return buf[64]
|
||||
// retval: 1=error 0=OK
|
||||
|
||||
|
||||
|
||||
#define pi_prnStateArraySize 20
|
||||
#define pi_prnFontArraySize 20
|
||||
|
||||
void epi_restorePrinterState(uint8_t *buf);
|
||||
|
||||
void gpi_storePrinterState(uint8_t *buf);
|
||||
void gpi_storePrinterState(uint8_t const *buf);
|
||||
|
||||
void epi_restorePrinterFonts(uint8_t *buf);
|
||||
void gpi_storePrinterFonts(uint8_t const *buf);
|
||||
|
||||
void gpi_storePrinterFonts(uint8_t *buf);
|
||||
|
||||
|
||||
|
||||
|
||||
void gpi_storeMdbState(uint8_t busReady, uint8_t V12on, uint8_t V5on );
|
||||
|
||||
bool gpi_storeMdbState(bool busReady, bool V12on, bool V5on);
|
||||
bool epi_restoreMdbBusReady(void);
|
||||
|
||||
bool epi_restoreMdbV12Ready(void);
|
||||
|
||||
bool epi_restoreMdbV5Ready(void);
|
||||
|
||||
|
||||
void gpi_storeMdbResponse(uint8_t leng, uint8_t *data);
|
||||
|
||||
void gpi_storeMdbResponse(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data);
|
||||
// last received mdb answer (from mdb device)
|
||||
// only needed if a special command was sent directly
|
||||
@@ -444,12 +344,9 @@ void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data);
|
||||
// DB2: nr of received (payload) data bytes (apart from ACK, can be 0....34)
|
||||
// DB3...DB38: rec.data (payload)
|
||||
|
||||
|
||||
void gpi_storeEmpSettings(uint8_t leng, uint8_t *data);
|
||||
|
||||
void gpi_storeEmpSettings(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data);
|
||||
|
||||
|
||||
/*
|
||||
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data);
|
||||
|
||||
@@ -463,67 +360,60 @@ void epi_restoreEmpCoinSignal(uint8_t *leng, uint8_t *data);
|
||||
void epi_clearEmpCoinSignal();
|
||||
*/
|
||||
|
||||
#define MEMDEPTH_GOTCOINS 16
|
||||
|
||||
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data);
|
||||
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t const *data);
|
||||
|
||||
uint8_t epi_isNewCoinLeft(void);
|
||||
// retval: 0...16 coins left in FIFO
|
||||
|
||||
void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value);
|
||||
|
||||
|
||||
|
||||
void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t *data);
|
||||
|
||||
void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data);
|
||||
|
||||
|
||||
void gpi_storeMachineIDsettings(uint8_t leng, uint8_t *data);
|
||||
|
||||
void gpi_storeMachineIDsettings(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data);
|
||||
|
||||
|
||||
|
||||
|
||||
void epi_clearCurrentPayment(void);
|
||||
|
||||
void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue);
|
||||
|
||||
uint32_t epi_CurrentPaymentGetAmount(void);
|
||||
|
||||
uint16_t epi_CurrentPaymentGetLastCoin(void);
|
||||
|
||||
bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values);
|
||||
// alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht
|
||||
|
||||
|
||||
void gpi_storeWakeSources(uint8_t *receivedData);
|
||||
|
||||
void gpi_storeWakeSources(uint8_t const *receivedData);
|
||||
uint64_t epi_getWakeSources(void);
|
||||
|
||||
|
||||
|
||||
void gpi_storeExtendedTime(uint8_t leng, uint8_t *data);
|
||||
|
||||
void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data);
|
||||
|
||||
|
||||
|
||||
void gpi_storeDeviceConditions(uint8_t leng, uint8_t *data);
|
||||
|
||||
void gpi_storeDeviceConditions(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data);
|
||||
|
||||
|
||||
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data);
|
||||
|
||||
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
|
||||
|
||||
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t const *data);
|
||||
void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs);
|
||||
// return accNrs[0..7]
|
||||
|
||||
void epi_iniVRstorage(void);
|
||||
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t const *data);
|
||||
bool epi_checkIfVaultRecordAvailable(void);
|
||||
bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf);
|
||||
// true if completly received
|
||||
|
||||
void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins);
|
||||
|
||||
uint32_t epi_getCashBoxContent(void);
|
||||
uint16_t epi_getNrOfCoinsInCashBox(void);
|
||||
|
||||
void gpi_storeNewMifareCard(uint8_t typ, uint8_t const *holder);
|
||||
|
||||
uint8_t epi_mifGetCardType(uint8_t const *holder);
|
||||
//holder[8] = name of card holder
|
||||
// retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -13,6 +13,9 @@ uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t L
|
||||
|
||||
uint8_t uint2uchar(uint16_t uival, bool getHighB);
|
||||
|
||||
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr);
|
||||
// getBytNr: 0=LSB 3=MSB
|
||||
|
||||
|
||||
void delay(uint16_t MilliSec);
|
||||
|
||||
|
@@ -122,17 +122,17 @@ struct T_vaultRecord
|
||||
//16
|
||||
char label3buffer[4]; // mw >
|
||||
|
||||
// Verkauf, T<EFBFBD>r zu:
|
||||
uint32_t VKcoinsInserted[16]; // nur f<EFBFBD>r Wechsler, soviel wurde eingeworfen
|
||||
uint32_t VKcoinsReturned[6]; // nur f<EFBFBD>r Wechsler, Anzahl M<EFBFBD>nzen pro Typ, soviel wurde zur<EFBFBD>ckgegeben
|
||||
// Verkauf, Tür zu:
|
||||
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||
//88
|
||||
|
||||
// Service, T<EFBFBD>r offen:
|
||||
uint16_t ServCoinsInserted[16]; // nur f<EFBFBD>r Wechsler, soviel wurde eingeworfen
|
||||
uint16_t ServCoinsReturned[6]; // nur f<EFBFBD>r Wechsler, Anzahl M<EFBFBD>nzen pro Typ, soviel wurde zur<EFBFBD>ckgegeben
|
||||
// Service, Tür offen:
|
||||
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||
uint16_t resint3;
|
||||
uint16_t resint4;
|
||||
uint16_t currentTubeContent[6]; // nur f<EFBFBD>r Wechsler, aktueller F<EFBFBD>llstand
|
||||
uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand
|
||||
uint16_t resint5;
|
||||
uint16_t resint6;
|
||||
// 56
|
||||
@@ -265,6 +265,7 @@ class hwinf
|
||||
|
||||
public:
|
||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||
enum class FileTypeJson {CONFIG=1, DEVICE, CASH, SERIAL, TIME, PRINTER};
|
||||
|
||||
virtual ~hwinf() {}
|
||||
|
||||
@@ -305,6 +306,17 @@ public:
|
||||
QString comPort) const = 0;
|
||||
// download binary file down into device controller
|
||||
|
||||
virtual bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||
QVector<int> templateIdx,
|
||||
QVector<QString> fnames,
|
||||
QString br,
|
||||
QString serial) const = 0;
|
||||
|
||||
virtual bool dc_printTemplate(enum FileTypeJson type,
|
||||
QVector<int> templateIdx,
|
||||
QString br,
|
||||
QString serial) const = 0;
|
||||
|
||||
virtual void dc_autoRequest(bool on) const =0;
|
||||
// on = true: select that all READ-Requests are sent automatically
|
||||
// on = false: select that all READ-Requests are sent manually one by one
|
||||
@@ -320,7 +332,7 @@ public:
|
||||
// get data back in "payLoad", max 64 byte, can be used for diagnosis
|
||||
// retval = nr of bytes received. If host buffer too small then
|
||||
// only plBufSiz bytes are copied to "payLoad"
|
||||
// plBufSiz<EFBFBD>z=size of host buffer
|
||||
// plBufSizz=size of host buffer
|
||||
|
||||
virtual void dc_requTestResponse() const =0;
|
||||
// tell DC2 to send a test-string, useful to see if cable and baudrate is OK
|
||||
@@ -441,10 +453,10 @@ public:
|
||||
|
||||
// Analog values:
|
||||
virtual uint32_t dc_getTemperature(void) const =0;
|
||||
// in Sax-Format 0...400 (0=-50,0<EFBFBD>C 100=0,0<EFBFBD>C 141=20,5<EFBFBD>C 400=150,0<EFBFBD>C)
|
||||
// in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
|
||||
|
||||
virtual QString dc_getTemperaturStr(void) const =0;
|
||||
// as string like "-12,5<EFBFBD>C"
|
||||
// as string like "-12,5°C"
|
||||
|
||||
virtual uint32_t dc_getVoltage(void) const =0;
|
||||
// as value in mV, 0...65,535V
|
||||
@@ -599,7 +611,7 @@ public:
|
||||
uint8_t kindOfModem, uint8_t kindOfCredit ) const =0;
|
||||
// enable hardware in device controller:
|
||||
// kindOfPrinter: 0:off 1: GPT4672 (only this one implemented)
|
||||
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C<EFBFBD>_changer
|
||||
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer
|
||||
// kindOfMifareReader: 0:off 1: SL025 (only this one implemented)
|
||||
// suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason
|
||||
// kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented)
|
||||
@@ -705,7 +717,7 @@ public:
|
||||
// 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!)
|
||||
// byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!)
|
||||
// not batched! don't use twice within 100ms
|
||||
|
||||
virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0;
|
||||
@@ -1273,7 +1285,7 @@ public:
|
||||
|
||||
|
||||
// Komplett-schreib Funktion, noch nicht getestet
|
||||
// Nachteil: keine R<EFBFBD>ckmeldung wie lang's noch dauert
|
||||
// Nachteil: keine Rückmeldung wie lang's noch dauert
|
||||
//virtual void bl_startSending(void) const=0;
|
||||
// call once after BL is working and file is loaded
|
||||
//virtual void bl_sendFile(void) const=0;
|
||||
@@ -1299,7 +1311,7 @@ public:
|
||||
buf[4]=GlobTime.Month;
|
||||
buf[5]=GlobTime.Day;
|
||||
buf[6]=GlobTime.DOW;
|
||||
buf[7]=' '; // immer auf 32bit auff<EFBFBD>llen sonst Speicherproblem beim Master!
|
||||
buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master!
|
||||
uitmp=GlobTime.MinOfDay;
|
||||
buf[8]=swl_getOneByteFromUint(uitmp, 0);
|
||||
buf[9]=swl_getOneByteFromUint(uitmp, 1);
|
||||
|
@@ -1,422 +1,310 @@
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include "tslib.h"
|
||||
//#include "controlBus.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// control serial interface gui <--> serial
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
void epi_setSerial(int BaudNr,
|
||||
QString BaudStr,
|
||||
QString ComName,
|
||||
uint8_t connect) {
|
||||
memset(&SharedMemBuffer::getData()->rs.comportName[0], 0x00,
|
||||
sizeof(SharedMemBuffer::getData()->rs.comportName));
|
||||
strncpy(SharedMemBuffer::getData()->rs.comportName,
|
||||
ComName.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->rs.comportName)-1);
|
||||
|
||||
static QString rs_comportName; // z.B. "COM48"
|
||||
static QString rs_baudStr; // z.B. "19200"
|
||||
static int rs_baudNr; //0...5 oder -1
|
||||
static uint8_t rs_connect; // 0,1
|
||||
memset(&SharedMemBuffer::getData()->rs.baudStr[0], 0x00,
|
||||
sizeof(SharedMemBuffer::getData()->rs.baudStr));
|
||||
strncpy(SharedMemBuffer::getData()->rs.baudStr,
|
||||
BaudStr.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->rs.baudStr)-1);
|
||||
|
||||
void epi_setSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
|
||||
{
|
||||
// qDebug() << "ENTER" << BaudNr << BaudStr << ComName << connect;
|
||||
|
||||
rs_comportName = ComName;
|
||||
rs_baudStr = BaudStr;
|
||||
rs_baudNr = BaudNr; // 0=1200 1=9600 2=19200 3=38400 4=57600 5=115200 oder -1
|
||||
rs_connect = connect; // 0/1
|
||||
|
||||
// qDebug() << "LEAVE" << rs_baudNr << rs_baudStr << rs_comportName << rs_connect;
|
||||
SharedMemBuffer::getData()->rs.baudNr = BaudNr;
|
||||
SharedMemBuffer::getData()->rs.connect = connect;
|
||||
}
|
||||
|
||||
void epi_closeSerial(void)
|
||||
{
|
||||
rs_connect=0;
|
||||
// qDebug() << "ENTER/LEAVE rc_connect=0";
|
||||
void epi_closeSerial(void) {
|
||||
SharedMemBuffer::getData()->rs.connect = 0;
|
||||
}
|
||||
|
||||
|
||||
void gpi_serialChanged(void)
|
||||
{
|
||||
void gpi_serialChanged(void) {
|
||||
// serial confirms that port was closed or opened
|
||||
rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
||||
//qDebug() << "ENTER/LEAVE rc_connect=2";
|
||||
// rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
||||
SharedMemBuffer::getData()->rs.connect = 2;
|
||||
}
|
||||
|
||||
uint8_t gpi_getSerialConn(void)
|
||||
{
|
||||
return rs_connect;
|
||||
uint8_t gpi_getSerialConn(void) {
|
||||
return SharedMemBuffer::getDataConst()->rs.connect;
|
||||
}
|
||||
|
||||
|
||||
int gpi_getBaudNr(void)
|
||||
{
|
||||
return rs_baudNr;
|
||||
int gpi_getBaudNr(void) {
|
||||
return SharedMemBuffer::getDataConst()->rs.baudNr;
|
||||
}
|
||||
|
||||
QString gpi_getComPortName(void)
|
||||
{
|
||||
return rs_comportName;
|
||||
QString gpi_getComPortName(void) {
|
||||
return SharedMemBuffer::getDataConst()->rs.comportName;
|
||||
}
|
||||
|
||||
static bool rs_portIsOpen;
|
||||
|
||||
void gpi_serialIsOpen(bool offen)
|
||||
{
|
||||
//qDebug() << "ENTER/LEAVE offen=" << offen;
|
||||
rs_portIsOpen=offen;
|
||||
void gpi_serialIsOpen(bool offen) {
|
||||
SharedMemBuffer::getData()->rs.portIsOpen = offen;
|
||||
}
|
||||
|
||||
bool epi_isSerialPortOpen()
|
||||
{
|
||||
bool epi_isSerialPortOpen() {
|
||||
// true: port is open false: port is closed
|
||||
//qDebug() << "ENTER/LEAVE offen=" << rs_portIsOpen;
|
||||
return rs_portIsOpen;
|
||||
return SharedMemBuffer::getDataConst()->rs.portIsOpen;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// Control transfer gui <--> serial
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
||||
|
||||
void epi_startEmmision(char start)
|
||||
{
|
||||
AutoEmissionOn=start;
|
||||
void epi_startEmmision(char start) {
|
||||
SharedMemBuffer::getData()->AutoEmissionOn = start;
|
||||
}
|
||||
|
||||
bool gpi_isEmmisionOn(void)
|
||||
{
|
||||
return AutoEmissionOn;
|
||||
bool gpi_isEmmisionOn(void) {
|
||||
return SharedMemBuffer::getDataConst()->AutoEmissionOn;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
static uint16_t datif_sendingPeriod;
|
||||
static bool datif_sendingPer_changed;
|
||||
|
||||
uint16_t gpi_getPeriodicSendTimeVal()
|
||||
{
|
||||
datif_sendingPer_changed=0;
|
||||
if (datif_sendingPeriod<3 || datif_sendingPeriod>10000)
|
||||
uint16_t gpi_getPeriodicSendTimeVal() {
|
||||
SharedMemBuffer::getData()->datif.sendingPer_changed = 0;
|
||||
if ((SharedMemBuffer::getDataConst()->datif.sendingPeriod < 3) ||
|
||||
(SharedMemBuffer::getDataConst()->datif.sendingPeriod > 10000)) {
|
||||
return 130; // ms, default
|
||||
else
|
||||
return datif_sendingPeriod;
|
||||
}
|
||||
return SharedMemBuffer::getDataConst()->datif.sendingPeriod;
|
||||
}
|
||||
|
||||
void epi_setPeriodicSendTimeVal(uint16_t val)
|
||||
{
|
||||
if (val>=3 && val<10000)
|
||||
{
|
||||
datif_sendingPer_changed=1;
|
||||
datif_sendingPeriod=val;
|
||||
void epi_setPeriodicSendTimeVal(uint16_t val) {
|
||||
if (val>=3 && val<10000) {
|
||||
SharedMemBuffer::getData()->datif.sendingPer_changed = 1;
|
||||
SharedMemBuffer::getData()->datif.sendingPeriod = val;
|
||||
}
|
||||
}
|
||||
|
||||
bool gpi_PeriodicSendTimeHasChanged()
|
||||
{
|
||||
return datif_sendingPer_changed;
|
||||
bool gpi_PeriodicSendTimeHasChanged() {
|
||||
return SharedMemBuffer::getDataConst()->datif.sendingPer_changed;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// Status Display gui <--> serial
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// linke Spalte, über Connect Button
|
||||
static QString txt4comStateLine;
|
||||
|
||||
QString epi_getTxt4comStateLine(void)
|
||||
{
|
||||
QString epi_getTxt4comStateLine(void) {
|
||||
// GUI: get Text for serial Comport-State Line
|
||||
return txt4comStateLine;
|
||||
return SharedMemBuffer::getDataConst()->txt4.comStateLine;
|
||||
}
|
||||
|
||||
void gpi_setTxt4comStateLine(QString txtline) // gpi
|
||||
{
|
||||
void gpi_setTxt4comStateLine(QString txtline) {
|
||||
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
||||
txt4comStateLine.clear();
|
||||
if (txtline=="")
|
||||
txt4comStateLine.clear();
|
||||
else
|
||||
txt4comStateLine=txtline;
|
||||
memset(SharedMemBuffer::getData()->txt4.comStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.comStateLine));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.comStateLine,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.comStateLine)-1);
|
||||
}
|
||||
|
||||
void epi_clrTxt4comStateLine()
|
||||
{
|
||||
txt4comStateLine.clear();
|
||||
void epi_clrTxt4comStateLine() {
|
||||
memset(SharedMemBuffer::getData()->txt4.comStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.comStateLine));
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// rechte Spalte, oberste Statuszeile
|
||||
// I) "Handshakes" (serial Control) flow.cpp
|
||||
// geht überhaupt was raus? kommt überhaupt was zurück?
|
||||
static QString txt4HsStateLine;
|
||||
|
||||
QString epi_getTxt4HsStateLine(void)
|
||||
{
|
||||
return txt4HsStateLine;
|
||||
QString epi_getTxt4HsStateLine(void) {
|
||||
return SharedMemBuffer::getDataConst()->txt4.HsStateLine;
|
||||
}
|
||||
|
||||
void gpi_setTxt4HsStateLine(QString txtline)
|
||||
{
|
||||
txt4HsStateLine.clear();
|
||||
if (txtline=="")
|
||||
txt4HsStateLine.clear();
|
||||
else
|
||||
txt4HsStateLine=txtline;
|
||||
void gpi_setTxt4HsStateLine(QString txtline) {
|
||||
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
||||
memset(SharedMemBuffer::getData()->txt4.HsStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.HsStateLine));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.HsStateLine,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.HsStateLine)-1);
|
||||
}
|
||||
|
||||
void epi_clrTxt4HsStateLine()
|
||||
{
|
||||
txt4HsStateLine.clear();
|
||||
void epi_clrTxt4HsStateLine() {
|
||||
memset(SharedMemBuffer::getData()->txt4.HsStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.HsStateLine));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// II) Master receive state (empfangenes Telgramm OK? crc? length? )
|
||||
// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
|
||||
static QString txt4masterStateLine;
|
||||
|
||||
QString epi_getTxt4masterStateLine(void)
|
||||
{
|
||||
return txt4masterStateLine;
|
||||
QString epi_getTxt4masterStateLine(void) {
|
||||
return SharedMemBuffer::getDataConst()->txt4.masterStateLine;
|
||||
}
|
||||
|
||||
void gpi_setTxt4masterStateLine(QString txtline)
|
||||
{
|
||||
txt4masterStateLine.clear();
|
||||
if (txtline=="")
|
||||
txt4masterStateLine.clear();
|
||||
else
|
||||
txt4masterStateLine=txtline;
|
||||
void gpi_setTxt4masterStateLine(QString txtline) {
|
||||
memset(SharedMemBuffer::getData()->txt4.masterStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.masterStateLine));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.masterStateLine,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.masterStateLine)-1);
|
||||
}
|
||||
|
||||
void epi_clrTxt4masterStateLine()
|
||||
{
|
||||
txt4masterStateLine.clear();
|
||||
void epi_clrTxt4masterStateLine() {
|
||||
memset(SharedMemBuffer::getData()->txt4.masterStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.masterStateLine));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// III Slave receive (from Master) OK? if then show results, if not then show errors
|
||||
// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR
|
||||
// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch
|
||||
// nicht verwenden und nichts ausgeben oder einlesen
|
||||
|
||||
static QString txt4resultStateLine;
|
||||
|
||||
QString epi_getTxt4resultStateLine(void)
|
||||
{
|
||||
return txt4resultStateLine;
|
||||
QString epi_getTxt4resultStateLine(void) {
|
||||
return SharedMemBuffer::getDataConst()->txt4.resultStateLine;
|
||||
}
|
||||
|
||||
void gpi_setTxt4resultStateLine(QString txtline)
|
||||
{
|
||||
txt4resultStateLine.clear();
|
||||
if (txtline=="")
|
||||
txt4resultStateLine.clear();
|
||||
else
|
||||
txt4resultStateLine=txtline;
|
||||
void gpi_setTxt4resultStateLine(QString txtline) {
|
||||
memset(SharedMemBuffer::getData()->txt4.resultStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.resultStateLine));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.resultStateLine,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.resultStateLine)-1);
|
||||
}
|
||||
|
||||
void epi_clrTxt4resultStateLine()
|
||||
{
|
||||
txt4resultStateLine.clear();
|
||||
void epi_clrTxt4resultStateLine() {
|
||||
memset(SharedMemBuffer::getData()->txt4.resultStateLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.resultStateLine));
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// IV Statuszeile Empfangsdaten
|
||||
static QString txt4dataLine;
|
||||
|
||||
QString epi_getTxt4dataStateLine(void)
|
||||
{
|
||||
QString epi_getTxt4dataStateLine(void) {
|
||||
// GUI: get Text for serial Comport-State Line
|
||||
return txt4dataLine;
|
||||
|
||||
return SharedMemBuffer::getDataConst()->txt4.dataLine;
|
||||
}
|
||||
|
||||
void gpi_setTxt4dataStateLine(QString txtline)
|
||||
{
|
||||
void gpi_setTxt4dataStateLine(QString txtline) {
|
||||
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
||||
txt4dataLine.clear();
|
||||
if (txtline=="")
|
||||
txt4dataLine.clear();
|
||||
else
|
||||
txt4dataLine=txtline;
|
||||
memset(SharedMemBuffer::getData()->txt4.dataLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.dataLine));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.dataLine,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.dataLine)-1);
|
||||
}
|
||||
|
||||
void epi_clrTxt4dataStateLine()
|
||||
{
|
||||
txt4dataLine.clear();
|
||||
void epi_clrTxt4dataStateLine() {
|
||||
memset(SharedMemBuffer::getData()->txt4.dataLine,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.dataLine));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// 5. Zeile: Datif Ergebnis, Daten brauchbar?
|
||||
|
||||
static QString txt4datifReceive;
|
||||
|
||||
QString epi_getTxt4datifLine(void)
|
||||
{
|
||||
|
||||
return txt4datifReceive;
|
||||
|
||||
QString epi_getTxt4datifLine(void) {
|
||||
return SharedMemBuffer::getDataConst()->txt4.datifReceive;
|
||||
}
|
||||
|
||||
void gpi_setTxt4datifLine(QString txtline)
|
||||
{
|
||||
|
||||
txt4datifReceive.clear();
|
||||
if (txtline=="")
|
||||
txt4datifReceive.clear();
|
||||
else
|
||||
txt4datifReceive=txtline;
|
||||
void gpi_setTxt4datifLine(QString txtline) {
|
||||
memset(SharedMemBuffer::getData()->txt4.datifReceive,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.datifReceive));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.datifReceive,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.datifReceive)-1);
|
||||
}
|
||||
|
||||
void epi_clrTxt4datifLine()
|
||||
{
|
||||
txt4datifReceive.clear();
|
||||
void epi_clrTxt4datifLine() {
|
||||
memset(SharedMemBuffer::getData()->txt4.datifReceive,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.datifReceive));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
static QString txt4diagWindow;
|
||||
|
||||
QString epi_getTxt4RsDiagWin(void)
|
||||
{
|
||||
return txt4diagWindow;
|
||||
|
||||
QString epi_getTxt4RsDiagWin(void) {
|
||||
return SharedMemBuffer::getDataConst()->txt4.diagWindow;
|
||||
}
|
||||
|
||||
void gpi_setTxt4RsDiagWin(QString txtline)
|
||||
{
|
||||
txt4diagWindow.clear();
|
||||
if (txtline=="")
|
||||
txt4diagWindow.clear();
|
||||
else
|
||||
txt4diagWindow=txtline;
|
||||
void gpi_setTxt4RsDiagWin(QString txtline) {
|
||||
memset(SharedMemBuffer::getData()->txt4.diagWindow,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.diagWindow));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.diagWindow,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.diagWindow)-1);
|
||||
}
|
||||
|
||||
void epi_clrTxt4RsDiagWin()
|
||||
{
|
||||
txt4diagWindow.clear();
|
||||
void epi_clrTxt4RsDiagWin() {
|
||||
memset(SharedMemBuffer::getData()->txt4.diagWindow,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.diagWindow));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
static QString sndTxt4diagWindow;
|
||||
|
||||
QString epi_get2ndTxt4RsDiagWin(void)
|
||||
{
|
||||
return sndTxt4diagWindow;
|
||||
|
||||
QString epi_get2ndTxt4RsDiagWin(void) {
|
||||
return SharedMemBuffer::getDataConst()->txt4.sndDiagWindow;
|
||||
}
|
||||
|
||||
void gpi_set2ndTxt4RsDiagWin(QString txtline)
|
||||
{
|
||||
sndTxt4diagWindow.clear();
|
||||
if (txtline=="")
|
||||
sndTxt4diagWindow.clear();
|
||||
else
|
||||
sndTxt4diagWindow=txtline;
|
||||
void gpi_set2ndTxt4RsDiagWin(QString txtline) {
|
||||
memset(SharedMemBuffer::getData()->txt4.sndDiagWindow,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.sndDiagWindow));
|
||||
memcpy(SharedMemBuffer::getData()->txt4.sndDiagWindow,
|
||||
txtline.toStdString().c_str(),
|
||||
sizeof(SharedMemBuffer::getData()->txt4.sndDiagWindow)-1);
|
||||
}
|
||||
|
||||
void epi_clr2ndTxt4RsDiagWin()
|
||||
{
|
||||
sndTxt4diagWindow.clear();
|
||||
void epi_clr2ndTxt4RsDiagWin() {
|
||||
memset(SharedMemBuffer::getData()->txt4.sndDiagWindow,
|
||||
0x00, sizeof(SharedMemBuffer::getData()->txt4.sndDiagWindow));
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// Memory for Slave responses, common data
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static bool Sdata_serialTestResult;
|
||||
|
||||
void gpi_storeResult_serialTestOK(bool wasOk)
|
||||
{
|
||||
Sdata_serialTestResult=wasOk;
|
||||
void gpi_storeResult_serialTestOK(bool wasOk) {
|
||||
SharedMemBuffer::getData()->Sdata.serialTestResult = wasOk;
|
||||
}
|
||||
|
||||
bool epi_getResult_serialTestOK()
|
||||
{
|
||||
bool epi_getResult_serialTestOK() {
|
||||
// retval: true: test was successful, got right response
|
||||
return Sdata_serialTestResult;
|
||||
return SharedMemBuffer::getDataConst()->Sdata.serialTestResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// Store received data for hwapi
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
static uint8_t Sdata_pProtResultOk;
|
||||
|
||||
void gpi_startNewRequest()
|
||||
{
|
||||
Sdata_pProtResultOk=0;
|
||||
void gpi_startNewRequest() {
|
||||
SharedMemBuffer::getData()->Sdata.pProtResultOk = 0;
|
||||
}
|
||||
|
||||
void gpi_storeResultOfLastRequest(bool answisok)
|
||||
{
|
||||
if (answisok)
|
||||
Sdata_pProtResultOk=1;
|
||||
else
|
||||
Sdata_pProtResultOk=2;
|
||||
void gpi_storeResultOfLastRequest(bool answisok) {
|
||||
SharedMemBuffer::getData()->Sdata.pProtResultOk = answisok ? 1 : 2;
|
||||
}
|
||||
|
||||
uint8_t epi_getResultOfLastRequest()
|
||||
{
|
||||
uint8_t epi_getResultOfLastRequest() {
|
||||
// retval: 0: in progress 1: OK 2: error
|
||||
return Sdata_pProtResultOk;
|
||||
return SharedMemBuffer::getDataConst()->Sdata.pProtResultOk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static uint16_t Sdata_receivedDataLength;
|
||||
static uint8_t Sdata_receivedDataBlock[64];
|
||||
|
||||
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t *receivedData)
|
||||
{
|
||||
Sdata_receivedDataLength=uint16_t(RdDlen);
|
||||
if (Sdata_receivedDataLength>64)
|
||||
Sdata_receivedDataLength=64;
|
||||
tslib_strclr(Sdata_receivedDataBlock,0,64);
|
||||
tslib_strcpy(receivedData, Sdata_receivedDataBlock, Sdata_receivedDataLength);
|
||||
|
||||
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData) {
|
||||
SharedMemBuffer::getData()->Sdata.receivedDataLength
|
||||
= std::min(RdDlen, (uint8_t)(64));
|
||||
memset((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
|
||||
0x00, sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock));
|
||||
strncpy((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
|
||||
(char const *)receivedData,
|
||||
sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock)-1);
|
||||
}
|
||||
|
||||
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad)
|
||||
{
|
||||
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad) {
|
||||
// get data back in *pl, max 64 byte
|
||||
// retval = nr of bytes received. If host buffer too small then
|
||||
// only plBufSíz bytes are copied to pl
|
||||
// plBufSíz=size of host buffer
|
||||
|
||||
uint16_t ml=plBufSiz;
|
||||
if (ml>64) ml=64;
|
||||
if (Sdata_receivedDataLength<ml)
|
||||
ml=Sdata_receivedDataLength;
|
||||
tslib_strcpy(Sdata_receivedDataBlock, payLoad, ml);
|
||||
return Sdata_receivedDataLength;
|
||||
uint16_t ml = std::min(plBufSiz, (uint16_t)(64));
|
||||
if (SharedMemBuffer::getDataConst()->Sdata.receivedDataLength < ml) {
|
||||
ml = SharedMemBuffer::getDataConst()->Sdata.receivedDataLength;
|
||||
}
|
||||
strncpy((char *)payLoad,
|
||||
(char const *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
|
||||
ml);
|
||||
|
||||
return SharedMemBuffer::getDataConst()->Sdata.receivedDataLength;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
602
src/datIf.cpp
602
src/datIf.cpp
File diff suppressed because it is too large
Load Diff
746
src/dcBL.cpp
746
src/dcBL.cpp
File diff suppressed because it is too large
Load Diff
551
src/hwapi.cpp
551
src/hwapi.cpp
@@ -10,6 +10,9 @@
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <thread>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "tslib.h"
|
||||
#include "hwapi.h"
|
||||
@@ -18,29 +21,65 @@
|
||||
#include "controlBus.h"
|
||||
#include "storeINdata.h"
|
||||
#include "dcBL.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
#include <QDebug>
|
||||
#include <../plugins/interfaces.h>
|
||||
#include <QSharedMemory>
|
||||
|
||||
#include "interfaces.h"
|
||||
|
||||
static uint32_t hwapi_lastStartAmount;
|
||||
|
||||
static const QMap<QString, int> baudrateMap = {
|
||||
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
|
||||
{"57600" , 4}, {"115200" , 5}
|
||||
};
|
||||
|
||||
hwapi::hwapi(QWidget *parent) : QObject(parent)
|
||||
{
|
||||
// constructor
|
||||
//epi_resetAllDOs();
|
||||
//PI_INI();
|
||||
hwapi::hwapi(QWidget *parent) : QObject(parent) {
|
||||
// create or attach shared memory segment
|
||||
// !!! The compoment creating the shared memory MUST be ATBQT !!!
|
||||
m_sharedMem = SharedMemBuffer::getShm(sizeof(SharedMemBuffer));
|
||||
if (m_sharedMem) {
|
||||
if (m_sharedMem->isAttached()) {
|
||||
qInfo() << "Shared memory ("
|
||||
<< sizeof(SharedMemBuffer) << "bytes) created and attached";
|
||||
}
|
||||
} else {
|
||||
qCritical() << "Creating/attaching shared memory failed";
|
||||
}
|
||||
sendWRcmd_INI();
|
||||
|
||||
myDatif = new T_datif();
|
||||
|
||||
connect(myDatif, SIGNAL(datif_templatePrintFinished_OK()), this, SLOT(hwapi_slotPrintFinished_OK()));
|
||||
connect(myDatif, SIGNAL(datif_templatePrintFinished_Err()), this, SLOT(hwapi_slotPrintFinished_Err()));
|
||||
connect(myDatif, SIGNAL(datif_gotNewCoin()), this, SLOT(hwapi_slotGotCoin()));
|
||||
}
|
||||
|
||||
hwapi::~hwapi() {
|
||||
if (m_sharedMem && m_sharedMem->isAttached()) {
|
||||
m_sharedMem->detach();
|
||||
}
|
||||
}
|
||||
|
||||
void hwapi::hwapi_slotPrintFinished_OK(void) {
|
||||
emit hwapi_templatePrintFinished_OK();
|
||||
}
|
||||
|
||||
void hwapi::sub_storeSendingText(QByteArray *buf) const
|
||||
{
|
||||
void hwapi::hwapi_slotPrintFinished_Err(void) {
|
||||
emit hwapi_templatePrintFinished_Err();
|
||||
}
|
||||
|
||||
void hwapi::hwapi_slotGotCoin(void) {
|
||||
// new coin was inserted while transaction and new amount reported:
|
||||
emit hwapi_gotNewCoin();
|
||||
|
||||
uint32_t newSum=epi_CurrentPaymentGetAmount();
|
||||
|
||||
if (newSum>=hwapi_lastStartAmount)
|
||||
emit hwapi_vendStopByMax();
|
||||
|
||||
}
|
||||
|
||||
void hwapi::sub_storeSendingText(QByteArray *buf) const {
|
||||
|
||||
char local[70], copie[1350]; // 64byte more then max buffer size!
|
||||
int LL, nn, len, maxruns=20;
|
||||
@@ -130,6 +169,22 @@ bool hwapi::dc_openSerial(int BaudNr, QString BaudStr,
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList hwapi::dc_getStatus() const {
|
||||
QStringList status;
|
||||
|
||||
if (m_sharedMem) {
|
||||
SharedMemBuffer const *shMem = SharedMemBuffer::getDataConst();
|
||||
status += QString("comport : %1").arg(shMem->rs.comportName);
|
||||
status += QString("baudrate : %1").arg(shMem->rs.baudNr);
|
||||
status += QString("baudNr : %1").arg(shMem->rs.baudStr);
|
||||
status += QString("connect : %1").arg(shMem->rs.connect);
|
||||
status += QString("port open: %1").arg(shMem->rs.portIsOpen);
|
||||
// to be continued
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool hwapi::dc_closeSerial(void) const {
|
||||
epi_closeSerial();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
@@ -404,6 +459,135 @@ bool hwapi::dc_updateDC(QString bFile, QString br, QString serial) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
//
|
||||
// LEVEL 3: hwapi::dc_updatePrinterTemplate
|
||||
//
|
||||
/******************************************************************************/
|
||||
bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||
QVector<int> templatesIdx,
|
||||
QVector<QString> fnames,
|
||||
QString br,
|
||||
QString serial) const {
|
||||
// sanity checks
|
||||
if (!baudrateMap.contains(br)) {
|
||||
qCritical() << "passed wrong baudrate" << br;
|
||||
return false;
|
||||
}
|
||||
if (templatesIdx.size() != fnames.size()) {
|
||||
qCritical() << "list sizes must be equal" << br;
|
||||
return false;
|
||||
}
|
||||
if (!std::all_of(templatesIdx.cbegin(), templatesIdx.cend(),
|
||||
[](int i) { return i >= 1 && i <= 32; })) {
|
||||
qCritical() << "wrong template indices";
|
||||
return false;
|
||||
}
|
||||
if (type != FileTypeJson::PRINTER) {
|
||||
qCritical() << "wrong file type" << (uint8_t)type;
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "updating: " << fnames << br << serial << "...";
|
||||
|
||||
if (!serial.isNull()) {
|
||||
if (!openSerial(baudrateMap.value(br), br, serial)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int nTry = 50;
|
||||
while (!sys_ready4sending()) { // wait max. 5 seconds
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
if (--nTry <= 0) {
|
||||
qCritical() << "sys not ready for sending";
|
||||
if (!serial.isNull()) {
|
||||
closeSerial(serial);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
for (int i = 0; i < fnames.size(); ++i) {
|
||||
QFile file(fnames[i]);
|
||||
if (file.exists() && file.open(QIODevice::ReadOnly)) {
|
||||
QByteArray ba = file.readAll();
|
||||
if (ba.size() <= 800) { // max. size is 800 bytes
|
||||
if (sys_sendJsonFileToDc((uint8_t)(type),
|
||||
templatesIdx[i],
|
||||
(uint8_t *)ba.data())) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
qInfo() << "sent file" << fnames[i] << "to dc";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << fnames[i] << "!!! does not exist!!!";
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!serial.isNull()) {
|
||||
closeSerial(serial);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool hwapi::dc_printTemplate(enum FileTypeJson type,
|
||||
QVector<int> templateIdx,
|
||||
QString br,
|
||||
QString serial) const {
|
||||
// sanity checks
|
||||
if (!baudrateMap.contains(br)) {
|
||||
qCritical() << "passed wrong baudrate" << br;
|
||||
return false;
|
||||
}
|
||||
if (!std::all_of(templateIdx.cbegin(), templateIdx.cend(),
|
||||
[](int i) { return i >= 1 && i <= 32; })) {
|
||||
qCritical() << "wrong template indices";
|
||||
return false;
|
||||
}
|
||||
if (type != FileTypeJson::PRINTER) {
|
||||
qCritical() << "wrong file type" << (uint8_t)type;
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "printing: " << templateIdx << br << serial << "...";
|
||||
|
||||
if (!serial.isNull()) {
|
||||
if (!openSerial(baudrateMap.value(br), br, serial)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int nTry = 50;
|
||||
while (!sys_ready4sending()) { // wait max. 5 seconds
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
if (--nTry <= 0) {
|
||||
qCritical() << "sys not ready for sending";
|
||||
if (!serial.isNull()) {
|
||||
closeSerial(serial);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
for (int i = 0; i < templateIdx.size(); ++i) {
|
||||
if (prn_printTemplate(templateIdx[i])) {
|
||||
qDebug() << "printing template" << templateIdx[i];
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
} else {
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!serial.isNull()) {
|
||||
closeSerial(serial);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 1, control device-controller (functions of µC)
|
||||
@@ -607,13 +791,16 @@ QString hwapi::rtc_getTimStr() const
|
||||
{
|
||||
uint8_t hh, mm, ss, buf[20], nn;
|
||||
QString qbuf;
|
||||
|
||||
char ctmp;
|
||||
qbuf.clear();
|
||||
for (nn=0; nn<20; nn++) buf[nn]=0;
|
||||
epi_getTime(&hh, &mm, &ss);
|
||||
GetTimeString(hh, mm, ss, HourSys24h, MITSEK, buf); // about 12byte long
|
||||
for (nn=0; nn<20; nn++) qbuf[nn]=buf[nn];
|
||||
|
||||
for (nn=0; nn<20; nn++)
|
||||
{
|
||||
ctmp=buf[nn];
|
||||
qbuf[nn]=ctmp;
|
||||
}
|
||||
return qbuf;
|
||||
}
|
||||
|
||||
@@ -621,14 +808,17 @@ QString hwapi::rtc_getDatStr() const
|
||||
{
|
||||
uint8_t day, month, year, buf[20], nn;
|
||||
QString qbuf;
|
||||
char ctmp;
|
||||
|
||||
qbuf.clear();
|
||||
for (nn=0; nn<20; nn++) buf[nn]=0;
|
||||
epi_getDate(&year, &month, &day);
|
||||
GetDateString(day, month, 0x20, year, DateFormatDeutsch, 0, buf);
|
||||
for (nn=0; nn<20; nn++)
|
||||
qbuf[nn]=buf[nn];
|
||||
|
||||
{
|
||||
ctmp= buf[nn];
|
||||
qbuf[nn]=ctmp;
|
||||
}
|
||||
return qbuf;
|
||||
}
|
||||
|
||||
@@ -1582,8 +1772,7 @@ void hwapi::readback_machineIDdata(uint8_t *length, uint8_t *data) const
|
||||
static uint16_t hwapi_shutterTime;
|
||||
|
||||
// locks, 2.Level: (Motor stops automatical on end switch or by 5s timeout)
|
||||
uint8_t hwapi::lock_openUpperDoor(void) const
|
||||
{
|
||||
uint8_t hwapi::lock_openUpperDoor(void) const {
|
||||
//bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
||||
// commands are defined in PIdefines.h
|
||||
sendWRcmd_setSendCommand4(SENDDIRCMD_OPENUP_DOOR, 1, 0, 0, 0);
|
||||
@@ -1611,54 +1800,39 @@ uint8_t hwapi::lock_closeLowerDoor(void) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hwapi::shut_openOnce(void) const
|
||||
{
|
||||
void hwapi::shut_openOnce(void) const {
|
||||
// and close automatic after shutter time
|
||||
uint16_t zeit=hwapi_shutterTime;
|
||||
zeit/=100;
|
||||
uint16_t zeit = (SharedMemBuffer::getDataConst()->hwapi.shutterTime) / 100;
|
||||
sendWRcmd_setSendCommand4(SENDDIRCMD_SHUTOPENBYTIME, uint8_t(zeit) ,0,0,0);
|
||||
|
||||
}
|
||||
|
||||
void hwapi::shut_openForCoin(bool start) const
|
||||
{
|
||||
void hwapi::shut_openForCoin(bool start) const {
|
||||
// start=true: start opening flap if coin is attached
|
||||
// start=false: stop process
|
||||
|
||||
uint16_t zeit=hwapi_shutterTime;
|
||||
zeit/=100;
|
||||
uint16_t zeit = (SharedMemBuffer::getDataConst()->hwapi.shutterTime) / 100;
|
||||
sendWRcmd_setSendCommand4(SENDDIRCMD_SHUTOPENBYCOIN, uint8_t(start), uint8_t(zeit),0,0);
|
||||
|
||||
}
|
||||
|
||||
void hwapi::shut_sendOpeningTime(uint16_t timeIn_ms ) const
|
||||
{
|
||||
void hwapi::shut_sendOpeningTime(uint16_t timeIn_ms ) const {
|
||||
// after this time without retrigger the flap is closed
|
||||
//sendWRcmd_setSendCommand4(SENDDIRCMD_SHUT_SENDTIME, timeIn100ms,0,0,0);
|
||||
hwapi_shutterTime=timeIn_ms;
|
||||
|
||||
SharedMemBuffer::getData()->hwapi.shutterTime = timeIn_ms;
|
||||
}
|
||||
|
||||
|
||||
void hwapi::esc_takeMoney(void) const
|
||||
{
|
||||
void hwapi::esc_takeMoney(void) const {
|
||||
// and close automatically after escrow time (1s)
|
||||
sendWRcmd_setSendCommand0(SENDDIRCMD_ESCRO_TAKE);
|
||||
}
|
||||
|
||||
void hwapi::esc_returnMoney(void) const
|
||||
{
|
||||
void hwapi::esc_returnMoney(void) const {
|
||||
// and close automatically after time
|
||||
sendWRcmd_setSendCommand0(SENDDIRCMD_ESCRO_GIVE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// --------------------------------------------- MIFARE -----------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
@@ -2089,7 +2263,8 @@ bool hwapi::pri_TD_addText(QByteArray text) const
|
||||
|
||||
bool hwapi::pri_TD_addValue(int val) const
|
||||
{
|
||||
QString tmpStr;
|
||||
// QString tmpStr;
|
||||
QByteArray tmpStr;
|
||||
tmpStr.setNum(val,10); // up to 12 chars
|
||||
if (ticketTemplate.length()>1266)
|
||||
return false;
|
||||
@@ -2939,7 +3114,7 @@ bool hwapi::bl_isUp(void) const
|
||||
}
|
||||
|
||||
|
||||
void hwapi::bl_sendAddress(u_int16_t blockNumber) const
|
||||
void hwapi::bl_sendAddress(uint16_t blockNumber) const
|
||||
{
|
||||
// send start address, nr of 64byte-block, start with 0
|
||||
// will be sent only for folling block-numbers:
|
||||
@@ -2974,7 +3149,7 @@ void hwapi::bl_openBinary(void) const
|
||||
dcBL_loadBinary(0);
|
||||
}
|
||||
|
||||
void hwapi::bl_sendDataBlock(uint8_t length, u_int8_t *buffer) const
|
||||
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
|
||||
{
|
||||
// send 64 byte from bin file
|
||||
uint8_t LL=length, sendBuf[80], sendLen;
|
||||
@@ -3005,6 +3180,7 @@ void hwapi::bl_sendLastBlock(void) const
|
||||
|
||||
len=dcBL_writeLastPage(buf);
|
||||
sendWRcmd_setSendBlock160(len, buf);
|
||||
|
||||
}
|
||||
|
||||
uint8_t hwapi::bl_wasSendingDataOK(void) const
|
||||
@@ -3177,6 +3353,60 @@ bool hwapi::rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const
|
||||
|
||||
}
|
||||
|
||||
bool hwapi::rtc_getExtendedTime(struct T_extTime *exTime) const
|
||||
{
|
||||
uint8_t len;
|
||||
uint16_t LL, nn;
|
||||
uint8_t *start;
|
||||
uint8_t buf[66];
|
||||
|
||||
epi_restoreExtendedTime(&len, buf);
|
||||
// Puffer in struct eintragen:
|
||||
LL=sizeof(struct T_extTime);
|
||||
start = &(exTime->Hours);
|
||||
nn=0;
|
||||
do
|
||||
{
|
||||
*start = buf[nn];
|
||||
start++;
|
||||
} while(++nn<LL);
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
/*
|
||||
struct T_extTime
|
||||
{
|
||||
uint8_t Hours;
|
||||
uint8_t Min;
|
||||
uint8_t Sec;
|
||||
uint8_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t Day;
|
||||
uint8_t DOW;
|
||||
uint8_t res1;
|
||||
uint16_t MinOfDay;
|
||||
uint16_t res2;
|
||||
uint32_t SecOfDay;
|
||||
uint8_t isLeapYear;
|
||||
uint8_t nxtLeapYear;
|
||||
uint8_t lastLeapYear;
|
||||
uint8_t hoursOfThisWeek;
|
||||
uint16_t minutesOfThisWeek;
|
||||
uint16_t hoursOfThisMonth;
|
||||
uint16_t daysOfThisYear;
|
||||
uint16_t GetHoursOfYear;
|
||||
uint16_t res3;
|
||||
uint32_t GetMinutesOfYear;
|
||||
uint8_t getWakeIntvSec;
|
||||
uint8_t res4;
|
||||
uint16_t res5;
|
||||
uint32_t MinutesOfMillenium;
|
||||
};
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
bool hwapi::sys_runCompleteTest(void) const
|
||||
{
|
||||
// warning: lasts 20s in one pace
|
||||
@@ -3188,9 +3418,8 @@ bool hwapi::sys_ready4sending(void) const
|
||||
// return true if a Json-file can be sent
|
||||
|
||||
// check free memory
|
||||
uint8_t frei=FDLONG_STACKDEPTH - check4FDlongCmd();
|
||||
uint8_t frei=check4freeFDlongCmd();
|
||||
// Command-Stack sollte 16 Commands fassen, je 64byte Nutzdaten = 1024byte
|
||||
// in check4FDlongCmd() steht wieviele Plaetze bereits belegt sind
|
||||
// frei gibt also die Anzahl freier 64byte Bloecke zurueck
|
||||
// das Json-File hat max 800 byte = 13 bloecke
|
||||
if (frei<16) // Puffer muss ganz leer sein! nicht dass was durcheinander kommt
|
||||
@@ -3225,9 +3454,8 @@ bool hwapi::sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8
|
||||
dateiLang<<=6; // auf volle 64byte aufgerundet
|
||||
|
||||
// check free memory
|
||||
frei=FDLONG_STACKDEPTH - check4FDlongCmd();
|
||||
frei=check4freeFDlongCmd();
|
||||
// Command-Stack sollte 16 Commands fassen, je 64byte Nutzdaten = 1024byte
|
||||
// in check4FDlongCmd() steht wieviele Plaetze bereits belegt sind
|
||||
// frei gibt also die Anzahl freier 64byte Bloecke zurueck
|
||||
// das Json-File hat max 800 byte = 13 bloecke
|
||||
if (frei<16) // Puffer muss ganz leer sein! nicht dass was durcheinander kommt
|
||||
@@ -3248,7 +3476,8 @@ bool hwapi::sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8
|
||||
{
|
||||
biox_CopyBlock(inhaltOfJson, uitmp, temp, 0, 64);
|
||||
longFDcmd_set(31,0, bn++, 64, temp);
|
||||
uitmp<<=6;
|
||||
//uitmp<<=6; // falsch
|
||||
uitmp+=64;
|
||||
} while(uitmp < dateiLang);
|
||||
|
||||
longFDcmd_set(32, 0,0, 0,temp); // Abschluss
|
||||
@@ -3279,11 +3508,12 @@ bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
|
||||
return sendFDcmd_set(152, 0,0, nrOftemplate,0,0,0);
|
||||
}
|
||||
|
||||
void hwapi::log_getHoldAccountNumbers(uint32_t *accNr ) const
|
||||
// returns all acc nrs of the backuped vault records
|
||||
// use: uint32_t backupedAccNumbers[8]
|
||||
void hwapi::log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const
|
||||
{
|
||||
Q_UNUSED(accNr);
|
||||
// returns all acc nrs of the backuped vault records
|
||||
// use: uint16_t backupedAccNumbers[8]
|
||||
|
||||
epi_restoreDCbackupAccNr(nrOfVals, accNr);
|
||||
}
|
||||
|
||||
|
||||
@@ -3291,21 +3521,62 @@ void hwapi::log_getHoldAccountNumbers(uint32_t *accNr ) const
|
||||
bool hwapi::log_selectVaultRecord(uint16_t accountNr ) const
|
||||
{
|
||||
// return true if sending, false if cmd-stack is full
|
||||
uint8_t dat1, dat2;
|
||||
// and trigger transfer
|
||||
|
||||
uint8_t dat1, dat2;
|
||||
bool ret;
|
||||
|
||||
uint8_t frei=check4freeFDshortCmd();
|
||||
if (frei<8)
|
||||
return false;
|
||||
|
||||
epi_iniVRstorage();
|
||||
dat1=uint2uchar(accountNr, LOWBYTE);
|
||||
dat2=uint2uchar(accountNr, HIGHBYTE);
|
||||
return sendFDcmd_set(153, 0,0, dat1,dat2,0,0);
|
||||
ret=sendFDcmd_set(153, 0,0, dat1,dat2,0,0); // select this record
|
||||
// true means "will be sent"
|
||||
sendFDcmd_set(0,38,0, 0,0,0,0); // return VaultRecord block-Nr.0
|
||||
sendFDcmd_set(0,38,1, 0,0,0,0); // return VaultRecord block-Nr.1
|
||||
sendFDcmd_set(0,38,2, 0,0,0,0); // return VaultRecord block-Nr.2
|
||||
sendFDcmd_set(0,38,3, 0,0,0,0); // return VaultRecord block-Nr.3
|
||||
sendFDcmd_set(0,38,4, 0,0,0,0); // return VaultRecord block-Nr.4
|
||||
sendFDcmd_set(0,38,5, 0,0,0,0); // return VaultRecord block-Nr.4
|
||||
// 38: <100 to get long 64byte response
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool hwapi::log_chkIfVaultRecordAvailable(void) const
|
||||
{
|
||||
// return true if completly received
|
||||
return epi_checkIfVaultRecordAvailable();
|
||||
return false;
|
||||
}
|
||||
|
||||
//request, isAvailable
|
||||
void hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
|
||||
bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
|
||||
// which was selected by: log_selectVaultRecord()
|
||||
// to be forwarded to Ismas
|
||||
// return true if completly received
|
||||
{
|
||||
Q_UNUSED(retVR);
|
||||
|
||||
uint16_t LL, nn, len;
|
||||
char *start;
|
||||
uint8_t buf[400];
|
||||
bool ret;
|
||||
|
||||
ret=epi_restoreVaultRecord(&len, buf); // true if completly received
|
||||
if (ret==false)
|
||||
return false;
|
||||
// Puffer in struct eintragen:
|
||||
LL=sizeof(struct T_vaultRecord); // =320
|
||||
start = &retVR->startbuffer[0];
|
||||
nn=0;
|
||||
do
|
||||
{
|
||||
*start = buf[nn];
|
||||
start++;
|
||||
} while(++nn<LL);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hwapi::prn_printAccountReceipt(void) const
|
||||
@@ -3320,14 +3591,19 @@ bool hwapi::prn_printTestTicket(void) const
|
||||
|
||||
}
|
||||
|
||||
bool hwapi::cash_startPayment(uint16_t amount) const
|
||||
bool hwapi::cash_startPayment(uint32_t amount) const
|
||||
{
|
||||
uint8_t dat1, dat2;
|
||||
// 17.4.23TS: extended to 32bit
|
||||
uint8_t dat1, dat2, dat3, dat4;
|
||||
|
||||
hwapi_lastStartAmount=amount;
|
||||
epi_clearCurrentPayment();
|
||||
dat1=uint2uchar(amount, LOWBYTE);
|
||||
dat2=uint2uchar(amount, HIGHBYTE);
|
||||
return sendFDcmd_set(155, 0,0, dat1,dat2,0,0);
|
||||
dat1=ulong2uchar(amount, 0);
|
||||
dat2=ulong2uchar(amount, 1);
|
||||
dat3=ulong2uchar(amount, 2);
|
||||
dat4=ulong2uchar(amount, 3);
|
||||
|
||||
return sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4);
|
||||
|
||||
}
|
||||
|
||||
@@ -3361,6 +3637,7 @@ bool hwapi::cash_stopPayment(void) const
|
||||
{
|
||||
// DB1: 1=encash 2=cancel & return coins
|
||||
// 3=stop and keep coins in escrow
|
||||
emit hwapi_vendStopByPushbutton();
|
||||
return sendFDcmd_set(156, 0,0, 3,0,0,0);
|
||||
|
||||
}
|
||||
@@ -3383,17 +3660,24 @@ bool hwapi::vend_failed(void) const
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t hwapi::mif_getCardType(QString cardholder) const
|
||||
uint8_t hwapi::mif_getCardType(QString *cardholder) const
|
||||
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
||||
// cardholder: 7byte Name-String
|
||||
{
|
||||
Q_UNUSED(cardholder);
|
||||
return 0; // to satisfy compiler
|
||||
uint8_t type, buf[8], nn;
|
||||
char ctmp;
|
||||
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
type=epi_mifGetCardType(&buf[0]);
|
||||
//holder[8] = name of card holder
|
||||
// retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
|
||||
for (nn=0;nn<8; nn++) {
|
||||
ctmp=buf[nn];
|
||||
cardholder[nn]=ctmp;
|
||||
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
uint64_t hwapi::sys_getWakeSource(void) const
|
||||
@@ -3402,17 +3686,138 @@ uint64_t hwapi::sys_getWakeSource(void) const
|
||||
return epi_getWakeSources();
|
||||
}
|
||||
|
||||
//void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const
|
||||
|
||||
void hwapi::sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const
|
||||
{
|
||||
//uint8_t leng, data[66];
|
||||
epi_restoreDeviceConditions(leng, data);
|
||||
}
|
||||
|
||||
//void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const
|
||||
void hwapi::sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const
|
||||
void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const
|
||||
{
|
||||
epi_restoreDeviceConditions(leng, data);
|
||||
uint16_t LL, nn;
|
||||
uint8_t *start;
|
||||
uint8_t buf[70], leng;
|
||||
|
||||
epi_restoreDeviceConditions(&leng, buf);
|
||||
|
||||
// Puffer in struct eintragen:
|
||||
LL=sizeof(struct T_moduleCondition);
|
||||
start = &devCond->ram;
|
||||
nn=0;
|
||||
do
|
||||
{
|
||||
*start = buf[nn];
|
||||
start++;
|
||||
} while(++nn<LL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void hwapi::sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const
|
||||
{
|
||||
epi_restoreDynMachineConditions(leng, data);
|
||||
}
|
||||
|
||||
void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const
|
||||
{
|
||||
|
||||
uint16_t LL, nn;
|
||||
char *start;
|
||||
uint8_t buf[70], 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(++nn<LL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint32_t hwapi::cash_getAmountInVault(void) const
|
||||
{
|
||||
return epi_getCashBoxContent();
|
||||
}
|
||||
|
||||
uint16_t hwapi::cash_getNrCoinsInVault(void) const
|
||||
{
|
||||
return epi_getNrOfCoinsInCashBox();
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t hwapi::prn_getPrintResult() const
|
||||
{
|
||||
// return: 0: unknown
|
||||
// 1: OK - last template was printed succesful
|
||||
// 2: error - last template was not printed
|
||||
|
||||
struct T_dynamicCondition dynMachCon;
|
||||
//uint8_t buf[70], leng,
|
||||
uint8_t res;
|
||||
static uint8_t lastState;
|
||||
//uint32_t aa;
|
||||
|
||||
// aa=&dynMachCon;
|
||||
sys_getDynMachineConditions(&dynMachCon);
|
||||
res= dynMachCon.resultOfLastTemplPrint;
|
||||
// 0: unknown or printing in progress
|
||||
// 1: OK, doc was printed 2: error, doc was not printed
|
||||
|
||||
if (res==0)
|
||||
{
|
||||
if (lastState>0)
|
||||
{
|
||||
// print was started
|
||||
lastState=res;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (lastState==0)
|
||||
{
|
||||
// result hat sich auf 1 oder 2 geändert, d.h. Druck ist fertig
|
||||
if (res==1)
|
||||
{
|
||||
|
||||
//emit hwapi_templatePrintFinished_OK();
|
||||
} else
|
||||
if (res==2)
|
||||
{
|
||||
|
||||
//emit hwapi_templatePrintFinished_Err();
|
||||
}
|
||||
lastState=res;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t hwapi::prn_getCurrentPrinterState() const
|
||||
{
|
||||
// 0: printer OK
|
||||
// bit0: near paper end bit1: no paper
|
||||
// bit2: temperature error bit3: error head open
|
||||
// bit4: paper jam in cutter
|
||||
// bit6: no response bit7: serial rec. error
|
||||
// bit5: printer not ready
|
||||
|
||||
|
||||
uint8_t lastPrinterStatus;
|
||||
uint8_t buf[70], leng;
|
||||
|
||||
// 2nd way to get dyn.conditions:
|
||||
epi_restoreDynMachineConditions(&leng, buf);
|
||||
lastPrinterStatus=buf[53];
|
||||
|
||||
return lastPrinterStatus;
|
||||
}
|
||||
|
||||
|
||||
|
9
src/main.cpp
Normal file
9
src/main.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <QCoreApplication>
|
||||
#include "tslib.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
return a.exec();
|
||||
}
|
@@ -1,283 +1,157 @@
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
#include "tslib.h"
|
||||
#include "sendWRcmd.h"
|
||||
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
void indat_PrnPwr(void);
|
||||
|
||||
/* convention: use simple (not rotating) FIFO Stack:
|
||||
Example: nrOfCmdsInQueue=4 then
|
||||
nextAsynchsendCmd0[0]=cmd1 // was stored as first
|
||||
nextAsynchsendCmd0[1]=cmd2
|
||||
nextAsynchsendCmd0[2]=cmd3
|
||||
nextAsynchsendCmd0[3]=cmd4 // came in as last
|
||||
|
||||
void sendWRcmd_INI(void)
|
||||
{
|
||||
Send: [0] first, then move buffer 1 down:
|
||||
nextAsynchsendCmd0[0]=cmd2
|
||||
nextAsynchsendCmd0[1]=cmd3
|
||||
nextAsynchsendCmd0[2]=cmd4
|
||||
nextAsynchsendCmd0[3]=0;
|
||||
nrOfCmdsInQueue=3 now
|
||||
*/
|
||||
template <typename T, std::size_t N>
|
||||
static void *move_buffer_down_by_one(T (&buffer)[N]) {
|
||||
return memmove(buffer, &buffer[1], sizeof(buffer)-sizeof(buffer[0]));
|
||||
}
|
||||
template <typename T, std::size_t N>
|
||||
static void clear(T (&buffer)[N]) {
|
||||
memset((char *)(&buffer[0]), 0x00, sizeof(buffer));
|
||||
}
|
||||
template <typename T, std::size_t M, std::size_t N>
|
||||
static void clear(T (&buffer)[M][N]) {
|
||||
memset((char *)(&buffer[0][0]), 0x00, sizeof(buffer));
|
||||
}
|
||||
template <typename T>
|
||||
static void sendWRcmd_clearCmdStack(T &cmdStack) {
|
||||
clear(cmdStack.AsynchSend);
|
||||
clear(cmdStack.para1);
|
||||
clear(cmdStack.para2);
|
||||
clear(cmdStack.para3);
|
||||
clear(cmdStack.para4);
|
||||
cmdStack.nrOfCmdsInQueue = 0;
|
||||
}
|
||||
template <typename T, typename T1, typename T2, typename T3, typename T4>
|
||||
static bool sendWRcmd_setSendCmd(T &cmdStack, uint16_t nextCmd, T1 dat1,
|
||||
T2 dat2, T3 dat3, T4 dat4) {
|
||||
uint8_t const &n = cmdStack.nrOfCmdsInQueue;
|
||||
int const STACKDEPTH = sizeof(cmdStack.para1);
|
||||
if (n < STACKDEPTH) {
|
||||
cmdStack.AsynchSend[n] = nextCmd;
|
||||
cmdStack.para1[n] = dat1;
|
||||
cmdStack.para2[n] = dat2;
|
||||
cmdStack.para3[n] = dat3;
|
||||
cmdStack.para4[n] = dat4;
|
||||
cmdStack.nrOfCmdsInQueue += 1;
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
qCritical() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
template <typename T, typename T1, typename T2, typename T3, typename T4>
|
||||
static bool sendWRcmd_getSendCmd(T &cmdStack, T1 *dat1, T2 *dat2,
|
||||
T3 *dat3, T4 *dat4) {
|
||||
if (dat1 && dat2 && dat3 && dat4) {
|
||||
uint8_t const &n = cmdStack.nrOfCmdsInQueue;
|
||||
int const STACKDEPTH = sizeof(cmdStack.para1);
|
||||
if ((n > 0) && (n <= STACKDEPTH)) {
|
||||
uint16_t const nxt = cmdStack.AsynchSend[0];
|
||||
move_buffer_down_by_one(cmdStack.AsynchSend);
|
||||
*dat1 = cmdStack.para1[n];
|
||||
*dat2 = cmdStack.para2[n];
|
||||
*dat3 = cmdStack.para3[n];
|
||||
*dat4 = cmdStack.para4[n];
|
||||
cmdStack.nrOfCmdsInQueue = n - 1;
|
||||
return nxt;
|
||||
}
|
||||
}
|
||||
qCritical() << "cannot fetch cmd";
|
||||
return 0; // error
|
||||
}
|
||||
|
||||
void sendWRcmd_INI(void) {
|
||||
sendWRcmd_clrCmdStack();
|
||||
sendWRcmd_clrCmd4Stack();
|
||||
sendFDcmd_clrStack();
|
||||
longFDcmd_clrStack();
|
||||
}
|
||||
|
||||
// Command Stack for commands without parameters
|
||||
|
||||
|
||||
static uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH];
|
||||
static uint8_t nrOfCmdsInQueue;
|
||||
/* convention: use simple (not rotating) FIFO Stack:
|
||||
Example: nrOfCmdsInQueue=4 then
|
||||
nextAsynchsendCmd0[0]=cmd1 // was stored as first
|
||||
nextAsynchsendCmd0[1]=cmd2
|
||||
nextAsynchsendCmd0[2]=cmd3
|
||||
nextAsynchsendCmd0[3]=cmd4 // came in as last
|
||||
|
||||
Send: [0] first, then move buffer 1 down:
|
||||
nextAsynchsendCmd0[0]=cmd2
|
||||
nextAsynchsendCmd0[1]=cmd3
|
||||
nextAsynchsendCmd0[2]=cmd4
|
||||
nextAsynchsendCmd0[3]=0;
|
||||
nrOfCmdsInQueue=3 now
|
||||
*/
|
||||
|
||||
void sendWRcmd_clrCmdStack(void)
|
||||
{
|
||||
uint8_t nn;
|
||||
for (nn=0; nn<CMDSTACKDEPTH; nn++)
|
||||
nextAsynchsendCmd0[nn]=0;
|
||||
nrOfCmdsInQueue=0;
|
||||
void sendWRcmd_clrCmdStack(void) {
|
||||
sendWRcmd_clearCmdStack(SharedMemBuffer::getData()->Cmd0);
|
||||
}
|
||||
void sendWRcmd_clrCmd4Stack(void) {
|
||||
sendWRcmd_clearCmdStack(SharedMemBuffer::getData()->Cmd4);
|
||||
}
|
||||
void sendWRcmd_clrCmd8Stack(void) {
|
||||
sendWRcmd_clearCmdStack(SharedMemBuffer::getData()->Cmd8);
|
||||
}
|
||||
|
||||
bool sendWRcmd_setSendCommand0(uint16_t nextCmd)
|
||||
{
|
||||
bool sendWRcmd_setSendCommand0(uint16_t nextCmd, uint8_t dat1, uint8_t dat2,
|
||||
uint8_t dat3, uint8_t dat4) {
|
||||
// write Command to memory, wait for transport
|
||||
if (nrOfCmdsInQueue>=CMDSTACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
nextAsynchsendCmd0[nrOfCmdsInQueue++]=nextCmd;
|
||||
//qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue;
|
||||
return true; // ok, will be sent
|
||||
return sendWRcmd_setSendCmd(SharedMemBuffer::getData()->Cmd0,
|
||||
nextCmd, dat1, dat2, dat3, dat4);
|
||||
}
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand0(void)
|
||||
{
|
||||
uint16_t nxtAsynchCmd;
|
||||
uint8_t nn, ll;
|
||||
if (nrOfCmdsInQueue==0 || nrOfCmdsInQueue>CMDSTACKDEPTH)
|
||||
return 0; // error
|
||||
nxtAsynchCmd=nextAsynchsendCmd0[0];
|
||||
|
||||
// move Puffer down by one element
|
||||
if (CMDSTACKDEPTH>0)
|
||||
ll=CMDSTACKDEPTH-1;
|
||||
else
|
||||
ll=0;
|
||||
for (nn=0; nn<ll; nn++)
|
||||
nextAsynchsendCmd0[nn]=nextAsynchsendCmd0[nn+1];
|
||||
|
||||
if (nrOfCmdsInQueue>0)
|
||||
nrOfCmdsInQueue--;
|
||||
//qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
|
||||
return nxtAsynchCmd;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// Command Stack for commands with 4 parameters
|
||||
|
||||
|
||||
|
||||
static uint16_t nextAsynchsendCmd4[CMD4STACKDEPTH];
|
||||
static uint8_t nextCmd4para1[CMD4STACKDEPTH];
|
||||
static uint8_t nextCmd4para2[CMD4STACKDEPTH];
|
||||
static uint8_t nextCmd4para3[CMD4STACKDEPTH];
|
||||
static uint8_t nextCmd4para4[CMD4STACKDEPTH];
|
||||
static uint8_t nrOfCmds4InQueue;
|
||||
/* convention: use simple (not rotating) FIFO Stack:
|
||||
Example: nrOfCmdsInQueue=4 then
|
||||
nextAsynchsendCmd0[0]=cmd1 // was stored as first
|
||||
nextAsynchsendCmd0[1]=cmd2
|
||||
nextAsynchsendCmd0[2]=cmd3
|
||||
nextAsynchsendCmd0[3]=cmd4 // came in as last
|
||||
|
||||
Send: [0] first, then move buffer 1 down:
|
||||
nextAsynchsendCmd0[0]=cmd2
|
||||
nextAsynchsendCmd0[1]=cmd3
|
||||
nextAsynchsendCmd0[2]=cmd4
|
||||
nextAsynchsendCmd0[3]=0;
|
||||
nrOfCmdsInQueue=3 now
|
||||
*/
|
||||
|
||||
|
||||
void sendWRcmd_clrCmd4Stack(void)
|
||||
{
|
||||
uint8_t nn;
|
||||
for (nn=0; nn<CMD4STACKDEPTH; nn++)
|
||||
{
|
||||
nextAsynchsendCmd4[nn]=0;
|
||||
nextCmd4para1[nn]=0;
|
||||
nextCmd4para2[nn]=0;
|
||||
nextCmd4para3[nn]=0;
|
||||
nextCmd4para4[nn]=0;
|
||||
}
|
||||
nrOfCmds4InQueue=0;
|
||||
}
|
||||
|
||||
bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4)
|
||||
{
|
||||
bool sendWRcmd_setSendCommand4(uint16_t nextCmd,
|
||||
uint8_t dat1, uint8_t dat2,
|
||||
uint8_t dat3, uint8_t dat4) {
|
||||
// write Command to memory, wait for transport
|
||||
if (nrOfCmds4InQueue>=CMD4STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
nextAsynchsendCmd4[nrOfCmds4InQueue]=nextCmd;
|
||||
nextCmd4para1[nrOfCmds4InQueue]=dat1;
|
||||
nextCmd4para2[nrOfCmds4InQueue]=dat2;
|
||||
nextCmd4para3[nrOfCmds4InQueue]=dat3;
|
||||
nextCmd4para4[nrOfCmds4InQueue]=dat4;
|
||||
//qDebug() << "data with 4 data byte saved, pp=" << nrOfCmds4InQueue;
|
||||
//qDebug() << " dat1=" << nextCmd4para1[nrOfCmds4InQueue] << " dat2=" << nextCmd4para2[nrOfCmds4InQueue]
|
||||
// << " dat3=" << nextCmd4para3[nrOfCmds4InQueue] << " dat4=" << nextCmd4para4[nrOfCmds4InQueue];
|
||||
nrOfCmds4InQueue++;
|
||||
return true; // ok, will be sent
|
||||
return sendWRcmd_setSendCmd(SharedMemBuffer::getData()->Cmd4, nextCmd, dat1,
|
||||
dat2, dat3, dat4);
|
||||
}
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
|
||||
{
|
||||
uint16_t nxtAsynchCmd;
|
||||
uint8_t nn, ll;
|
||||
|
||||
if (nrOfCmds4InQueue==0 || nrOfCmds4InQueue>CMD4STACKDEPTH)
|
||||
return 0; // error
|
||||
nxtAsynchCmd=nextAsynchsendCmd4[0];
|
||||
*dat1=nextCmd4para1[0];
|
||||
*dat2=nextCmd4para2[0];
|
||||
*dat3=nextCmd4para3[0];
|
||||
*dat4=nextCmd4para4[0];
|
||||
//qDebug() << "cmd4 restored to send from [0]; pp=" << nrOfCmds4InQueue;
|
||||
//qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] <<
|
||||
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
|
||||
|
||||
// move Puffer down by one element
|
||||
if (CMD4STACKDEPTH>0)
|
||||
ll=CMD4STACKDEPTH-1;
|
||||
else
|
||||
ll=0;
|
||||
for (nn=0; nn<ll; nn++)
|
||||
{
|
||||
nextAsynchsendCmd4[nn]=nextAsynchsendCmd4[nn+1];
|
||||
nextCmd4para1[nn]=nextCmd4para1[nn+1];
|
||||
nextCmd4para2[nn]=nextCmd4para2[nn+1];
|
||||
nextCmd4para3[nn]=nextCmd4para3[nn+1];
|
||||
nextCmd4para4[nn]=nextCmd4para4[nn+1];
|
||||
}
|
||||
if (nrOfCmds4InQueue>0)
|
||||
nrOfCmds4InQueue--;
|
||||
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
|
||||
return nxtAsynchCmd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static uint16_t nextAsynchsendCmd8[CMD8STACKDEPTH];
|
||||
static uint8_t nextCmd8para1[CMD8STACKDEPTH];
|
||||
static uint8_t nextCmd8para2[CMD8STACKDEPTH];
|
||||
static uint16_t nextCmd8para3[CMD8STACKDEPTH];
|
||||
static uint32_t nextCmd8para4[CMD8STACKDEPTH];
|
||||
static uint8_t nrOfCmds8InQueue;
|
||||
|
||||
void sendWRcmd_clrCmd8Stack(void)
|
||||
{
|
||||
uint8_t nn;
|
||||
for (nn=0; nn<CMD8STACKDEPTH; nn++)
|
||||
{
|
||||
nextAsynchsendCmd8[nn]=0;
|
||||
nextCmd8para1[nn]=0;
|
||||
nextCmd8para2[nn]=0;
|
||||
nextCmd8para3[nn]=0;
|
||||
nextCmd8para4[nn]=0;
|
||||
}
|
||||
nrOfCmds8InQueue=0;
|
||||
}
|
||||
|
||||
bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint16_t dat3, uint32_t dat4)
|
||||
{
|
||||
bool sendWRcmd_setSendCommand8(uint16_t nextCmd,
|
||||
uint8_t dat1, uint8_t dat2,
|
||||
uint16_t dat3, uint32_t dat4) {
|
||||
// write Command to memory, wait for transport
|
||||
if (nrOfCmds8InQueue>=CMD8STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
nextAsynchsendCmd8[nrOfCmds8InQueue]=nextCmd;
|
||||
nextCmd8para1[nrOfCmds8InQueue]=dat1;
|
||||
nextCmd8para2[nrOfCmds8InQueue]=dat2;
|
||||
nextCmd8para3[nrOfCmds8InQueue]=dat3;
|
||||
nextCmd8para4[nrOfCmds8InQueue]=dat4;
|
||||
nrOfCmds8InQueue++;
|
||||
return sendWRcmd_setSendCmd(SharedMemBuffer::getData()->Cmd8, nextCmd, dat1,
|
||||
dat2, dat3, dat4);
|
||||
}
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand0(uint8_t *dat1, uint8_t *dat2,
|
||||
uint8_t *dat3, uint8_t *dat4) {
|
||||
return sendWRcmd_getSendCmd(SharedMemBuffer::getData()->Cmd0, dat1, dat2,
|
||||
dat3, dat4);
|
||||
}
|
||||
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2,
|
||||
uint8_t *dat3, uint8_t *dat4) {
|
||||
return sendWRcmd_getSendCmd(SharedMemBuffer::getData()->Cmd4, dat1, dat2,
|
||||
dat3, dat4);
|
||||
}
|
||||
uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2,
|
||||
uint16_t *dat3, uint32_t *dat4) {
|
||||
return sendWRcmd_getSendCmd(SharedMemBuffer::getData()->Cmd8, dat1, dat2,
|
||||
dat3, dat4);
|
||||
}
|
||||
|
||||
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t const *buf) {
|
||||
SharedMemBuffer::getData()->next.sendAsyDatLen = std::min(leng, (uint8_t)160);
|
||||
clear(SharedMemBuffer::getData()->next.sendAsynchDataBuf);
|
||||
memcpy((char *)(&SharedMemBuffer::getData()->next.sendAsynchDataBuf),
|
||||
(char const *)(buf),
|
||||
SharedMemBuffer::getDataConst()->next.sendAsyDatLen);
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4)
|
||||
{
|
||||
uint16_t nxtAsynchCmd;
|
||||
uint8_t nn, ll;
|
||||
|
||||
if (nrOfCmds8InQueue==0 || nrOfCmds8InQueue>CMD8STACKDEPTH)
|
||||
return 0; // error
|
||||
nxtAsynchCmd=nextAsynchsendCmd8[0];
|
||||
*dat1=nextCmd8para1[0];
|
||||
*dat2=nextCmd8para2[0];
|
||||
*dat3=nextCmd8para3[0];
|
||||
*dat4=nextCmd8para4[0];
|
||||
|
||||
// move buffer down by one element
|
||||
if (CMD8STACKDEPTH>0)
|
||||
ll=CMD8STACKDEPTH-1;
|
||||
else
|
||||
ll=0;
|
||||
for (nn=0; nn<ll; nn++)
|
||||
{
|
||||
nextAsynchsendCmd8[nn]=nextAsynchsendCmd8[nn+1];
|
||||
nextCmd8para1[nn]=nextCmd8para1[nn+1];
|
||||
nextCmd8para2[nn]=nextCmd8para2[nn+1];
|
||||
nextCmd8para3[nn]=nextCmd8para3[nn+1];
|
||||
nextCmd8para4[nn]=nextCmd8para4[nn+1];
|
||||
}
|
||||
if (nrOfCmds8InQueue>0)
|
||||
nrOfCmds8InQueue--;
|
||||
return nxtAsynchCmd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer
|
||||
static uint8_t sendAsyDatLen;
|
||||
|
||||
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf)
|
||||
{
|
||||
//qDebug() << "pi epi: storing send data";
|
||||
if (leng>160) leng=160;
|
||||
sendAsyDatLen=leng;
|
||||
tslib_strclr(sendAsynchDataBuf, 0, 160);
|
||||
for (uint8_t nn=0; nn<leng; nn++)
|
||||
sendAsynchDataBuf[nn]=buf[nn];
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf)
|
||||
{
|
||||
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf) {
|
||||
//qDebug() << "pi gpi: restoring send data";
|
||||
*leng=sendAsyDatLen;
|
||||
for (uint8_t nn=0; nn<sendAsyDatLen; nn++)
|
||||
buf[nn]=sendAsynchDataBuf[nn];
|
||||
sendAsyDatLen=0;
|
||||
//tslib_strclr(sendAsynchDataBuf, 0, 64);
|
||||
*leng = SharedMemBuffer::getDataConst()->next.sendAsyDatLen;
|
||||
memcpy((char *)buf,
|
||||
(char const *)(SharedMemBuffer::getData()->next.sendAsynchDataBuf),
|
||||
*leng);
|
||||
SharedMemBuffer::getData()->next.sendAsyDatLen = 0;
|
||||
return *leng;
|
||||
}
|
||||
|
||||
@@ -290,184 +164,141 @@ uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf)
|
||||
// start with: SENDDIRCMD_EXCHGMDB,
|
||||
// send crude data from here to DC, DC to mdb slaves, mdb answer, return here within 50ms
|
||||
|
||||
|
||||
static uint8_t Sdata_mdbSendBuffer[64];
|
||||
static uint8_t Sdata_mdbSendLen;
|
||||
|
||||
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf)
|
||||
{
|
||||
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t const *buf) {
|
||||
// HWapi writes data to be forwarded to DC and further to mdb-device
|
||||
for (uint8_t nn=0; nn<length; nn++)
|
||||
Sdata_mdbSendBuffer[nn]=buf[nn];
|
||||
Sdata_mdbSendLen=length;
|
||||
memcpy((char *)(&SharedMemBuffer::getData()->Sdata.mdbSendBuffer[0]),
|
||||
(char const *)buf, length);
|
||||
SharedMemBuffer::getData()->Sdata.mdbSendLen = length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t gpi_restore64ByteSendData(uint8_t *length, uint8_t *buf)
|
||||
{
|
||||
uint8_t gpi_restore64ByteSendData(uint8_t *length, uint8_t *buf) {
|
||||
// datif reads data to forward to dc
|
||||
for (uint8_t nn=0; nn<Sdata_mdbSendLen; nn++)
|
||||
buf[nn]=Sdata_mdbSendBuffer[nn];
|
||||
*length=Sdata_mdbSendLen;
|
||||
Sdata_mdbSendLen=0;
|
||||
memcpy((char *)(buf),
|
||||
(char const *)(&SharedMemBuffer::getDataConst()->Sdata.mdbSendBuffer[0]),
|
||||
SharedMemBuffer::getDataConst()->Sdata.mdbSendLen);
|
||||
*length = SharedMemBuffer::getDataConst()->Sdata.mdbSendLen;
|
||||
SharedMemBuffer::getData()->Sdata.mdbSendLen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------
|
||||
//---------------------------------------- Printer Text Fifo -------------------------
|
||||
static uint8_t prnDataParameters[4];
|
||||
static uint8_t prnDataBufferUser;
|
||||
|
||||
void epi_storeUserOfSendingTextBuffer(uint8_t user, uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4 )
|
||||
{
|
||||
void epi_storeUserOfSendingTextBuffer(uint8_t user, uint8_t para1,
|
||||
uint8_t para2, uint8_t para3,
|
||||
uint8_t para4 ) {
|
||||
// user=1: Text-Print is using this buffer
|
||||
// 2: QR-code-Printer is using this buffer
|
||||
prnDataBufferUser=user;
|
||||
prnDataParameters[0]=para1;
|
||||
prnDataParameters[1]=para2;
|
||||
prnDataParameters[2]=para3;
|
||||
prnDataParameters[3]=para4;
|
||||
|
||||
// qDebug() << "new user stored: " << user;
|
||||
|
||||
SharedMemBuffer::getData()->prn.DataBufferUser = user;
|
||||
SharedMemBuffer::getData()->prn.DataParameters[0] = para1;
|
||||
SharedMemBuffer::getData()->prn.DataParameters[1] = para2;
|
||||
SharedMemBuffer::getData()->prn.DataParameters[2] = para3;
|
||||
SharedMemBuffer::getData()->prn.DataParameters[3] = para4;
|
||||
}
|
||||
|
||||
uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *para3, uint8_t *para4)
|
||||
{
|
||||
uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2,
|
||||
uint8_t *para3, uint8_t *para4) {
|
||||
// user=1: Text-Print is using this buffer
|
||||
// 2: QR-code-Printer is using this buffer
|
||||
//qDebug() << "returning user "<< prnDataBufferUser;
|
||||
|
||||
*para1=prnDataParameters[0];
|
||||
*para2=prnDataParameters[1];
|
||||
*para3=prnDataParameters[2];
|
||||
*para4=prnDataParameters[3];
|
||||
return prnDataBufferUser;
|
||||
|
||||
*para1 = SharedMemBuffer::getDataConst()->prn.DataParameters[0];
|
||||
*para2 = SharedMemBuffer::getDataConst()->prn.DataParameters[1];
|
||||
*para3 = SharedMemBuffer::getDataConst()->prn.DataParameters[2];
|
||||
*para4 = SharedMemBuffer::getDataConst()->prn.DataParameters[3];
|
||||
return SharedMemBuffer::getDataConst()->prn.DataBufferUser;
|
||||
}
|
||||
|
||||
|
||||
// Sending Text Fifo
|
||||
// Sending Text Fifo
|
||||
// ONE printer doc consists of 20 x 64 byte
|
||||
// #define MAXNROF_PRNBYTES 64
|
||||
// #define MAXNROF_PRNBLOCKS 20
|
||||
static char Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
|
||||
static uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
|
||||
|
||||
// static char Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
|
||||
// static uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
|
||||
|
||||
//static uint8_t pPrnDataBuff; // points to next waiting printer text
|
||||
// defined above, needed if more then one text is stored (before sent)
|
||||
// every block will be sent after 100ms, if 8 blocks are stored within this 100ms
|
||||
// then pointer goes up to 8. Important: FIFO!!!!!!!!
|
||||
|
||||
void epi_resetPrinterStack(void)
|
||||
{
|
||||
pPrnDataBuff=0;
|
||||
void epi_resetPrinterStack(void) {
|
||||
SharedMemBuffer::getData()->prn.pDataBuff = 0;
|
||||
}
|
||||
|
||||
uint8_t epi_storePrnText(char *buf, uint8_t leng)
|
||||
{
|
||||
uint8_t epi_storePrnText(char *buf, uint8_t leng) {
|
||||
// store text from Gui in next higher free memory 0....9
|
||||
|
||||
uint16_t len;
|
||||
uint8_t pp, nn;
|
||||
uint16_t const len = std::min(leng, (uint8_t)MAXNROF_PRNBYTES);
|
||||
int const pp = SharedMemBuffer::getDataConst()->prn.pDataBuff;
|
||||
|
||||
pp=pPrnDataBuff; // next free memory block with 64byte each
|
||||
if (pp>=MAXNROF_PRNBLOCKS)
|
||||
return 1; // not possible, no free mem
|
||||
|
||||
//len=tslib_strlen(buf); // kennt keine Binärzeichen!!!!!!
|
||||
len=leng;
|
||||
if (len>MAXNROF_PRNBYTES)
|
||||
len=MAXNROF_PRNBYTES;
|
||||
|
||||
tslib_strclr(Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES);
|
||||
|
||||
for (nn=0; nn<len; nn++)
|
||||
Sdata_PRN_TEXT[pp][nn]=buf[nn]; // copy new text into buffer
|
||||
|
||||
if (pPrnDataBuff<MAXNROF_PRNBLOCKS)
|
||||
pPrnDataBuff++; // inc pointer if end not yet reached
|
||||
// next free memory block with 64byte each
|
||||
if (pp < MAXNROF_PRNBLOCKS) {
|
||||
clear(SharedMemBuffer::getData()->Sdata.PRN_TEXT[pp]);
|
||||
// copy new text into buffer
|
||||
memcpy((char *)(&SharedMemBuffer::getData()->Sdata.PRN_TEXT[pp][0]),
|
||||
(char const *)(buf), len);
|
||||
// inc pointer if end not yet reached
|
||||
SharedMemBuffer::getData()->prn.pDataBuff++;
|
||||
return 0; // OK
|
||||
}
|
||||
|
||||
return 1; // not possible, no free mem
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t gpi_restorePrnText(uint8_t *retbuf)
|
||||
{
|
||||
uint8_t gpi_restorePrnText(uint8_t *retbuf) {
|
||||
// read printer text and send to slave, size of retbuf == 64
|
||||
|
||||
// always read from [0] because this is the oldest (Fifo)
|
||||
// then move all text lines down by one and dec pointer
|
||||
int pp = SharedMemBuffer::getDataConst()->prn.pDataBuff;
|
||||
|
||||
uint8_t nn, pp=pPrnDataBuff;
|
||||
|
||||
if (pp==0) // next free memory block with 64byte each
|
||||
return 1; // no text in buffer
|
||||
|
||||
if (pp > 0) { // next free memory block with 64byte each
|
||||
// example: pp=5: then buffers [0...4] are occupied
|
||||
|
||||
for (nn=0; nn<MAXNROF_PRNBYTES; nn++)
|
||||
retbuf[nn] = uint8_t (Sdata_PRN_TEXT[0][nn]); // restore oldest text
|
||||
memcpy((char *)retbuf, // restore oldest text
|
||||
(char const *)(&SharedMemBuffer::getData()->Sdata.PRN_TEXT[0][0]),
|
||||
sizeof(SharedMemBuffer::getDataConst()->Sdata.PRN_TEXT[0]));
|
||||
|
||||
// now copy textline [1] to [0], then
|
||||
// copy textline [2] to [1], then
|
||||
// copy textline [3] to [2] .... upto [pp-1] to [pp-2]
|
||||
// hint: copying from 9....0 would delete all strings!!!!!!
|
||||
|
||||
for (nn=0; nn<(pp-1); nn++)
|
||||
tslib_strcpy(Sdata_PRN_TEXT[nn+1], Sdata_PRN_TEXT[nn], MAXNROF_PRNBYTES);
|
||||
if (pPrnDataBuff>0)
|
||||
pPrnDataBuff--;
|
||||
pp=pPrnDataBuff;
|
||||
for (int nn=0; nn < (pp-1); nn++) {
|
||||
memmove((char *)(&SharedMemBuffer::getData()->Sdata.PRN_TEXT[nn+1][0]),
|
||||
(char const *)(&SharedMemBuffer::getDataConst()->Sdata.PRN_TEXT[nn][0]),
|
||||
sizeof(SharedMemBuffer::getDataConst()->Sdata.PRN_TEXT[0]));
|
||||
}
|
||||
|
||||
if (SharedMemBuffer::getDataConst()->prn.pDataBuff > 0) {
|
||||
SharedMemBuffer::getData()->prn.pDataBuff--;
|
||||
}
|
||||
|
||||
pp = SharedMemBuffer::getDataConst()->prn.pDataBuff;
|
||||
// example: pp=4: then buffers [0...3] are still occupied, pp=0: all buffers empty
|
||||
|
||||
// now clear highest copyed line (which got free now)
|
||||
tslib_strclr(Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES);
|
||||
clear(SharedMemBuffer::getData()->Sdata.PRN_TEXT[pp]);
|
||||
|
||||
// optionally: clear all remaining higher lines:
|
||||
for (nn=(pp+1); nn<MAXNROF_PRNBLOCKS; nn++)
|
||||
tslib_strclr(Sdata_PRN_TEXT[nn], 0, MAXNROF_PRNBYTES);
|
||||
|
||||
for (int nn = (pp+1); nn < MAXNROF_PRNBLOCKS; nn++) {
|
||||
clear(SharedMemBuffer::getData()->Sdata.PRN_TEXT[nn]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1; // no text in buffer
|
||||
}
|
||||
|
||||
uint8_t gpi_chk4remainingText(void)
|
||||
{
|
||||
uint8_t gpi_chk4remainingText(void) {
|
||||
// retval: 0: no more textline left (to send) >0: nr of 64byte-blocks
|
||||
return (pPrnDataBuff);
|
||||
return SharedMemBuffer::getDataConst()->prn.pDataBuff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// 11.4.23 neu, Kommando direkt an "FastDevice"-protokoll senden, nicht mehr umsetzen
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// short command, 4 data bytes
|
||||
static uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
||||
|
||||
static uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
||||
static uint8_t p_nextFDcmdsInQueue;
|
||||
/* convention: use simple (not rotating) FIFO Stack:
|
||||
Example: nrOfCmdsInQueue=4 then
|
||||
nextAsynchsendCmd0[0]=cmd1 // was stored as first
|
||||
@@ -483,180 +314,144 @@ Example: nrOfCmdsInQueue=4 then
|
||||
nrOfCmdsInQueue=3 now
|
||||
*/
|
||||
|
||||
|
||||
void sendFDcmd_clrStack(void)
|
||||
{
|
||||
uint8_t nn;
|
||||
for (nn=0; nn<FDCMD_STACKDEPTH; nn++)
|
||||
{
|
||||
nextFDwrCmd[nn]=0;
|
||||
nextFDrdCmd[nn]=0;
|
||||
nextFDblkNr[nn]=0;
|
||||
nextFDpara1[nn]=0;
|
||||
nextFDpara2[nn]=0;
|
||||
nextFDpara3[nn]=0;
|
||||
nextFDpara4[nn]=0;
|
||||
}
|
||||
p_nextFDcmdsInQueue=0;
|
||||
void sendFDcmd_clrStack(void) {
|
||||
clear(SharedMemBuffer::getData()->FDShort.wrCmd);
|
||||
clear(SharedMemBuffer::getData()->FDShort.rdCmd);
|
||||
clear(SharedMemBuffer::getData()->FDShort.blkNr);
|
||||
clear(SharedMemBuffer::getData()->FDShort.para1);
|
||||
clear(SharedMemBuffer::getData()->FDShort.para2);
|
||||
clear(SharedMemBuffer::getData()->FDShort.para3);
|
||||
clear(SharedMemBuffer::getData()->FDShort.para4);
|
||||
SharedMemBuffer::getData()->FDShort.cmdsInQueue = 0;
|
||||
}
|
||||
|
||||
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4)
|
||||
{
|
||||
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum,
|
||||
uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4) {
|
||||
// write Command to memory, wait for transport
|
||||
if (p_nextFDcmdsInQueue>=FDCMD_STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
nextFDwrCmd[p_nextFDcmdsInQueue]=nextWrCmd;
|
||||
nextFDrdCmd[p_nextFDcmdsInQueue]=nextRdCmd;
|
||||
nextFDblkNr[p_nextFDcmdsInQueue]=blockNum;
|
||||
nextFDpara1[p_nextFDcmdsInQueue]=dat1;
|
||||
nextFDpara2[p_nextFDcmdsInQueue]=dat2;
|
||||
nextFDpara3[p_nextFDcmdsInQueue]=dat3;
|
||||
nextFDpara4[p_nextFDcmdsInQueue]=dat4;
|
||||
//qDebug() << "data with 4 data byte saved, pp=" << nrOfCmds4InQueue;
|
||||
//qDebug() << " dat1=" << nextCmd4para1[nrOfCmds4InQueue] << " dat2=" << nextCmd4para2[nrOfCmds4InQueue]
|
||||
// << " dat3=" << nextCmd4para3[nrOfCmds4InQueue] << " dat4=" << nextCmd4para4[nrOfCmds4InQueue];
|
||||
p_nextFDcmdsInQueue++;
|
||||
int const c = SharedMemBuffer::getDataConst()->FDShort.cmdsInQueue;
|
||||
if (c < FDCMD_STACKDEPTH) {
|
||||
SharedMemBuffer::getData()->FDShort.wrCmd[c] = nextWrCmd;
|
||||
SharedMemBuffer::getData()->FDShort.rdCmd[c] = nextRdCmd;
|
||||
SharedMemBuffer::getData()->FDShort.blkNr[c] = blockNum;
|
||||
SharedMemBuffer::getData()->FDShort.para1[c] = dat1;
|
||||
SharedMemBuffer::getData()->FDShort.para2[c] = dat2;
|
||||
SharedMemBuffer::getData()->FDShort.para3[c] = dat3;
|
||||
SharedMemBuffer::getData()->FDShort.para4[c] = dat4;
|
||||
SharedMemBuffer::getData()->FDShort.cmdsInQueue = (c + 1);
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
qCritical() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
|
||||
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
|
||||
{
|
||||
uint8_t nn, ll;
|
||||
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum,
|
||||
uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4) {
|
||||
|
||||
if (p_nextFDcmdsInQueue==0 || p_nextFDcmdsInQueue>FDCMD_STACKDEPTH)
|
||||
return false; // not possible
|
||||
int const c = SharedMemBuffer::getDataConst()->FDShort.cmdsInQueue;
|
||||
|
||||
*nextWrCmd=nextFDwrCmd[0];
|
||||
*nextRdCmd=nextFDrdCmd[0];
|
||||
*blockNum=nextFDblkNr[0];
|
||||
*dat1=nextFDpara1[0];
|
||||
*dat2=nextFDpara2[0];
|
||||
*dat3=nextFDpara3[0];
|
||||
*dat4=nextFDpara4[0];
|
||||
//qDebug() << "cmd4 restored to send from [0]; pp=" << nrOfCmds4InQueue;
|
||||
//qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] <<
|
||||
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
|
||||
if ((c > 0) && (c <= FDCMD_STACKDEPTH)) {
|
||||
*nextWrCmd = SharedMemBuffer::getDataConst()->FDShort.wrCmd[c];
|
||||
*nextRdCmd = SharedMemBuffer::getDataConst()->FDShort.rdCmd[c];
|
||||
*blockNum = SharedMemBuffer::getDataConst()->FDShort.blkNr[c];
|
||||
*dat1 = SharedMemBuffer::getDataConst()->FDShort.para1[c];
|
||||
*dat2 = SharedMemBuffer::getDataConst()->FDShort.para2[c];
|
||||
*dat3 = SharedMemBuffer::getDataConst()->FDShort.para3[c];
|
||||
*dat4 = SharedMemBuffer::getDataConst()->FDShort.para4[c];
|
||||
|
||||
// move Puffer down by one element
|
||||
if (FDCMD_STACKDEPTH>0)
|
||||
ll=FDCMD_STACKDEPTH-1;
|
||||
else
|
||||
ll=0;
|
||||
for (nn=0; nn<ll; nn++)
|
||||
{
|
||||
nextFDwrCmd[nn]=nextFDwrCmd[nn+1];
|
||||
nextFDrdCmd[nn]=nextFDrdCmd[nn+1];
|
||||
nextFDblkNr[nn]=nextFDblkNr[nn+1];
|
||||
nextFDpara1[nn]=nextFDpara1[nn+1];
|
||||
nextFDpara2[nn]=nextFDpara2[nn+1];
|
||||
nextFDpara3[nn]=nextFDpara3[nn+1];
|
||||
nextFDpara4[nn]=nextFDpara4[nn+1];
|
||||
for (int m = 0; m < c-1; ++m) {
|
||||
int const n = m + 1;
|
||||
SharedMemBuffer::getData()->FDShort.wrCmd[m] = SharedMemBuffer::getDataConst()->FDShort.wrCmd[n];
|
||||
SharedMemBuffer::getData()->FDShort.rdCmd[m] = SharedMemBuffer::getDataConst()->FDShort.rdCmd[n];
|
||||
SharedMemBuffer::getData()->FDShort.blkNr[m] = SharedMemBuffer::getDataConst()->FDShort.blkNr[n];
|
||||
SharedMemBuffer::getData()->FDShort.para1[m] = SharedMemBuffer::getDataConst()->FDShort.para1[n];
|
||||
SharedMemBuffer::getData()->FDShort.para2[m] = SharedMemBuffer::getDataConst()->FDShort.para2[n];
|
||||
SharedMemBuffer::getData()->FDShort.para3[m] = SharedMemBuffer::getDataConst()->FDShort.para3[n];
|
||||
SharedMemBuffer::getData()->FDShort.para4[m] = SharedMemBuffer::getDataConst()->FDShort.para4[n];
|
||||
}
|
||||
if (p_nextFDcmdsInQueue>0)
|
||||
p_nextFDcmdsInQueue--;
|
||||
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
|
||||
SharedMemBuffer::getData()->FDShort.cmdsInQueue = c - 1;
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
uint8_t check4FDshortCmd(void)
|
||||
{
|
||||
// returns number of waiting command
|
||||
return p_nextFDcmdsInQueue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// long command, 64 data bytes
|
||||
static uint8_t longFDwrCmd[FDLONG_STACKDEPTH];
|
||||
static uint8_t longFDrdCmd[FDLONG_STACKDEPTH];
|
||||
static uint8_t longFDblkNr[FDLONG_STACKDEPTH];
|
||||
static uint8_t longFDlength[FDLONG_STACKDEPTH];
|
||||
|
||||
static uint8_t longFDpara[FDLONG_STACKDEPTH][64];
|
||||
static uint8_t p_longFDcmdsInQueue;
|
||||
|
||||
|
||||
void longFDcmd_clrStack(void)
|
||||
{
|
||||
uint8_t nn, mm;
|
||||
for (nn=0; nn<FDLONG_STACKDEPTH; nn++)
|
||||
{
|
||||
longFDwrCmd[nn]=0;
|
||||
longFDrdCmd[nn]=0;
|
||||
longFDblkNr[nn]=0;
|
||||
longFDlength[nn]=0;
|
||||
for (mm=0; mm<64; mm++)
|
||||
longFDpara[nn][mm]=0;
|
||||
}
|
||||
p_longFDcmdsInQueue=0;
|
||||
return false; // not possible
|
||||
}
|
||||
|
||||
uint8_t check4FDshortCmd(void) { // returns number of waiting command, max FDCMD_STACKDEPTH
|
||||
return SharedMemBuffer::getDataConst()->FDShort.cmdsInQueue;
|
||||
}
|
||||
|
||||
|
||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data)
|
||||
{
|
||||
uint8_t check4freeFDshortCmd(void) { // returns number of free places in short-command stack
|
||||
return FDCMD_STACKDEPTH - SharedMemBuffer::getDataConst()->FDShort.cmdsInQueue;
|
||||
}
|
||||
|
||||
void longFDcmd_clrStack(void) {
|
||||
clear(SharedMemBuffer::getData()->FDLong.wrCmd);
|
||||
clear(SharedMemBuffer::getData()->FDLong.rdCmd);
|
||||
clear(SharedMemBuffer::getData()->FDLong.blkNr);
|
||||
clear(SharedMemBuffer::getData()->FDLong.length);
|
||||
clear(SharedMemBuffer::getData()->FDLong.para);
|
||||
SharedMemBuffer::getData()->FDLong.cmdsInQueue = 0;
|
||||
}
|
||||
|
||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum,
|
||||
uint8_t length, uint8_t const *data) {
|
||||
// write Command to memory, wait for transport
|
||||
// data buffer size always 64! data[64], padded with 0
|
||||
uint8_t nn;
|
||||
if (p_longFDcmdsInQueue>=FDLONG_STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
longFDwrCmd[p_longFDcmdsInQueue]=nextWrCmd;
|
||||
longFDrdCmd[p_longFDcmdsInQueue]=nextRdCmd;
|
||||
longFDblkNr[p_longFDcmdsInQueue]=blockNum;
|
||||
longFDlength[p_longFDcmdsInQueue]=length;
|
||||
for (nn=0; nn<64; nn++)
|
||||
longFDpara[p_longFDcmdsInQueue][nn]=data[nn];
|
||||
int const c = SharedMemBuffer::getDataConst()->FDLong.cmdsInQueue;
|
||||
|
||||
p_longFDcmdsInQueue++;
|
||||
if (c > 0 && c <= FDLONG_STACKDEPTH) {
|
||||
SharedMemBuffer::getData()->FDLong.wrCmd[c] = nextWrCmd;
|
||||
SharedMemBuffer::getData()->FDLong.rdCmd[c] = nextRdCmd;
|
||||
SharedMemBuffer::getData()->FDLong.blkNr[c] = blockNum;
|
||||
SharedMemBuffer::getData()->FDLong.length[c] = length;
|
||||
memcpy((char *)SharedMemBuffer::getData()->FDLong.para[c],
|
||||
(char const *)data,
|
||||
sizeof(SharedMemBuffer::getDataConst()->FDLong.para[0]));
|
||||
|
||||
SharedMemBuffer::getData()->FDLong.cmdsInQueue = c + 1;
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
qCritical() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
|
||||
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data)
|
||||
{
|
||||
uint8_t nn, mm, ll;
|
||||
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum,
|
||||
uint8_t *length, uint8_t *data) {
|
||||
|
||||
if (p_longFDcmdsInQueue==0 || p_longFDcmdsInQueue>FDLONG_STACKDEPTH)
|
||||
return false; // not possible
|
||||
int const c = SharedMemBuffer::getDataConst()->FDLong.cmdsInQueue;
|
||||
|
||||
*nextWrCmd= longFDwrCmd[0];
|
||||
*nextRdCmd= longFDrdCmd[0];
|
||||
*blockNum = longFDblkNr[0];
|
||||
*length = longFDlength[0];
|
||||
for (mm=0; mm<64; mm++)
|
||||
data[mm] = longFDpara[0][mm];
|
||||
if (c > 0 && c <= FDLONG_STACKDEPTH) {
|
||||
*nextWrCmd = SharedMemBuffer::getDataConst()->FDLong.wrCmd[c];
|
||||
*nextRdCmd = SharedMemBuffer::getDataConst()->FDLong.rdCmd[c];
|
||||
*blockNum = SharedMemBuffer::getDataConst()->FDLong.blkNr[c];
|
||||
*length = SharedMemBuffer::getDataConst()->FDLong.length[c];
|
||||
memcpy((char *)data,
|
||||
(char const *)SharedMemBuffer::getDataConst()->FDLong.para[c],
|
||||
sizeof(SharedMemBuffer::getDataConst()->FDLong.para[0]));
|
||||
|
||||
// move Puffer down by one element
|
||||
if (FDLONG_STACKDEPTH>0)
|
||||
ll=FDLONG_STACKDEPTH-1;
|
||||
else
|
||||
ll=0;
|
||||
for (nn=0; nn<ll; nn++)
|
||||
{
|
||||
longFDwrCmd[nn] = longFDwrCmd[nn+1];
|
||||
longFDrdCmd[nn] = longFDrdCmd[nn+1];
|
||||
longFDblkNr[nn] = longFDblkNr[nn+1];
|
||||
longFDlength[nn] = longFDlength[nn+1];
|
||||
|
||||
for (mm=0; mm<64; mm++)
|
||||
longFDpara[nn][mm] = longFDpara[nn+1][mm];
|
||||
|
||||
for (int m = 0; m < c-1; ++m) {
|
||||
int const n = m + 1;
|
||||
SharedMemBuffer::getData()->FDLong.wrCmd[m] = SharedMemBuffer::getDataConst()->FDLong.wrCmd[n];
|
||||
SharedMemBuffer::getData()->FDLong.rdCmd[m] = SharedMemBuffer::getDataConst()->FDLong.rdCmd[n];
|
||||
SharedMemBuffer::getData()->FDLong.blkNr[m] = SharedMemBuffer::getDataConst()->FDLong.blkNr[n];
|
||||
SharedMemBuffer::getData()->FDLong.length[m] = SharedMemBuffer::getData()->FDLong.length[n];
|
||||
memcpy((char *)SharedMemBuffer::getData()->FDLong.para[m],
|
||||
(char const *)SharedMemBuffer::getData()->FDLong.para[n],
|
||||
sizeof(SharedMemBuffer::getDataConst()->FDLong.para[0]));
|
||||
}
|
||||
if (p_longFDcmdsInQueue>0)
|
||||
p_longFDcmdsInQueue--;
|
||||
|
||||
SharedMemBuffer::getData()->FDLong.cmdsInQueue = c - 1;
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
qCritical() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
|
||||
uint8_t check4FDlongCmd(void)
|
||||
{
|
||||
// returns number of waiting command
|
||||
return p_longFDcmdsInQueue;
|
||||
uint8_t check4FDlongCmd(void) { // returns number of waiting command
|
||||
return SharedMemBuffer::getDataConst()->FDLong.cmdsInQueue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t check4freeFDlongCmd(void) { // returns number of free places in command stack
|
||||
return FDLONG_STACKDEPTH - SharedMemBuffer::getDataConst()->FDLong.cmdsInQueue;
|
||||
}
|
||||
|
15
src/serial_port_thread.cpp
Normal file
15
src/serial_port_thread.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "serial_port_thread.h"
|
||||
|
||||
|
||||
SerialPortThread::SerialPortThread(QObject *parent)
|
||||
: QThread(parent) {
|
||||
this->setObjectName("SerialPortThread");
|
||||
}
|
||||
|
||||
SerialPortThread::~SerialPortThread() {
|
||||
m_loop.quit();
|
||||
}
|
||||
|
||||
void SerialPortThread::run() {
|
||||
m_loop.exec();
|
||||
}
|
244
src/serial_port_worker.cpp
Normal file
244
src/serial_port_worker.cpp
Normal file
@@ -0,0 +1,244 @@
|
||||
#include "serial_port_worker.h"
|
||||
#include "serial_port_thread.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
|
||||
std::atomic<uint8_t> Command::m_nextSendBufferIndex{0};
|
||||
std::atomic<uint8_t> Command::m_nextRecvBufferIndex{0};
|
||||
char Command::m_sendBuffers[256][SEND_BLOCK_SIZE]{{0}};
|
||||
char Command::m_recvBuffers[256][SEND_BLOCK_SIZE]{{0}};
|
||||
|
||||
uint32_t Command::getNextCommandPriority(uint8_t priorityClass) {
|
||||
static std::atomic<std::uint32_t> priority_1{0};
|
||||
static std::atomic<std::uint32_t> priority_2{1000000000};
|
||||
static std::atomic<std::uint32_t> priority_3{2000000000};
|
||||
static std::atomic<std::uint32_t> priority_4{3000000000};
|
||||
switch (priorityClass) {
|
||||
case PRIORITY_1:
|
||||
return priority_1.fetch_add(1);
|
||||
case PRIORITY_2:
|
||||
return priority_2.fetch_add(1);
|
||||
case PRIORITY_3:
|
||||
return priority_3.fetch_add(1);
|
||||
case PRIORITY_4:
|
||||
return priority_4.fetch_add(1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *Command::getNextSendBuffer() {
|
||||
uint8_t const nextIndex = m_nextSendBufferIndex.fetch_add(1);
|
||||
return &m_sendBuffers[nextIndex][0];
|
||||
}
|
||||
|
||||
char *Command::getNextRecvBuffer() {
|
||||
uint8_t const nextIndex = m_nextRecvBufferIndex.fetch_add(1);
|
||||
return &m_recvBuffers[nextIndex][0];
|
||||
}
|
||||
|
||||
Command::Command(uint16_t cmdId, uint8_t sendBufferLength,
|
||||
uint8_t recvBufferLength, uint8_t priorityClass)
|
||||
: m_priority(getNextCommandPriority(priorityClass))
|
||||
, m_priorityClass(priorityClass)
|
||||
, m_cmdId(cmdId)
|
||||
, m_sendBuffer(Command::getNextSendBuffer())
|
||||
, m_recvBuffer(Command::getNextRecvBuffer())
|
||||
, m_sendBufferLength(sendBufferLength)
|
||||
, m_recvBufferLength(recvBufferLength) {
|
||||
memset(m_sendBuffer, 0x00, sizeof(m_sendBuffers[0]));
|
||||
}
|
||||
|
||||
Command::Command()
|
||||
: m_priority(0)
|
||||
, m_priorityClass(0)
|
||||
, m_cmdId(0)
|
||||
, m_sendBuffer(0)
|
||||
, m_recvBuffer(0)
|
||||
, m_sendBufferLength(0)
|
||||
, m_recvBufferLength(0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Constructor for SerialPort
|
||||
*
|
||||
* @date 08.11.2022 – first draft.
|
||||
*
|
||||
*/
|
||||
SerialPortWorker::SerialPortWorker(QString portName, enum QSerialPort::BaudRate baudRate, QObject *parent)
|
||||
: QThread(parent)
|
||||
, m_serialPort()
|
||||
, m_serialPortOpened(false)
|
||||
, m_portName(portName)
|
||||
, m_baudRate(baudRate)
|
||||
, m_bytesWritten(0) {
|
||||
this->setObjectName("SerialPortWorker");
|
||||
|
||||
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
|
||||
if (!info.isNull()) {
|
||||
qDebug() << "Name .......... " << info.portName();
|
||||
qDebug() << "Description ... " << info.description();
|
||||
qDebug() << "Manufacturer .. " << info.manufacturer();
|
||||
qDebug() << "SerialNumber .. " << info.serialNumber();
|
||||
if (info.hasProductIdentifier()) {
|
||||
qDebug() << "Product-ID .... " << info.productIdentifier();
|
||||
}
|
||||
if (info.hasVendorIdentifier()) {
|
||||
qDebug() << "Vendor-ID ..... " << info.vendorIdentifier();
|
||||
}
|
||||
qDebug() << "Location ...... " << info.systemLocation();
|
||||
|
||||
if (info.portName() == m_portName) {
|
||||
m_serialPortInfo = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_serialPortInfo.portName() == m_portName) {
|
||||
m_serialPort.setPort(m_serialPortInfo);
|
||||
m_serialPort.setPortName(m_portName);
|
||||
m_serialPort.setDataBits(QSerialPort::Data8);
|
||||
m_serialPort.setParity(QSerialPort::NoParity);
|
||||
m_serialPort.setStopBits(QSerialPort::OneStop);
|
||||
m_serialPort.setFlowControl(QSerialPort::NoFlowControl);
|
||||
m_serialPortOpened = m_serialPort.open(QIODevice::ReadWrite);
|
||||
}
|
||||
}
|
||||
|
||||
SerialPortWorker::~SerialPortWorker() {
|
||||
closeSerialPort();
|
||||
}
|
||||
|
||||
void SerialPortWorker::run() {
|
||||
SerialPortThread serialPortThread;
|
||||
this->moveToThread(&serialPortThread); // not really necessary
|
||||
|
||||
// Note: because this thread is moved to serialPortThread, the event loop
|
||||
// used will be the one of serialPortThread (this-thread does not even have one).
|
||||
// This is the only purpose of serialPortThread.
|
||||
serialPortThread.start();
|
||||
|
||||
connect(&m_serialPort, SIGNAL(readyRead()), this, SLOT(getBytesAvailable()));
|
||||
connect(&m_serialPort, SIGNAL(bytesWritten(qint64)), this, SLOT(getNumberOfBytesWritten(qint64)));
|
||||
|
||||
while (m_serialPortOpened) {
|
||||
Command nextCmd = getNextCommand();
|
||||
if (nextCmd.m_cmdId == Command::QUIT_SENTINEL) {
|
||||
break;
|
||||
}
|
||||
QByteArray data(nextCmd.getNextSendBuffer(), nextCmd.m_sendBufferLength);
|
||||
m_bytesWritten = 0;
|
||||
m_serialPort.write(data);
|
||||
// process events in event loop of associated thread
|
||||
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||
int maxWaitTime = WAIT_TIME_MAX;
|
||||
|
||||
while (maxWaitTime > 0 && m_bytesWritten < (uint32_t)data.size()) {
|
||||
if (!m_serialPort.waitForBytesWritten(100)) { // wait timeout-ms for the bytes to be written
|
||||
// process events in event loop of associated thread
|
||||
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||
maxWaitTime -= TIMEOUT;
|
||||
}
|
||||
}
|
||||
if (m_bytesWritten == (uint32_t)data.size()) { // data written, wait for result
|
||||
if (nextCmd.m_recvBufferLength > 0) {
|
||||
// process events in event loop of associated thread
|
||||
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||
maxWaitTime = WAIT_TIME_MAX;
|
||||
while (maxWaitTime > 0 && m_bytesAvailable < nextCmd.m_recvBufferLength) {
|
||||
if (!m_serialPort.waitForReadyRead(100)) {
|
||||
// process events in event loop of associated thread
|
||||
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||
maxWaitTime -= TIMEOUT;
|
||||
}
|
||||
}
|
||||
uint32_t const bytesAvailable = m_bytesAvailable;
|
||||
if (bytesAvailable == nextCmd.m_recvBufferLength) {
|
||||
QByteArray result = m_serialPort.read(bytesAvailable);
|
||||
if (!result.isEmpty() && ((uint32_t)result.size() == bytesAvailable)) {
|
||||
memcpy(nextCmd.m_recvBuffer, result.data(), bytesAvailable);
|
||||
insertResult(nextCmd);
|
||||
}
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
} // while (m_serialPortOpened)
|
||||
|
||||
serialPortThread.quit();
|
||||
serialPortThread.wait();
|
||||
}
|
||||
|
||||
bool SerialPortWorker::openSerialPort() {
|
||||
if (!m_serialPortOpened) {
|
||||
return m_serialPort.open(QIODevice::ReadWrite);
|
||||
}
|
||||
return false; // opening twice is not allowed
|
||||
}
|
||||
|
||||
void SerialPortWorker::closeSerialPort() {
|
||||
if (m_serialPortOpened) {
|
||||
m_serialPort.close();
|
||||
m_serialPortOpened = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SerialPortWorker::quit() {
|
||||
Command cmd(Command::QUIT_SENTINEL, 0, 0, Command::PRIORITY_1);
|
||||
insertCommand(cmd);
|
||||
}
|
||||
|
||||
void SerialPortWorker::insertCommand(Command const &cmd) {
|
||||
{ std::lock_guard<std::mutex> lock(m_sendQueueMutex);
|
||||
m_sendQueue.push(cmd);
|
||||
} // release lock
|
||||
m_sendQueueCondVar.notify_one();
|
||||
}
|
||||
|
||||
Command SerialPortWorker::getNextCommand() {
|
||||
Command nextCmd;
|
||||
{ std::unique_lock<std::mutex> lock(m_sendQueueMutex);
|
||||
m_sendQueueCondVar.wait(lock, [this]{ return !this->m_sendQueue.empty(); });
|
||||
nextCmd = m_sendQueue.top();
|
||||
m_sendQueue.pop();
|
||||
} // release lock
|
||||
return nextCmd;
|
||||
}
|
||||
|
||||
void SerialPortWorker::insertResult(Command const &result) {
|
||||
{ std::lock_guard<std::mutex> lock(m_recvQueueMutex);
|
||||
m_recvQueue.push_back(result);
|
||||
} // release lock
|
||||
m_recvQueueCondVar.notify_one();
|
||||
}
|
||||
|
||||
bool SerialPortWorker::getNextResult(Command &nextResult, int timeout) {
|
||||
bool timed_out = false;
|
||||
{ std::unique_lock<std::mutex> lock(m_recvQueueMutex);
|
||||
if (m_recvQueueCondVar.wait_for(lock, std::chrono::milliseconds(timeout),
|
||||
[this]{ return !this->m_recvQueue.empty(); })) {
|
||||
nextResult = m_recvQueue.front();
|
||||
m_recvQueue.pop_front();
|
||||
return true;
|
||||
} else {
|
||||
timed_out = true;
|
||||
}
|
||||
} // release lock
|
||||
return (timed_out == false);
|
||||
}
|
||||
|
||||
void SerialPortWorker::getBytesAvailable() {
|
||||
m_bytesAvailable += m_serialPort.bytesAvailable();
|
||||
}
|
||||
|
||||
bool SerialPortWorker::getNumberOfBytesWritten(qint64 bytesWritten) {
|
||||
if (bytesWritten > 0) {
|
||||
m_bytesWritten += (uint32_t)bytesWritten;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
123
src/shared_mem_buffer.cpp
Normal file
123
src/shared_mem_buffer.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <atomic>
|
||||
|
||||
#ifdef QT_POSIX_IPC
|
||||
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
||||
// option to the Qt configure script. If it is enabled, the QT_POSIX_IPC
|
||||
// macro will be defined. -> we use SystemV shared memory
|
||||
#error "QT_POSIX_IPC defined"
|
||||
#else
|
||||
#include <sys/ipc.h> // ftok
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define PROCESS_SHARED (PTHREAD_PROCESS_SHARED)
|
||||
|
||||
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
||||
|
||||
QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||
static QSharedMemory shMem;
|
||||
if (size > 0) {
|
||||
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||
shMem.setKey(fkey);
|
||||
if (!shMem.isAttached()) {
|
||||
if (shMem.create(size)) {
|
||||
// the creator is the owner of the shared-memory segment
|
||||
SharedMemBuffer *shm = (SharedMemBuffer *)(shMem.data());
|
||||
if (shm) {
|
||||
shm->init = 0;
|
||||
// mark the shm
|
||||
memset(shm->appName, 0x00, sizeof(shm->appName));
|
||||
strncpy(shm->appName,
|
||||
QCoreApplication::applicationName().toLocal8Bit().constData(),
|
||||
sizeof(shm->appName)-1);
|
||||
shm->pid = getpid();
|
||||
|
||||
// create condition variables plus associated mutexes for
|
||||
// sending/receiving commands to dc
|
||||
int r = 0;
|
||||
if ((r = pthread_mutexattr_init(&shm->sndMtxA)) != 0) {
|
||||
qCritical() << "init mutex attribute"
|
||||
<< strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_mutexattr_setpshared(
|
||||
&shm->sndMtxA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||
qCritical() << "set s-mutex attribute to process shared"
|
||||
<< strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_mutex_init(&shm->sndMtx,
|
||||
&shm->sndMtxA) != 0)) {
|
||||
qCritical() << "init s-mutex" << strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_condattr_init(&shm->sndCndA) != 0)) {
|
||||
qCritical() << "init s-mutex" << strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_condattr_setpshared(
|
||||
&shm->sndCndA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||
qCritical() << "init s-cond attribute to process shared"
|
||||
<< strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_cond_init(&shm->sndCndV,
|
||||
&shm->sndCndA) != 0)) {
|
||||
qCritical() << "init s-condvar" << strerror(errno) << r;
|
||||
}
|
||||
|
||||
if ((r = pthread_mutexattr_init(&shm->rcvMtxA)) != 0) {
|
||||
qCritical() << "init r-mutex attribute"
|
||||
<< strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_mutexattr_setpshared(
|
||||
&shm->rcvMtxA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||
qCritical() << "set r-mutex attribute to process shared"
|
||||
<< strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_mutex_init(&shm->rcvMtx,
|
||||
&shm->rcvMtxA) != 0)) {
|
||||
qCritical() << "init r-mutex" << strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_condattr_init(&shm->rcvCndA) != 0)) {
|
||||
qCritical() << "init r-mutex" << strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_condattr_setpshared(
|
||||
&shm->rcvCndA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||
qCritical() << "init r-cond attribute to process shared"
|
||||
<< strerror(errno) << r;
|
||||
}
|
||||
if ((r == 0) &&
|
||||
(r = pthread_cond_init(&shm->rcvCndV,
|
||||
&shm->rcvCndA) != 0)) {
|
||||
qCritical() << "init s-condvar" << strerror(errno) << r;
|
||||
}
|
||||
shm->init = 1;
|
||||
}
|
||||
return &shMem;
|
||||
} else {
|
||||
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||
if (shMem.attach()) {
|
||||
return &shMem;
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||
<< shMem.error() << shMem.errorString();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return &shMem;
|
||||
}
|
1530
src/storeINdata.cpp
1530
src/storeINdata.cpp
File diff suppressed because it is too large
Load Diff
@@ -76,6 +76,23 @@ uint8_t uint2uchar(uint16_t uival, bool getHighB)
|
||||
}
|
||||
|
||||
|
||||
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr)
|
||||
{
|
||||
// getBytNr: 0=LSB 3=MSB
|
||||
uint32_t ultmp=ulval;
|
||||
if (getBytNr==0)
|
||||
return uint8_t(ultmp);
|
||||
ultmp>>=8;
|
||||
if (getBytNr==1)
|
||||
return uint8_t(ultmp);
|
||||
ultmp>>=8;
|
||||
if (getBytNr==2)
|
||||
return uint8_t(ultmp);
|
||||
ultmp>>=8;
|
||||
return uint8_t(ultmp);
|
||||
|
||||
}
|
||||
|
||||
void delay(uint16_t MilliSec)
|
||||
{
|
||||
QThread::msleep(uint32_t(MilliSec));
|
||||
|
Reference in New Issue
Block a user