Compare commits

..

78 Commits

Author SHA1 Message Date
23fe319497 Merge from master-branch 2024-02-09 12:57:22 +01:00
3fc8562a2b bl_sendDataBlock(): Fix buffer overflow. 2024-02-09 12:51:11 +01:00
544bab4332 run(): improve on output sent to GUI of ATBUpdateTool. 2024-02-09 12:49:09 +01:00
35f7d56c2a gpi_storeHW/SWver(): store passed parameter ('QString text') in shared memory. 2024-02-09 12:46:49 +01:00
a63e7018a4 Minor: add some exteneded debug output. 2024-02-09 12:44:04 +01:00
b05325e5f4 Minor: remove some obsolete (commented) lines. 2024-02-09 12:43:16 +01:00
5cfc346317 run(): download device controller using some older (home-grown) algorithm. 2024-02-09 12:42:08 +01:00
15151a9df4 run(): Minor: add some extended debug output. 2024-02-09 12:41:19 +01:00
b7449ff4a2 T_runProc::bl_isUp(): fix check for "02:65:30:df:83:03". 2024-02-09 12:25:13 +01:00
04055e9607 Minor: add sanitizer-flags (future use) 2024-02-09 12:19:13 +01:00
bdef3ff652 Minor: only show new-version name of device-controller (only possible if a new one has been downloaded) 2024-02-06 11:35:47 +01:00
7130d052e7 Merge branch 'SiegfriedSiegert-pu/FixGetDeviceConditions' 2024-02-06 09:55:57 +01:00
ad84464bf4 Merge branch 'pu/FixGetDeviceConditions' of https://git.mimbach49.de/SiegfriedSiegert/DCLibraries into SiegfriedSiegert-pu/FixGetDeviceConditions 2024-02-06 09:55:38 +01:00
352b550190 Fix Q_ASSERTS 2024-02-06 09:55:00 +01:00
69d0420e7d sys_restoreDeviceParameter() check size of struct T_devices 2024-02-06 09:39:21 +01:00
9b2433c2cd Fix: check size of struct T_devices 2024-02-05 17:36:53 +01:00
5599c56114 Minor: added some debug output 2024-02-05 14:52:09 +01:00
0723ef335c Added some debug output. 2024-02-05 14:51:16 +01:00
ef31911e74 hw/sw-version: always store different version than current onew 2024-02-05 14:50:17 +01:00
100ada06f8 Improve on storing hw/sw version of device controller 2024-02-02 13:41:13 +01:00
fb5cf3cc6a Minor: add debug out put. memset buffers to be printed. 2024-02-02 13:40:21 +01:00
287106d8f3 Make sure reporting thread is executed by GUI thread. 2024-02-02 13:39:00 +01:00
e7f45251a9 Improve on download functionlity 2024-02-02 13:38:40 +01:00
0839254f06 Do real download, not just some simulation. 2024-02-02 13:36:09 +01:00
6005fddc66 Start download thread when requested. 2024-02-02 13:35:06 +01:00
392b849a9b User version 1.0.2 2024-02-02 13:34:39 +01:00
6fa689f142 Use version 1.0.2 2024-02-02 13:34:13 +01:00
fc28666946 Improved creating/attaching shared memory: there is a possibility of a stale shared memory
under /tmp.
2024-02-02 13:32:56 +01:00
3bf3e741a0 Add os_release, date and creator variables. 2024-02-02 13:32:16 +01:00
f6efb1ee9a Use actually reporting coe, not just some test code. 2024-02-02 13:31:32 +01:00
a1237749dc Minor change: add some commented out code 2024-02-02 13:31:04 +01:00
f5613d5aad Minor: directly initialize doenload/reporting-thread pointers. 2024-02-02 11:09:14 +01:00
3564bac8d4 Add reference to plugin (m_hw), so it is possible to start the download thread. 2024-02-02 11:07:40 +01:00
Thomas
c5054fe4a0 removed lines for turning so-file into executable binary 2024-02-01 15:01:18 +01:00
02f15421ba Add sources for download/reporting thread 2023-12-20 17:06:37 +01:00
3c9cd16144 Add headers for download/reporting thread 2023-12-20 17:05:47 +01:00
760f4018b5 Merge branch 'master' of https://git.mimbach49.de/GerhardHoffmann/DCLibraries 2023-12-20 16:52:13 +01:00
a344ba1b7d Add implementations for helpers for downloading device controller.
NOTE : They are not called at the moment.
2023-12-20 16:50:50 +01:00
490fdd9209 Minor: add some debug output (versions, build times) 2023-12-20 16:50:23 +01:00
0c417c6940 Add headers for download/reporting thread. 2023-12-20 16:50:00 +01:00
fafea93a62 Add reporting thread and defines for output of versions and build dates/times. 2023-12-20 16:48:57 +01:00
ba99795bf3 Add download thread and define macros to output versions and build times. 2023-12-20 16:47:59 +01:00
135c508320 Add struct DCDownload for downloading the device controller. 2023-12-20 16:46:54 +01:00
f9dfc2b5e7 define git commnds only for linux 2023-12-20 16:46:21 +01:00
fc2abd3e89 Add helers and signals for downloading the device controller. 2023-12-20 16:44:03 +01:00
15671e3a37 Add helpers and signals for downloading the device controller. 2023-12-20 16:42:56 +01:00
54993ac592 Test for commit. 2023-12-18 12:28:43 +01:00
2c67638c34 Add some debug output in case the dc-data-valid flag is reset to false. 2023-12-18 12:12:30 +01:00
e7538ae5df Set compiler check: make sure MASTER and SLAVE defines are not set at the same time. 2023-12-18 12:11:45 +01:00
cb403b5dbb Remove references to com, datif and prot components. 2023-12-18 12:10:33 +01:00
f226179e24 Add com, datif and prot components. 2023-12-18 12:09:59 +01:00
3eff32b45c Fix: remove lines from TEMPLATE=lib on. This will completely confuse Qt creator 2023-12-18 12:09:24 +01:00
075a9d9316 Remove com, datif and prot, and add them in lib_ca_master.pro 2023-12-18 12:08:04 +01:00
8c261af1a7 Remove com, datif and prot (so we cannot link). 2023-12-18 10:44:08 +01:00
e0346e0a9b Explicitlz remove define THIS_IS_CA_SLAVE. 2023-12-18 10:43:01 +01:00
16b6ea8087 Add COMPILER-CHECKS: datif is only valid inside the master-lib. 2023-12-18 10:41:56 +01:00
9bdc08f6fc no change 2023-12-16 09:39:51 +01:00
a3bc3d53cd diagnosis 2023-12-16 09:39:36 +01:00
9971b7ac2e diagnosis 2023-12-16 09:38:29 +01:00
15ada1ad26 diagnosis 2023-12-16 09:37:50 +01:00
1811842082 no more define 2023-12-16 09:36:53 +01:00
13ff32b108 no change 2023-12-16 09:36:19 +01:00
cea817cbcb // minor add comment for function bna_getCurrentNotes 2023-12-13 15:21:04 +01:00
e50871cf9f // made connection to DC more reliable, tries to open until succeeded 2023-12-13 15:20:28 +01:00
f6f90fe770 // made connection to DC more reliable, tries to open until succeeded 2023-12-13 15:17:14 +01:00
7b1ea963e2 Merge https://git.mimbach49.de/GerhardHoffmann/DCLibraries 2023-12-08 12:05:53 +01:00
8163be5022 Fix: correct order of steps in cash_paymentProcessing (NOTE: not compatible with Szeged at the moment.
This will require an update of the firmware device controller).
2023-12-08 12:02:25 +01:00
1fdbf3b9ca Minor: add some comments. 2023-12-08 11:58:55 +01:00
d380bcafe8 Check if THIS_IS_CA_MASTER is already defined.
Thomas has some issues in his environment.
2023-12-06 14:57:01 +01:00
27c0aa56ee Prepare new implementation of downloading the bootloader. 2023-12-06 14:45:22 +01:00
6377c6c18f Include previous main for windows. 2023-12-06 14:42:57 +01:00
e906213441 Change as for cash_cancelPayment(). 2023-12-06 14:37:37 +01:00
57b4ade2e5 cashCancelPayment(): while printing quick request while printing and changing. 2023-12-06 14:35:57 +01:00
f817d07e8c Extend sendINrequestsAutomatic(): add several requests. 2023-12-06 14:33:30 +01:00
fc2bc6bafc Mark hwapi-functions as overridden. 2023-12-06 14:30:45 +01:00
7f672db841 Add new timer myTO. 2023-12-06 14:28:24 +01:00
d8232e0163 Change hwapi_functions as pure virtual signals due to compiler problems. 2023-12-06 14:26:06 +01:00
fc2132184e Minor: add header. 2023-12-06 14:20:02 +01:00
32 changed files with 5573 additions and 431 deletions

View File

@@ -21,14 +21,15 @@ INCLUDEPATH += ../include
win32 { win32 {
BUILD_DATE=$$system("date /t") BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t") BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
} else { } else {
BUILD_DATE=$$system("date +%d-%m-%y") BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S") BUILD_TIME=$$system("date +%H:%M:%S")
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
} }
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
DEFINES+=APP_VERSION=\\\"$$VERSION\\\" DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\" DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"

View File

@@ -375,6 +375,9 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// bit0,1: enable/disable button "next" // bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home" // bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back" // bit4,5: enable/disable button "back"
QString bs, cn;
int br, ci;
this->updateGui(); this->updateGui();
*nextScreen=0; // 0=no change *nextScreen=0; // 0=no change
@@ -385,22 +388,29 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// load and use last settings: -------------------- // load and use last settings: --------------------
QByteArray myBA; QByteArray myBA;
myBA=datei_readFromFile(FILENAME_COMPORT); myBA=datei_readFromFile(FILENAME_COMPORT);
if (myBA.length()>0)
//uint32_t len= datei_nrOfEntriesInFile(myBA); {
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0); bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
//qDebug()<<"win_startup load long numer: "<<ulltmp; br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
bs=csv_getEntryAsString(myBA,2); // z.B 115200 bs=csv_getEntryAsString(myBA,2); // z.B 115200
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9 cn=csv_getEntryAsString(myBA,3); // z.B. COM9
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
HWaccess->dc_openSerial(br,bs,cn,1); HWaccess->dc_openSerial(br,bs,cn,1);
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken" connectButton->setChecked(true); // connect Taste "druecken"
} else
{
// open with default settings
qDebug()<<"CArunGui: open serial with default values";
bs="115200";
br=5;
//cn="COM14"; // Windows
cn="ttymxc2"; // PTU5
ci=2;
HWaccess->dc_openSerial(br,bs,cn,1);
}
myTO->start(100); // restart myTO->start(100); // restart
myStep++; myStep++;
} else } else
@@ -410,9 +420,13 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (!myTO->isActive()) if (!myTO->isActive())
{ {
if (HWaccess->dc_isPortOpen()) if (HWaccess->dc_isPortOpen())
{
myStep++; myStep++;
else } else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: port is still closed, restarting..";
}
myTO->start(100); myTO->start(100);
} }
} else } else
@@ -434,7 +448,10 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (HWaccess->dc_readAnswTestResponse()) if (HWaccess->dc_readAnswTestResponse())
myStep++; // response was correct myStep++; // response was correct
else else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: got no answer from DC, retry..";
}
myTO->start(100); myTO->start(100);
} }
@@ -445,23 +462,38 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
HWaccess->dc_autoRequest(1); HWaccess->dc_autoRequest(1);
AutSendButton->setChecked(true); // taste "druecken" AutSendButton->setChecked(true); // taste "druecken"
myStep++; myStep++;
myTO->start(2000);
} else } else
if (myStep==5) if (myStep==5)
{ {
// got next screen: if (!myTO->isActive())
//myNextStep=2; // nicht bei CArun {
if (HWaccess->sys_areDCdataValid())
{
qDebug()<<"CArunGui: DC is connected";
myStep=7; // OK, connection is up and running
} else
{
qDebug()<<"CArunGui: auto request is not running, retry...";
myStep++; myStep++;
myTO->start(100);
}
}
} else } else
if (myStep==6) if (myStep==6)
{ {
// stop here, everything done // restart autoconnect cycle
myTO->start(100); // restart
myStep=0;
} else } else
if (myStep==7) if (myStep==7)
{ {
// stay here, DC connection is up and running
} else } else
{ {
@@ -470,7 +502,6 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (myNextStep) if (myNextStep)
{ {
//qDebug()<<"fenster1 working: "<< myNextStep;
*nextScreen=myNextStep; *nextScreen=myNextStep;
myNextStep=0; myNextStep=0;
} }

View File

@@ -33,6 +33,8 @@ QMAKE_CXXFLAGS += -C
QMAKE_CXXFLAGS += -O2 -O QMAKE_CXXFLAGS += -O2 -O
QMAKE_CXXFLAGS += -g QMAKE_CXXFLAGS += -g
QMAKE_CXXFLAGS += -Wno-deprecated-copy QMAKE_CXXFLAGS += -Wno-deprecated-copy
# QMAKE_CXXFLAGS += -fsanitize=address
# QMAKE_CXXFLAGS += -fno-omit-frame-pointer
QMAKE_LFLAGS += -Wl,-e,main QMAKE_LFLAGS += -Wl,-e,main
@@ -81,37 +83,27 @@ contains( CONFIG, PTU5_YOCTO ) {
} }
HEADERS += \ HEADERS += \
$${PWD}/include/com.h \
$${PWD}/include/datei.h \ $${PWD}/include/datei.h \
$${PWD}/include/runProc.h \ $${PWD}/include/runProc.h \
$${PWD}/include/controlBus.h \ $${PWD}/include/controlBus.h \
$${PWD}/include/datIf.h \
$${PWD}/include/dcBL.h \ $${PWD}/include/dcBL.h \
$${PWD}/include/hwapi.h \ $${PWD}/include/hwapi.h \
$${PWD}/include/interfaces.h \ $${PWD}/include/interfaces.h \
$${PWD}/include/prot.h \
$${PWD}/include/sendWRcmd.h \ $${PWD}/include/sendWRcmd.h \
$${PWD}/include/storeINdata.h \ $${PWD}/include/storeINdata.h \
$${PWD}/include/tslib.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 += \ SOURCES += \
$${PWD}/src/com.cpp \
$${PWD}/src/datei.cpp \ $${PWD}/src/datei.cpp \
$${PWD}/src/runProc.cpp \ $${PWD}/src/runProc.cpp \
$${PWD}/src/controlBus.cpp \ $${PWD}/src/controlBus.cpp \
$${PWD}/src/datIf.cpp \
$${PWD}/src/dcBL.cpp \ $${PWD}/src/dcBL.cpp \
$${PWD}/src/hwapi.cpp \ $${PWD}/src/hwapi.cpp \
$${PWD}/src/prot.cpp \
$${PWD}/src/sendWRcmd.cpp \ $${PWD}/src/sendWRcmd.cpp \
$${PWD}/src/storeINdata.cpp \ $${PWD}/src/storeINdata.cpp \
$${PWD}/src/tslib.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 # INTERFACE = DeviceController

View File

@@ -1,4 +1,5 @@
TEMPLATE = subdirs TEMPLATE = subdirs
CONFIG += ordered CONFIG += ordered
SUBDIRS = lib_ca_master lib_ca_slave CArunGUI dCArun SUBDIRS = lib_ca_master lib_ca_slave CArunGUI dCArun

BIN
build/CArunGui Executable file

Binary file not shown.

1147
build/carun_out.txt Normal file

File diff suppressed because it is too large Load Diff

BIN
build/dCArun Executable file

Binary file not shown.

2492
build/interfaces.h Executable file

File diff suppressed because it is too large Load Diff

BIN
build/libCAmaster.so Executable file

Binary file not shown.

BIN
build/libCAslave.so Executable file

Binary file not shown.

View File

@@ -25,14 +25,15 @@ INCLUDEPATH += ../include
win32 { win32 {
BUILD_DATE=$$system("date /t") BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t") BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
} else { } else {
BUILD_DATE=$$system("date +%d-%m-%y") BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S") BUILD_TIME=$$system("date +%H:%M:%S")
}
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1") GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}" EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
}
DEFINES+=APP_VERSION=\\\"$$VERSION\\\" DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\" DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"

View File

@@ -375,6 +375,9 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// bit0,1: enable/disable button "next" // bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home" // bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back" // bit4,5: enable/disable button "back"
QString bs, cn;
int br, ci;
this->updateGui(); this->updateGui();
*nextScreen=0; // 0=no change *nextScreen=0; // 0=no change
@@ -385,22 +388,29 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// load and use last settings: -------------------- // load and use last settings: --------------------
QByteArray myBA; QByteArray myBA;
myBA=datei_readFromFile(FILENAME_COMPORT); myBA=datei_readFromFile(FILENAME_COMPORT);
if (myBA.length()>0)
//uint32_t len= datei_nrOfEntriesInFile(myBA); {
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0); bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
//qDebug()<<"win_startup load long numer: "<<ulltmp; br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
bs=csv_getEntryAsString(myBA,2); // z.B 115200 bs=csv_getEntryAsString(myBA,2); // z.B 115200
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9 cn=csv_getEntryAsString(myBA,3); // z.B. COM9
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
HWaccess->dc_openSerial(br,bs,cn,1); HWaccess->dc_openSerial(br,bs,cn,1);
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken" connectButton->setChecked(true); // connect Taste "druecken"
} else
{
// open with default settings
qDebug()<<"CArunGui: open serial with default values";
bs="115200";
br=5;
//cn="COM14"; // Windows
cn="ttymxc2"; // PTU5
ci=2;
HWaccess->dc_openSerial(br,bs,cn,1);
}
myTO->start(100); // restart myTO->start(100); // restart
myStep++; myStep++;
} else } else
@@ -410,9 +420,13 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (!myTO->isActive()) if (!myTO->isActive())
{ {
if (HWaccess->dc_isPortOpen()) if (HWaccess->dc_isPortOpen())
{
myStep++; myStep++;
else } else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: port is still closed, restarting..";
}
myTO->start(100); myTO->start(100);
} }
} else } else
@@ -434,7 +448,10 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (HWaccess->dc_readAnswTestResponse()) if (HWaccess->dc_readAnswTestResponse())
myStep++; // response was correct myStep++; // response was correct
else else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: got no answer from DC, retry..";
}
myTO->start(100); myTO->start(100);
} }
@@ -445,23 +462,38 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
HWaccess->dc_autoRequest(1); HWaccess->dc_autoRequest(1);
AutSendButton->setChecked(true); // taste "druecken" AutSendButton->setChecked(true); // taste "druecken"
myStep++; myStep++;
myTO->start(2000);
} else } else
if (myStep==5) if (myStep==5)
{ {
// got next screen: if (!myTO->isActive())
//myNextStep=2; // nicht bei CArun {
if (HWaccess->sys_areDCdataValid())
{
qDebug()<<"CArunGui: DC is connected";
myStep=7; // OK, connection is up and running
} else
{
qDebug()<<"CArunGui: auto request is not running, retry...";
myStep++; myStep++;
myTO->start(100);
}
}
} else } else
if (myStep==6) if (myStep==6)
{ {
// stop here, everything done // restart autoconnect cycle
myTO->start(100); // restart
myStep=0;
} else } else
if (myStep==7) if (myStep==7)
{ {
// stay here, DC connection is up and running
} else } else
{ {
@@ -470,7 +502,6 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (myNextStep) if (myNextStep)
{ {
//qDebug()<<"fenster1 working: "<< myNextStep;
*nextScreen=myNextStep; *nextScreen=myNextStep;
myNextStep=0; myNextStep=0;
} }

View File

@@ -133,8 +133,9 @@
#define SENDCOMBINED 0 #define SENDCOMBINED 0
class hwinf;
class DownloadThread; class DownloadThread;
class hwinf;
class T_datif : public QObject class T_datif : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -165,8 +166,7 @@ class T_datif : public QObject
T_prot *myDCIF; T_prot *myDCIF;
QTimer *datif_trigger; QTimer *datif_trigger;
uint8_t selectedSlaveAddr; uint8_t selectedSlaveAddr;
DownloadThread *m_downloadThread; hwinf *m_hw = nullptr;
hwinf *m_hw;
private slots: private slots:
char datif_cycleSend(); char datif_cycleSend();

View File

@@ -1,6 +1,7 @@
#ifndef DATEI_H #ifndef DATEI_H
#define DATEI_H #define DATEI_H
#include <stdint.h>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QDebug> #include <QDebug>

View File

@@ -26,6 +26,8 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
#ifndef hwapi_H #ifndef hwapi_H
#define hwapi_H #define hwapi_H
#include <stdint.h>
//#include <QTabWidget>
#include <QtPlugin> #include <QtPlugin>
#include <QTimer> #include <QTimer>
#include <QObject> #include <QObject>
@@ -37,11 +39,11 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
#include "controlBus.h" #include "controlBus.h"
#include "storeINdata.h" #include "storeINdata.h"
#include "dcBL.h" #include "dcBL.h"
#include "interfaces.h" //#include <../plugins/interfaces.h>
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include "runProc.h" #include "runProc.h"
#include "download_thread.h" #include "interfaces.h"
#include "reporting_thread.h"
/* /*
* select Plugin Type here * select Plugin Type here
@@ -73,10 +75,13 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
//#undef THIS_IS_CA_MASTER //#undef THIS_IS_CA_MASTER
//for CAmaster: //for CAmaster:
//#define THIS_IS_CA_MASTER
class QSharedMemory; class QSharedMemory;
class ReportingThread;
class DownloadThread; class DownloadThread;
class ReportingThread;
class hwapi : public QObject, class hwapi : public QObject,
public hwinf public hwinf
{ {
@@ -88,13 +93,13 @@ private:
void sub_storeSendingText(QByteArray *buf) const; void sub_storeSendingText(QByteArray *buf) const;
QTimer *hwapi_TimerPayment; QTimer *hwapi_TimerPayment;
QSharedMemory *m_sharedMem; QSharedMemory *m_sharedMem;
ReportingThread *m_reportingThread; ReportingThread *m_reportingThread = nullptr;
DownloadThread *m_downloadThread; DownloadThread *m_downloadThread = nullptr;
//QTimer *hwapi_triggerBL;
public: public:
explicit hwapi(QWidget *parent = nullptr); explicit hwapi(QWidget *parent = nullptr);
#ifdef THIS_IS_CA_MASTER #ifdef THIS_IS_CA_MASTER
T_datif *myDatif; T_datif *myDatif;
#endif #endif
@@ -1296,8 +1301,15 @@ public:
uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const override; uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const override;
// returns number of collected bank notes since start-command (current transaction) // returns number of collected bank notes since start-command (current transaction)
// latestBill: last accepted bank note, value in cent // return value: numbers of bills or 99 in case of error
// currentNotes an array with up to 16 (further) notes collected // latestBill: not used
// in case of error: currentNotes[0,1,2,3] = 1..4 error number(s)
// in normal case:
// currentNotes[0]: last bill in cent (e.g. 1000 = 10€)
// currentNotes[1]: bin 1 = bill is still in escrow else bill is stacked
// note: by now (dec2023) escrow is not used, bills always go to stacker (box)
// currentNotes[2]: total sum of bills in cent, low word (16bit)
// currentNotes[3]: total sum of bills in cent, high word (16bit)
void bna_requestStackerLevel(void) const override; void bna_requestStackerLevel(void) const override;
@@ -1306,7 +1318,6 @@ public:
// countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-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 // countOfBills[1] for 10€ and so on
// download device controller // download device controller
bool dcDownloadRequest(QString const &fileToDownload) const override; bool dcDownloadRequest(QString const &fileToDownload) const override;
bool dcDownloadRequested() const override; bool dcDownloadRequested() const override;
@@ -1319,7 +1330,6 @@ public:
bool dcDownloadReportRunning() const override; bool dcDownloadReportRunning() const override;
bool dcDownloadReportFinished() override; bool dcDownloadReportFinished() override;
bool dcDownloadThreadStart() override; bool dcDownloadThreadStart() override;
bool dcDownloadThreadRunning() const override; bool dcDownloadThreadRunning() const override;
void dcDownloadThreadFinalize(DownloadThread *) override; void dcDownloadThreadFinalize(DownloadThread *) override;
@@ -1344,34 +1354,38 @@ public:
virtual QObject const *getAPI() override; virtual QObject const *getAPI() override;
signals: // for download signals:
void hwapi_reportDCDownloadStatus(QString const&) const; void hwapi_reportDCDownloadStatus(QString const&) const;
void hwapi_reportDCDownloadSuccess(QString const&) const; void hwapi_reportDCDownloadSuccess(QString const&) const;
void hwapi_reportDCDownloadFailure(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;
void hwapi_coinCollectionJustStarted(void) const; void hwapi_templatePrintFinished_OK(void) const override;
void hwapi_coinCollectionAborted(void) const; void hwapi_templatePrintFinished_Err(void) const override;
void hwapi_gotNewCoin(void) const; void hwapi_coinCollectionJustStarted(void) const override;
void hwapi_payStopByMax(void) const; void hwapi_coinCollectionAborted(void) const override;
void hwapi_payStopByPushbutton(void) const;
void hwapi_payStopByEscrow(void) const; void hwapi_gotNewCoin(void) const override;
void hwapi_payStopByError(void) const; void hwapi_payStopByMax(void) const override;
void hwapi_payStopByTimeout(void) const; void hwapi_payStopByPushbutton(void) const override;
void hwapi_payCancelled(void) const;
void hwapi_coinProcessJustStopped(void) const; void hwapi_payStopByEscrow(void) const override;
void hwapi_payStopByError(void) const override;
void hwapi_payStopByTimeout(void) const override;
void hwapi_payCancelled(void) const override;
void hwapi_coinProcessJustStopped(void) const override;
// new from 2023.06.12 // new from 2023.06.12
void hwapi_doorServiceDoorOpened(void) const; void hwapi_doorServiceDoorOpened(void) const override;
void hwapi_doorVaultDoorOpened(void) const; void hwapi_doorVaultDoorOpened(void) const override;
void hwapi_doorCoinBoxRemoved(void) const; void hwapi_doorCoinBoxRemoved(void) const override;
void hwapi_doorCoinBoxInserted(void) const; void hwapi_doorCoinBoxInserted(void) const override;
void hwapi_doorCBinAndAllDoorsClosed(void) const; void hwapi_doorCBinAndAllDoorsClosed(void) const override;
void hwapi_doorAllDoorsClosed(void) const; void hwapi_doorAllDoorsClosed(void) const override;
private slots: private slots:
//void hwapi_slotPrintFinished_OK(void); //void hwapi_slotPrintFinished_OK(void);

View File

@@ -2,7 +2,6 @@
#define INTERFACE_H #define INTERFACE_H
#include <QtPlugin> #include <QtPlugin>
#include <QString>
@@ -25,6 +24,7 @@ struct T_emp
// dynamic: // dynamic:
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine): uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
/*
// 0=start command // 0=start command
// 1=powered, do emp ini, send reset // 1=powered, do emp ini, send reset
// 2=delay // 2=delay
@@ -40,7 +40,7 @@ struct T_emp
// 90: stop all, 1s delay // 90: stop all, 1s delay
// 99: off, all stopped // 99: off, all stopped
*/
uint8_t pollingRunning; uint8_t pollingRunning;
uint8_t paymentRunning; uint8_t paymentRunning;
@@ -239,6 +239,7 @@ struct T_dynamicCondition
uint8_t lastVDoorState; uint8_t lastVDoorState;
uint8_t lastCBstate; uint8_t lastCBstate;
char paymentInProgress; char paymentInProgress;
// Version Szeged: aug2023
// 0: stopped by timeout // 0: stopped by timeout
// 1: running 2: wait4lastCoin // 1: running 2: wait4lastCoin
// 3: payment stopped manually, coins in Escrow // 3: payment stopped manually, coins in Escrow
@@ -247,6 +248,21 @@ struct T_dynamicCondition
// 6: coins encashed 7:coins returned // 6: coins encashed 7:coins returned
// 8: CoinChecker or MDB on Error // 8: CoinChecker or MDB on Error
// since Schoenau with bill and changer, nov2023
//0 = no payment
//will be set to 1 by cash_startCollection()
//neu 1: wait for devices getting ready for payment
//2 = payment,
//3 = wait for last coin/bill
//4 = Bezahlvorgang manuell beendet
//5 = payment stopped autom, amount collected, coins in Escrow
//6 = Bezahlvorgang beendet weil ZK voll
//4,5,6: payment done, keep on polling, wait for cash or return command
//7 = encash collected money from coin escrow into cash box
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
//9 = wait for changer result
//10= print refund receipt with "amountToReturn"
char res1; char res1;
uint16_t U_Batt; uint16_t U_Batt;
@@ -398,7 +414,6 @@ struct T_bna
}; };
class hwapi;
class DownloadThread; class DownloadThread;
class hwinf class hwinf
{ {
@@ -2255,14 +2270,23 @@ public:
virtual void bna_requestCurrentNotes() const {} virtual void bna_requestCurrentNotes() const {}
// send command to DC in order to get transaction data // send command to DC in order to get transaction data
virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const { virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const
{
Q_UNUSED(latestBill); Q_UNUSED(latestBill);
Q_UNUSED(currentNotes); Q_UNUSED(currentNotes);
return 0; return 0;
} }
// returns number of collected bank notes since start-command (current transaction) // returns number of collected bank notes since start-command (current transaction)
// latestBill: last accepted bank note, value in cent // return value: numbers of bills or 99 in case of error
// currentNotes an array with up to 16 (further) notes collected // latestBill: not used
// in case of error: currentNotes[0,1,2,3] = 1..4 error number(s)
// in normal case:
// currentNotes[0]: last bill in cent (e.g. 1000 = 10€)
// currentNotes[1]: bin 1 = bill is still in escrow else bill is stacked
// note: by now (dec2023) escrow is not used, bills always go to stacker (box)
// currentNotes[2]: total sum of bills in cent, low word (16bit)
// currentNotes[3]: total sum of bills in cent, high word (16bit)
virtual void bna_requestStackerLevel() const {} virtual void bna_requestStackerLevel() const {}
@@ -2326,12 +2350,49 @@ public:
virtual QObject const *getAPI() { return nullptr; } virtual QObject const *getAPI() { return nullptr; }
signals: // for download
void hwapi_reportDCDownloadStatus(QString const&) const; signals:
void hwapi_reportDCDownloadSuccess(QString const&) const; /*
void hwapi_reportDCDownloadFailure(QString const&) const; NOTE: the difference between a virtual Qt signal and a normal Qt signal:
A Qt virtual signal is a connection that is established using a pointer
or reference and is not connected to an object or data. It is therefore
not bound to a particular object, but to a specific class (object type).
Qt virtual signals are useful because they allow you to create
connections without worrying about whether an object or a specific data
element has been destroyed.
https://www.youtube.com/watch?v=HTH3VFfqsXw
*/
virtual void hwapi_reportDCDownloadStatus(QString const&) const {}
virtual void hwapi_reportDCDownloadSuccess(QString const&) const {}
virtual void hwapi_reportDCDownloadFailure(QString const&) const {}
virtual void hwapi_templatePrintFinished_OK(void) const=0;
virtual void hwapi_templatePrintFinished_Err(void) const=0;
virtual void hwapi_coinCollectionJustStarted(void) const=0;
virtual void hwapi_coinCollectionAborted(void) const=0;
virtual void hwapi_gotNewCoin(void) const=0;
virtual void hwapi_payStopByMax(void) const=0;
virtual void hwapi_payStopByPushbutton(void) const=0;
virtual void hwapi_payStopByEscrow(void) const=0;
virtual void hwapi_payStopByError(void) const=0;
virtual void hwapi_payStopByTimeout(void) const=0;
virtual void hwapi_payCancelled(void) const=0;
virtual void hwapi_coinProcessJustStopped(void) const=0;
virtual void hwapi_doorServiceDoorOpened(void) const=0;
virtual void hwapi_doorVaultDoorOpened(void) const=0;
virtual void hwapi_doorCoinBoxRemoved(void) const=0;
virtual void hwapi_doorCoinBoxInserted(void) const=0;
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
virtual void hwapi_doorAllDoorsClosed(void) const=0;
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid. // NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
/* GH Version, bringt Fehler
void hwapi_templatePrintFinished_OK() const; void hwapi_templatePrintFinished_OK() const;
void hwapi_templatePrintFinished_Err() const; void hwapi_templatePrintFinished_Err() const;
@@ -2354,6 +2415,7 @@ signals: // for download
void hwapi_doorCoinBoxInserted() const; void hwapi_doorCoinBoxInserted() const;
void hwapi_doorCBinAndAllDoorsClosed() const; void hwapi_doorCBinAndAllDoorsClosed() const;
void hwapi_doorAllDoorsClosed() const; void hwapi_doorAllDoorsClosed() const;
*/
}; };

View File

@@ -3,6 +3,7 @@
#include <QThread> #include <QThread>
#include <QString> #include <QString>
// #include <functional>
class hwapi; class hwapi;
class ReportingThread : public QThread { class ReportingThread : public QThread {
@@ -12,6 +13,14 @@ public:
ReportingThread(hwapi *hw); ReportingThread(hwapi *hw);
~ReportingThread(); ~ReportingThread();
//void setFunction(std::function<void(QString const&)> f) {
// m_f = f;
//}
//std::function<void(QString const&)> function() {
// return m_f;
//}
protected: protected:
// reporting thread does not have a running event queue, and therefore // reporting thread does not have a running event queue, and therefore
// no slots. signals work the usual way. // no slots. signals work the usual way.
@@ -20,6 +29,7 @@ protected:
private: private:
hwapi *m_hw; hwapi *m_hw;
QString m_fileToDownload; QString m_fileToDownload;
//std::function<void(QString const&)> m_f;
}; };
#endif // REPORTING_THREAD_H_INCLUDED #endif // REPORTING_THREAD_H_INCLUDED

View File

@@ -2,6 +2,7 @@
#ifndef RUN_PROCESS_H #ifndef RUN_PROCESS_H
#define RUN_PROCESS_H #define RUN_PROCESS_H
#include <stdint.h>
#include <QMainWindow> #include <QMainWindow>
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
@@ -25,7 +26,7 @@
class T_runProc : public QObject class T_runProc : public QObject
{ {
Q_OBJECT Q_OBJECT
QTimer *hwapi_TimerPayment, *hwapi_triggerBL; QTimer *hwapi_TimerPayment, *hwapi_triggerBL, *myTO;
void sub_emp_getAllParameters(struct T_emp *emp); void sub_emp_getAllParameters(struct T_emp *emp);
void changer_getAllParameters(struct T_changer *mw); void changer_getAllParameters(struct T_changer *mw);

View File

@@ -300,7 +300,6 @@ struct SharedMem
uint8_t p_nextFDcmdsInQueue; uint8_t p_nextFDcmdsInQueue;
// download of device controller and json files // download of device controller and json files
struct DCDownload { struct DCDownload {
enum class FILE_INDEX { enum class FILE_INDEX {
@@ -322,6 +321,11 @@ struct SharedMem
std::atomic_bool m_finished{false}; std::atomic_bool m_finished{false};
} m_downLoadDC; } m_downLoadDC;
// meta-data
char os_release[64];
char date_of_creation[32];
char creator[128]; // name of application plus pid
static QSharedMemory *getShm(std::size_t s = 0); static QSharedMemory *getShm(std::size_t s = 0);
static SharedMem *getData() static SharedMem *getData()

View File

@@ -0,0 +1,601 @@
#ifndef SHARED_MEM_BUFFER_INCLUDED_H
#define SHARED_MEM_BUFFER_INCLUDED_H
#include <cinttypes>
#include <atomic>
#include <QSharedMemory>
#include <QtGlobal>
#include <QDebug>
bool shdMem_firstUse(void);
// Vorsicht: im shared memory ist kein QString erlaubt!!!!!!!!!!!!!!!!!!!!!!
// nur standard C Typen!!!!!!
// also auch kein QByteArray o.ä.
// Vorsicht: Zugriffe auf Comport NICHT ins shared mem --> Absturz!!!!
struct SharedMem
{
#ifndef QT_NO_DEBUG
char mem_guard_1;
#endif
// ------------------ Comport Control --------------------------------
bool rs_portIsOpen;
bool AutoEmissionOn;
bool Sdata_serialTestResult;
uint8_t Sdata_pProtResultOk;
uint16_t Sdata_receivedDataLength;
uint8_t Sdata_receivedDataBlock[64];
uint8_t ndbs, pari, nsb, br;
#ifndef QT_NO_DEBUG
char mem_guard_2;
#endif
uint8_t Sdata_lastResult;
uint8_t Sdata_OverallResult;
bool Sdata_startSV;
#ifndef QT_NO_DEBUG
char mem_guard_3;
#endif
// ------------------ Data INPUT --------------------------------
bool indat_savePrnPwr;
bool indat_saveMifPwr;
bool indat_MdbIsOn;
//QString indat_HWversion;
//QString indat_SWversion;
//QString indat_DCstate;
#define versionBufferLen 32
char indat_HWversion[versionBufferLen];
#ifndef QT_NO_DEBUG
char mem_guard_4;
#endif
char indat_SWversion[versionBufferLen];
#ifndef QT_NO_DEBUG
char mem_guard_5;
#endif
char indat_DCstate[versionBufferLen];
#ifndef QT_NO_DEBUG
char mem_guard_6;
#endif
struct Sdata
{
uint64_t slaveUID;
uint8_t UIDstr[8];
} Sdata;
#ifndef QT_NO_DEBUG
char mem_guard_7;
#endif
struct T_globTime
{
// Reihenfolge nicht vertauschen!!!!!
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t Year;
uint8_t Month;
uint8_t DayOfMonth;
uint8_t DayOfWeek; // 1=monday...7
uint8_t reserve1;
uint16_t MinutesOfToday;
uint16_t reserve2;
uint32_t SecondsOfToday;
uint8_t IsLeapyear;
uint8_t nextLeap;
uint8_t lastLeap;
uint8_t hoursOfWeek;
uint16_t minOfWeek;
uint16_t hoursOfMonth;
uint16_t minOfMonth;
uint16_t dayOfYear;
uint16_t hoursOfYear;
uint16_t reserve3;
uint32_t minOfYear;
uint8_t squareOutMode;
uint8_t free1;
uint16_t reserve4;
uint32_t minOfMillenium;
// bis hierher 44byts
uint32_t free2;
uint32_t free3;
uint32_t free4;
} getGlobalTime;
#ifndef QT_NO_DEBUG
char mem_guard_8;
#endif
#define MAXNROF_AI 4
uint16_t AI_val[MAXNROF_AI];
#ifndef QT_NO_DEBUG
char mem_guard_9;
#endif
#define MAXNROF_MEASURE 4
uint32_t Sdata_measurement[MAXNROF_MEASURE];
#ifndef QT_NO_DEBUG
char mem_guard_10;
#endif
uint8_t di_doorSwitch;
uint8_t di_vaultSwitch;
uint8_t di_lockSwitch;
uint8_t di_opto;
uint8_t di_aux;
bool di_wakeFromPtu;
bool di_wakeFromMdb;
bool di_PrnReady;
bool di_CoinAttach;
bool di_CoinEscrowOpen;
bool di_mifCardTap;
bool di_wakeFromModem;
bool di_contactPwrOn;
bool di_mifarePwrOn;
bool di_rdbk_mdbTxd;
bool di_AuxPwrOn;
bool di_gsmPwrOn;
bool di_creditPwrOn;
bool di_printerPwrOn;
bool di_mdbPwrOn;
bool di_rejMot_home;
uint8_t di_npe_sensor;
#ifndef QT_NO_DEBUG
char mem_guard_11;
#endif
uint8_t do_mbdRxTst;
uint8_t do_motorBits;
uint8_t do_serialSwitch;
uint8_t do_ledsAndFan;
uint8_t do_laermUndRelay;
uint8_t do_ptuWake;
uint8_t do_auxPower;
uint8_t do_coinShutter;
uint8_t do_coinEscrow;
uint8_t do_printerPower;
#ifndef QT_NO_DEBUG
char mem_guard_12;
#endif
//#define NROFMIFSTATEBYTES 40
//uint8_t Sdata_MIF_STATE[NROFMIFSTATEBYTES];
uint8_t Sdata_MIF_DATA[64];
//uint8_t mif_cardType;
//uint8_t mif_cardHolder[8];
uint8_t Sdata_MIF_ATB[64];
#ifndef QT_NO_DEBUG
char mem_guard_13;
#endif
#define pi_prnStateArraySize 20
uint8_t Sdata_PRN_STATE[pi_prnStateArraySize];
#ifndef QT_NO_DEBUG
char mem_guard_14;
#endif
#define pi_prnFontArraySize 20
uint8_t Sdata_PRN_FONTS[pi_prnFontArraySize];
#ifndef QT_NO_DEBUG
char mem_guard_15;
#endif
bool Sdata_mdb_busRdy;
bool Sdata_mdb_V12on;
bool Sdata_mdb_V5on;
uint8_t Sdata_mdbNrOfRecData;
uint8_t Sdata_RecBuff[40];
#ifndef QT_NO_DEBUG
char mem_guard_16;
#endif
uint8_t Sdata_empNrOfsettings;
uint8_t Sdata_emp_settingsBuff[66];
#ifndef QT_NO_DEBUG
char mem_guard_17;
#endif
struct T_coin
{
uint8_t valid;
uint8_t signal;
uint8_t error;
uint8_t pad;
uint16_t value;
};
#define MEMDEPTH_GOTCOINS 16
struct T_coin gotCoin[MEMDEPTH_GOTCOINS];
uint8_t ctr_gotCoin;
#ifndef QT_NO_DEBUG
char mem_guard_18;
#endif
uint8_t Sdata_NrOfDeviceSetting;
uint8_t Sdata_DeviceSettingBuff[66];
#ifndef QT_NO_DEBUG
char mem_guard_19;
#endif
uint8_t SizeMachineIDBuff;
uint8_t MachineIDBuff[66];
#ifndef QT_NO_DEBUG
char mem_guard_20;
#endif
uint32_t store_insertedAmount;
uint16_t store_lastCoinType[64];
#ifndef QT_NO_DEBUG
char mem_guard_21;
#endif
uint16_t store_lastCoinValue[64];
#ifndef QT_NO_DEBUG
char mem_guard_22;
#endif
uint8_t p_lastCoin;
char store_curPayNewCoin;
uint64_t stor_wakSrc;
uint8_t stor_reason;
uint8_t store_rbDevParamLen;
uint8_t store_rbDevParams[66];
#ifndef QT_NO_DEBUG
char mem_guard_23;
#endif
uint8_t store_deviceCondLen;
uint8_t store_deviceCond[66];
#ifndef QT_NO_DEBUG
char mem_guard_24;
#endif
uint8_t store_machCondLen;
uint8_t store_machCond[66];
#ifndef QT_NO_DEBUG
char mem_guard_25;
#endif
uint8_t store_DcBackupNrOfAccNr;
uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
#ifndef QT_NO_DEBUG
char mem_guard_26;
#endif
#define PI_SIZOFVAULTRECORD 400
uint8_t store_gotNrBlocksOfVaultRec;
uint8_t store_vaultrecord[PI_SIZOFVAULTRECORD];
#ifndef QT_NO_DEBUG
char mem_guard_27;
#endif
uint32_t store_amount;
uint16_t store_nrOfCoins;
bool store_DcDataAreValid;
uint8_t storeDCdynPrinterData[64];
uint8_t DCdynPrinterDataActual;
#ifndef QT_NO_DEBUG
char mem_guard_28;
#endif
uint16_t store_DCNextAccountNumber;
uint16_t storeMifCardTypDataLen;
uint8_t storeMcardTypData[64];
#ifndef QT_NO_DEBUG
char mem_guard_29;
#endif
// new from 6.9.23:
#define RAW_BL_DATALEN 150
uint8_t Sdata_rawData[RAW_BL_DATALEN];
uint8_t Sdata_LengthRawData;
#define numberOfJsons 36
#define versionStringLength 16
char store_jsonVersion[versionStringLength][numberOfJsons];
#ifndef QT_NO_DEBUG
char mem_guard_30;
#endif
uint8_t Sdata_changeResult;
uint32_t Sdata_changedAmount;
uint8_t store_tubeLev[64];
#ifndef QT_NO_DEBUG
char mem_guard_31;
#endif
uint8_t store_bnaParameter[64];
#ifndef QT_NO_DEBUG
char mem_guard_32;
#endif
uint8_t store_bnaCollect[8];
#ifndef QT_NO_DEBUG
char mem_guard_33;
#endif
uint8_t store_bnaContent[64];
#ifndef QT_NO_DEBUG
char mem_guard_34;
#endif
// Mitteilung von Hwapi zu Datif:
bool Sdata_coinPaymentNow;
bool Sdata_bootloadingNow;
// ------------------ Data OUTPUT --------------------------------
// sendWRcmd.cpp
#define CMDSTACKDEPTH 16
uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH];
uint8_t nrOfCmdsInQueue;
#ifndef QT_NO_DEBUG
char mem_guard_35;
#endif
#define CMD4STACKDEPTH 8
uint16_t nextAsynchsendCmd4[CMD4STACKDEPTH];
uint8_t nextCmd4para1[CMD4STACKDEPTH];
uint8_t nextCmd4para2[CMD4STACKDEPTH];
uint8_t nextCmd4para3[CMD4STACKDEPTH];
uint8_t nextCmd4para4[CMD4STACKDEPTH];
uint8_t nrOfCmds4InQueue;
#ifndef QT_NO_DEBUG
char mem_guard_36;
#endif
#define CMD8STACKDEPTH 4
uint16_t nextAsynchsendCmd8[CMD8STACKDEPTH];
uint8_t nextCmd8para1[CMD8STACKDEPTH];
uint8_t nextCmd8para2[CMD8STACKDEPTH];
uint16_t nextCmd8para3[CMD8STACKDEPTH];
uint32_t nextCmd8para4[CMD8STACKDEPTH];
uint8_t nrOfCmds8InQueue;
#ifndef QT_NO_DEBUG
char mem_guard_37;
#endif
#define SENDASYDAT_BUFFSIZE 200
uint8_t sendAsynchDataBuf[SENDASYDAT_BUFFSIZE]; // no stack, only ONE buffer
uint8_t sendAsyDatLen;
#ifndef QT_NO_DEBUG
char mem_guard_38;
#endif
#define MDBSEND_BUFFSIZE 64
uint8_t Sdata_mdbSendBuffer[MDBSEND_BUFFSIZE];
uint8_t Sdata_mdbSendLen;
#ifndef QT_NO_DEBUG
char mem_guard_39;
#endif
uint8_t prnDataParameters[4];
uint8_t prnDataBufferUser;
#ifndef QT_NO_DEBUG
char mem_guard_40;
#endif
// ONE printer doc consists of 20 x 64 byte
#define MAXNROF_PRNBYTES 64
#define MAXNROF_PRNBLOCKS 20
char Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
#ifndef QT_NO_DEBUG
char mem_guard_41;
#endif
//#define FDCMD_STACKDEPTH 16 // up to 1024 byte
#define FDCMD_STACKDEPTH 32 // up to 2048 byte
// header
uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
uint8_t nextFDshort[FDCMD_STACKDEPTH];
#ifndef QT_NO_DEBUG
char mem_guard_42;
#endif
// short data
uint8_t nextFDpara1[FDCMD_STACKDEPTH];
uint8_t nextFDpara2[FDCMD_STACKDEPTH];
uint8_t nextFDpara3[FDCMD_STACKDEPTH];
uint8_t nextFDpara4[FDCMD_STACKDEPTH];
// long data:
uint8_t longFDlength[FDCMD_STACKDEPTH];
uint8_t longFDpara[FDCMD_STACKDEPTH][64];
#ifndef QT_NO_DEBUG
char mem_guard_43;
#endif
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;
#ifndef QT_NO_DEBUG
char mem_guard_44;
#endif
// meta-data
char os_release[64];
#ifndef QT_NO_DEBUG
char mem_guard_45;
#endif
char date_of_creation[32];
#ifndef QT_NO_DEBUG
char mem_guard_46;
#endif
char creator[128]; // name of application plus pid
#ifndef QT_NO_DEBUG
char mem_guard_47;
#endif
static QSharedMemory *getShm(std::size_t s = 0);
static SharedMem *getData()
{
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
return (SharedMem *)getShm()->data();
}
static SharedMem const *getDataConst()
{
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
return (SharedMem const *)getShm()->data();
}
// static SharedMemBuffer *write()
static SharedMem *write()
{
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
return (SharedMem *)getShm()->data();
}
// static SharedMemBuffer const *read()
static SharedMem const *read()
{
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
return (SharedMem const *)getShm()->data();
}
bool thisIsTheFirstUse(void);
#ifndef QT_NO_DEBUG
char mem_guard_0;
#endif
static void check_mem_guards() {
#ifndef QT_NO_DEBUG
static const char memcmp_array[48] = {0,};
char mem[48];
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
SharedMem const *d = (SharedMem const *)getShm()->data();
mem[0] = d->mem_guard_0;
mem[1] = d->mem_guard_1; mem[2] = d->mem_guard_2; mem[3] = d->mem_guard_3;
mem[4] = d->mem_guard_4; mem[5] = d->mem_guard_5; mem[6] = d->mem_guard_6;
mem[7] = d->mem_guard_7; mem[8] = d->mem_guard_8; mem[9] = d->mem_guard_9;
mem[10] = d->mem_guard_10;
mem[11] = d->mem_guard_11; mem[12] = d->mem_guard_12; mem[13] = d->mem_guard_13;
mem[14] = d->mem_guard_14; mem[15] = d->mem_guard_15; mem[16] = d->mem_guard_16;
mem[17] = d->mem_guard_17; mem[18] = d->mem_guard_18; mem[19] = d->mem_guard_19;
mem[20] = d->mem_guard_20;
mem[21] = d->mem_guard_21; mem[22] = d->mem_guard_22; mem[23] = d->mem_guard_23;
mem[24] = d->mem_guard_24; mem[25] = d->mem_guard_25; mem[26] = d->mem_guard_26;
mem[27] = d->mem_guard_27; mem[28] = d->mem_guard_28; mem[29] = d->mem_guard_29;
mem[30] = d->mem_guard_30;
mem[31] = d->mem_guard_31; mem[32] = d->mem_guard_32; mem[33] = d->mem_guard_33;
mem[34] = d->mem_guard_34; mem[35] = d->mem_guard_35; mem[36] = d->mem_guard_36;
mem[37] = d->mem_guard_37; mem[38] = d->mem_guard_38; mem[39] = d->mem_guard_39;
mem[40] = d->mem_guard_40;
mem[41] = d->mem_guard_41; mem[42] = d->mem_guard_42; mem[43] = d->mem_guard_43;
mem[44] = d->mem_guard_44; mem[45] = d->mem_guard_45; mem[46] = d->mem_guard_46;
mem[47] = d->mem_guard_47;
if (memcmp(mem, memcmp_array, sizeof(memcmp_array))) {
qCritical() << QByteArray(mem, sizeof(memcmp_array)).toHex(':');
for (uint i = 0; i < sizeof(memcmp_array); ++i) {
fprintf(stderr, "%02d -> %02x", i, (unsigned char)mem[i]);
} fprintf(stderr, "\n");
}
#endif
}
};
#endif // SHARED_MEM_BUFFER_INCLUDED_H

View File

@@ -527,6 +527,9 @@ void gpi_storeDcDataValid(bool isVal);
bool epi_areDcDataValid(); bool epi_areDcDataValid();
void epi_setDcDataValid(void);
void epi_resetDcDataValid(void);
void epi_clearDynData(void); void epi_clearDynData(void);

View File

@@ -1,11 +1,42 @@
TEMPLATE = lib TEMPLATE = lib
TARGET = CAmaster TARGET = CAmaster
VERSION="1.0.0" VERSION="1.0.2"
HEADERS += \
../include/com.h \
../include/datIf.h \
../include/prot.h \
../include/download_thread.h
SOURCES += \
../src/com.cpp \
../src/datIf.cpp \
../src/prot.cpp \
../src/download_thread.cpp
include(../DCLibraries.pri) include(../DCLibraries.pri)
win32 {
BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
EXTENDED_VERSION_LIB=""
} else {
BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S")
GIT_COMMIT=$$system("git log -1 --format=oneline . | cut -d' ' -f1")
EXTENDED_VERSION_LIB="libCAmaster-$${VERSION}-$${GIT_COMMIT}"
}
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
DEFINES+=APP_EXTENDED_VERSION_LIB=\\\"$$EXTENDED_VERSION_LIB\\\"
DEFINES+=THIS_IS_CA_MASTER DEFINES+=THIS_IS_CA_MASTER
DEFINES-=THIS_IS_CA_SLAVE
DESTDIR=$${_PRO_FILE_PWD_}/../build DESTDIR=$${_PRO_FILE_PWD_}/../build
unix { unix {

View File

@@ -1,12 +1,36 @@
TEMPLATE = lib TEMPLATE = lib
TARGET = CAslave TARGET = CAslave
VERSION="1.0.0" VERSION="1.0.2"
HEADERS += \
../include/reporting_thread.h
SOURCES += \
../src/reporting_thread.cpp
include(../DCLibraries.pri) include(../DCLibraries.pri)
DEFINES+=THIS_IS_CA_SLAVE win32 {
DEFINES-=THIS_IS_CA_MASTER BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
EXTENDED_VERSION_LIB=""
} else {
BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S")
GIT_COMMIT=$$system("git log -1 --format=oneline . | cut -d' ' -f1")
EXTENDED_VERSION_LIB_="libCAslave-$${VERSION}-$${GIT_COMMIT}"
}
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
DEFINES+=APP_EXTENDED_VERSION_LIB=\\\"$$EXTENDED_VERSION_LIB\\\"
DEFINES+=THIS_IS_CA_SLAVE
DESTDIR=$${_PRO_FILE_PWD_}/../build DESTDIR=$${_PRO_FILE_PWD_}/../build
unix { unix {

View File

@@ -1,14 +1,22 @@
/*
History:
06.12.2023: weitere IN-requests in Autorequest übernommen
Umschaltung mit/ohne Verkauf, während VK nur 12 wichtige, sonst alle 36
*/
#include "datIf.h" #include "datIf.h"
#include "sendWRcmd.h" #include "sendWRcmd.h"
#include "controlBus.h" #include "controlBus.h"
#include "storeINdata.h" #include "storeINdata.h"
#include "download_thread.h" #include "download_thread.h"
#include "hwapi.h"
#include <QDebug> #include <QDebug>
#include <datei.h> #include <datei.h>
#include <QDir> #include <QDir>
#include <QString>
#include <QDateTime>
@@ -86,7 +94,8 @@ T_datif::T_datif(hwinf *hw, QObject *parent) : QObject(parent)
dif_scanStep=0; dif_scanStep=0;
selectedSlaveAddr=FIX_SLAVE_ADDR; selectedSlaveAddr=FIX_SLAVE_ADDR;
cycl_running=0; cycl_running=0;
gpi_storeDcDataValid(0); // data are not yet valid, no response from DC by now epi_resetDcDataValid(); // data are not yet valid, no response from DC by now
datif_noResponseCtr=0; datif_noResponseCtr=0;
datif_repeatCtr=0; datif_repeatCtr=0;
@@ -142,14 +151,14 @@ char T_datif::datif_cycleSend()
if ( !myDCIF->isPortOpen()) if ( !myDCIF->isPortOpen())
{ {
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben //qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
gpi_storeDcDataValid(0); // DC data not valid epi_resetDcDataValid(); // DC data not valid
return 0; return 0;
} }
// supervise if DC data are valid // supervise if DC data are valid
datif_noResponseCtr++; // inc every 20ms datif_noResponseCtr++; // inc every 20ms
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s
gpi_storeDcDataValid(0); // DC data has not updated for >=5s -> no longer valid! epi_resetDcDataValid(); // DC data has not updated for >=5s -> no longer valid!
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren // Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
if (gpi_wantToResetSupervision()) if (gpi_wantToResetSupervision())
@@ -167,10 +176,22 @@ char T_datif::datif_cycleSend()
// b) Antwort meldet Fehler -> 2x wiederholen (nach einer Luecke von 10ms ) // b) Antwort meldet Fehler -> 2x wiederholen (nach einer Luecke von 10ms )
// c) gar keine Antwort, Timeout nach 100ms -> 2x wiederholen (nach einer Luecke von 10ms ) // c) gar keine Antwort, Timeout nach 100ms -> 2x wiederholen (nach einer Luecke von 10ms )
// cycl_running=0: nichts zu tun 1: Mitteilung: Kommando wurde soeben abgesendet, 2,3,4 = Wiederholung // cycl_running=0: nichts zu tun 1: Mitteilung: Kommando wurde soeben abgesendet, 2,3,4 = Wiederholung
if (cycl_running == 0) {
if (cycl_running) // 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL) if (m_hw) {
if (m_hw->dcDownloadRequested()) { // only happens in ca-master
qCritical() << "DOWNLOAD REQUESTED";
if (!m_hw->dcDownloadThreadStart()) {
qCritical() << "DOWNLOAD-THREAD NOT RUNNING WITHIN 1000ms";
} else {
qCritical() << "DOWNLOAD-THREAD RUNNING";
}
return 0;
}
}
} else {
// 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL)
// if (cycl_running && doRepeat) // if (cycl_running && doRepeat)
{
// request is still running, wait for response before next sending // request is still running, wait for response before next sending
//qDebug()<< "datif wait for response"; //qDebug()<< "datif wait for response";
datif_trigger->stop(); datif_trigger->stop();
@@ -203,21 +224,8 @@ char T_datif::datif_cycleSend()
return 0; 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 ------------------------------------------------------------------- // 17.7.2023: repeat commands if result was !=OK -------------------------------------------------------------------
if (datif_cmdWasPerformed==2 && doRepeat) // Cmd was not or false performed und Wiederholen erwuenscht if (datif_cmdWasPerformed==2 && doRepeat) // Cmd was not or false performed und Wiederholen erwuenscht
@@ -355,7 +363,7 @@ char T_datif::datif_cycleSend()
else else
{ {
dif_scanStep=0; // always start from beginning dif_scanStep=0; // always start from beginning
gpi_storeDcDataValid(0); epi_resetDcDataValid();
} }
datif_cmdWasPerformed=0; // 0: no response by now datif_cmdWasPerformed=0; // 0: no response by now
@@ -368,9 +376,20 @@ char T_datif::datif_cycleSend()
char T_datif::sendINrequestsAutomatic(void) char T_datif::sendINrequestsAutomatic(void)
{ {
//qDebug() << "send IN request " << dif_scanStep; //qDebug() << "send IN request " << dif_scanStep;
// uint8_t datif_autoRequCommandList[50]={11, 12, 18, 104, 106, 103, 14, 27, 109, 17, 19, 23, 30, 31, 32, 33, 114, 35}; //uint8_t datif_autoRequCommandList[30]={11, 12, 14, 17, 18, 19, 22, 23, 27, 30,
uint8_t datif_autoRequCommandList[30]={11, 12, 14, 17, 18, 19, 22, 23, 27, 30, 31, 32, 33, 35, 102, 103, 104, 106, 107, 109, 114,0,0,0,0,0,0,0,0,0}; // 31, 32, 33, 35, 102, 103, 104, 106, 107, 109,
uint8_t datif_maxNrCommands=21, datif_sendNow; // 114,0,0,0,0,0,0,0,0,0};
// extension 6.12.23, complete list:
uint8_t datif_autoRequCommandList[40]={11, 12, 13, 14, 17, 18, 19, 21, 22, 23,
24, 25, 27, 30, 31, 32, 33, 35, 39, 40,
41, 42, 102,103,104,106,107,108,109,110,
112,113,114,115,116,0, 0, 0, 0, 0};
uint8_t datif_maxNrCommands=35, datif_sendNow;
// send quicker while transaction is ongoing:
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,31,32,40,41,42,23,0,0};
uint8_t datif_maxVendingCmds=13;
// special commands: // special commands:
// 102: get IOs run constantly!!! // 102: get IOs run constantly!!!
@@ -380,40 +399,44 @@ char T_datif::sendINrequestsAutomatic(void)
// 107, 22: MDB: poll if needed // 107, 22: MDB: poll if needed
doRepeat=true; // 20.9.23 15uhr (after release) doRepeat=true; // 20.9.23 15uhr (after release)
if (datif_sendSlowCmd>0)
{
// send special command, slowly
datif_sendNow=datif_autoRequCommandList[datif_pNextCmd++];
if (datif_pNextCmd >= datif_maxNrCommands)
datif_pNextCmd=0;
if (datif_sendNow>0) // never send Command 0
datif_sendIOrequest(0, datif_sendNow, 0);
else
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
//qDebug()<< "datif send request " << datif_sendNow; if (gpi_getNowCoinPay())
{
// send only important commands while transaction in progress
if (datif_pNextCmd>=datif_maxVendingCmds ) datif_pNextCmd=0;
datif_sendNow=datif_vendRequCommandList[datif_pNextCmd++];
if (datif_sendNow>0) // never send Command 0
{
datif_sendIOrequest(0, datif_sendNow, 0);
//qDebug() << "datif, VEND-request: " << datif_sendNow;
} else
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
} else } else
{ {
if (gpi_getNowCoinPay()) // no transaction, request all but request DI's more frequently
if (datif_sendSlowCmd>0) // send slow and fast commands alternating
{ {
// request coin input, high priority // send special command, slowly
datif_sendIOrequest(0, 112, 0); if (datif_pNextCmd>=datif_maxNrCommands ) datif_pNextCmd=0;
//qDebug()<< "datif send request 112 get coins"; datif_sendNow=datif_autoRequCommandList[datif_pNextCmd++];
if (datif_sendNow>0) // never send Command 0
{
datif_sendIOrequest(0, datif_sendNow, 0);
// qDebug() << "datif, auto-requ: " << datif_sendNow;
} else
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
} else } else
{ {
// request inputs, high priority // request inputs, high priority
datif_sendIOrequest(0, 31, 0); // 102 datif_sendIOrequest(0, 31, 0); // 102
// while coin collection DIs are polled slowly with datif_autoRequCommandList[] // while coin collection DIs are polled slower
//qDebug()<< "datif send requ.31 get DIs";
//qDebug()<< "datif send request 102 get DIs";
} }
}
if (++datif_sendSlowCmd>1) datif_sendSlowCmd=0; // 0,1,0,1,0,1,0.... if (++datif_sendSlowCmd>1) datif_sendSlowCmd=0; // 0,1,0,1,0,1,0....
}
return 0; // 25.9.2023, wichtig sonst bleibt die komplette PTU stehen!!!! return 0; // 25.9.2023, wichtig sonst bleibt die komplette PTU stehen!!!!
} }
@@ -457,7 +480,7 @@ char T_datif::loadRecDataFromFrame()
uint32_t ultmp; uint32_t ultmp;
//int portNr; //int portNr;
bool ret; bool ret;
uint8_t uctmp; //, res; // maxai uint8_t uctmp; //, nn; //, res; // maxai
char ctmp; char ctmp;
//static uint8_t lastResult; //static uint8_t lastResult;
//uint8_t prnResult; //uint8_t prnResult;
@@ -1032,7 +1055,7 @@ char T_datif::loadRecDataFromFrame()
case 31: // Get dynamic machine conditions (doors, voltage, alarm….) case 31: // Get dynamic machine conditions (doors, voltage, alarm….)
if (RdDleng>50) if (RdDleng>50)
{ {
gpi_storeDcDataValid(1); // DC-Data are valid as DC responded. epi_setDcDataValid(); // DC-Data are valid as DC responded.
// Could be set to every response but this (31) // Could be set to every response but this (31)
// is a very common and very important request // is a very common and very important request
gpi_storeDynMachineConditions(RdDleng, receivedData); gpi_storeDynMachineConditions(RdDleng, receivedData);
@@ -1123,9 +1146,7 @@ char T_datif::loadRecDataFromFrame()
break; break;
case 42: // get BNA box content and value of types case 42: // get BNA box content and value of types
// qDebug()<< "CAmaster datif_got 42 "; //qDebug()<< "CAslave datif_got 42";
// for (uctmp=0; uctmp<64; uctmp++)
// qDebug()<<receivedData[uctmp]<<" ";
if (RdDleng>60) if (RdDleng>60)
{ {

View File

@@ -104,7 +104,25 @@ void DownloadThread::run() {
m_hw->dcDownloadRequestAck(); m_hw->dcDownloadRequestAck();
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED"; qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): DOWNLOAD THREAD STARTED:";
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName();
QDateTime const start = QDateTime::currentDateTime();
#if 1
QFile fn(m_hw->dcDownloadFileName());
if (!fn.exists()) {
// output via CONSOLE() etc
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName() << "DOES NOT EXIST";;
} else {
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): DC-CONTROLLER SW-VERSION BEFORE"
<< m_hw->dc_getSWversion();
// load binary device controller file into memory // load binary device controller file into memory
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName()); QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
@@ -115,25 +133,53 @@ void DownloadThread::run() {
// fill last block of data to be sent with 0xFF // fill last block of data to be sent with 0xFF
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF)); ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
m_hw->dc_autoRequest(true); // turn auto-request setting on
m_hw->request_DC2_HWversion();
m_hw->request_DC2_SWversion();
QThread::sleep(1);
// m_hw->dc_autoRequest(false); // turn auto-request setting on
resetDeviceController(); resetDeviceController();
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
if (startBootloader()) { if (startBootloader()) {
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size(); qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks; << "DownloadThread::run(): STARTED BOOT-LOADER";
int currentBlock = 0; m_hw->dc_autoRequest(false);// turn auto-request setting off for
// download of binary dc
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): TOTAL NUMBER OF FIRMWARE BLOCKS" << totalBlocks;
int currentBlock = 0; // download of binary dc
DownloadResult res = DownloadResult::OK; DownloadResult res = DownloadResult::OK;
qCritical() << "64-byte block " << currentBlock;
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) { while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) { if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) { if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock); m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): currentBlockNumber ..." << currentBlock;
currentBlock += 1; currentBlock += 1;
} }
} }
} }
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock; qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< QString("DownloadThread::run(): last 64-byte block %1").arg(currentBlock);
int const rest = ba.size() % 64; int const rest = ba.size() % 64;
int const offset = ba.size() - rest; int const offset = ba.size() - rest;
@@ -149,27 +195,92 @@ void DownloadThread::run() {
} else { } else {
m_hw->bl_sendLastBlock(); m_hw->bl_sendLastBlock();
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock); m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
// QThread::msleep(250);
} }
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK()); 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 stopBootloader(); // stop bootloader several times: if it
// test code: QThread::sleep(1); // is not stopped, then the PSA has to be
uint16_t const totalBlocks = 100; }
// restarted manually (!!!)
stopBootloader();
QThread::sleep(1);
}
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
stopBootloader(); // there is no harm in stopping the bootloader even
// if it was not started at all
m_hw->dc_autoRequest(true);
}
#else // test
// 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); m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
// fill last block of data to be sent with 0xFF
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
m_hw->dc_autoRequest(true); // turn auto-request setting on
m_hw->request_DC2_HWversion();
m_hw->request_DC2_SWversion();
QThread::sleep(1);
resetDeviceController();
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
QThread::sleep(1);
if (startBootloader()) {
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): STARTED BOOT-LOADER";
m_hw->dc_autoRequest(false);// turn auto-request setting off for
// download of binary dc
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) { for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock); m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
QThread::msleep(100); qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
QThread::msleep(250);
}
m_hw->dc_autoRequest(true); // turn auto-request setting on again
}
stopBootloader(); // there is no harm in stopping the bootloader even
// if it was not started at all
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
} }
#endif #endif
m_hw->dcDownloadSetRunning(false); m_hw->dcDownloadSetRunning(false);
m_hw->dcDownloadSetFinished(true); m_hw->dcDownloadSetFinished(true);
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD FINISHED"; QDateTime const end = QDateTime::currentDateTime();
quint64 secs = start.secsTo(end);
QString runtime;
if (secs % 60) {
runtime = QString("%1min %2s").arg(secs / 60).arg(secs % 60);
} else {
runtime = QString("%1min").arg((secs / 60) + 1);
}
qCritical() << end.time().toString(Qt::ISODateWithMs)
<< QString("DOWNLOAD THREAD FINISHED (RUNTIME %1)")
.arg(runtime);
// the object deletes itself ! This is the last line in run(). // the object deletes itself ! This is the last line in run().
// Never touch the object after this statement // Never touch the object after this statement
@@ -193,7 +304,6 @@ DownloadThread::sendNextAddress(int bNum) const {
int noAnswerCount = 0; int noAnswerCount = 0;
int errorCount = 0; int errorCount = 0;
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) { if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
// qDebug() << "addr-block" << bNum << "...";
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
m_hw->bl_sendAddress(bNum); m_hw->bl_sendAddress(bNum);
QThread::msleep(100); QThread::msleep(100);
@@ -232,9 +342,6 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
memcpy(local, binary.constData() + bAddr, 64); memcpy(local, binary.constData() + bAddr, 64);
local[64] = local[65] = 0x00; local[64] = local[65] = 0x00;
// QByteArray b((const char *)(&local[0]), 64);
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
m_hw->bl_sendDataBlock(64, local); m_hw->bl_sendDataBlock(64, local);
QThread::msleep(10); QThread::msleep(10);
@@ -247,9 +354,7 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
} }
} else { } else {
// qInfo() << "data for block" << bNum << "OK"; // qInfo() << "data for block" << bNum << "OK";
// TODO: hier ins shared mem schreiben // TODO: hier ins shared mem schreiben
return res; return res;
} }
} else { } else {
@@ -261,50 +366,65 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
} }
bool DownloadThread::startBootloader() const { bool DownloadThread::startBootloader() const {
qDebug() << "starting bootloader..."; qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "starting bootloader...";
int nTry = 5; int nTry = 5;
while (--nTry >= 0) { while (--nTry >= 0) {
m_hw->bl_startBL(); m_hw->bl_startBL();
QThread::msleep(5000); qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_startBL() ..." << nTry;
QThread::msleep(500);
m_hw->bl_checkBL(); m_hw->bl_checkBL();
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
QThread::msleep(500);
if (m_hw->bl_isUp()) { if (m_hw->bl_isUp()) {
qInfo() << "starting bootloader...OK"; qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bootloader... isUP" << nTry;
QThread::msleep(5000);
return true; return true;
} else { } else {
qCritical() << "bootloader not up (" << nTry << ")"; qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "bootloader not up (" << nTry << ")";
} }
} }
qCritical() << "starting bootloader...FAILED"; qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "starting bootloader FAILED";
return false; return false;
} }
bool DownloadThread::stopBootloader() const { bool DownloadThread::stopBootloader() const {
qDebug() << "stopping bootloader..."; qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "stopping bootloader...";
int nTry = 5; int nTry = 5;
while (--nTry >= 0) { while (--nTry >= 0) {
m_hw->bl_stopBL(); m_hw->bl_stopBL();
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "bl_stopBL() ...";
QThread::msleep(500); QThread::msleep(500);
m_hw->bl_checkBL();
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
if (!m_hw->bl_isUp()) { if (!m_hw->bl_isUp()) {
qInfo() << "stopping bootloader...OK"; qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "stopping bootloader OK";
return true; return true;
} }
} }
qCritical() << "stopping bootloader...FAILED"; qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "stopping bootloader FAILED";
return false; return false;
} }
bool DownloadThread::resetDeviceController() const { bool DownloadThread::resetDeviceController() const {
qDebug() << "resetting device controller..."; qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "resetting device controller...";
m_hw->bl_rebootDC(); m_hw->bl_rebootDC();
// wait maximally 3 seconds, before starting bootloader // wait maximally 3 seconds, before starting bootloader
QThread::sleep(1); QThread::sleep(1);
qInfo() << "resetting device controller...OK"; qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "resetting device controller...OK";
return true; return true;
} }
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const { QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
qDebug() << "loading dc binary" << filename << "..."; qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
<< "loading dc binary" << filename << "...";
QFile file(filename); // closed in destructor call QFile file(filename); // closed in destructor call
if (!file.exists()) { if (!file.exists()) {

View File

@@ -20,12 +20,14 @@
*/ */
#include "hwapi.h" #include "hwapi.h"
#include "reporting_thread.h"
#include "download_thread.h" #include "download_thread.h"
#include "reporting_thread.h"
#include "shared_mem_buffer.h"
#include <algorithm>
#include <cstring> #include <cstring>
#include <atomic> #include <QThread>
#include <QDebug>
#include <QApplication>
static uint32_t hwapi_lastStartAmount; static uint32_t hwapi_lastStartAmount;
static uint32_t hwapi_lastTotalAmount; static uint32_t hwapi_lastTotalAmount;
@@ -39,6 +41,12 @@ static uint8_t bl_startupStep;
hwapi::hwapi(QWidget *parent) : QObject(parent) hwapi::hwapi(QWidget *parent) : QObject(parent)
{ {
// constructor // constructor
qCritical() << " hwapi::hwapi() APP_VERSION:" << APP_VERSION;
qCritical() << " hwapi::hwapi() APP_BUILD_DATE:" << APP_BUILD_DATE;
qCritical() << " hwapi::hwapi() APP_BUILD_TIME:" << APP_BUILD_TIME;
qCritical() << " hwapi::hwapi() APP_EXTENDED_VERSION:" << APP_EXTENDED_VERSION;
qCritical() << "hwapi::hwapi() APP_EXTENDED_VERSION_LIB:" << APP_EXTENDED_VERSION_LIB;
// create or attach shared memory segment // create or attach shared memory segment
m_sharedMem = SharedMem::getShm(sizeof(SharedMem)); m_sharedMem = SharedMem::getShm(sizeof(SharedMem));
@@ -51,13 +59,30 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
qCritical() << "Creating/attaching shared memory failed"; qCritical() << "Creating/attaching shared memory failed";
} }
Q_ASSERT_X(sizeof(SharedMem) == m_sharedMem->size(), "check shm-sizes",
QString("sizes different %1 != %2")
.arg(sizeof(SharedMem))
.arg(m_sharedMem->size()).toStdString().c_str());
//if (shdMem_firstUse()) // für Master raus //if (shdMem_firstUse()) // für Master raus
// { // {
#ifdef THIS_IS_CA_MASTER #ifdef THIS_IS_CA_MASTER
#ifdef THIS_IS_CA_SLAVE
#error "SLAVE LIB COMPILED INTO MASTER"
#endif
myDatif = new T_datif(this); // 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
#ifdef THIS_IS_CA_SLAVE
#ifdef THIS_IS_CA_MASTER
#error "MASTER LIB COMPILED INTO MASTER"
#endif
#endif #endif
// } // }
@@ -115,10 +140,6 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
void hwapi::hwapi_slotPayProc(void) void hwapi::hwapi_slotPayProc(void)
{ {
//cash_paymentProcessing();
//doors_supervise();
//dcBL_cycle();
} }
@@ -1792,6 +1813,8 @@ void hwapi::prn_sendText(QByteArray *buf) const
uint16_t nn, pp, mm, leng_byt, leng_blk, llb, freeStak; uint16_t nn, pp, mm, leng_byt, leng_blk, llb, freeStak;
uint8_t tmp66[66]; uint8_t tmp66[66];
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -2617,12 +2640,23 @@ void hwapi::bl_openBinary(void) const
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
{ {
// send 64 byte from bin file // send 64 byte from bin file
uint8_t LL=length, sendBuf[80], sendLen; // gh, 09/02/2024: extend sendBuf. Buffer sometimes too small, sendLen=81
uint8_t LL=length, sendBuf[80+32], sendLen;
if (LL>64) LL=64; if (LL>64) LL=64;
tslib_strclr(sendBuf,0,80); memset(sendBuf, 0, sizeof(sendBuf));
sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame
// qCritical() << "(" __func__ << ":" << __LINE__ << ") sendLen=" << sendLen
// << ":" << QByteArray((const char *)sendBuf, sendLen);
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
// if (sendLen > 80) {
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
// << QByteArray((const char *)&sendBuf[80], 32).toHex(':');
// }
delay(100); delay(100);
} }
@@ -2896,6 +2930,8 @@ bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
{ {
// return true if sending, false if cmd-stack is full // return true if sending, false if cmd-stack is full
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -3000,6 +3036,8 @@ bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
bool hwapi::prn_printAccountReceipt(void) const bool hwapi::prn_printAccountReceipt(void) const
{ {
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
return sendFDcmd_set(154, 0,0, 0,0,0,0); return sendFDcmd_set(154, 0,0, 0,0,0,0);
@@ -3007,6 +3045,8 @@ bool hwapi::prn_printAccountReceipt(void) const
bool hwapi::prn_printTestTicket(void) const bool hwapi::prn_printTestTicket(void) const
{ {
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
// return true if sending to DC OK, false if cmd-stack is full // return true if sending to DC OK, false if cmd-stack is full
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -3062,7 +3102,9 @@ bool hwapi::cash_cancelPayment(void) const
{ {
// DB1: 1=encash 2=cancel & return coins // DB1: 1=encash 2=cancel & return coins
// 3=stop and keep coins in escrow // 3=stop and keep coins in escrow
epi_setNowCoinPay(false); // new since 20.9.23 //epi_setNowCoinPay(false); // new since 20.9.23
// am 6.12.23 wieder raus, waehrend Druck und wechseln auch schnell abfragen
//qCritical() << "cash cancel payment and return coins"; //qCritical() << "cash cancel payment and return coins";
return sendFDcmd_set(156, 0,0, 2,0,0,0); return sendFDcmd_set(156, 0,0, 2,0,0,0);
} }
@@ -3072,7 +3114,8 @@ bool hwapi::cash_stopPayment(void) const
{ {
// DB1: 1=encash 2=cancel & return coins // DB1: 1=encash 2=cancel & return coins
// 3=stop and keep coins in escrow // 3=stop and keep coins in escrow
epi_setNowCoinPay(false); // new since 20.9.23 //epi_setNowCoinPay(false); // new since 20.9.23
// am 6.12.23 wieder raus, waehrend Druck und wechseln auch schnell abfragen
//qCritical() << "cash stop payment and keep coins in escrow"; //qCritical() << "cash stop payment and keep coins in escrow";
// qCritical() << "emitting signal StopByPushbutton 2"; // qCritical() << "emitting signal StopByPushbutton 2";
emit hwapi_payStopByPushbutton(); emit hwapi_payStopByPushbutton();
@@ -3306,22 +3349,15 @@ void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const
// attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before // attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before
// cannot be used to see settings programmed by JsonFile // cannot be used to see settings programmed by JsonFile
uint8_t buf[64]; uint8_t buf[64];
uint8_t LL, nn; uint8_t LL;
tslib_strclr(buf,0,64); tslib_strclr(buf,0,64);
uint8_t *start;
//runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die??? //runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die???
epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer
// Puffer in struct eintragen: Q_STATIC_ASSERT(sizeof(*deviceSettings) <= sizeof(buf));
start = &deviceSettings->kindOfPrinter;
nn=0;
do
{
*start = buf[nn];
start++;
} while(++nn<LL);
memcpy(deviceSettings, buf, sizeof(*deviceSettings));
} }
bool hwapi::sys_areDCdataValid(void) const bool hwapi::sys_areDCdataValid(void) const
@@ -3433,6 +3469,8 @@ bool hwapi::prn_printKombiticket(uint8_t nrOfKombi) const
if ((nrOfKombi<1) || (nrOfKombi>8)) if ((nrOfKombi<1) || (nrOfKombi>8))
return false; return false;
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -3563,6 +3601,8 @@ bool hwapi::log_getVaultData(uint8_t *data) const
// new from 1.8.23 // new from 1.8.23
bool hwapi::prn_printOneAccountReceipt(uint16_t accountNr) const bool hwapi::prn_printOneAccountReceipt(uint16_t accountNr) const
{ {
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
// print one out of eight stored last accounting receipts // print one out of eight stored last accounting receipts
// function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts // function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
@@ -4382,6 +4422,7 @@ QObject const *hwapi::getAPI() {
} }
bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const { bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
// called by worker-thread (see atbupdatetool)
SharedMem *data = SharedMem::getData(); SharedMem *data = SharedMem::getData();
if (!data) { if (!data) {
return false; return false;
@@ -4405,9 +4446,15 @@ bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
} }
bool hwapi::dcDownloadRequested() const { bool hwapi::dcDownloadRequested() const {
SharedMem const *data = SharedMem::getData(); SharedMem *data = SharedMem::getData();
// should be false at entry Q_ASSERT_X(data != nullptr, "check", "pointer invalid");
return data ? data->m_downLoadDC.m_requested.load() : false; Q_ASSERT_X((void *)data == m_sharedMem->data(), "compare pointers", "pointers different");
Q_ASSERT_X(sizeof(*data) == m_sharedMem->size(), "compare sizes", "sizes different");
// called by download-thread
// 1: true at entry: reset atomically to false
// 2: false at entry: no change
return data ? data->m_downLoadDC.m_requested.exchange(false) : false;
} }
bool hwapi::dcDownloadResetRequest() const { bool hwapi::dcDownloadResetRequest() const {
@@ -4419,14 +4466,12 @@ bool hwapi::dcDownloadResetRequest() const {
} }
bool hwapi::dcDownloadRequestAck() const { bool hwapi::dcDownloadRequestAck() const {
// called by download-thread
SharedMem *data = SharedMem::getData(); SharedMem *data = SharedMem::getData();
if (data) { if (data) {
if (data->m_downLoadDC.m_requested) {
data->m_downLoadDC.m_requested = false;
data->m_downLoadDC.m_running = true; data->m_downLoadDC.m_running = true;
data->m_downLoadDC.m_finished = false; data->m_downLoadDC.m_finished = false;
} }
}
return false; return false;
} }
@@ -4435,14 +4480,16 @@ bool hwapi::dcDownloadRunning() const {
if (data) { if (data) {
int cnt = 10; int cnt = 10;
while (--cnt > 0) { while (--cnt > 0) {
bool running = data->m_downLoadDC.m_running.load(); bool running = data->m_downLoadDC.m_running;
bool finished = data->m_downLoadDC.m_finished.load(); bool finished = data->m_downLoadDC.m_finished;
if (!running || finished) { if ((running == true) && (finished == false)) {
// see dcDownloadRequestAck()
break;
}
if (cnt < 3) { if (cnt < 3) {
qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished; qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished;
} }
QThread::msleep(500); QThread::msleep(500);
} else break;
} }
// qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0); // qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0);
return (cnt > 0); return (cnt > 0);
@@ -4451,18 +4498,16 @@ bool hwapi::dcDownloadRunning() const {
} }
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) { void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
delete dthread; Q_UNUSED(dthread);
// delete dthread;
m_downloadThread = nullptr; m_downloadThread = nullptr;
} }
bool hwapi::dcDownloadFinished() { bool hwapi::dcDownloadFinished() {
SharedMem const *data = SharedMem::getDataConst();
if (data) {
int cnt = 10; int cnt = 10;
while ((--cnt > 0) && while (dcDownloadRunning()) {
((data->m_downLoadDC.m_running.load() == true) && if (--cnt == 0) {
(data->m_downLoadDC.m_finished.load() == false))) { return false;
QThread::sleep(1);
} }
//if (cnt > 0) { //if (cnt > 0) {
@@ -4471,12 +4516,13 @@ bool hwapi::dcDownloadFinished() {
// return true; // return true;
//} //}
} }
return false; return true;
} }
// download thread // download thread
bool hwapi::dcDownloadThreadStart() { bool hwapi::dcDownloadThreadStart() {
// called by timer in datIf.cpp: T_datif::datif_cycleSend()
m_downloadThread = new DownloadThread(this); m_downloadThread = new DownloadThread(this);
if (m_downloadThread) { if (m_downloadThread) {
m_downloadThread->start(); m_downloadThread->start();
@@ -4508,6 +4554,7 @@ bool hwapi::dcDownloadReportThreadStart() { // only start reporting thread
if (cnt > 0) { if (cnt > 0) {
m_reportingThread = new ReportingThread(this); m_reportingThread = new ReportingThread(this);
if (m_reportingThread) { if (m_reportingThread) {
m_reportingThread->moveToThread(QApplication::instance()->thread());
m_reportingThread->start(); m_reportingThread->start();
cnt = 10; cnt = 10;
while (--cnt > 0 && !dcDownloadReportThreadRunning()) { while (--cnt > 0 && !dcDownloadReportThreadRunning()) {
@@ -4539,7 +4586,9 @@ void hwapi::dcDownloadReportThreadQuit() {
} }
bool hwapi::dcDownloadReportThreadFinished() const { bool hwapi::dcDownloadReportThreadFinished() const {
return m_reportingThread ? m_reportingThread->isFinished() : false; // if the pointer to the underlying c++-object is not valid, the thread
// counts as finished
return m_reportingThread ? m_reportingThread->isFinished() : true;
} }
bool hwapi::dcDownloadReportStart() const { bool hwapi::dcDownloadReportStart() const {
@@ -4565,9 +4614,11 @@ bool hwapi::dcDownloadReportFinished() {
} }
if (dcDownloadReportThreadFinished()) { if (dcDownloadReportThreadFinished()) {
if (m_reportingThread) {
delete m_reportingThread; delete m_reportingThread;
m_reportingThread = nullptr; m_reportingThread = nullptr;
} }
}
return true; return true;
} }

View File

@@ -1,5 +1,16 @@
#ifdef WIN32
#ifndef WIN32 #include <QCoreApplication>
#include "tslib.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
#else
#undef _FORTIFY_SOURCE #undef _FORTIFY_SOURCE
@@ -7,11 +18,11 @@
#include <stdio.h> #include <stdio.h>
// Must define the interpreter to be the dynamic linker // Must define the interpreter to be the dynamic linker
#ifdef __LP64__ //#ifdef __LP64__
#error "__LP64__ not defined for PTU5" //#error "__LP64__ not defined for PTU5"
#else //#else
const char service_interp[] __attribute__((section(".interp"))) = "/lib/ld-linux-armhf.so.3"; //const char service_interp[] __attribute__((section(".interp"))) = "/lib/ld-linux-armhf.so.3";
#endif //#endif
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {

View File

@@ -4,10 +4,16 @@
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QApplication>
#include <QCoreApplication>
#include <cmath>
#include <algorithm>
ReportingThread::ReportingThread(hwapi *hw) ReportingThread::ReportingThread(hwapi *hw)
: m_hw(hw) : m_hw(hw)
, m_fileToDownload(m_hw->dcDownloadFileName()) { , m_fileToDownload(m_hw->dcDownloadFileName()) {
// , m_f([](QString const&){}) {
} }
ReportingThread::~ReportingThread() { ReportingThread::~ReportingThread() {
@@ -17,7 +23,10 @@ ReportingThread::~ReportingThread() {
// each component which has connects for the corresponding signals. // each component which has connects for the corresponding signals.
void ReportingThread::run() { void ReportingThread::run() {
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD"; qCritical()
<< QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "START REPORT THREAD"
<< "(PART OF APPLICATION" << QCoreApplication::applicationName() << ")";
static QString report(""); static QString report("");
@@ -25,9 +34,9 @@ void ReportingThread::run() {
while (!m_hw->dcDownloadGetRunning()) { while (!m_hw->dcDownloadGetRunning()) {
if (--cnt > 0) { if (--cnt > 0) {
report = QString("%1 waiting for download to start %2") report = QString("%1 waiting for download to start %2")
.arg(QDateTime::currentDateTime().toString(Qt::ISODate)) .arg(QDateTime::currentDateTime().time().toString(Qt::ISODate))
.arg(cnt); .arg(cnt);
qCritical() << __LINE__ << "STATUS" << report; qCritical() << "(" << __func__ << ":" << __LINE__ << ") STATUS" << report;
emit m_hw->hwapi_reportDCDownloadStatus(report); emit m_hw->hwapi_reportDCDownloadStatus(report);
QThread::sleep(1); QThread::sleep(1);
} else break; } else break;
@@ -91,33 +100,79 @@ void ReportingThread::run() {
#endif #endif
uint16_t const totalBlocks = m_hw->dcDownloadGetTotalBlockNumber(); uint16_t totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
cnt = 10;
while(--cnt > 0 && totalBlocks == 0) {
totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
<< QString("line=%1 TOTAL BLOCKS=%2 (%3)")
.arg(__LINE__).arg(totalBlocks).arg(cnt);
QThread::sleep(1);
}
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks; qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << __PRETTY_FUNCTION__
<< QString("line=%1 TOTAL BLOCKS=%2").arg(__LINE__).arg(totalBlocks);
if (totalBlocks) { if (totalBlocks) {
qint64 const start = QDateTime::currentMSecsSinceEpoch(); QDateTime const start = QDateTime::currentDateTime();
double durationMillis = 0;
uint16_t currentBlockNumber = 0; uint16_t currentBlockNumber = 0;
uint16_t prevBlockNumber = ~0;
uint64_t estimatedMinutesLeftMax = ~0ULL;
uint64_t estimatedSecondsLeftMax = ~0ULL;
uint64_t estimatedMinutesLeftPrev = 0;
uint64_t estimatedSecondsLeftPrev = 0;
while (m_hw->dcDownloadGetRunning()) { while (m_hw->dcDownloadGetRunning()) {
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber(); currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
if (prevBlockNumber != currentBlockNumber) {
double durationSecs = start.secsTo(QDateTime::currentDateTime());
durationMillis += QDateTime::currentMSecsSinceEpoch() - start; double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationSecs / currentBlockNumber) : durationSecs;
uint64_t estimatedSecondsLeft = lround((timeAveragePerBlock * (totalBlocks - currentBlockNumber)));
uint64_t estimatedMinutesLeft =
((estimatedSecondsLeft % 60) == 0) ?
(estimatedSecondsLeft / 60) :
((estimatedSecondsLeft + 60) / 60);
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis; estimatedSecondsLeft = (estimatedSecondsLeft % 60);
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
if ((estimatedMinutesLeft <= estimatedMinutesLeftMax)
|| (estimatedSecondsLeft <= estimatedSecondsLeftMax)) {
estimatedMinutesLeftMax = estimatedMinutesLeft;
estimatedSecondsLeftMax = estimatedSecondsLeft;
estimatedMinutesLeftPrev = estimatedMinutesLeft;
estimatedSecondsLeftPrev = estimatedSecondsLeft;
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0; double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4s)") report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
.arg(totalBlocks) .arg(totalBlocks)
.arg(currentBlockNumber) .arg(currentBlockNumber)
.arg(percent, 0, 'f', 2) .arg(percent, 0, 'f', 2)
.arg(estimatedSecondsLeft, 0, 'f', 2); .arg(estimatedMinutesLeft)
.arg(estimatedSecondsLeft, 2);
qCritical() << "RT report" << report; qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< QString("line=%1: RT report").arg(__LINE__) << report;
emit m_hw->hwapi_reportDCDownloadStatus(report); emit m_hw->hwapi_reportDCDownloadStatus(report);
} else {
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
.arg(totalBlocks)
.arg(currentBlockNumber)
.arg(percent, 0, 'f', 2)
.arg(estimatedMinutesLeftPrev)
.arg(estimatedSecondsLeftPrev, 2);
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< QString("line=%1: RT report").arg(__LINE__) << report;
emit m_hw->hwapi_reportDCDownloadStatus(report);
}
prevBlockNumber = currentBlockNumber;
}
QThread::msleep(100); QThread::msleep(100);
} }
@@ -133,7 +188,7 @@ void ReportingThread::run() {
} }
} }
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__ qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << __PRETTY_FUNCTION__
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__); << QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
cnt = 10; cnt = 10;

View File

@@ -2,7 +2,6 @@
#include <QDebug> #include <QDebug>
#include "controlBus.h" #include "controlBus.h"
#include "dcBL.h" #include "dcBL.h"
#include "interfaces.h"
static uint32_t hwapi_lastStartAmount; static uint32_t hwapi_lastStartAmount;
static uint32_t hwapi_lastTotalAmount; static uint32_t hwapi_lastTotalAmount;
@@ -29,25 +28,31 @@ T_runProc::T_runProc()
QTimer *runProc_callProcesses = new QTimer(); QTimer *runProc_callProcesses = new QTimer();
connect(runProc_callProcesses, SIGNAL(timeout()), this, SLOT(runProc_slotProcess())); connect(runProc_callProcesses, SIGNAL(timeout()), this, SLOT(runProc_slotProcess()));
runProc_callProcesses->setSingleShot(false); runProc_callProcesses->setSingleShot(false);
runProc_callProcesses->start(100); // in ms runProc_callProcesses->start(10); // in ms
hwapi_lastDoorState=0; // default: all doors (should be) closed, coin box inserted hwapi_lastDoorState=0; // default: all doors (should be) closed, coin box inserted
// bit0: upper door 1:middle 2:lower 3=cash-box out // bit0: upper door 1:middle 2:lower 3=cash-box out
hwapi_triggerBL = new QTimer(); // hwapi_triggerBL = new QTimer();
connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart())); // connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart()));
hwapi_triggerBL->setSingleShot(false); // hwapi_triggerBL->setSingleShot(false);
hwapi_triggerBL->stop(); // hwapi_triggerBL->stop();
myTO = new QTimer();
myTO->setSingleShot(true);
myTO->start(200);
} }
void T_runProc::runProc_slotProcess(void) void T_runProc::runProc_slotProcess(void)
{ {
#ifndef THIS_IS_CA_MASTER
cash_paymentProcessing(); cash_paymentProcessing();
doors_supervise(); doors_supervise();
bl_performComplStart(); // neu 1.12.23
dcBL_cycle(); dcBL_cycle();
#endif
} }
bool T_runProc::cash_startPayment(uint32_t amount) bool T_runProc::cash_startPayment(uint32_t amount)
@@ -160,6 +165,7 @@ uint8_t T_runProc::cash_paymentProcessing(void)
sub_getDynMachineConditions(&myDynMachCond); sub_getDynMachineConditions(&myDynMachCond);
payInProg= myDynMachCond.paymentInProgress; payInProg= myDynMachCond.paymentInProgress;
// Version Szeged: aug2023
// 0: stopped by timeout // 0: stopped by timeout
// 1: running 2: wait4lastCoin // 1: running 2: wait4lastCoin
// 3: payment stopped manually, coins in Escrow // 3: payment stopped manually, coins in Escrow
@@ -169,9 +175,26 @@ uint8_t T_runProc::cash_paymentProcessing(void)
// 7: coins returned 2 cases: due to cancel-button or printer-error // 7: coins returned 2 cases: due to cancel-button or printer-error
// 8: CoinChecker or MDB on Error // 8: CoinChecker or MDB on Error
// since Schoenau with bill and changer, nov2023
//0 = no payment
//will be set to 1 by cash_startCollection()
//neu 1: wait for devices getting ready for payment
//2 = payment,
//3 = wait for last coin/bill
//4 = Bezahlvorgang manuell beendet
//5 = payment stopped autom, amount collected, coins in Escrow
//6 = Bezahlvorgang beendet weil ZK voll
//4,5,6: payment done, keep on polling, wait for cash or return command
//7 = encash collected money from coin escrow into cash box
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
//9 = wait for changer result
//10= print refund receipt with "amountToReturn"
// qCritical() << "emitting signal payCancelled"; // qCritical() << "emitting signal payCancelled";
// emit runProc_payCancelled(); // emit runProc_payCancelled();
/*
// gabs bei Szeged, jetzt nicht mehr:
if (payInProg==8) if (payInProg==8)
{ {
// coin checker faulty, cannot start // coin checker faulty, cannot start
@@ -182,11 +205,11 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_coinCollectionAborted(); emit runProc_coinCollectionAborted();
//sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment //sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment
} }
return 10; // error cannot start return 10; // error cannot start
} }*/
if (empState>=10 && empState<=12 && (payInProg==1 || payInProg==2) ) // if (empState>=10 && empState<=12 && (payInProg==1 || payInProg==2) ) // Szeged
if ( payInProg==2 ) //8.12.23
{ {
// coin acceptance is active now: // coin acceptance is active now:
if (hwapi_paymentStarted==1) // && (( payInProg==0) || ( payInProg>5))) //16.6.23 if (hwapi_paymentStarted==1) // && (( payInProg==0) || ( payInProg>5))) //16.6.23
@@ -219,7 +242,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
} else } else
if (payInProg==3) // user pressed "Next/Continue", keep coin //if (payInProg==3) // user pressed "Next/Continue", keep coin
if (payInProg==4) // user pressed "Next/Continue", keep coin since nov2023
{ {
hwapi_paymentStarted++; hwapi_paymentStarted++;
collActiv=3; collActiv=3;
@@ -227,7 +251,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_payStopByPushbutton(); emit runProc_payStopByPushbutton();
} else } else
if (payInProg==4) // max achieved, keep coins //if (payInProg==4) // max achieved, keep coins
if (payInProg==5) // max achieved, keep coins since nov2023
{ {
hwapi_paymentStarted++; hwapi_paymentStarted++;
collActiv=4; collActiv=4;
@@ -235,7 +260,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_payStopByMax(); emit runProc_payStopByMax();
} else } else
if (payInProg==5) // escrow full, keep coins //if (payInProg==5) // escrow full, keep coins
if (payInProg==6) // escrow full, keep coins since nov2023
{ {
hwapi_paymentStarted++; hwapi_paymentStarted++;
collActiv=5; collActiv=5;
@@ -243,14 +269,14 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_payStopByEscrow(); emit runProc_payStopByEscrow();
} }
/* 5.10.23 raus, geht auf 99 wenn Betrag erreicht, ist aber kein fehler // 5.10.23 raus, geht auf 99 wenn Betrag erreicht, ist aber kein fehler
if ( (empState<10) || (empState>12)) // error if ( (empState<10) || (empState>12)) // error
{ {
collActiv=13; //collActiv=13;
hwapi_paymentStarted=90; //hwapi_paymentStarted=90;
qCritical() << "emitting signal payStopByError" << empState; //qCritical() << "emitting signal payStopByError" << empState;
emit runProc_payStopByError(); //emit runProc_payStopByError();
} */ }
} }
@@ -258,7 +284,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
{ {
// coin collection finished, but coins kept until printing done // coin collection finished, but coins kept until printing done
collActiv=2; collActiv=2;
if (payInProg==6) // coins encashed //if (payInProg==6) // coins encashed
if (payInProg==7) // coins encashed since nov2023
{ {
collActiv=6; collActiv=6;
hwapi_paymentStarted++; hwapi_paymentStarted++;
@@ -266,7 +293,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_coinProcessJustStopped(); emit runProc_coinProcessJustStopped();
} else } else
if (payInProg==7) // coins returned, printing failed //if (payInProg==7) // coins returned, printing failed
if (payInProg==0) // coins returned, printing failed since nov2023
{ {
collActiv=7; collActiv=7;
hwapi_paymentStarted++; hwapi_paymentStarted++;
@@ -613,8 +641,11 @@ void T_runProc::bl_rebootDC(void)
// BL is working for 5s after power-on-reset. // BL is working for 5s after power-on-reset.
uint8_t len, buf[20]; uint8_t len, buf[20];
memset(buf, 0x00, sizeof(buf));
len=dcBL_restartDC(buf); len=dcBL_restartDC(buf);
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
sendWRcmd_setSendBlock160(len, buf); sendWRcmd_setSendBlock160(len, buf);
} }
@@ -624,8 +655,13 @@ void T_runProc::bl_startBL(void)
// otherwise the BL jumps to normal DC application // otherwise the BL jumps to normal DC application
uint8_t len, buf[20]; uint8_t len, buf[20];
memset(buf, 0x00, sizeof(buf));
len=dcBL_activatBootloader(buf); len=dcBL_activatBootloader(buf);
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
sendWRcmd_setSendBlock160(len, buf); sendWRcmd_setSendBlock160(len, buf);
epi_setNowIsBootload(true); epi_setNowIsBootload(true);
} }
@@ -633,8 +669,11 @@ void T_runProc::bl_checkBL(void)
{ {
// call this function in order to get information, afterwards use "bl_isUp()" // call this function in order to get information, afterwards use "bl_isUp()"
uint8_t len, buf[20]; uint8_t len, buf[20];
memset(buf, 0x00, sizeof(buf));
len=dcBL_readFWversion(buf); len=dcBL_readFWversion(buf);
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
sendWRcmd_setSendBlock160(len, buf); sendWRcmd_setSendBlock160(len, buf);
} }
@@ -645,6 +684,7 @@ bool T_runProc::bl_isUp(void)
for (nn=0; nn<160; nn++) receivedData[nn]=0; for (nn=0; nn<160; nn++) receivedData[nn]=0;
LL=epi_getRawRecLength(); LL=epi_getRawRecLength();
if (LL>0) if (LL>0)
{ {
epi_getRawReceivedData(receivedData); epi_getRawReceivedData(receivedData);
@@ -654,18 +694,29 @@ bool T_runProc::bl_isUp(void)
receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176) receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
{ {
qDebug() << "got BL response to readFWversion"; qDebug() << "got BL response to readFWversion";
epi_clrRawReceivedString(); //epi_clrRawReceivedString();
return true; return true;
} }
// response to "start BL"
if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 && // response to "start BL" { 2, 101, 48, 223, 131, 3}
receivedData[3]==223 && receivedData[4] ==131 ) static uint8_t const cmp[6] = {0x02, 0x65, 0x30, 0xdf, 0x83, 0x03};
{
qDebug() << "hwapi_bl_isUp: got BL response to start"; if (LL >= 6 && LL <= 13) {
epi_clrRawReceivedString(); // (1) "02:63:34:35:62:33:03:02:65:30:df:83:03"
// (2) "02:65:30:df:83:03"
// qCritical() << "(" << __func__ << ":" << __LINE__
// << ") CHECK" << QByteArray((char const*)receivedData, LL).toHex(':');
for (int i=0; i <= LL-6; ++i) {
if (memcmp(cmp, &receivedData[i], 6) == 0) {
qCritical() << "(" << __func__ << ":" << __LINE__
<< ") BL RESPONSE to bl_start(): BOOTLOADER IS UP";
return true; return true;
} }
} }
}
}
return false; return false;
} }
@@ -677,7 +728,8 @@ void T_runProc::bl_completeStart(void)
bool T_runProc::bl_performComplStart(void) bool T_runProc::bl_performComplStart(void)
{ {
// must be called cyclic by timer bool result;
static uint8_t retryCtr; static uint8_t retryCtr;
if ((bl_startupStep<1) || (bl_startupStep>10)) if ((bl_startupStep<1) || (bl_startupStep>10))
@@ -691,58 +743,69 @@ bool T_runProc::bl_performComplStart(void)
if (bl_startupStep==2) if (bl_startupStep==2)
{ {
qDebug()<<"rebooting";
bl_rebootDC(); bl_rebootDC();
hwapi_triggerBL->stop(); myTO->stop();
hwapi_triggerBL->start(1000); // call next step in 1s myTO->start(500);
retryCtr=0; retryCtr=0;
bl_startupStep++; bl_startupStep++;
} else } else
if (bl_startupStep==3) if (bl_startupStep==3)
{ {
//qDebug()<<"starting BL"; if (!myTO->isActive())
{
qDebug()<<"starting BL";
bl_startBL(); bl_startBL();
hwapi_triggerBL->stop(); myTO->stop();
hwapi_triggerBL->start(100); myTO->start(500);
bl_startupStep++; bl_startupStep++;
}
} else } else
if (bl_startupStep==4) if (bl_startupStep==4)
{ {
//if (!myTO->isActive()) if (!myTO->isActive())
//{ {
qDebug()<<"checking BL";
bl_checkBL(); bl_checkBL();
hwapi_triggerBL->stop(); myTO->stop();
hwapi_triggerBL->start(100); myTO->start(200);
bl_startupStep++; bl_startupStep++;
}
//}
} else } else
if (bl_startupStep==5) if (bl_startupStep==5)
{ {
hwapi_triggerBL->stop(); if (!myTO->isActive())
if (bl_isUp()) {
qDebug()<<"step 5";
result = bl_isUp();
qDebug()<<"BL result: "<< result;
if (result)
{ {
bl_startupStep=99; bl_startupStep=99;
qDebug()<<"BL is working now...";
// BL is up and running // BL is up and running
return true;
} else } else
{ {
retryCtr++; // start again retryCtr++; // start again
if (retryCtr>=15) if (retryCtr>=10)
{ {
bl_startupStep=99; bl_startupStep=99;
//qDebug()<<"BL error!!!"; qDebug()<<"BL error!!!";
} else } else
{ {
bl_startupStep=3; bl_startupStep=3;
//qDebug()<<"BL retry..."; myTO->stop();
myTO->start(200);
qDebug()<<"BL retry...";
} }
} }
}
} }
return true; return false;
} }

View File

@@ -1,7 +1,13 @@
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include <QDebug> #include <QDebug>
#include <QFile>
#include <QString>
#include <QTextStream>
#include <QDateTime>
#include <QCoreApplication>
#include <atomic> #include <atomic>
#include <algorithm>
#ifdef QT_POSIX_IPC #ifdef QT_POSIX_IPC
// The POSIX backend can be explicitly selected using the -feature-ipc_posix // The POSIX backend can be explicitly selected using the -feature-ipc_posix
@@ -9,33 +15,124 @@
// macro will be defined. -> we use SystemV shared memory // macro will be defined. -> we use SystemV shared memory
#error "QT_POSIX_IPC defined" #error "QT_POSIX_IPC defined"
#else #else
#ifdef __linux__ #ifdef linux
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h> // ftok #include <sys/ipc.h> // ftok
#endif #endif
#endif #endif
//static bool shdMemFirstUse; //static bool shdMemFirstUse;
static QString read1stLineOfFile(QString fileName) { // read for instance /etc/os-release
QFile f(fileName);
if (f.exists()) {
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&f);
in.setCodec("UTF-8");
while(!in.atEnd()) {
return in.readLine();
}
}
}
return "N/A";
}
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) { //QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
QSharedMemory *SharedMem::getShm(std::size_t size) { QSharedMemory *SharedMem::getShm(std::size_t size) {
static QSharedMemory shMem; static QSharedMemory shMem;
if (size > 0) { if (size > 0) {
#ifdef __linux__ #ifdef linux
//static const long nativeKey = ftok("/etc/os-release", 'H'); static const long nativeKey = ftok("/etc/os-release", 'H');
//static const QString fkey = std::to_string(nativeKey).c_str(); static const QString fkey = std::to_string(nativeKey).c_str();
static const QString fkey = "0123456?000=7"; //static const QString fkey = "0123456?000=7";
#else #else
static const QString fkey = "0123456?000=9"; static const QString fkey = "0123456?000=9";
#endif #endif
qCritical() << __func__ << ":" << __LINE__ << ": size" << size;
shMem.setKey(fkey); shMem.setKey(fkey);
if (!shMem.isAttached()) { if (!shMem.isAttached()) {
if (shMem.create(size)) { if (shMem.create(size)) {
qCritical() << __func__ << ":" << __LINE__ << ": created shared memory";
#ifdef linux
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
qCritical() << __func__ << ":" << __LINE__
<< "size=" << size
<< "shMem.size=" << shMem.size()
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
<< "ABOUT TO REBOOT SYSTEM...";
if (system("reboot")) {
// reboot system -> shared memory re-created
}
}
struct SharedMem *sh = (SharedMem *)(shMem.data());
memset(sh->indat_HWversion, 0x00, sizeof(sh->indat_HWversion));
memset(sh->indat_SWversion, 0x00, sizeof(sh->indat_SWversion));
memset(sh->os_release, 0x00, sizeof(sh->os_release));
memset(sh->date_of_creation, 0x00, sizeof(sh->date_of_creation));
memset(sh->creator, 0x00, sizeof(sh->creator));
QString const &os_release = read1stLineOfFile("/etc/os-release");
strncpy(sh->os_release, os_release.toStdString().c_str(),
std::min((int)os_release.size(), (int)sizeof(sh->os_release)-1));
QString const &currentDateTime = QDateTime::currentDateTime().toString(Qt::ISODate);
char const *current = currentDateTime.toUtf8().constData();
strncpy(sh->date_of_creation, current,
std::min((int)strlen(current), (int)sizeof(sh->date_of_creation)-1));
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationPid());
strncpy(sh->creator, appPid.toStdString().c_str(),
std::min((int)strlen(appPid.toStdString().c_str()),
(int)sizeof(sh->creator)-1));
qCritical() << "os-release:" << sh->os_release;
qCritical() << " creator:" << sh->creator;
qCritical() << " date:" << sh->date_of_creation;
#else
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
#endif
return &shMem; return &shMem;
} else { } else {
if (shMem.error() == QSharedMemory::AlreadyExists) { if (shMem.error() == QSharedMemory::AlreadyExists) {
if (shMem.attach()) { if (shMem.attach()) {
#ifdef linux
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
qCritical() << __func__ << ":" << __LINE__
<< "size=" << size
<< "shMem.size=" << shMem.size()
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
<< "ABOUT TO REBOOT SYSTEM...";
if (system("reboot")) {
// reboot system -> shared memory re-created
}
}
#else
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
#endif
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationPid());
qCritical() << __func__ << ":" << __LINE__ << appPid << "attached shared memory";
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
qCritical() << "os-release:" << sh->os_release;
qCritical() << " creator:" << sh->creator;
qCritical() << " date:" << sh->date_of_creation;
return &shMem; return &shMem;
} }
} }
@@ -43,6 +140,13 @@ QSharedMemory *SharedMem::getShm(std::size_t size) {
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data() qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
<< shMem.error() << shMem.errorString(); << shMem.error() << shMem.errorString();
return nullptr; return nullptr;
} else {
qCritical() << __func__ << ":" << __LINE__ << "shared memory already attached";
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
qCritical() << "os-release:" << sh->os_release;
qCritical() << " creator:" << sh->creator;
qCritical() << " date:" << sh->date_of_creation;
} }
} }
return &shMem; return &shMem;

View File

@@ -0,0 +1,232 @@
#include "shared_mem_buffer.h"
#include <QDebug>
#include <QFile>
#include <QString>
#include <QTextStream>
#include <QDateTime>
#include <QCoreApplication>
#include <atomic>
#include <algorithm>
#ifdef QT_POSIX_IPC
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
// option to the Qt configure script. If it is enabled, the QT_POSIX_IPC
// macro will be defined. -> we use SystemV shared memory
#error "QT_POSIX_IPC defined"
#else
#ifdef linux
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h> // ftok
#endif
#endif
//static bool shdMemFirstUse;
static QString read1stLineOfFile(QString fileName) { // read for instance /etc/os-release
QFile f(fileName);
if (f.exists()) {
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&f);
in.setCodec("UTF-8");
while(!in.atEnd()) {
return in.readLine();
}
}
}
return "N/A";
}
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
QSharedMemory *SharedMem::getShm(std::size_t size) {
static QSharedMemory shMem;
if (size > 0) {
#ifdef linux
static const long nativeKey = ftok("/etc/os-release", 'H');
static const QString fkey = std::to_string(nativeKey).c_str();
//static const QString fkey = "0123456?000=7";
#else
static const QString fkey = "0123456?000=9";
#endif
qCritical() << __func__ << ":" << __LINE__ << ": size" << size;
shMem.setKey(fkey);
if (!shMem.isAttached()) {
if (shMem.create(size)) {
qCritical() << __func__ << ":" << __LINE__ << ": created shared memory";
#ifdef linux
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
qCritical() << __func__ << ":" << __LINE__
<< "size=" << size
<< "shMem.size=" << shMem.size()
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
<< "ABOUT TO REBOOT SYSTEM...";
if (system("reboot")) {
// reboot system -> shared memory re-created
}
}
struct SharedMem *sh = (SharedMem *)(shMem.data());
#ifndef QT_NO_DEBUG
sh->mem_guard_0 = 0;
sh->mem_guard_1 = 0; sh->mem_guard_2 = 0; sh->mem_guard_3 = 0;
sh->mem_guard_4 = 0; sh->mem_guard_5 = 0; sh->mem_guard_6 = 0;
sh->mem_guard_7 = 0; sh->mem_guard_8 = 0; sh->mem_guard_9 = 0;
sh->mem_guard_10 = 0;
sh->mem_guard_11 = 0; sh->mem_guard_12 = 0; sh->mem_guard_13 = 0;
sh->mem_guard_14 = 0; sh->mem_guard_15 = 0; sh->mem_guard_16 = 0;
sh->mem_guard_17 = 0; sh->mem_guard_18 = 0; sh->mem_guard_19 = 0;
sh->mem_guard_20 = 0;
sh->mem_guard_21 = 0; sh->mem_guard_22 = 0; sh->mem_guard_23 = 0;
sh->mem_guard_24 = 0; sh->mem_guard_25 = 0; sh->mem_guard_26 = 0;
sh->mem_guard_27 = 0; sh->mem_guard_28 = 0; sh->mem_guard_29 = 0;
sh->mem_guard_30 = 0;
sh->mem_guard_31 = 0; sh->mem_guard_32 = 0; sh->mem_guard_33 = 0;
sh->mem_guard_34 = 0; sh->mem_guard_35 = 0; sh->mem_guard_36 = 0;
sh->mem_guard_37 = 0; sh->mem_guard_38 = 0; sh->mem_guard_39 = 0;
sh->mem_guard_40 = 0;
sh->mem_guard_41 = 0; sh->mem_guard_42 = 0; sh->mem_guard_43 = 0;
sh->mem_guard_44 = 0; sh->mem_guard_45 = 0; sh->mem_guard_46 = 0;
sh->mem_guard_47 = 0;
#endif
memset(sh->indat_HWversion, 0x00, sizeof(sh->indat_HWversion));
memset(sh->indat_SWversion, 0x00, sizeof(sh->indat_SWversion));
memset(sh->os_release, 0x00, sizeof(sh->os_release));
memset(sh->date_of_creation, 0x00, sizeof(sh->date_of_creation));
memset(sh->creator, 0x00, sizeof(sh->creator));
QString const &os_release = read1stLineOfFile("/etc/os-release");
strncpy(sh->os_release, os_release.toStdString().c_str(),
std::min((int)os_release.size(), (int)sizeof(sh->os_release)-1));
QString const &currentDateTime = QDateTime::currentDateTime().toString(Qt::ISODate);
char const *current = currentDateTime.toUtf8().constData();
strncpy(sh->date_of_creation, current,
std::min((int)strlen(current), (int)sizeof(sh->date_of_creation)-1));
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationPid());
strncpy(sh->creator, appPid.toStdString().c_str(),
std::min((int)strlen(appPid.toStdString().c_str()),
(int)sizeof(sh->creator)-1));
qCritical() << "os-release:" << sh->os_release;
qCritical() << " creator:" << sh->creator;
qCritical() << " date:" << sh->date_of_creation;
#else
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
#endif
return &shMem;
} else {
if (shMem.error() == QSharedMemory::AlreadyExists) {
if (shMem.attach()) {
#ifdef linux
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
qCritical() << __func__ << ":" << __LINE__
<< "size=" << size
<< "shMem.size=" << shMem.size()
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
<< "ABOUT TO REBOOT SYSTEM...";
if (system("reboot")) {
// reboot system -> shared memory re-created
}
}
#else
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
#endif
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationPid());
qCritical() << __func__ << ":" << __LINE__ << appPid << "attached shared memory";
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
qCritical() << "os-release:" << sh->os_release;
qCritical() << " creator:" << sh->creator;
qCritical() << " date:" << sh->date_of_creation;
return &shMem;
}
}
}
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
<< shMem.error() << shMem.errorString();
return nullptr;
} else {
qCritical() << __func__ << ":" << __LINE__ << "shared memory already attached";
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
qCritical() << "os-release:" << sh->os_release;
qCritical() << " creator:" << sh->creator;
qCritical() << " date:" << sh->date_of_creation;
}
}
return &shMem;
}
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
/*
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
QSharedMemory *SharedMem::getShm(std::size_t size) {
static QSharedMemory shMem;
if (size > 0) {
#ifdef __linux__
static const long nativeKey = ftok("/etc/os-release", 'H');
static const QString fkey = std::to_string(nativeKey).c_str();
#else
static const QString fkey = "0123456?000=9";
#endif
shdMemFirstUse=false;
shMem.setKey(fkey);
if (!shMem.isAttached())
{
if (shMem.create(size))
{
// sm was created successful, did not exist before
shdMemFirstUse=true;
return &shMem;
} else
{
// create was false because mem already existed
if (shMem.error() == QSharedMemory::AlreadyExists)
{
if (shMem.attach())
{
return &shMem;
}
}
}
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
<< shMem.error() << shMem.errorString();
return nullptr;
}
}
return &shMem;
}
bool shdMem_firstUse(void)
{
return shdMemFirstUse;
}
*/

View File

@@ -6,12 +6,15 @@
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include "datei.h" #include "datei.h"
#include <QTextCodec>
// gpi: grafical access to PI: access from external devices over device controller FOR GUI // gpi: grafical access to PI: access from external devices over device controller FOR GUI
// epi: external access from GUI to PI: FOR external devices (DC) // epi: external access from GUI to PI: FOR external devices (DC)
// store power on/off condition of the devices to control the data request // store power on/off condition of the devices to control the data request
//static bool indat_savePrnPwr; //static bool indat_savePrnPwr;
@@ -63,66 +66,64 @@ bool indat_isMdbOn()
void gpi_storeHWver(QString text) void gpi_storeHWver(QString text)
{ {
// change Qstring to array of chars, because shared mem allowes no QString! QString prev(QByteArray(SharedMem::read()->indat_HWversion, versionBufferLen-1));
int nn, LL = text.length(); prev = prev.trimmed();
if (LL >= versionBufferLen)
LL=versionBufferLen-1; // leave place for termination
for (nn=0; nn<LL; nn++) QString const textTruncated = text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
{
SharedMem::write()->indat_HWversion[nn] = text.at(nn).toLatin1(); if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
&& textTruncated != prev) {
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
QString string = codec->toUnicode(textTruncated.toUtf8());
if (!string.isEmpty()) {
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
char *p = (char *)SharedMem::write()->indat_HWversion;
char *q = (char *)string.constData();
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
int const j = (sizeof(QChar) == 2) ? i*2 : i;
if (q[j]) {
*p++ = q[j];
}
}
}
} }
for (nn=LL; nn<versionBufferLen; nn++)
SharedMem::write()->indat_HWversion[nn] =0;
} }
QString epi_loadHWver(void) QString epi_loadHWver(void)
{ {
// load array of chars from SM and change to QString QString text(SharedMem::read()->indat_HWversion);
int nn, LL = versionBufferLen; return text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
char cc;
QString myStr;
myStr.clear();
for (nn=0; nn<LL; nn++)
{
cc = SharedMem::read()->indat_HWversion[nn];
myStr.append(cc);
}
return myStr;
} }
void gpi_storeSWver(QString text) void gpi_storeSWver(QString text)
{ {
int nn, LL = text.length(); QString prev(QByteArray(SharedMem::read()->indat_SWversion, 12));
if (LL >= versionBufferLen) prev = prev.trimmed();
LL=versionBufferLen-1; // leave place for termination
for (nn=0; nn<LL; nn++) QString const textTruncated = text.mid(0, qMin(12, text.size())).trimmed();
{
SharedMem::write()->indat_SWversion[nn] = text.at(nn).toLatin1(); if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
&& textTruncated != prev) {
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
QString string = codec->toUnicode(textTruncated.toUtf8());
if (!string.isEmpty()) {
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
char *p = (char *)SharedMem::write()->indat_SWversion;
char *q = (char *)string.constData();
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
int const j = (sizeof(QChar) == 2) ? i*2 : i;
if (q[j]) {
*p++ = q[j];
}
}
}
} }
for (nn=LL; nn<versionBufferLen; nn++)
SharedMem::write()->indat_SWversion[nn] =0;
} }
QString epi_loadSWver(void) QString epi_loadSWver(void)
{ {
int nn, LL = versionBufferLen; QString text(SharedMem::read()->indat_SWversion);
char cc; return text.mid(0, qMin(12, text.size())).trimmed();
QString myStr;
myStr.clear();
for (nn=0; nn<LL; nn++)
{
cc = SharedMem::read()->indat_SWversion[nn];
myStr.append(cc);
}
return myStr;
} }
void gpi_storeDCstate(QString text) void gpi_storeDCstate(QString text)
@@ -1984,7 +1985,7 @@ void epi_iniVRstorage(void)
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data ) void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data )
{ {
uint16_t start=blkNr, ii; 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 SharedMem::write()->store_gotNrBlocksOfVaultRec |= (1<<start); // setze pro Block ein bit, wir brauchen block 0...5
// also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen // also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen
start<<=6; // *64 start<<=6; // *64
@@ -2053,14 +2054,51 @@ uint16_t epi_getNrOfCoinsInCashBox(void)
//static bool store_DcDataAreValid; //static bool store_DcDataAreValid;
void gpi_storeDcDataValid(bool isVal) void gpi_storeDcDataValid(bool isVal)
{
bool now=SharedMem::read()->store_DcDataAreValid;
if (isVal != now)
{ {
SharedMem::write()->store_DcDataAreValid = isVal; SharedMem::write()->store_DcDataAreValid = isVal;
#ifdef THIS_IS_CA_MASTER
qDebug()<<"master lib sets DcDataValid to "<<isVal;
#else
qDebug()<<"slave lib sets DcDataValid to "<<isVal;
#endif
}
} }
void epi_setDcDataValid(void)
{
bool now=SharedMem::read()->store_DcDataAreValid;
if (now==false)
{
SharedMem::write()->store_DcDataAreValid = true;
#ifdef THIS_IS_CA_MASTER
qDebug()<<"master lib SET DcDataValid";
#else
qDebug()<<"slave lib SET DcDataValid";
#endif
}
}
void epi_resetDcDataValid(void)
{
bool now=SharedMem::read()->store_DcDataAreValid;
if (now==true)
{
SharedMem::write()->store_DcDataAreValid = false;
#ifdef THIS_IS_CA_MASTER
qDebug()<<"master lib RESET DcDataValid";
#else
qDebug()<<"slave lib RESET DcDataValid";
#endif
}
}
bool epi_areDcDataValid() bool epi_areDcDataValid()
{ {
return SharedMem::read()->store_DcDataAreValid; return SharedMem::read()->store_DcDataAreValid;
} }
// .................................................................................... // ....................................................................................
@@ -2165,8 +2203,8 @@ void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData)
SharedMem::write()->Sdata_LengthRawData=lrd; SharedMem::write()->Sdata_LengthRawData=lrd;
for (nn=0; nn<lrd; nn++) for (nn=0; nn<lrd; nn++)
SharedMem::write()->Sdata_rawData[nn]=receivedData[nn]; SharedMem::write()->Sdata_rawData[nn]=receivedData[nn];
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
} }
uint8_t epi_getRawReceivedData(uint8_t *receivedData) uint8_t epi_getRawReceivedData(uint8_t *receivedData)