Compare commits
45 Commits
1.0.0
...
gerhard-en
Author | SHA1 | Date | |
---|---|---|---|
4cc964e8c2 | |||
f910b7d057 | |||
5dd90e9597 | |||
47f09067ea | |||
65163354bd | |||
5f88c8f856 | |||
4efbbcbb5a | |||
1155b83ca9 | |||
631550b55e | |||
9e5c379e8a | |||
6b9e795206 | |||
b7ff6dcdbe | |||
2025a75d56 | |||
6176285b89 | |||
0344150950 | |||
68813a49c5 | |||
8e287e3163 | |||
fd58f41c87 | |||
ece75887e2 | |||
cee4caf77d | |||
6b2830ee83 | |||
cd4bddd169 | |||
8a380c9845 | |||
23619543b2 | |||
be16fe4981 | |||
cf621c02bd | |||
ee26eef50f | |||
78700e7bea
|
|||
3d3bc88269
|
|||
ae9a5b0920
|
|||
3cdd11cc36
|
|||
7746f22d01
|
|||
27f1a47e23
|
|||
eed4c278f8 | |||
1dd368dad3 | |||
|
53054ca2d0 | ||
|
ca067b0246 | ||
|
7c4fcab33c | ||
|
7628ec0d5f | ||
|
c89decdeae | ||
|
40848344f5 | ||
|
4eabff268e | ||
|
226f6d91c2 | ||
|
447d1ceb54 | ||
|
79868787cf |
@@ -4,6 +4,8 @@ QT +=network
|
||||
# for TCP-IP
|
||||
|
||||
TARGET = CArunGui
|
||||
TEMPLATE = app
|
||||
|
||||
VERSION = "1.0.0"
|
||||
|
||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||
@@ -50,7 +52,3 @@ HEADERS += \
|
||||
datei.h \
|
||||
plugin.h
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
@@ -9,7 +9,8 @@ char MainWindow::loadPlugIn(char lade1_entlade2)
|
||||
//pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse
|
||||
//pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5
|
||||
//pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows
|
||||
pluginLoader->setFileName("CAmaster.dll"); // for windows
|
||||
//pluginLoader->setFileName("CAmaster.dll"); // for windows
|
||||
pluginLoader->setFileName("/usr/lib/libCAmaster.so"); // for ptu5
|
||||
|
||||
if (lade1_entlade2==2)
|
||||
{
|
||||
|
@@ -93,7 +93,9 @@ HEADERS += \
|
||||
$${PWD}/include/sendWRcmd.h \
|
||||
$${PWD}/include/storeINdata.h \
|
||||
$${PWD}/include/tslib.h \
|
||||
$${PWD}/include/shared_mem_buffer.h
|
||||
$${PWD}/include/shared_mem_buffer.h \
|
||||
$${PWD}/include/download_thread.h \
|
||||
$${PWD}/include/reporting_thread.h
|
||||
|
||||
SOURCES += \
|
||||
$${PWD}/src/com.cpp \
|
||||
@@ -107,7 +109,9 @@ SOURCES += \
|
||||
$${PWD}/src/sendWRcmd.cpp \
|
||||
$${PWD}/src/storeINdata.cpp \
|
||||
$${PWD}/src/tslib.cpp \
|
||||
$${PWD}/src/shared_mem_buffer.cpp
|
||||
$${PWD}/src/shared_mem_buffer.cpp \
|
||||
$${PWD}/src/download_thread.cpp \
|
||||
$${PWD}/src/reporting_thread.cpp
|
||||
|
||||
|
||||
# INTERFACE = DeviceController
|
||||
@@ -126,9 +130,3 @@ SOURCES += \
|
||||
# version.variable_out = HEADERS
|
||||
# QMAKE_EXTRA_COMPILERS += version
|
||||
# QMAKE_CLEAN += $${PWD}/include/version.h
|
||||
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
1
config/comport.csv
Normal file
1
config/comport.csv
Normal file
@@ -0,0 +1 @@
|
||||
s,5,115200,ttymxc2,2,
|
|
@@ -4,6 +4,8 @@ QT +=network
|
||||
# for TCP-IP
|
||||
|
||||
TARGET = dCArun
|
||||
TEMPLATE = app
|
||||
|
||||
VERSION = "1.0.0"
|
||||
|
||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||
@@ -53,8 +55,3 @@ HEADERS += \
|
||||
win01_com.h \
|
||||
datei.h \
|
||||
plugin.h
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
@@ -9,7 +9,8 @@ char MainWindow::loadPlugIn(char lade1_entlade2)
|
||||
//pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse
|
||||
//pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5
|
||||
//pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows
|
||||
pluginLoader->setFileName("CAmaster.dll"); // for windows
|
||||
//pluginLoader->setFileName("CAmaster.dll"); // for windows
|
||||
pluginLoader->setFileName("/usr/lib/libCAmaster.so"); // for ptu5
|
||||
|
||||
if (lade1_entlade2==2)
|
||||
{
|
||||
|
@@ -133,8 +133,8 @@
|
||||
#define SENDCOMBINED 0
|
||||
|
||||
|
||||
|
||||
|
||||
class hwinf;
|
||||
class DownloadThread;
|
||||
class T_datif : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -165,13 +165,15 @@ class T_datif : public QObject
|
||||
T_prot *myDCIF;
|
||||
QTimer *datif_trigger;
|
||||
uint8_t selectedSlaveAddr;
|
||||
DownloadThread *m_downloadThread;
|
||||
hwinf *m_hw;
|
||||
|
||||
private slots:
|
||||
char datif_cycleSend();
|
||||
void StoredRecData();
|
||||
|
||||
public:
|
||||
T_datif(QObject *parent = nullptr);
|
||||
T_datif(hwinf *hw, QObject *parent = nullptr);
|
||||
|
||||
void resetChain(void);
|
||||
char isPortOpen(void);
|
||||
|
37
include/download_thread.h
Normal file
37
include/download_thread.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef DOWNLOAD_THREAD_H_INCLUDED
|
||||
#define DOWNLOAD_THREAD_H_INCLUDED
|
||||
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
class hwinf;
|
||||
class DownloadThread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||
|
||||
DownloadThread(hwinf *hw);
|
||||
~DownloadThread();
|
||||
|
||||
protected:
|
||||
// download thread does not have a running event queue, and therefore
|
||||
// no slots. signals work the usual way.
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
DownloadResult sendStatus(int ret) const;
|
||||
DownloadResult sendNextAddress(int bNum) const;
|
||||
DownloadResult sendNextDataBlock(QByteArray const &binary, int bNum) const;
|
||||
bool startBootloader() const;
|
||||
bool stopBootloader() const;
|
||||
QByteArray loadBinaryDCFile(QString dcFileName) const;
|
||||
bool resetDeviceController() const;
|
||||
DownloadResult dcDownloadBinary(QByteArray const &b) const;
|
||||
|
||||
hwinf *m_hw;
|
||||
QString m_fileToDownload;
|
||||
};
|
||||
|
||||
#endif // DOWNLOAD_THREAD_H_INCLUDED
|
@@ -40,7 +40,8 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
||||
#include "interfaces.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "runProc.h"
|
||||
|
||||
#include "download_thread.h"
|
||||
#include "reporting_thread.h"
|
||||
|
||||
/*
|
||||
* select Plugin Type here
|
||||
@@ -74,7 +75,8 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
||||
//for CAmaster:
|
||||
|
||||
class QSharedMemory;
|
||||
|
||||
class ReportingThread;
|
||||
class DownloadThread;
|
||||
class hwapi : public QObject,
|
||||
public hwinf
|
||||
{
|
||||
@@ -86,7 +88,8 @@ private:
|
||||
void sub_storeSendingText(QByteArray *buf) const;
|
||||
QTimer *hwapi_TimerPayment;
|
||||
QSharedMemory *m_sharedMem;
|
||||
//QTimer *hwapi_triggerBL;
|
||||
ReportingThread *m_reportingThread;
|
||||
DownloadThread *m_downloadThread;
|
||||
|
||||
public:
|
||||
explicit hwapi(QWidget *parent = nullptr);
|
||||
@@ -1304,8 +1307,47 @@ public:
|
||||
// countOfBills[1] for 10€ and so on
|
||||
|
||||
|
||||
// download device controller
|
||||
bool dcDownloadRequest(QString const &fileToDownload) const override;
|
||||
bool dcDownloadRequested() const override;
|
||||
bool dcDownloadResetRequest() const override;
|
||||
bool dcDownloadRequestAck() const override;
|
||||
bool dcDownloadRunning() const override;
|
||||
bool dcDownloadFinished() override;
|
||||
|
||||
signals:
|
||||
bool dcDownloadReportStart() const override;
|
||||
bool dcDownloadReportRunning() const override;
|
||||
bool dcDownloadReportFinished() override;
|
||||
|
||||
|
||||
bool dcDownloadThreadStart() override;
|
||||
bool dcDownloadThreadRunning() const override;
|
||||
void dcDownloadThreadFinalize(DownloadThread *) override;
|
||||
bool dcDownloadThreadFinished() const override;
|
||||
bool dcDownloadReportThreadStart() override;
|
||||
bool dcDownloadReportThreadRunning() const override;
|
||||
void dcDownloadReportThreadFinalize() override;
|
||||
void dcDownloadReportThreadQuit() override;
|
||||
bool dcDownloadReportThreadFinished() const override;
|
||||
|
||||
QString dcDownloadFileName() const override;
|
||||
bool dcDownloadSetRequested(bool) override;
|
||||
bool dcDownloadSetRunning(bool) override;
|
||||
bool dcDownloadSetFinished(bool) override;
|
||||
void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) override;
|
||||
void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) override;
|
||||
bool dcDownloadGetRequested() const override;
|
||||
bool dcDownloadGetRunning() const override;
|
||||
bool dcDownloadGetFinished() const override;
|
||||
uint16_t dcDownloadGetTotalBlockNumber() const override;
|
||||
uint16_t dcDownloadGetCurrentBlockNumber() const override;
|
||||
|
||||
virtual QObject const *getAPI() override;
|
||||
|
||||
signals: // for download
|
||||
void hwapi_reportDCDownloadStatus(QString const&) const;
|
||||
void hwapi_reportDCDownloadSuccess(QString const&) const;
|
||||
void hwapi_reportDCDownloadFailure(QString const&) const;
|
||||
// already declared in interfaces.h
|
||||
void hwapi_templatePrintFinished_OK(void) const;
|
||||
void hwapi_templatePrintFinished_Err(void) const;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#define INTERFACE_H
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QString>
|
||||
|
||||
|
||||
|
||||
@@ -377,9 +378,28 @@ struct T_changer
|
||||
|
||||
struct T_bna
|
||||
{
|
||||
// reported with STATUS:
|
||||
uint8_t setup; // 0: not 1: got valid parameters from device
|
||||
uint8_t FeatureLevel;
|
||||
uint16_t countryCode; // programmed in EMP
|
||||
uint16_t scalingFactor; // z.B. 5
|
||||
uint8_t decimalPlace;
|
||||
uint8_t pad1;
|
||||
uint16_t stackerCap;
|
||||
uint16_t billSecureLevel;
|
||||
uint8_t hasEscrow;
|
||||
uint8_t accBillTypes[16]; // programmed in EMP z.B. (bit 0..7): 1 2 4 10 20 40 0 0
|
||||
uint16_t currentStackerLevel; // requested number of notes in billbox
|
||||
|
||||
// settings from Master
|
||||
uint16_t intendedAccept; // bit 0 =5€
|
||||
uint16_t pad2;
|
||||
uint16_t billDenomination[16];
|
||||
|
||||
};
|
||||
|
||||
class hwapi;
|
||||
class DownloadThread;
|
||||
class hwinf
|
||||
{
|
||||
|
||||
@@ -1817,6 +1837,9 @@ public:
|
||||
virtual uint8_t prn_getPrintResult() const {
|
||||
return 0;
|
||||
}
|
||||
// return: 0: just printing, wait
|
||||
// 1: OK - last print was succesful
|
||||
// 2: error - not printed
|
||||
|
||||
|
||||
|
||||
@@ -2215,6 +2238,7 @@ public:
|
||||
Q_UNUSED(notesToAccept);
|
||||
}
|
||||
// can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid)
|
||||
// only valid till next start-payment. Cannot add notes which are not activated in Json
|
||||
|
||||
virtual void bna_requestParameters() const {}
|
||||
// send command to DC in order to get static invariable device parameters like currency
|
||||
@@ -2252,9 +2276,61 @@ public:
|
||||
// countOfBills[1] for 10€ and so on
|
||||
|
||||
|
||||
// download device controller
|
||||
virtual bool dcDownloadRequest(QString const &fileToDownload) const {
|
||||
Q_UNUSED(fileToDownload);
|
||||
return false;
|
||||
}
|
||||
virtual bool dcDownloadRequested() const { return false; }
|
||||
virtual bool dcDownloadResetRequest() const { return false; }
|
||||
virtual bool dcDownloadRequestAck() const { return false; }
|
||||
virtual bool dcDownloadRunning() const { return false; }
|
||||
virtual bool dcDownloadFinished() { return false; }
|
||||
|
||||
virtual bool dcDownloadReportStart() const { return false; }
|
||||
virtual bool dcDownloadReportRunning() const { return true; }
|
||||
virtual bool dcDownloadReportFinished() { return true; }
|
||||
|
||||
virtual bool dcDownloadThreadStart() { return false; }
|
||||
virtual bool dcDownloadThreadRunning() const { return true; }
|
||||
virtual void dcDownloadThreadFinalize(DownloadThread *) {}
|
||||
virtual bool dcDownloadThreadFinished() const { return true; }
|
||||
virtual bool dcDownloadReportThreadStart() { return false; }
|
||||
virtual bool dcDownloadReportThreadRunning() const { return true; }
|
||||
virtual void dcDownloadReportThreadFinalize() {}
|
||||
virtual void dcDownloadReportThreadQuit() {}
|
||||
virtual bool dcDownloadReportThreadFinished() const { return true; }
|
||||
|
||||
|
||||
signals:
|
||||
virtual QString dcDownloadFileName() const { return ""; }
|
||||
virtual bool dcDownloadSetRequested(bool requested) {
|
||||
Q_UNUSED(requested); return false;
|
||||
}
|
||||
virtual bool dcDownloadSetRunning(bool running) {
|
||||
Q_UNUSED(running); return false;
|
||||
}
|
||||
virtual bool dcDownloadSetFinished(bool finished) {
|
||||
Q_UNUSED(finished); return false;
|
||||
}
|
||||
virtual void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
|
||||
Q_UNUSED(totalBlockNumber);
|
||||
}
|
||||
virtual void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
|
||||
Q_UNUSED(currentBlockNumber);
|
||||
}
|
||||
virtual bool dcDownloadGetRequested() const { return false; }
|
||||
virtual bool dcDownloadGetRunning() const { return false; }
|
||||
virtual bool dcDownloadGetFinished() const { return false; }
|
||||
virtual uint16_t dcDownloadGetTotalBlockNumber() const { return 0; }
|
||||
virtual uint16_t dcDownloadGetCurrentBlockNumber() const { return 0; }
|
||||
|
||||
virtual QObject const *getAPI() { return nullptr; }
|
||||
|
||||
signals: // for download
|
||||
void hwapi_reportDCDownloadStatus(QString const&) const;
|
||||
void hwapi_reportDCDownloadSuccess(QString const&) const;
|
||||
void hwapi_reportDCDownloadFailure(QString const&) const;
|
||||
|
||||
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
|
||||
void hwapi_templatePrintFinished_OK() const;
|
||||
void hwapi_templatePrintFinished_Err() const;
|
||||
@@ -2335,9 +2411,15 @@ signals:
|
||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.0"
|
||||
// 10.10.2023: added coin changer
|
||||
|
||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.1"
|
||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.1"
|
||||
// 20.10.2023: added bill validator
|
||||
|
||||
// hier dazwischen: Umstellung ALLER Prototypen
|
||||
// hier von =0 auf {} durch Gerhard
|
||||
|
||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.2"
|
||||
// 7.11.2023: bna functions activated
|
||||
|
||||
|
||||
Q_DECLARE_INTERFACE(hwinf, HWINF_iid)
|
||||
|
||||
|
25
include/reporting_thread.h
Normal file
25
include/reporting_thread.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef REPORTING_THREAD_H_INCLUDED
|
||||
#define REPORTING_THREAD_H_INCLUDED
|
||||
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
|
||||
class hwapi;
|
||||
class ReportingThread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReportingThread(hwapi *hw);
|
||||
~ReportingThread();
|
||||
|
||||
protected:
|
||||
// reporting thread does not have a running event queue, and therefore
|
||||
// no slots. signals work the usual way.
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
hwapi *m_hw;
|
||||
QString m_fileToDownload;
|
||||
};
|
||||
|
||||
#endif // REPORTING_THREAD_H_INCLUDED
|
@@ -1,185 +1,12 @@
|
||||
|
||||
#ifndef SENDWRCMDS_DEFS_H
|
||||
#define SENDWRCMDS_DEFS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "tslib.h"
|
||||
#include <QString>
|
||||
|
||||
// asynch. Commands
|
||||
// store OUTPUT commands until time to send
|
||||
// problem: OUT commands are set if a button is pressed or a transaction event happens
|
||||
// so it's never synchron with sending grid
|
||||
// but sending must apply the 100ms time grid as we have to wait for the response before sending the next command!!!
|
||||
|
||||
|
||||
// aug2023: used with setSendCommand0
|
||||
//#define SENDDIRCMD_TestSerial 1
|
||||
//#define SENDDIRCMD_MakeReset 2
|
||||
//#define SENDDIRCMD_setTime 3
|
||||
//#define SENDDIRCMD_setWakeFrequ 4
|
||||
|
||||
//#define SENDDIRCMD_MOVEUP_LOCK 5
|
||||
//#define SENDDIRCMD_MOVEDN_LOCK 6
|
||||
//#define SENDDIRCMD_OPENUP_DOOR 7
|
||||
//#define SENDDIRCMD_OPENDN_DOOR 8
|
||||
|
||||
|
||||
//#define SENDDIRCMD_LEDILLU 9
|
||||
//#define SENDDIRCMD_LEDCOIN 10
|
||||
//#define SENDDIRCMD_LEDTICKET 11
|
||||
//#define SENDDIRCMD_LEDPAD 12
|
||||
//#define SENDDIRCMD_LEDSTART 13
|
||||
//#define SENDDIRCMD_LEDINSIDE 14
|
||||
//#define SENDDIRCMD_LED_ALL 15
|
||||
//#define SENDDIRCMD_FAN 16
|
||||
//#define SENDDIRCMD_LAERM 17
|
||||
//#define SENDDIRCMD_REL1 18
|
||||
|
||||
//#define SENDDIRCMD_WAKEPTU 20
|
||||
//#define SENDDIRCMD_AUXPWR 21
|
||||
//#define SENDDIRCMD_AUXDDR 22
|
||||
//#define SENDDIRCMD_AUXOUT 23
|
||||
|
||||
|
||||
//#define SENDDIRCMD_UCONTACT_ON 30
|
||||
//#define SENDDIRCMD_PRN2_SWONOFF 31
|
||||
|
||||
//#define SENDDIRCMD_MIF_SWONOFF 32
|
||||
//#define SENDDIRCMD_MIF_ATBCREATE 33
|
||||
|
||||
//#define SENDDIRCMD_MOD_SWONOFF 40
|
||||
//#define SENDDIRCMD_MOD_WAKE 41
|
||||
//#define SENDDIRCMD_MDB_POWER 42
|
||||
//#define SENDDIRCMD_MDB_WAKE 43
|
||||
//#define SENDDIRCMD_CRED_ON 44
|
||||
//#define SENDDIRCMD_CRED_WAKE 45
|
||||
|
||||
//#define SENDDIRCMD_SHUT_MOV 50
|
||||
//#define SENDDIRCMD_ESCRO_MOV 51
|
||||
//#define SENDDIR_OPENVAULT 52
|
||||
//#define SENDDIR_REJMOT_ON 53
|
||||
//#define SENDDIR_REJMOT_RUN 54
|
||||
|
||||
// Level 2 (serial from DC to devices)
|
||||
//#define SEND_REQU_SERCONF 100
|
||||
//#define SEND_REQU_HWversion 101
|
||||
//#define SEND_REQU_SWversion 102
|
||||
//#define SEND_REQU_CONDITION 103
|
||||
//#define SEND_REQU_UID 104
|
||||
//#define SEND_REQU_TIME 105
|
||||
// includes wake frequency
|
||||
//#define SEND_REQU_ANALOGS 110
|
||||
//#define SEND_REQU_DIG_INPUTS 111
|
||||
//#define SEND_REQU_DIG_OUTPUTS 112
|
||||
|
||||
//#define SEND_REQU_PRN_STATE 120
|
||||
//#define SEND_REQU_PRN_FONTS 121
|
||||
//#define SEND_REQU_PRN_ALL 122
|
||||
|
||||
//#define SEND_REQU_MIFSTATE 123
|
||||
// Type and state of reader
|
||||
|
||||
//#define SEND_REQU_MIFDATA 124
|
||||
// Type, UID, Header of card
|
||||
// read one card sector
|
||||
// sectors must be addressed by RD_ADD
|
||||
|
||||
//#define SEND_REQU_MIF_ATB_TYPE 125
|
||||
|
||||
//#define SEND_REQU_MDB_GETSTAT 126
|
||||
//#define SEND_REQU_MDB_GETWAK 127
|
||||
//#define SEND_REQU_MDB_GETRESP 128
|
||||
//#define SEND_REQU_EMP_GETALL 129
|
||||
//#define SEND_REQU_EMP_GETCOIN 130
|
||||
|
||||
|
||||
//#define SENDDIRCMD_DEVICE_PARA 131
|
||||
//#define SENDDIRCMD_MACHINE_ID 132
|
||||
//#define SEND_REQU_DEVICE_PARA 133
|
||||
//#define SEND_REQU_MACINE_ID 134
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO:
|
||||
//#define SENDDIRCMD_PRN_SETUP 72
|
||||
//#define SENDDIRCMD_MDB_SNDMSG 92
|
||||
//#define SENDDIRCMD_EMP_SETT 93
|
||||
//#define SENDDIRCMD_PRN_BC 80
|
||||
|
||||
|
||||
|
||||
// further: mdb state, coinchecker state, bill state, modem state, credit_state....
|
||||
/*
|
||||
#define SENDDIRCMD_SHUTOPENBYTIME 60
|
||||
#define SENDDIRCMD_SHUTOPENBYCOIN 61
|
||||
//#define SENDDIRCMD_SHUT_SENDTIME 62
|
||||
|
||||
#define SENDDIRCMD_ESCRO_TAKE 63
|
||||
#define SENDDIRCMD_ESCRO_GIVE 64
|
||||
|
||||
#define SENDDIRCMD_PRN_SYS_CMD 70
|
||||
#define SENDDIRCMD_PRN_ESC_CMD 71
|
||||
#define SENDDIRCMD_PRN_MOVE 73
|
||||
#define SENDDIRCMD_PRN_SETFONT 74
|
||||
#define SENDDIRCMD_PRN_SETLETT 75
|
||||
#define SENDDIRCMD_PRN_CUT 76
|
||||
//#define SENDDIRCMD_PRN_TXT // not needed
|
||||
#define SENDDIRCMD_PRN_LF 78
|
||||
#define SENDDIRCMD_PRN_FONTTAB 79
|
||||
#define SENDDIRCMD_PRN_QR 81
|
||||
#define SENDDIRCMD_PRN_STOREDQR 82
|
||||
#define SENDDIRCMD_PRN_LOGO_FL 83
|
||||
//#define SENDDIRCMD_PRN_LOGO_GRAF 84
|
||||
//#define SENDDIRCMD_PRN_LOGODAT 85
|
||||
//#define SENDDIRCMD_PRN_STORBC 86
|
||||
#define SENDDIRCMD_PRN_STORQR 87
|
||||
#define SENDDIRCMD_PRN_DOC 88
|
||||
#define SENDDIRCMD_PRN_CLEARDOC 89
|
||||
|
||||
//#define SENDDIRCMD_MDB_POWER 42
|
||||
//#define SENDDIRCMD_MDB_WAKE 43
|
||||
#define SENDDIRCMD_MDB_RES 90
|
||||
#define SENDDIRCMD_MDB_SENDCMD 91
|
||||
#define SENDDIRCMD_EMP_POLL 94
|
||||
#define SENDDIRCMD_EMP_STARPPAY 95
|
||||
#define SENDDIRCMD_EMP_STOPPAY 96
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// obsolete:
|
||||
/*
|
||||
#define SENDDIRCMD_PRN1_SENDTEXT 54
|
||||
#define SENDDIRCMD_PRN1_SENDCMD 55
|
||||
#define SENDDIRCMD_PRN1_SERPAR 56
|
||||
#define SENDDIRCMD_PRN_LEVEL2_4B 58
|
||||
#define SENDDIRCMD_PRN_LEVEL2_64 59
|
||||
*/
|
||||
|
||||
// highest priority
|
||||
//#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);
|
||||
// GUI or app sends a command to DC transfered by serial
|
||||
|
||||
//uint16_t sendWRcmd_getSendCommand0(void);
|
||||
|
||||
// lower priority
|
||||
//#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
|
||||
//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);
|
||||
|
||||
|
||||
|
||||
// lowest priority
|
||||
// wait for resonse before send next!
|
||||
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf);
|
||||
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf);
|
||||
@@ -187,47 +14,6 @@ uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf);
|
||||
|
||||
void sendWRcmd_INI(void);
|
||||
|
||||
|
||||
|
||||
//uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf);
|
||||
// HWapi writes data to be forwarded to DC and further to mdb-device
|
||||
// not batched! don't use twice within 100ms
|
||||
|
||||
//uint8_t gpi_restore64ByteSendData(uint8_t *length, uint8_t *buf);
|
||||
// datif reads data to forward to dc
|
||||
|
||||
|
||||
|
||||
// ONE printer doc consists of 20 x 64 byte
|
||||
//#define MAXNROF_PRNBYTES 64
|
||||
//#define MAXNROF_PRNBLOCKS 20
|
||||
/*
|
||||
void epi_resetPrinterStack(void);
|
||||
|
||||
uint8_t epi_storePrnText(char *buf, uint8_t leng);
|
||||
// store text and binary data from Gui in next higher free memory 0....9
|
||||
|
||||
uint8_t gpi_restorePrnText(uint8_t *retbuf);
|
||||
// read printer text and send to slave, size of retbuf== 64
|
||||
|
||||
uint8_t gpi_chk4remainingText(void);
|
||||
// retval: 0: no more textline left (to send) >0: nr of lines
|
||||
*/
|
||||
|
||||
|
||||
//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
|
||||
|
||||
//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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// #define FDCMD_STACKDEPTH 16 / 32
|
||||
// short and long commands are queued into the same stack to guaranty right order
|
||||
void sendFDcmd_clrStack(void);
|
||||
|
@@ -226,6 +226,13 @@ struct SharedMem
|
||||
uint32_t Sdata_changedAmount;
|
||||
uint8_t store_tubeLev[64];
|
||||
|
||||
uint8_t store_bnaParameter[64];
|
||||
uint8_t store_bnaCollect[8];
|
||||
uint8_t store_bnaContent[64];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Mitteilung von Hwapi zu Datif:
|
||||
bool Sdata_coinPaymentNow;
|
||||
@@ -294,9 +301,26 @@ struct SharedMem
|
||||
uint8_t p_nextFDcmdsInQueue;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// download of device controller and json files
|
||||
struct DCDownload {
|
||||
enum class FILE_INDEX {
|
||||
DC_BINARY = 0, DC2C_CASH = 1, DC2C_CONF = 2, DC2C_SERIAL=3,
|
||||
DC2C_PRINT_01, DC2C_PRINT_02, DC2C_PRINT_03, DC2C_PRINT_04,
|
||||
DC2C_PRINT_05, DC2C_PRINT_06, DC2C_PRINT_07, DC2C_PRINT_08,
|
||||
DC2C_PRINT_09, DC2C_PRINT_10, DC2C_PRINT_11, DC2C_PRINT_12,
|
||||
DC2C_PRINT_13, DC2C_PRINT_14, DC2C_PRINT_15, DC2C_PRINT_16,
|
||||
DC2C_PRINT_17, DC2C_PRINT_18, DC2C_PRINT_19, DC2C_PRINT_20,
|
||||
DC2C_PRINT_21, DC2C_PRINT_22, DC2C_PRINT_23, DC2C_PRINT_24,
|
||||
DC2C_PRINT_25, DC2C_PRINT_26, DC2C_PRINT_27, DC2C_PRINT_28,
|
||||
DC2C_PRINT_29, DC2C_PRINT_30, DC2C_PRINT_31, DC2C_PRINT_32
|
||||
};
|
||||
char m_filename[(int)FILE_INDEX::DC2C_PRINT_32][512];
|
||||
std::atomic_ushort m_totalBlocks;
|
||||
std::atomic_ushort m_currentblockNumber;
|
||||
std::atomic_bool m_requested{false};
|
||||
std::atomic_bool m_running{false};
|
||||
std::atomic_bool m_finished{false};
|
||||
} m_downLoadDC;
|
||||
|
||||
static QSharedMemory *getShm(std::size_t s = 0);
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
|
||||
#ifndef STOREINDATA_H
|
||||
#define STOREINDATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "tslib.h"
|
||||
#include <QString>
|
||||
|
||||
@@ -607,6 +609,27 @@ void gpi_storeTubeLevel(uint8_t *data);
|
||||
|
||||
void epi_restoreTubeLevel(uint8_t *data);
|
||||
|
||||
void gpi_storeBnaParams(uint8_t *data);
|
||||
|
||||
void epi_restoreBnaParams(uint8_t *data);
|
||||
|
||||
void gpi_storeBnaCollection(uint8_t *data);
|
||||
|
||||
void epi_restoreBnaCollection(uint8_t *data);
|
||||
|
||||
void gpi_storeBnaContent(uint8_t *data);
|
||||
|
||||
void epi_restoreBnaContent(uint8_t *data);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -5,6 +5,7 @@ VERSION="1.0.0"
|
||||
include(../DCLibraries.pri)
|
||||
|
||||
DEFINES+=THIS_IS_CA_MASTER
|
||||
DEFINES-=THIS_IS_CA_SLAVE
|
||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||
|
||||
unix {
|
||||
|
@@ -5,6 +5,8 @@ VERSION="1.0.0"
|
||||
include(../DCLibraries.pri)
|
||||
|
||||
DEFINES+=THIS_IS_CA_SLAVE
|
||||
DEFINES-=THIS_IS_CA_MASTER
|
||||
|
||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||
|
||||
unix {
|
||||
|
@@ -2,6 +2,9 @@
|
||||
#include "sendWRcmd.h"
|
||||
#include "controlBus.h"
|
||||
#include "storeINdata.h"
|
||||
#include "download_thread.h"
|
||||
#include "hwapi.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <datei.h>
|
||||
#include <QDir>
|
||||
@@ -47,8 +50,10 @@ static uint8_t datif_pNextCmd, datif_sendSlowCmd;
|
||||
//#define DATIF_CTR_GOTRESPVAL 100
|
||||
|
||||
|
||||
T_datif::T_datif(QObject *parent) : QObject(parent)
|
||||
T_datif::T_datif(hwinf *hw, QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_hw = hw;
|
||||
|
||||
QByteArray myBA;
|
||||
QDir myDir("../dmd");
|
||||
|
||||
@@ -198,8 +203,21 @@ char T_datif::datif_cycleSend()
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_hw->dcDownloadRequested()) { // only happens in ca-master
|
||||
m_hw->dcDownloadResetRequest();
|
||||
|
||||
// start download-thread.
|
||||
m_downloadThread = new DownloadThread(m_hw);
|
||||
m_downloadThread->start();
|
||||
|
||||
int cnt = 10;
|
||||
while (--cnt > 0 && !m_downloadThread->isRunning()) {
|
||||
QThread::msleep(100);
|
||||
}
|
||||
if (cnt <= 0) {
|
||||
qCritical() << "DOWNLOAD-THREAD NOT RUNNING WITHIN 1000ms";
|
||||
}
|
||||
}
|
||||
|
||||
// 17.7.2023: repeat commands if result was !=OK -------------------------------------------------------------------
|
||||
if (datif_cmdWasPerformed==2 && doRepeat) // Cmd was not or false performed und Wiederholen erwuenscht
|
||||
@@ -1058,15 +1076,15 @@ char T_datif::loadRecDataFromFrame()
|
||||
//if (RdDleng>50) // 1.8.23 nach Verlängerung des Datensatzes um 20byte falsch!!!
|
||||
//{
|
||||
gpi_storeVaultRecord(readAddress, receivedData ); // always/max 64byte
|
||||
/*
|
||||
/*
|
||||
qDebug()<<"datif cmd38 got vault data. blockNr: "<<readAddress;
|
||||
if (readAddress==5)
|
||||
if (readAddress==0)
|
||||
for (nn=0; nn<64; nn+=8)
|
||||
{
|
||||
qDebug()<<receivedData[nn]<<" "<<receivedData[nn+1]<<" "<<receivedData[nn+2]<<" "<<receivedData[nn+3]<<" "
|
||||
<<receivedData[nn+4]<<" "<<receivedData[nn+5]<<" "<<receivedData[nn+6]<<" "<<receivedData[nn+7];
|
||||
}
|
||||
*/
|
||||
*/
|
||||
//}
|
||||
break;
|
||||
|
||||
@@ -1085,17 +1103,35 @@ char T_datif::loadRecDataFromFrame()
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case 41: // get BNA parameters
|
||||
if (RdDleng>50)
|
||||
{
|
||||
gpi_storeBnaParams(receivedData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 21: // readback version strings of all Json-File in DC
|
||||
//
|
||||
gpi_storeJsonVersion(readAddress, receivedData);
|
||||
break;
|
||||
|
||||
case 116: // get BNA current collection
|
||||
if (RdDleng>7)
|
||||
{
|
||||
gpi_storeBnaCollection(receivedData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 42: // get BNA box content and value of types
|
||||
// qDebug()<< "CAmaster datif_got 42 ";
|
||||
// for (uctmp=0; uctmp<64; uctmp++)
|
||||
// qDebug()<<receivedData[uctmp]<<" ";
|
||||
|
||||
if (RdDleng>60)
|
||||
{
|
||||
gpi_storeBnaContent(receivedData);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
readSource=0; // 17.05.2023: to avoid multiple recording
|
||||
|
320
src/download_thread.cpp
Normal file
320
src/download_thread.cpp
Normal file
@@ -0,0 +1,320 @@
|
||||
#include "download_thread.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "hwapi.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
DownloadThread::DownloadThread(hwinf *hw)
|
||||
: m_hw(hw)
|
||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
||||
// connect(this, &QThread::finished,
|
||||
// dynamic_cast<QObject const *>(m_hw), &QThread::deleteLater);
|
||||
}
|
||||
|
||||
DownloadThread::~DownloadThread() {
|
||||
}
|
||||
|
||||
/*
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// USING THE DC BOOTLOADER
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1 : bl_reboot() // send to application, want DC2 to reset (in order to
|
||||
// start the bootloader)
|
||||
//
|
||||
// NOTE: this function is NOT reliable !!! Sometimes it
|
||||
// simply does not work, in which case bl_startBL,
|
||||
// bl_checkBL and bl_isUp do not work as well.
|
||||
// Alas, there is no feedback if bl_reboot worked!
|
||||
//
|
||||
// NOTE: this function can be called only once per
|
||||
// minute, because once called again, the controller
|
||||
// performs some self-checks consuming some time.
|
||||
//
|
||||
// NOTE: after a successful bl_reboot(), the device is
|
||||
// waiting about 4 seconds in the bootloader. To stay in
|
||||
// the bootloader, we have to send the command
|
||||
// bl_startBL(), which is kind of a misnomer, as it
|
||||
// should be bl_doNotLeaveBL().
|
||||
//
|
||||
2 : bl_startBL(): // send within 4s after DC power-on, otherwise
|
||||
// bootloader is left.
|
||||
//
|
||||
// NOTE: a running bootloader is a MUST for the download
|
||||
// process of a device controller firmware as it does
|
||||
// the actual writing of the memory (the bl_reboot()
|
||||
// from above erases the available memory).
|
||||
//
|
||||
3 : bl_check(): // send command to verify if bl is up
|
||||
//
|
||||
// NOTE: this command is kind of a request that we want
|
||||
// to check if the bootloader is up. The device
|
||||
// (actually the bootloader) responds with its version.
|
||||
//
|
||||
4 : bl_isUp(): // returns true if bl is up and running
|
||||
//
|
||||
// NOTE: we know what the bootloader version actually is
|
||||
// as the bootloader does not change. By comparing the
|
||||
// string received in the previous step with this known
|
||||
// version string we know if the bootloader is up.
|
||||
//
|
||||
// NOTE FOR ALL PREVIOUS STEPS: execute them in their
|
||||
// own slots each to be sure to receive any possible
|
||||
// responds from the device.
|
||||
//
|
||||
5 : bl_sendAddress(blockNumber)
|
||||
// send start address, nr of 64-byte block, start with 0
|
||||
// will be sent only for following block-numbers:
|
||||
// 0, 1024, 2048, 3072 and 4096, so basically every
|
||||
// 64kByte.
|
||||
// for other addresses nothing happens
|
||||
|
||||
6 : bl_wasSendingAddOK()
|
||||
// return val: 0: no response by now
|
||||
// 1: error
|
||||
// 10: OK
|
||||
|
||||
7 : bl_sendDataBlock()
|
||||
// send 64 byte from bin file
|
||||
|
||||
8 : bl_sendLastBlock()
|
||||
// send this command after all data are transferred
|
||||
|
||||
9 : bl_wasSendingDataOK()
|
||||
// return val: 0: no response by now
|
||||
// 1: error
|
||||
// 10: OK
|
||||
|
||||
10 : bl_stopBL() // leave bl and start (the new) application
|
||||
//
|
||||
// NOTE: this function MUST work under all conditions.
|
||||
// Alas, there is no direct result for this command, so
|
||||
// the only way of knowing it was successful is to ask
|
||||
// the device if the bootloader is still running.
|
||||
// There is no problem to repeat this command until the
|
||||
// bootloader is really not running anymore.
|
||||
*/
|
||||
void DownloadThread::run() {
|
||||
// download thread running in ca-master sends the dc-file down to firmware
|
||||
// TODO: send the json files as well
|
||||
|
||||
m_hw->dcDownloadRequestAck();
|
||||
|
||||
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED";
|
||||
|
||||
// load binary device controller file into memory
|
||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
||||
if (ba.size() > 0) {
|
||||
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
|
||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
||||
|
||||
// fill last block of data to be sent with 0xFF
|
||||
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||
|
||||
resetDeviceController();
|
||||
if (startBootloader()) {
|
||||
|
||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||
|
||||
int currentBlock = 0;
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
qCritical() << "64-byte block " << currentBlock;
|
||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
currentBlock += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
||||
|
||||
int const rest = ba.size() % 64;
|
||||
int const offset = ba.size() - rest;
|
||||
char const *startAddress = ba.constData() + offset;
|
||||
|
||||
if (rest > 0) {
|
||||
// SHOULD NEVER HAPPEN !!!
|
||||
uint8_t local[66];
|
||||
memset(local, 0xFF, sizeof(local));
|
||||
memcpy(local, startAddress, rest);
|
||||
qCritical() << "DownloadThread::run(): ERROR SEND REMAINING" << rest << "BYTES";
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
} else {
|
||||
m_hw->bl_sendLastBlock();
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
}
|
||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
}
|
||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||
} // if it was not started at all
|
||||
|
||||
#if 0
|
||||
// test code:
|
||||
uint16_t const totalBlocks = 100;
|
||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
||||
|
||||
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
QThread::msleep(100);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_hw->dcDownloadSetRunning(false);
|
||||
m_hw->dcDownloadSetFinished(true);
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD FINISHED";
|
||||
|
||||
// the object deletes itself ! This is the last line in run().
|
||||
// Never touch the object after this statement
|
||||
// m_hw->dcDownloadThreadFinalize(this);
|
||||
}
|
||||
|
||||
DownloadThread::DownloadResult DownloadThread::sendStatus(int ret) const {
|
||||
switch (ret) { // return values of dc are:
|
||||
case 0: // 0: no answer by now
|
||||
return DownloadResult::NOP; // 1: error
|
||||
case 10: // 10: success
|
||||
return DownloadResult::OK;
|
||||
default:;
|
||||
}
|
||||
return DownloadResult::ERROR;
|
||||
}
|
||||
|
||||
DownloadThread::DownloadResult
|
||||
DownloadThread::sendNextAddress(int bNum) const {
|
||||
// sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||
// qDebug() << "addr-block" << bNum << "...";
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
QThread::msleep(100);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "addr-block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else { // res == DownloadResult::OK
|
||||
// qInfo() << "addr-block" << bNum << "...OK";
|
||||
|
||||
// TODO: hier ins shared-mem schreiben
|
||||
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
// blockNumber is not one of 0, 1024, 2048, 3072, 4096 -> do nothing
|
||||
return DownloadResult::NOP;
|
||||
}
|
||||
|
||||
DownloadThread::DownloadResult
|
||||
DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
uint8_t local[66];
|
||||
int const bAddr = bNum * 64;
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
memcpy(local, binary.constData() + bAddr, 64);
|
||||
local[64] = local[65] = 0x00;
|
||||
|
||||
// QByteArray b((const char *)(&local[0]), 64);
|
||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
||||
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
QThread::msleep(10);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "data for block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
// qInfo() << "data for block" << bNum << "OK";
|
||||
|
||||
// TODO: hier ins shared mem schreiben
|
||||
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
|
||||
bool DownloadThread::startBootloader() const {
|
||||
qDebug() << "starting bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_startBL();
|
||||
QThread::msleep(5000);
|
||||
m_hw->bl_checkBL();
|
||||
if (m_hw->bl_isUp()) {
|
||||
qInfo() << "starting bootloader...OK";
|
||||
QThread::msleep(5000);
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << "bootloader not up (" << nTry << ")";
|
||||
}
|
||||
}
|
||||
qCritical() << "starting bootloader...FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DownloadThread::stopBootloader() const {
|
||||
qDebug() << "stopping bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
QThread::msleep(500);
|
||||
if (!m_hw->bl_isUp()) {
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
qCritical() << "stopping bootloader...FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DownloadThread::resetDeviceController() const {
|
||||
qDebug() << "resetting device controller...";
|
||||
m_hw->bl_rebootDC();
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
QThread::sleep(1);
|
||||
qInfo() << "resetting device controller...OK";
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
|
||||
qDebug() << "loading dc binary" << filename << "...";
|
||||
|
||||
QFile file(filename); // closed in destructor call
|
||||
if (!file.exists()) {
|
||||
qCritical() << file.fileName() << "does not exist";
|
||||
return QByteArray();
|
||||
}
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "cannot open file" << file.fileName();
|
||||
return QByteArray();
|
||||
}
|
||||
qInfo() << "loading dc binary" << filename << "...OK";
|
||||
return file.readAll();
|
||||
}
|
449
src/hwapi.cpp
449
src/hwapi.cpp
@@ -20,6 +20,12 @@
|
||||
*/
|
||||
|
||||
#include "hwapi.h"
|
||||
#include "reporting_thread.h"
|
||||
#include "download_thread.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <atomic>
|
||||
|
||||
static uint32_t hwapi_lastStartAmount;
|
||||
static uint32_t hwapi_lastTotalAmount;
|
||||
@@ -49,7 +55,7 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
|
||||
// {
|
||||
|
||||
#ifdef THIS_IS_CA_MASTER
|
||||
myDatif = new T_datif(); // für die CAslave-Lib auskommentieren!
|
||||
myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
|
||||
#else
|
||||
qCritical()<<"hwapi: error CAslave cannot include T_datif";
|
||||
#endif
|
||||
@@ -501,6 +507,8 @@ uint8_t hwapi::rtc_setDateTime(void) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void hwapi::rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const
|
||||
{
|
||||
epi_getTime(hh, mm, ss);
|
||||
@@ -2968,7 +2976,7 @@ bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
|
||||
|
||||
// 14.9.23 neu: Datensatz erst pruefen, [0..3] enthaelt "Psa>" und [4,5 =Abr.Nr]
|
||||
uint16_t ds_acc_nr=uchar2uint(buf[5], buf[4]);
|
||||
if (buf[0]=='P' && buf[1]=='S' && buf[2]=='A' && buf[3]=='>' && ds_acc_nr<60000)
|
||||
if (buf[0]=='P' && buf[1]=='s' && buf[2]=='a' && buf[3]=='>' && ds_acc_nr<60000)
|
||||
{
|
||||
// valid data, copy data to struct
|
||||
do
|
||||
@@ -3228,10 +3236,17 @@ uint16_t hwapi::cash_getNrCoinsInVault(void) const
|
||||
|
||||
uint8_t hwapi::prn_getPrintResult() const
|
||||
{
|
||||
// return: 0: unknown
|
||||
// 1: OK - last template was printed succesful
|
||||
// 2: error - last template was not printed
|
||||
return 1;
|
||||
// return: 0: just printing, wait
|
||||
// 1: OK - last print was succesful
|
||||
// 2: error - not printed
|
||||
|
||||
struct T_dynamicCondition myDynMachCond;
|
||||
sys_getDynMachineConditions(&myDynMachCond);
|
||||
|
||||
return myDynMachCond.resultOfLastTemplPrint;
|
||||
// 0: unknown or printing in progress
|
||||
// 1: OK, doc was printed 2: error, doc was not printed
|
||||
|
||||
}
|
||||
|
||||
uint8_t hwapi::prn_getCurrentPrinterState() const
|
||||
@@ -3255,6 +3270,12 @@ uint8_t hwapi::prn_getCurrentPrinterState() const
|
||||
lastPrinterStatus=buf[52];
|
||||
|
||||
return lastPrinterStatus;
|
||||
|
||||
// oder mit:
|
||||
//struct T_dynamicCondition myDynMachCond;
|
||||
//sys_getDynMachineConditions(&myDynMachCond);
|
||||
//myDynMachCond.lastPrinterStatus
|
||||
|
||||
}
|
||||
|
||||
// 21.4.23TS: change function "sendDeviceSettings()" to use this struct: "struct T_devices"
|
||||
@@ -4176,22 +4197,55 @@ void hwapi::bna_sendSettings(uint16_t notesToAccept, uint16_t parameters,
|
||||
// acceptanceLimit: device will stop acceptance once this amount is reached and
|
||||
// optionally keep last bill in escrow until vend_success()
|
||||
// is called (put bill to stacker) or vend_failed() is called (return bill)
|
||||
Q_UNUSED(notesToAccept);
|
||||
Q_UNUSED(parameters);
|
||||
Q_UNUSED(billDenomination);
|
||||
Q_UNUSED(acceptanceLimit);
|
||||
|
||||
uint16_t noteAcc=notesToAccept;
|
||||
uint16_t para=parameters;
|
||||
uint16_t denom[16];
|
||||
uint32_t limit=acceptanceLimit;
|
||||
uint8_t buf[64], nn, pp;
|
||||
|
||||
for (nn=0; nn<16; nn++)
|
||||
denom[nn]=billDenomination[nn];
|
||||
|
||||
|
||||
buf[0]=uint2uchar(noteAcc, LOWBYTE);
|
||||
buf[1]=uint2uchar(noteAcc, HIGHBYTE);
|
||||
buf[2]=uint2uchar(para, LOWBYTE);
|
||||
buf[3]=uint2uchar(para, HIGHBYTE);
|
||||
pp=4;
|
||||
for (nn=0; nn<16; nn++)
|
||||
{
|
||||
buf[pp++]=uint2uchar(denom[nn], LOWBYTE);
|
||||
buf[pp++]=uint2uchar(denom[nn], HIGHBYTE);
|
||||
}
|
||||
|
||||
buf[pp++]=ulong2uchar(limit, 0);
|
||||
buf[pp++]=ulong2uchar(limit, 1);
|
||||
buf[pp++]=ulong2uchar(limit, 2);
|
||||
buf[pp++]=ulong2uchar(limit, 3);
|
||||
|
||||
longFDcmd_set(35, 41, 0, pp, buf);
|
||||
|
||||
}
|
||||
|
||||
void hwapi::bna_setCurrentAcceptance(uint16_t notesToAccept) const
|
||||
{
|
||||
// can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid)
|
||||
Q_UNUSED(notesToAccept);
|
||||
uint8_t LB, HB;
|
||||
uint16_t val=notesToAccept;
|
||||
|
||||
LB=uint2uchar(val, LOWBYTE);
|
||||
HB=uint2uchar(val, HIGHBYTE);
|
||||
|
||||
sendFDcmd_set(170, 0, 0, LB, HB, LB, HB);
|
||||
}
|
||||
|
||||
void hwapi::bna_requestParameters(void) const
|
||||
{
|
||||
// send command to DC in order to get static invariable device parameters like currency
|
||||
// device must be powered and polled to get these
|
||||
|
||||
sendFDcmd_set(0, 41, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
bool hwapi::bna_getAllParameters(struct T_bna *bna) const
|
||||
@@ -4199,38 +4253,387 @@ bool hwapi::bna_getAllParameters(struct T_bna *bna) const
|
||||
// get all constant data from reader (e.g. currency)
|
||||
// and actual Host-Settings (sent with bna_sendSettings() or json)
|
||||
// retval = true if data are valid
|
||||
Q_UNUSED(bna);
|
||||
uint8_t buf[66], nn, pp;
|
||||
|
||||
epi_restoreBnaParams(buf);
|
||||
bna->setup=buf[0];
|
||||
bna->FeatureLevel=buf[1];
|
||||
bna->countryCode=uchar2uint(buf[3], buf[2]);
|
||||
bna->scalingFactor=uchar2uint(buf[5], buf[4]);
|
||||
bna->decimalPlace=buf[6];
|
||||
bna->pad1=0;
|
||||
bna->stackerCap=uchar2uint(buf[8], buf[7]);
|
||||
bna->billSecureLevel=uchar2uint(buf[10], buf[9]);
|
||||
bna->hasEscrow=buf[11];
|
||||
|
||||
for (nn=0; nn<16; nn++)
|
||||
bna->accBillTypes[nn] = buf[nn+12];
|
||||
|
||||
bna->currentStackerLevel = uchar2uint(buf[29], buf[28]);
|
||||
bna->intendedAccept = uchar2uint(buf[31], buf[30]);
|
||||
bna->pad2=0;
|
||||
pp=32;
|
||||
for (nn=0; nn<16; nn++)
|
||||
{
|
||||
bna->billDenomination[nn] = uchar2uint(buf[pp+1], buf[pp]);
|
||||
pp+=2;
|
||||
}
|
||||
if (bna->setup)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void hwapi::bna_requestCurrentNotes(void) const
|
||||
{
|
||||
// send command to DC in order to get transaction data
|
||||
sendFDcmd_set(0, 116, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
uint8_t hwapi::bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const
|
||||
{
|
||||
// returns number of collected bank notes since start-command (current transaction)
|
||||
// latestBill: last accepted bank note, value in cent
|
||||
// currentNotes an array with up to 16 (further) notes collected
|
||||
Q_UNUSED(latestBill);
|
||||
Q_UNUSED(currentNotes);
|
||||
return 0;
|
||||
// latestBill: not used
|
||||
// currentNotes[0] = last bill value
|
||||
// currentNotes[1] = 0/1 1 if bill in escrow 0 if bill in cash box (stacker)
|
||||
// currentNotes[2,3] = total sum of collected bills within this transaction
|
||||
|
||||
// incoming data:
|
||||
//DB1: nr of bills (this transaction)
|
||||
//DB2: 1 if bill in escrow
|
||||
//DB3..6: collected amount
|
||||
//DB7,8: denomination of last bill
|
||||
|
||||
uint8_t buf[10], haveBilInEscrow, haveNrOfBills;
|
||||
uint16_t lastBillVal;
|
||||
uint32_t collAmountThisTrans;
|
||||
|
||||
epi_restoreBnaCollection(buf);
|
||||
haveNrOfBills=buf[0];
|
||||
haveBilInEscrow=buf[1];
|
||||
collAmountThisTrans = uchar2ulong(buf[5],buf[4],buf[3],buf[2]);
|
||||
lastBillVal = uchar2uint(buf[7],buf[6]);
|
||||
|
||||
currentNotes[0]=latestBill; // just to get rid of compiler warning
|
||||
currentNotes[0]=lastBillVal;
|
||||
currentNotes[1]=haveBilInEscrow;
|
||||
currentNotes[2]=uint16_t(collAmountThisTrans);
|
||||
collAmountThisTrans>>=16;
|
||||
currentNotes[3]=uint16_t(collAmountThisTrans);
|
||||
|
||||
return haveNrOfBills;
|
||||
}
|
||||
|
||||
void hwapi::bna_requestStackerLevel(void) const
|
||||
{
|
||||
|
||||
sendFDcmd_set(0, 42, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOfBills) const
|
||||
{
|
||||
// return val: nr of bills in stacker
|
||||
// countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker
|
||||
// countOfBills[1] for 10€ and so on
|
||||
Q_UNUSED(amountInStacker);
|
||||
Q_UNUSED(countOfBills);
|
||||
return 0;
|
||||
// countOfBills[0..7] = count of bills of bill-type 0..7 (e.g. countOfBills[0]=nr of 5€-bills in stacker)
|
||||
// countOfBills[8..15] = value of bill-type 0...7
|
||||
|
||||
// receive data:
|
||||
//je zwei Byte pro Wert,
|
||||
//1…16: Anzahl Scheine pro Typ
|
||||
//33…48: Wertigkeit der Typen
|
||||
uint8_t buf[66], nn, pp, qq;
|
||||
uint16_t nrOfBills[16], valueOfBills[16], anzahl=0;
|
||||
uint32_t totalSum=0;
|
||||
|
||||
epi_restoreBnaContent(buf);
|
||||
|
||||
pp=0; qq=32;
|
||||
for (nn=0; nn<16; nn++)
|
||||
{
|
||||
nrOfBills[nn]=uchar2uint(buf[pp+1],buf[pp]);
|
||||
pp+=2;
|
||||
valueOfBills[nn]=uchar2uint(buf[qq+1],buf[qq]);
|
||||
qq+=2;
|
||||
}
|
||||
|
||||
//qDebug()<< "CAmaster hwapi::bna_getStackerLevel " << nrOfBills[0] <<" "<< nrOfBills[1]
|
||||
// <<" "<<nrOfBills[2]<<" "<<nrOfBills[3];
|
||||
// qDebug()<< valueOfBills[0] <<" "<< valueOfBills[1] <<" "<<valueOfBills[2]<<" "<<valueOfBills[3];
|
||||
|
||||
// nur 8 zurueckmelden, mehr kommen derzeit von DC auch nicht
|
||||
for (nn=0; nn<8; nn++)
|
||||
{
|
||||
countOfBills[nn]=nrOfBills[nn];
|
||||
countOfBills[nn+7]=valueOfBills[nn];
|
||||
}
|
||||
|
||||
for (nn=0; nn<8; nn++)
|
||||
{
|
||||
totalSum += nrOfBills[nn] * valueOfBills[nn];
|
||||
anzahl += nrOfBills[nn];
|
||||
}
|
||||
|
||||
//qDebug()<<"sum: "<< totalSum <<" Anzahl: "<<anzahl;
|
||||
|
||||
*amountInStacker=totalSum;
|
||||
return anzahl;
|
||||
}
|
||||
|
||||
QObject const *hwapi::getAPI() {
|
||||
return this;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char *fNameBuffer = data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY];
|
||||
size_t const size = sizeof(data->m_downLoadDC.m_filename);
|
||||
|
||||
std::memset(fNameBuffer, 0x00, size);
|
||||
std::memcpy(fNameBuffer, dcFileToDownload.toStdString().c_str(),
|
||||
std::min(size, strlen(fNameBuffer)-1));
|
||||
|
||||
data->m_downLoadDC.m_totalBlocks = 0;
|
||||
data->m_downLoadDC.m_currentblockNumber = 0;
|
||||
|
||||
data->m_downLoadDC.m_requested = true;
|
||||
data->m_downLoadDC.m_running = false; // download thread is not running
|
||||
data->m_downLoadDC.m_finished = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRequested() const {
|
||||
SharedMem const *data = SharedMem::getData();
|
||||
// should be false at entry
|
||||
return data ? data->m_downLoadDC.m_requested.load() : false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadResetRequest() const {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_requested = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRequestAck() const {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
if (data->m_downLoadDC.m_requested) {
|
||||
data->m_downLoadDC.m_requested = false;
|
||||
data->m_downLoadDC.m_running = true;
|
||||
data->m_downLoadDC.m_finished = false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRunning() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
if (data) {
|
||||
int cnt = 10;
|
||||
while (--cnt > 0) {
|
||||
bool running = data->m_downLoadDC.m_running.load();
|
||||
bool finished = data->m_downLoadDC.m_finished.load();
|
||||
if (!running || finished) {
|
||||
if (cnt < 3) {
|
||||
qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished;
|
||||
}
|
||||
QThread::msleep(500);
|
||||
} else break;
|
||||
}
|
||||
// qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0);
|
||||
return (cnt > 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
|
||||
delete dthread;
|
||||
m_downloadThread = nullptr;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadFinished() {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
if (data) {
|
||||
int cnt = 10;
|
||||
while ((--cnt > 0) &&
|
||||
((data->m_downLoadDC.m_running.load() == true) &&
|
||||
(data->m_downLoadDC.m_finished.load() == false))) {
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
//if (cnt > 0) {
|
||||
// delete m_downloadThread;
|
||||
// m_downloadThread = nullptr;
|
||||
// return true;
|
||||
//}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// download thread
|
||||
|
||||
bool hwapi::dcDownloadThreadStart() {
|
||||
m_downloadThread = new DownloadThread(this);
|
||||
if (m_downloadThread) {
|
||||
m_downloadThread->start();
|
||||
int cnt = 10;
|
||||
while (--cnt > 0 && !dcDownloadThreadRunning()) {
|
||||
QThread::msleep(200);
|
||||
}
|
||||
return (cnt > 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadThreadRunning() const {
|
||||
return (dcDownloadGetRunning() == true)
|
||||
&& (dcDownloadGetFinished() == false);
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadThreadFinished() const {
|
||||
return (dcDownloadThreadRunning() == false);
|
||||
}
|
||||
|
||||
|
||||
// report thread
|
||||
bool hwapi::dcDownloadReportThreadStart() { // only start reporting thread
|
||||
int cnt = 10; // if download thread is running
|
||||
while (--cnt > 0 && !dcDownloadRunning()) {
|
||||
QThread::msleep(500);
|
||||
}
|
||||
if (cnt > 0) {
|
||||
m_reportingThread = new ReportingThread(this);
|
||||
if (m_reportingThread) {
|
||||
m_reportingThread->start();
|
||||
cnt = 10;
|
||||
while (--cnt > 0 && !dcDownloadReportThreadRunning()) {
|
||||
QThread::msleep(200);
|
||||
}
|
||||
return (cnt > 0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportThreadRunning() const {
|
||||
return m_reportingThread ? m_reportingThread->isRunning() : false;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadReportThreadFinalize() {
|
||||
if (m_reportingThread) {
|
||||
if (m_reportingThread->isFinished()) {
|
||||
delete m_reportingThread;
|
||||
m_reportingThread = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadReportThreadQuit() {
|
||||
if (m_reportingThread) {
|
||||
m_reportingThread->quit();
|
||||
}
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportThreadFinished() const {
|
||||
return m_reportingThread ? m_reportingThread->isFinished() : false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportStart() const {
|
||||
int cnt = 10;
|
||||
while (--cnt > 0 && !dcDownloadRunning()) {
|
||||
QThread::msleep(200);
|
||||
}
|
||||
return (cnt == 0);
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportRunning() const {
|
||||
return dcDownloadReportThreadRunning();
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportFinished() {
|
||||
int cnt = 10;
|
||||
while (--cnt > 0 && !dcDownloadReportThreadFinished()) {
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
if (cnt == 0 && !dcDownloadReportThreadFinished()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dcDownloadReportThreadFinished()) {
|
||||
delete m_reportingThread;
|
||||
m_reportingThread = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString hwapi::dcDownloadFileName() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY] : "";
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadSetRequested(bool requested) {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_requested = requested;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadSetRunning(bool running) {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_running = running;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadSetFinished(bool finished) {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_finished = finished;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
|
||||
SharedMem::getData()->m_downLoadDC.m_totalBlocks = totalBlockNumber;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
|
||||
SharedMem::getData()->m_downLoadDC.m_currentblockNumber = currentBlockNumber;
|
||||
}
|
||||
|
||||
uint16_t hwapi::dcDownloadGetTotalBlockNumber() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_totalBlocks.load() : 0;
|
||||
}
|
||||
|
||||
uint16_t hwapi::dcDownloadGetCurrentBlockNumber() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_currentblockNumber.load() : 0;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadGetRequested() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_requested.load() : 0;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadGetRunning() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_running.load() : 0;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadGetFinished() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_running.load() : 0;
|
||||
}
|
||||
|
155
src/reporting_thread.cpp
Normal file
155
src/reporting_thread.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
#include "reporting_thread.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "hwapi.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
||||
ReportingThread::ReportingThread(hwapi *hw)
|
||||
: m_hw(hw)
|
||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
||||
}
|
||||
|
||||
ReportingThread::~ReportingThread() {
|
||||
}
|
||||
|
||||
// download thread running in ca-slave sends reports of download process to
|
||||
// each component which has connects for the corresponding signals.
|
||||
void ReportingThread::run() {
|
||||
|
||||
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
|
||||
|
||||
static QString report("");
|
||||
|
||||
int cnt = 5;
|
||||
while (!m_hw->dcDownloadGetRunning()) {
|
||||
if (--cnt > 0) {
|
||||
report = QString("%1 waiting for download to start %2")
|
||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate))
|
||||
.arg(cnt);
|
||||
qCritical() << __LINE__ << "STATUS" << report;
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
QThread::sleep(1);
|
||||
} else break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (cnt == 0) {
|
||||
m_hw->dcDownloadResetRequest();
|
||||
status = QString("%1 reset download request")
|
||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
qCritical() << __LINE__ << "STATUS" << status;
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(status);
|
||||
|
||||
cnt = 5;
|
||||
while (!m_hw->dcDownloadRunning()) {
|
||||
if (--cnt > 0) {
|
||||
QThread::sleep(1);
|
||||
} else break;
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
status = QString("%1 download request failure")
|
||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
qCritical() << __LINE__ << "STATUS" << status;
|
||||
emit m_hw->hwapi_reportDCDownloadFailure(status);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t const tnr = 1750;
|
||||
uint16_t cnr = 0;
|
||||
|
||||
while (cnr <= tnr) {
|
||||
QThread::msleep(100);
|
||||
QString report("");
|
||||
|
||||
if (cnr > 0) {
|
||||
double percent = ((double)cnr / (double)tnr) * 100.0;
|
||||
report = QString(": total blocks %1, current block %2 [%3]")
|
||||
.arg(tnr).arg(cnr).arg(percent, 0, 'f', 2);
|
||||
} else {
|
||||
report = QString(": total blocks %1, current block %2 [0]")
|
||||
.arg(tnr).arg(cnr);
|
||||
}
|
||||
status = QDateTime::currentDateTime().toString(Qt::ISODate) + report;
|
||||
|
||||
qCritical() << "STATUS" << status;
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(status);
|
||||
cnr += 1;
|
||||
}
|
||||
|
||||
if (tnr == cnr) {
|
||||
m_hw->hwapi_reportDCDownloadSuccess(
|
||||
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
|
||||
} else {
|
||||
m_hw->hwapi_reportDCDownloadFailure(
|
||||
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
|
||||
.arg(m_fileToDownload).arg(tnr).arg(cnr));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
uint16_t const totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
|
||||
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
||||
|
||||
if (totalBlocks) {
|
||||
qint64 const start = QDateTime::currentMSecsSinceEpoch();
|
||||
double durationMillis = 0;
|
||||
uint16_t currentBlockNumber = 0;
|
||||
|
||||
while (m_hw->dcDownloadGetRunning()) {
|
||||
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
||||
|
||||
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
|
||||
|
||||
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis;
|
||||
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
|
||||
|
||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4s)")
|
||||
.arg(totalBlocks)
|
||||
.arg(currentBlockNumber)
|
||||
.arg(percent, 0, 'f', 2)
|
||||
.arg(estimatedSecondsLeft, 0, 'f', 2);
|
||||
|
||||
qCritical() << "RT report" << report;
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
QThread::msleep(100);
|
||||
}
|
||||
|
||||
QThread::msleep(100);
|
||||
|
||||
if (totalBlocks == currentBlockNumber) {
|
||||
m_hw->hwapi_reportDCDownloadSuccess(
|
||||
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
|
||||
} else {
|
||||
m_hw->hwapi_reportDCDownloadFailure(
|
||||
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
|
||||
.arg(m_fileToDownload).arg(totalBlocks).arg(currentBlockNumber));
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
|
||||
|
||||
cnt = 10;
|
||||
|
||||
bool running = m_hw->dcDownloadGetRunning();
|
||||
bool finished = m_hw->dcDownloadGetFinished();
|
||||
|
||||
while (--cnt > 0 && (running && !finished)) {
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 REPORT THREAD: WAIT FOR END OF DOWNLOAD THREAD %2 %3 (%4)")
|
||||
.arg(__LINE__).arg(running).arg(finished).arg(cnt);
|
||||
QThread::sleep(1);
|
||||
running = m_hw->dcDownloadGetRunning();
|
||||
finished = m_hw->dcDownloadGetFinished();
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 FINISH REPORT THREAD").arg(__LINE__);
|
||||
}
|
0
src/runProc.cpp
Executable file → Normal file
0
src/runProc.cpp
Executable file → Normal file
@@ -1,811 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include "tslib.h"
|
||||
#include "sendWRcmd.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
|
||||
void indat_PrnPwr(void);
|
||||
|
||||
|
||||
void sendWRcmd_INI(void)
|
||||
{
|
||||
|
||||
sendWRcmd_clrCmdStack();
|
||||
sendWRcmd_clrCmd4Stack();
|
||||
sendFDcmd_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++)
|
||||
SharedMem::write()->nextAsynchsendCmd0[nn]=0;
|
||||
SharedMem::write()->nrOfCmdsInQueue=0;
|
||||
}
|
||||
|
||||
bool sendWRcmd_setSendCommand0(uint16_t nextCmd)
|
||||
{
|
||||
// write Command to memory, wait for transport
|
||||
uint8_t ciq=SharedMem::read()->nrOfCmdsInQueue;
|
||||
if (ciq>=CMDSTACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
|
||||
SharedMem::write()->nextAsynchsendCmd0[ciq++]=nextCmd;
|
||||
SharedMem::write()->nrOfCmdsInQueue=ciq;
|
||||
|
||||
//qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue;
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand0(void)
|
||||
{
|
||||
uint16_t nxtAsynchCmd, data;
|
||||
uint8_t nn, ll;
|
||||
uint8_t ciq=SharedMem::read()->nrOfCmdsInQueue;
|
||||
|
||||
if (ciq==0 || ciq>CMDSTACKDEPTH)
|
||||
return 0; // error
|
||||
nxtAsynchCmd=SharedMem::read()->nextAsynchsendCmd0[0];
|
||||
|
||||
// move Puffer down by one element
|
||||
if (ciq>0)
|
||||
ll=ciq-1;
|
||||
else
|
||||
ll=0;
|
||||
for (nn=0; nn<ll; nn++)
|
||||
{
|
||||
data=SharedMem::read()->nextAsynchsendCmd0[nn+1];
|
||||
SharedMem::write()->nextAsynchsendCmd0[nn]=data;
|
||||
}
|
||||
SharedMem::write()->nrOfCmdsInQueue=ciq;
|
||||
//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;
|
||||
*/
|
||||
|
||||
|
||||
void sendWRcmd_clrCmd4Stack(void)
|
||||
{
|
||||
uint8_t nn;
|
||||
for (nn=0; nn<CMD4STACKDEPTH; nn++)
|
||||
{
|
||||
SharedMem::write()->nextAsynchsendCmd4[nn]=0;
|
||||
SharedMem::write()->nextCmd4para1[nn]=0;
|
||||
SharedMem::write()->nextCmd4para2[nn]=0;
|
||||
SharedMem::write()->nextCmd4para3[nn]=0;
|
||||
SharedMem::write()->nextCmd4para4[nn]=0;
|
||||
}
|
||||
SharedMem::write()->nrOfCmds4InQueue=0;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
uint8_t ciq;
|
||||
ciq=SharedMem::read()->nrOfCmds4InQueue;
|
||||
|
||||
if (ciq>=CMD4STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
|
||||
SharedMem::write()->nextAsynchsendCmd4[ciq]=nextCmd;
|
||||
SharedMem::write()->nextCmd4para1[ciq]=dat1;
|
||||
SharedMem::write()->nextCmd4para2[ciq]=dat2;
|
||||
SharedMem::write()->nextCmd4para3[ciq]=dat3;
|
||||
SharedMem::write()->nextCmd4para4[ciq]=dat4;
|
||||
ciq++;
|
||||
SharedMem::write()->nrOfCmds4InQueue=ciq;
|
||||
|
||||
//qDebug() << QDateTime::currentDateTime().time()
|
||||
// << "sendWRcmd 4 byte saved, pp=" << nextCmd
|
||||
// << " para: " << SharedMem::getDataConst()->nextCmd4para1[pp];
|
||||
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
|
||||
{
|
||||
uint16_t nxtAsynchCmd, data;
|
||||
uint8_t nn;
|
||||
uint8_t ciq=SharedMem::read()->nrOfCmds4InQueue;
|
||||
|
||||
if (ciq==0 || ciq > CMD4STACKDEPTH)
|
||||
return 0; // error
|
||||
|
||||
nxtAsynchCmd=SharedMem::read()->nextAsynchsendCmd4[0];
|
||||
*dat1=SharedMem::read()->nextCmd4para1[0];
|
||||
*dat2=SharedMem::read()->nextCmd4para2[0];
|
||||
*dat3=SharedMem::read()->nextCmd4para3[0];
|
||||
*dat4=SharedMem::read()->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 (ciq>0) ciq--;
|
||||
|
||||
for (nn=0; nn<ciq; nn++)
|
||||
{
|
||||
data=SharedMem::read()->nextAsynchsendCmd4[nn+1];
|
||||
SharedMem::write()->nextAsynchsendCmd4[nn]=data;
|
||||
data=SharedMem::read()->nextCmd4para1[nn+1];
|
||||
SharedMem::write()->nextCmd4para1[nn]=data;
|
||||
data=SharedMem::read()->nextCmd4para2[nn+1];
|
||||
SharedMem::write()->nextCmd4para2[nn]=data;
|
||||
data=SharedMem::read()->nextCmd4para3[nn+1];
|
||||
SharedMem::write()->nextCmd4para3[nn]=data;
|
||||
data=SharedMem::read()->nextCmd4para4[nn+1];
|
||||
SharedMem::write()->nextCmd4para4[nn]=data;
|
||||
}
|
||||
|
||||
SharedMem::write()->nrOfCmds4InQueue=ciq;
|
||||
return nxtAsynchCmd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sendWRcmd_clrCmd8Stack(void)
|
||||
{
|
||||
uint8_t nn;
|
||||
for (nn=0; nn<CMD8STACKDEPTH; nn++)
|
||||
{
|
||||
SharedMem::write()->nextAsynchsendCmd8[nn]=0;
|
||||
SharedMem::write()->nextCmd8para1[nn]=0;
|
||||
SharedMem::write()->nextCmd8para2[nn]=0;
|
||||
SharedMem::write()->nextCmd8para3[nn]=0;
|
||||
SharedMem::write()->nextCmd8para4[nn]=0;
|
||||
}
|
||||
SharedMem::write()->nrOfCmds8InQueue=0;
|
||||
}
|
||||
|
||||
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
|
||||
uint8_t ciq;
|
||||
ciq=SharedMem::read()->nrOfCmds8InQueue;
|
||||
|
||||
if (ciq>=CMD8STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
SharedMem::write()->nextAsynchsendCmd8[ciq]=nextCmd;
|
||||
SharedMem::write()->nextCmd8para1[ciq]=dat1;
|
||||
SharedMem::write()->nextCmd8para2[ciq]=dat2;
|
||||
SharedMem::write()->nextCmd8para3[ciq]=dat3;
|
||||
SharedMem::write()->nextCmd8para4[ciq]=dat4;
|
||||
ciq++;
|
||||
SharedMem::write()->nrOfCmds8InQueue=ciq;
|
||||
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, data;
|
||||
uint8_t nn;
|
||||
|
||||
uint8_t ciq=SharedMem::read()->nrOfCmds8InQueue;
|
||||
|
||||
if (ciq==0 || ciq > CMD8STACKDEPTH)
|
||||
return 0; // error
|
||||
|
||||
nxtAsynchCmd=SharedMem::read()->nextAsynchsendCmd8[0];
|
||||
*dat1=SharedMem::read()->nextCmd8para1[0];
|
||||
*dat2=SharedMem::read()->nextCmd8para2[0];
|
||||
*dat3=SharedMem::read()->nextCmd8para3[0];
|
||||
*dat4=SharedMem::read()->nextCmd8para4[0];
|
||||
|
||||
// move buffer down by one element
|
||||
if (ciq>0) ciq--;
|
||||
|
||||
for (nn=0; nn<ciq; nn++)
|
||||
{
|
||||
data=SharedMem::read()->nextAsynchsendCmd8[nn+1];
|
||||
SharedMem::write()->nextAsynchsendCmd8[nn]=data;
|
||||
data=SharedMem::read()->nextCmd8para1[nn+1];
|
||||
SharedMem::write()->nextCmd8para1[nn]=data;
|
||||
data=SharedMem::read()->nextCmd8para2[nn+1];
|
||||
SharedMem::write()->nextCmd8para2[nn]=data;
|
||||
data=SharedMem::read()->nextCmd8para3[nn+1];
|
||||
SharedMem::write()->nextCmd8para3[nn]=data;
|
||||
data=SharedMem::read()->nextCmd8para4[nn+1];
|
||||
SharedMem::write()->nextCmd8para4[nn]=data;
|
||||
}
|
||||
SharedMem::write()->nrOfCmds8InQueue=ciq;
|
||||
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)
|
||||
{
|
||||
if (leng>SENDASYDAT_BUFFSIZE) leng=SENDASYDAT_BUFFSIZE;
|
||||
SharedMem::write()->sendAsyDatLen=leng;
|
||||
tslib_strclr(SharedMem::write()->sendAsynchDataBuf, 0, SENDASYDAT_BUFFSIZE);
|
||||
for (uint8_t nn=0; nn<leng; nn++)
|
||||
SharedMem::write()->sendAsynchDataBuf[nn]=buf[nn];
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf)
|
||||
{
|
||||
|
||||
uint8_t dl=SharedMem::read()->sendAsyDatLen;
|
||||
*leng=dl;
|
||||
for (uint8_t nn=0; nn<dl; nn++)
|
||||
buf[nn]=SharedMem::read()->sendAsynchDataBuf[nn];
|
||||
SharedMem::write()->sendAsyDatLen=0;
|
||||
//tslib_strclr(SharedMem::write()->sendAsynchDataBuf, 0, SENDASYDAT_BUFFSIZE);
|
||||
return *leng;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// MDB Sendind Data are store here for next transport to DC (Device Controller)
|
||||
// Transport to Slave runs every 100ms, answer from mdb-slave (e.g. coin changer) comes rigth
|
||||
// with next slave answer
|
||||
|
||||
// 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[MDBSEND_BUFFSIZE];
|
||||
//static uint8_t Sdata_mdbSendLen;
|
||||
|
||||
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf)
|
||||
{
|
||||
if (length>MDBSEND_BUFFSIZE) length=MDBSEND_BUFFSIZE;
|
||||
|
||||
// HWapi writes data to be forwarded to DC and further to mdb-device
|
||||
for (uint8_t nn=0; nn<length; nn++)
|
||||
SharedMem::write()->Sdata_mdbSendBuffer[nn]=buf[nn];
|
||||
SharedMem::write()->Sdata_mdbSendLen=length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t gpi_restore64ByteSendData(uint8_t *length, uint8_t *buf)
|
||||
{
|
||||
// datif reads data to forward to dc
|
||||
uint8_t dl=SharedMem::read()->Sdata_mdbSendLen;
|
||||
|
||||
for (uint8_t nn=0; nn<dl; nn++)
|
||||
buf[nn]=SharedMem::read()->Sdata_mdbSendBuffer[nn];
|
||||
*length=dl;
|
||||
SharedMem::write()->Sdata_mdbSendLen=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------
|
||||
//---------------------------------------- Printer Text Fifo -------------------------
|
||||
//static uint8_t prnDataParameters[];
|
||||
//static uint8_t prnDataBufferUser;
|
||||
|
||||
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
|
||||
SharedMem::write()->prnDataBufferUser=user;
|
||||
SharedMem::write()->prnDataParameters[0]=para1;
|
||||
SharedMem::write()->prnDataParameters[1]=para2;
|
||||
SharedMem::write()->prnDataParameters[2]=para3;
|
||||
SharedMem::write()->prnDataParameters[3]=para4;
|
||||
|
||||
// qDebug() << "new user stored: " << user;
|
||||
|
||||
}
|
||||
|
||||
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=SharedMem::read()->prnDataParameters[0];
|
||||
*para2=SharedMem::read()->prnDataParameters[1];
|
||||
*para3=SharedMem::read()->prnDataParameters[2];
|
||||
*para4=SharedMem::read()->prnDataParameters[3];
|
||||
return SharedMem::read()->prnDataBufferUser;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 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)
|
||||
{
|
||||
SharedMem::write()->pPrnDataBuff=0;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
pp=SharedMem::read()->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(SharedMem::write()->Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES);
|
||||
|
||||
for (nn=0; nn<len; nn++)
|
||||
SharedMem::write()->Sdata_PRN_TEXT[pp][nn]=buf[nn]; // copy new text into buffer
|
||||
|
||||
if (SharedMem::read()->pPrnDataBuff<MAXNROF_PRNBLOCKS)
|
||||
SharedMem::write()->pPrnDataBuff++; // inc pointer if end not yet reached
|
||||
return 0; // OK
|
||||
}
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
uint8_t nn, mm, pp=SharedMem::read()->pPrnDataBuff;
|
||||
char buf[MAXNROF_PRNBYTES];
|
||||
|
||||
if (pp==0) // next free memory block with 64byte each
|
||||
return 1; // no text in buffer
|
||||
|
||||
// example: pp=5: then buffers [0...4] are occupied
|
||||
|
||||
for (nn=0; nn<MAXNROF_PRNBYTES; nn++)
|
||||
retbuf[nn] = uint8_t (SharedMem::read()->Sdata_PRN_TEXT[0][nn]); // restore oldest text
|
||||
|
||||
// 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++)
|
||||
{
|
||||
for (mm=0; mm<MAXNROF_PRNBYTES; mm++)
|
||||
buf[mm]=SharedMem::read()->Sdata_PRN_TEXT[nn+1][mm];
|
||||
for (mm=0; mm<MAXNROF_PRNBYTES; mm++)
|
||||
SharedMem::write()->Sdata_PRN_TEXT[nn][mm]=buf[mm];
|
||||
}
|
||||
if (pp>0) pp--;
|
||||
SharedMem::write()->pPrnDataBuff=pp;
|
||||
|
||||
// example: pp=4: then buffers [0...3] are still occupied, pp=0: all buffers empty
|
||||
|
||||
// now clear highest copyed line (which became free now)
|
||||
tslib_strclr(SharedMem::write()->Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES);
|
||||
|
||||
// optionally: clear all remaining higher lines:
|
||||
for (nn=(pp+1); nn<MAXNROF_PRNBLOCKS; nn++)
|
||||
tslib_strclr(SharedMem::write()->Sdata_PRN_TEXT[nn], 0, MAXNROF_PRNBYTES);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t gpi_chk4remainingText(void)
|
||||
{
|
||||
// retval: 0: no more textline left (to send) >0: nr of 64byte-blocks
|
||||
return (SharedMem::read()->pPrnDataBuff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// 11.4.23 neu, Kommando direkt an "FastDevice"-protokoll senden, nicht mehr umsetzen
|
||||
// ---------------------------------------------------------------------------------
|
||||
/*
|
||||
// header
|
||||
static uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDshort[FDCMD_STACKDEPTH];
|
||||
|
||||
// short data
|
||||
static uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
||||
static uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
||||
// long data:
|
||||
static uint8_t longFDlength[FDCMD_STACKDEPTH];
|
||||
static uint8_t longFDpara[FDCMD_STACKDEPTH][64];
|
||||
|
||||
static uint8_t p_nextFDcmdsInQueue;
|
||||
*/
|
||||
|
||||
/* 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 sendFDcmd_clrStack(void)
|
||||
{
|
||||
uint8_t nn;
|
||||
for (nn=0; nn<FDCMD_STACKDEPTH; nn++)
|
||||
{
|
||||
SharedMem::write()->nextFDwrCmd[nn]=0;
|
||||
SharedMem::write()->nextFDrdCmd[nn]=0;
|
||||
SharedMem::write()->nextFDblkNr[nn]=0;
|
||||
SharedMem::write()->nextFDshort[nn]=0;
|
||||
SharedMem::write()->nextFDpara1[nn]=0;
|
||||
SharedMem::write()->nextFDpara2[nn]=0;
|
||||
SharedMem::write()->nextFDpara3[nn]=0;
|
||||
SharedMem::write()->nextFDpara4[nn]=0;
|
||||
SharedMem::write()->longFDlength[nn]=0;
|
||||
memset(&SharedMem::write()->longFDpara[nn][0],0,64);
|
||||
}
|
||||
|
||||
SharedMem::write()->p_nextFDcmdsInQueue=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)
|
||||
{
|
||||
|
||||
// write Command to memory, wait for transport
|
||||
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
|
||||
|
||||
if (pFDcmd >=FDCMD_STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
SharedMem::write()->nextFDwrCmd[pFDcmd]=nextWrCmd;
|
||||
SharedMem::write()->nextFDrdCmd[pFDcmd]=nextRdCmd;
|
||||
SharedMem::write()->nextFDblkNr[pFDcmd]=blockNum;
|
||||
SharedMem::write()->nextFDpara1[pFDcmd]=dat1;
|
||||
SharedMem::write()->nextFDpara2[pFDcmd]=dat2;
|
||||
SharedMem::write()->nextFDpara3[pFDcmd]=dat3;
|
||||
SharedMem::write()->nextFDpara4[pFDcmd]=dat4;
|
||||
//qDebug() << "data with 4 data byte saved, pp=" << pFDcmd;
|
||||
//qDebug() << " dat1=" << nextCmd4para1[pFDcmd] << " dat2=" << nextCmd4para2[pFDcmd]
|
||||
// << " dat3=" << nextCmd4para3[pFDcmd] << " dat4=" << nextCmd4para4[pFDcmd];
|
||||
SharedMem::write()->nextFDshort[pFDcmd]=1; // 1=short
|
||||
pFDcmd++;
|
||||
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
|
||||
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
|
||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data)
|
||||
{
|
||||
// write Command to memory, wait for transport
|
||||
// data buffer size always 64! data[64], padded with 0
|
||||
uint8_t nn;
|
||||
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
|
||||
|
||||
if (pFDcmd>=FDCMD_STACKDEPTH)
|
||||
{
|
||||
qDebug() << "cannot save cmd because stack is full";
|
||||
return false; // not possible
|
||||
}
|
||||
SharedMem::write()->nextFDwrCmd[pFDcmd]=nextWrCmd;
|
||||
SharedMem::write()->nextFDrdCmd[pFDcmd]=nextRdCmd;
|
||||
SharedMem::write()->nextFDblkNr[pFDcmd]=blockNum;
|
||||
|
||||
SharedMem::write()->longFDlength[pFDcmd]=length;
|
||||
|
||||
for (nn=0; nn<64; nn++)
|
||||
SharedMem::write()->longFDpara[pFDcmd][nn]=data[nn];
|
||||
|
||||
SharedMem::write()->nextFDshort[pFDcmd]=2;
|
||||
pFDcmd++;
|
||||
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
|
||||
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, mm, data; // ll
|
||||
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
|
||||
|
||||
if (pFDcmd==0 || pFDcmd>FDCMD_STACKDEPTH)
|
||||
return false; // not possible
|
||||
|
||||
*nextWrCmd=SharedMem::read()->nextFDwrCmd[0];
|
||||
*nextRdCmd=SharedMem::read()->nextFDrdCmd[0];
|
||||
*blockNum=SharedMem::read()->nextFDblkNr[0];
|
||||
*dat1=SharedMem::read()->nextFDpara1[0];
|
||||
*dat2=SharedMem::read()->nextFDpara2[0];
|
||||
*dat3=SharedMem::read()->nextFDpara3[0];
|
||||
*dat4=SharedMem::read()->nextFDpara4[0];
|
||||
//qDebug() << "sendFDcmd_get [0]; pp=" << SharedMem::read()->p_nextFDcmdsInQueue;
|
||||
//qDebug() << " data1: " << SharedMem::read()->nextCmd4para1[0] << " data2: " << SharedMem::read()->nextCmd4para2[0] <<
|
||||
// " data3: " << SharedMem::read()->nextCmd4para3[0] << " data4: " << SharedMem::read()->nextCmd4para4[0];
|
||||
|
||||
// move Puffer down by one element
|
||||
//if (FDCMD_STACKDEPTH>0)
|
||||
// ll=FDCMD_STACKDEPTH-1;
|
||||
//else
|
||||
// ll=0;
|
||||
|
||||
if (pFDcmd>0) pFDcmd--; else pFDcmd=0;
|
||||
|
||||
//for (nn=0; nn<ll; nn++)
|
||||
for (nn=0; nn<pFDcmd; nn++)
|
||||
{
|
||||
data=SharedMem::read()->nextFDwrCmd[nn+1];
|
||||
SharedMem::write()->nextFDwrCmd[nn]=data;
|
||||
data=SharedMem::read()->nextFDrdCmd[nn+1];
|
||||
SharedMem::write()->nextFDrdCmd[nn]=data;
|
||||
data=SharedMem::read()->nextFDblkNr[nn+1];
|
||||
SharedMem::write()->nextFDblkNr[nn]=data;
|
||||
data=SharedMem::read()->nextFDpara1[nn+1];
|
||||
SharedMem::write()->nextFDpara1[nn]=data;
|
||||
data=SharedMem::read()->nextFDpara2[nn+1];
|
||||
SharedMem::write()->nextFDpara2[nn]=data;
|
||||
data=SharedMem::read()->nextFDpara3[nn+1];
|
||||
SharedMem::write()->nextFDpara3[nn]=data;
|
||||
data=SharedMem::read()->nextFDpara4[nn+1];
|
||||
SharedMem::write()->nextFDpara4[nn]=data;
|
||||
|
||||
data=SharedMem::read()->nextFDshort[nn+1];
|
||||
SharedMem::write()->nextFDshort[nn] = data;
|
||||
|
||||
data=SharedMem::read()->longFDlength[nn+1];
|
||||
SharedMem::write()->longFDlength[nn] = data;
|
||||
|
||||
for (mm=0; mm<64; mm++)
|
||||
{
|
||||
SharedMem::write()->longFDpara[nn][mm] = SharedMem::read()->longFDpara[nn+1][mm];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
|
||||
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
|
||||
|
||||
// clear released buffer:
|
||||
//for (nn=p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH; nn++)
|
||||
//{
|
||||
SharedMem::write()->nextFDwrCmd[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDrdCmd[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDblkNr[pFDcmd]=0;
|
||||
|
||||
SharedMem::write()->nextFDpara1[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDpara2[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDpara3[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDpara4[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDshort[pFDcmd]=0;
|
||||
SharedMem::write()->longFDlength[pFDcmd]=0;
|
||||
for (mm=0; mm<64; mm++)
|
||||
SharedMem::write()->longFDpara[pFDcmd][mm] = 0;
|
||||
//}
|
||||
|
||||
/*
|
||||
qDebug() << "sendFDcmd_set, stack now: " << p_nextFDcmdsInQueue;
|
||||
for (nn=0; nn<16; nn++)
|
||||
{
|
||||
qDebug() << "header: " << nextFDwrCmd[nn] << " / " << nextFDrdCmd[nn] << " / "<< nextFDblkNr[nn] << " / " << nextFDshort[nn];
|
||||
|
||||
qDebug() << " short data: " << nextFDpara1[nn] << " / "<< nextFDpara2[nn] << " / "<< nextFDpara3[nn]<< " / "<< nextFDpara4[nn];
|
||||
|
||||
qDebug() << " long data: " << longFDlength[nn] << " / "<< longFDpara[nn][0] << " / "<< longFDpara[nn][1]
|
||||
<< " / "<< longFDpara[nn][2] << " / "<< longFDpara[nn][3] << " / "<< longFDpara[nn][4];
|
||||
}
|
||||
*/
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
uint8_t checkNextFDcmd(void)
|
||||
{
|
||||
// return 0: no command waiting
|
||||
// 1: short cmd
|
||||
// 2: long cmd
|
||||
//qDebug() << "chk nxt fd cmd: "<<p_nextFDcmdsInQueue<<" "<<nextFDshort[0]<<" "<<nextFDshort[1]<<" "<<nextFDshort[2]<<" "<<nextFDshort[3];
|
||||
if (SharedMem::read()->p_nextFDcmdsInQueue==0)
|
||||
return 0;
|
||||
if (SharedMem::read()->nextFDshort[0]==1)
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
uint8_t check4FDshortCmd(void)
|
||||
{
|
||||
// returns number of waiting command, max FDCMD_STACKDEPTH
|
||||
return SharedMem::read()->p_nextFDcmdsInQueue;
|
||||
}
|
||||
|
||||
|
||||
uint8_t check4freeFDshortCmd(void)
|
||||
{
|
||||
// returns number of free places in short-command stack
|
||||
return FDCMD_STACKDEPTH - SharedMem::read()->p_nextFDcmdsInQueue;
|
||||
}
|
||||
|
||||
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data)
|
||||
{
|
||||
uint8_t nn, mm, uctmp;
|
||||
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
|
||||
|
||||
if (pFDcmd==0 || pFDcmd>FDCMD_STACKDEPTH)
|
||||
return false; // not possible
|
||||
|
||||
*nextWrCmd=SharedMem::read()->nextFDwrCmd[0];
|
||||
*nextRdCmd=SharedMem::read()->nextFDrdCmd[0];
|
||||
*blockNum=SharedMem::read()->nextFDblkNr[0];
|
||||
*length = SharedMem::read()->longFDlength[0];
|
||||
for (mm=0; mm<64; mm++)
|
||||
data[mm] = SharedMem::read()->longFDpara[0][mm];
|
||||
|
||||
if (pFDcmd>0) pFDcmd--; else pFDcmd=0;
|
||||
|
||||
//for (nn=0; nn<ll; nn++)
|
||||
for (nn=0; nn<pFDcmd; nn++)
|
||||
{
|
||||
uctmp=SharedMem::read()->nextFDwrCmd[nn+1];
|
||||
SharedMem::write()->nextFDwrCmd[nn]=uctmp;
|
||||
uctmp=SharedMem::read()->nextFDrdCmd[nn+1];
|
||||
SharedMem::write()->nextFDrdCmd[nn]=uctmp;
|
||||
uctmp=SharedMem::read()->nextFDblkNr[nn+1];
|
||||
SharedMem::write()->nextFDblkNr[nn]=uctmp;
|
||||
|
||||
uctmp=SharedMem::read()->nextFDpara1[nn+1];
|
||||
SharedMem::write()->nextFDpara1[nn]=uctmp;
|
||||
uctmp=SharedMem::read()->nextFDpara2[nn+1];
|
||||
SharedMem::write()->nextFDpara2[nn]=uctmp;
|
||||
uctmp=SharedMem::read()->nextFDpara3[nn+1];
|
||||
SharedMem::write()->nextFDpara3[nn]=uctmp;
|
||||
uctmp=SharedMem::read()->nextFDpara4[nn+1];
|
||||
SharedMem::write()->nextFDpara4[nn]=uctmp;
|
||||
|
||||
uctmp=SharedMem::read()->nextFDshort[nn+1];
|
||||
SharedMem::write()->nextFDshort[nn]=uctmp;
|
||||
uctmp=SharedMem::read()->longFDlength[nn+1];
|
||||
SharedMem::write()->longFDlength[nn]=uctmp;
|
||||
|
||||
for (mm=0; mm<64; mm++)
|
||||
{
|
||||
SharedMem::write()->longFDpara[nn][mm] = SharedMem::read()->longFDpara[nn+1][mm];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
|
||||
// clear released buffer:
|
||||
SharedMem::write()->nextFDwrCmd[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDrdCmd[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDblkNr[pFDcmd]=0;
|
||||
|
||||
SharedMem::write()->nextFDpara1[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDpara2[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDpara3[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDpara4[pFDcmd]=0;
|
||||
SharedMem::write()->nextFDshort[pFDcmd]=0;
|
||||
SharedMem::write()->longFDlength[pFDcmd]=0;
|
||||
for (mm=0; mm<64; mm++)
|
||||
SharedMem::write()->longFDpara[pFDcmd][mm] = 0;
|
||||
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1984,7 +1984,7 @@ void epi_iniVRstorage(void)
|
||||
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data )
|
||||
{
|
||||
uint16_t start=blkNr, ii;
|
||||
qDebug()<<"storing vault data "<<blkNr;
|
||||
//qDebug()<<"storing vault data "<<blkNr;
|
||||
SharedMem::write()->store_gotNrBlocksOfVaultRec |= (1<<start); // setze pro Block ein bit, wir brauchen block 0...5
|
||||
// also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen
|
||||
start<<=6; // *64
|
||||
@@ -2332,7 +2332,67 @@ void epi_restoreTubeLevel(uint8_t *data)
|
||||
|
||||
|
||||
|
||||
|
||||
void gpi_storeBnaParams(uint8_t *data)
|
||||
{
|
||||
int nn;
|
||||
for (nn=0; nn<64; nn++)
|
||||
{
|
||||
SharedMem::write()->store_bnaParameter[nn]=data[nn];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void epi_restoreBnaParams(uint8_t *data)
|
||||
{
|
||||
int nn;
|
||||
for (nn=0; nn<64; nn++)
|
||||
{
|
||||
data[nn]=SharedMem::read()->store_bnaParameter[nn];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gpi_storeBnaCollection(uint8_t *data)
|
||||
{
|
||||
int nn;
|
||||
for (nn=0; nn<8; nn++)
|
||||
{
|
||||
SharedMem::write()->store_bnaCollect[nn]=data[nn];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void epi_restoreBnaCollection(uint8_t *data)
|
||||
{
|
||||
int nn;
|
||||
for (nn=0; nn<8; nn++)
|
||||
{
|
||||
data[nn]=SharedMem::read()->store_bnaCollect[nn];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gpi_storeBnaContent(uint8_t *data)
|
||||
{
|
||||
int nn;
|
||||
for (nn=0; nn<64; nn++)
|
||||
{
|
||||
SharedMem::write()->store_bnaContent[nn]=data[nn];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void epi_restoreBnaContent(uint8_t *data)
|
||||
{
|
||||
int nn;
|
||||
for (nn=0; nn<64; nn++)
|
||||
{
|
||||
data[nn]=SharedMem::read()->store_bnaContent[nn];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user