commit 68fc83ba670a8a5273548b6a48a853fa071e65f7 Author: Gerhard Hoffmann Date: Thu Feb 29 11:36:24 2024 +0100 Add DownloadDCFirmware and DownloadDCJsonFiles diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1fa4e7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tags +*.tags diff --git a/ATBUpdateTool.pro b/ATBUpdateTool.pro new file mode 100644 index 0000000..3546aee --- /dev/null +++ b/ATBUpdateTool.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = DownloadDCFirmware DownloadDCJsonFiles + diff --git a/DownloadDCFirmware/ATBDownloadDCFirmware.ini b/DownloadDCFirmware/ATBDownloadDCFirmware.ini new file mode 100644 index 0000000..e69de29 diff --git a/DownloadDCFirmware/DownloadDCFirmware.pro b/DownloadDCFirmware/DownloadDCFirmware.pro new file mode 100644 index 0000000..495f199 --- /dev/null +++ b/DownloadDCFirmware/DownloadDCFirmware.pro @@ -0,0 +1,78 @@ +QT += core +QT += serialport network + +TARGET = ATBDownloadDCFirmware + +VERSION="0.1.0" +win32 { + BUILD_DATE=$$system("date /t") + BUILD_TIME=$$system("time /t") +} 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="$${VERSION}-$${GIT_COMMIT}" + +CONFIG += c++17 + +DEFINES+=APP_VERSION=\\\"$$VERSION\\\" +DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\" +DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\" +DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\" + +# keep comments, as /* fall through */ +QMAKE_CXXFLAGS += -C +QMAKE_CXXFLAGS += -g +QMAKE_CXXFLAGS += -Wno-deprecated-copy -O + +contains( CONFIG, PTU5 ) { + greaterThan(QT_MAJOR_VERSION, 4): QT += serialport + CONFIG += link_pkgconfig + lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport + QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7 + # QMAKE_CXXFLAGS += -Wno-deprecated-copy + ARCH = PTU5 + DEFINES+=PTU5 +} +contains( CONFIG, PTU5_YOCTO ) { + greaterThan(QT_MAJOR_VERSION, 4): QT += serialport + QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7 + # QMAKE_CXXFLAGS += -Wno-deprecated-copy + PTU5BASEPATH = /opt/devel/ptu5 + ARCH = PTU5 + DEFINES+=PTU5 + + # add qmqtt lib + #LIBS += -lQt5Qmqtt +} +contains( CONFIG, DesktopLinux ) { + greaterThan(QT_MAJOR_VERSION, 4): QT += serialport + lessThan(QT_MAJOR_VERSION, 5): CONFIG += extserialport + # QMAKE_CC = ccache $$QMAKE_CC + # QMAKE_CXX = ccache $$QMAKE_CXX + QMAKE_CXXFLAGS += -std=c++17 + # QMAKE_CXXFLAGS += -Wno-deprecated-copy + linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments } + ARCH = DesktopLinux + DEFINES+=DesktopLinux +} + +SOURCES += \ + main.cpp + +# HEADERS += + +OTHER_FILES += \ + ATBDownloadDCFirmware.ini + + +########################################################################################## +# for running program on target through QtCreator +contains( CONFIG, PTU5 ) { + qnx: target.path = /tmp/$${TARGET}/bin + else: unix:!android: target.path = /opt/app/tools/atbupdate/ + !isEmpty(target.path): INSTALLS += target +} diff --git a/DownloadDCFirmware/README.md b/DownloadDCFirmware/README.md new file mode 100644 index 0000000..e69de29 diff --git a/DownloadDCFirmware/main.cpp b/DownloadDCFirmware/main.cpp new file mode 100644 index 0000000..7dfe867 --- /dev/null +++ b/DownloadDCFirmware/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char **argv) { + Q_UNUSED(argc); + Q_UNUSED(argv); + + return 0; +} diff --git a/DownloadDCFirmware/message_handler.cpp b/DownloadDCFirmware/message_handler.cpp new file mode 100755 index 0000000..996bd2f --- /dev/null +++ b/DownloadDCFirmware/message_handler.cpp @@ -0,0 +1,97 @@ +#include "message_handler.h" + +#include +#include +#include +#include +#include + + +static char const *DBG_NAME[] = { "DBG ", "WARN ", "CRIT ", "FATAL", "INFO " }; +static bool installedMsgHandler = false; +static int debugLevel = LOG_NOTICE; + +int getDebugLevel() { return debugLevel; } +void setDebugLevel(int newDebugLevel) { + debugLevel = newDebugLevel; +} + +bool messageHandlerInstalled() { + return installedMsgHandler; +} + +QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler) { + installedMsgHandler = (handler != 0); + static QtMessageHandler prevHandler = nullptr; + if (handler) { + prevHandler = qInstallMessageHandler(handler); + return prevHandler; + } else { + return qInstallMessageHandler(prevHandler); + } +} + +/// +/// \brief Print message according to given debug level. +/// +/// \note Install this function using qInstallMsgHandler(). +/// +/// int main(int argc, char **argv) { +/// installMsgHandler(atbDebugOutput); +/// QApplication app(argc, argv); +/// ... +/// return app.exec(); +/// } +/// +#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + Q_UNUSED(context); + QString const localMsg = QString(DBG_NAME[type]) + msg.toLocal8Bit(); + + switch (debugLevel) { + case LOG_DEBUG: { // debug-level message + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } break; + case LOG_INFO: { // informational message + if (type != QtDebugMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_NOTICE: { // normal, but significant, condition + if (type != QtDebugMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_WARNING: { // warning conditions + if (type != QtInfoMsg && type != QtDebugMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_ERR: { // error conditions + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_CRIT: { // critical conditions + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_ALERT: { // action must be taken immediately + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_EMERG: { // system is unusable + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + default: { + //fprintf(stderr, "%s No ErrorLevel defined! %s\n", + // datetime.toStdString().c_str(), msg.toStdString().c_str()); + } + } +} +#endif + diff --git a/DownloadDCFirmware/message_handler.h b/DownloadDCFirmware/message_handler.h new file mode 100755 index 0000000..98c4d7e --- /dev/null +++ b/DownloadDCFirmware/message_handler.h @@ -0,0 +1,23 @@ +#ifndef MESSAGE_HANDLER_H_INCLUDED +#define MESSAGE_HANDLER_H_INCLUDED + +#include +#ifdef __linux__ +#include +#endif + +int getDebugLevel(); +void setDebugLevel(int newDebugLevel); + +bool messageHandlerInstalled(); +QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler); + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +// typedef void (*QtMessageHandler)(QtMsgType, const char *); +void atbDebugOutput(QtMsgType type, const char *msg); +#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +// typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &); +void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg); +#endif + +#endif // MESSAGE_HANDLER_H_INCLUDED diff --git a/DownloadDCJsonFiles/ATBDownloadDCJsonFiles.ini b/DownloadDCJsonFiles/ATBDownloadDCJsonFiles.ini new file mode 100644 index 0000000..e69de29 diff --git a/DownloadDCJsonFiles/DownloadDCJsonFiles.pro b/DownloadDCJsonFiles/DownloadDCJsonFiles.pro new file mode 100644 index 0000000..372518b --- /dev/null +++ b/DownloadDCJsonFiles/DownloadDCJsonFiles.pro @@ -0,0 +1,88 @@ +QT += core +QT += serialport network + +TARGET = ATBDownloadDCJsonFiles + +VERSION="0.1.0" +win32 { + BUILD_DATE=$$system("date /t") + BUILD_TIME=$$system("time /t") +} 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="$${VERSION}-$${GIT_COMMIT}" + +!contains(CONFIG, INCLUDEINTERFACES) { + INCLUDEINTERFACES=/opt/ptu5/opt/DCLibraries/include +} +INCLUDEPATH += plugins $${INCLUDEINTERFACES} + +CONFIG += c++17 + +DEFINES+=APP_VERSION=\\\"$$VERSION\\\" +DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\" +DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\" +DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\" + +# keep comments, as /* fall through */ +QMAKE_CXXFLAGS += -C +QMAKE_CXXFLAGS += -g +QMAKE_CXXFLAGS += -Wno-deprecated-copy -O + +contains( CONFIG, PTU5 ) { + greaterThan(QT_MAJOR_VERSION, 4): QT += serialport + CONFIG += link_pkgconfig + lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport + QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7 + # QMAKE_CXXFLAGS += -Wno-deprecated-copy + ARCH = PTU5 + DEFINES+=PTU5 +} +contains( CONFIG, PTU5_YOCTO ) { + greaterThan(QT_MAJOR_VERSION, 4): QT += serialport + QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7 + # QMAKE_CXXFLAGS += -Wno-deprecated-copy + PTU5BASEPATH = /opt/devel/ptu5 + ARCH = PTU5 + DEFINES+=PTU5 + + # add qmqtt lib + #LIBS += -lQt5Qmqtt +} +contains( CONFIG, DesktopLinux ) { + greaterThan(QT_MAJOR_VERSION, 4): QT += serialport + lessThan(QT_MAJOR_VERSION, 5): CONFIG += extserialport + # QMAKE_CC = ccache $$QMAKE_CC + # QMAKE_CXX = ccache $$QMAKE_CXX + QMAKE_CXXFLAGS += -std=c++17 + # QMAKE_CXXFLAGS += -Wno-deprecated-copy + linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments } + ARCH = DesktopLinux + DEFINES+=DesktopLinux +} + +SOURCES += \ + main.cpp \ + message_handler.cpp \ + process/command.cpp + +HEADERS += \ + message_handler.h \ + plugins/interfaces.h \ + process/command.h + +OTHER_FILES += \ + ATBDownloadDCJsonFiles.ini + + +########################################################################################## +# for running program on target through QtCreator +contains( CONFIG, PTU5 ) { + qnx: target.path = /tmp/$${TARGET}/bin + else: unix:!android: target.path = /opt/app/tools/atbupdate/ + !isEmpty(target.path): INSTALLS += target +} diff --git a/DownloadDCJsonFiles/DownloadDCJsonFiles.pro.user b/DownloadDCJsonFiles/DownloadDCJsonFiles.pro.user new file mode 100644 index 0000000..411e76b --- /dev/null +++ b/DownloadDCJsonFiles/DownloadDCJsonFiles.pro.user @@ -0,0 +1,445 @@ + + + + + + EnvironmentId + {6a494cc5-6dea-4681-86fc-d47b9761a1f4} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 3 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + GenericLinuxOsType + Yocto i.MX6-ATB-PTU5 + Yocto i.MX6-ATB-PTU5 + {804f60e1-6e88-41af-b072-9f5c6a606099} + 0 + 0 + 0 + + 0 + /opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Debug + /opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Debug + + + true + QtProjectManager.QMakeBuildStep + CONFIG+=PTU5 + false + + + + true + Qt4ProjectManager.MakeStep + /usr/bin/make + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + /usr/bin/make + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Release + /opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Profile + /opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + + true + RemoteLinux.CheckForFreeDiskSpaceStep + + + + + / + 5242880 + + + + + true + RemoteLinux.KillAppStep + + + + + + + + 2 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + DeployToGenericLinux + + 1 + + true + true + true + + 1 + + DownloadDCJsonFiles + RemoteLinuxRunConfiguration:/opt/ptu5/opt/DownloadDCJsonFiles/DownloadDCJsonFiles.pro + /opt/ptu5/opt/DownloadDCJsonFiles/DownloadDCJsonFiles.pro + 1 + false + true + false + true + :0 + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Desktop Qt 5.12.12 GCC 64bit + Desktop Qt 5.12.12 GCC 64bit + qt.qt5.51212.gcc_64_kit + 0 + 0 + 0 + + 0 + /opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Debug + /opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Release + /opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Profile + /opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/DownloadDCJsonFiles/README.md b/DownloadDCJsonFiles/README.md new file mode 100644 index 0000000..e69de29 diff --git a/DownloadDCJsonFiles/main.cpp b/DownloadDCJsonFiles/main.cpp new file mode 100644 index 0000000..b6db3d0 --- /dev/null +++ b/DownloadDCJsonFiles/main.cpp @@ -0,0 +1,56 @@ + +#include +#include +#include + +#include "message_handler.h" +#include "plugins/interfaces.h" + + +//#include +//#include + +#ifdef PTU5 +#define SERIAL_PORT "ttymxc2" +#else +#define SERIAL_PORT "ttyUSB0" +#endif + +int main(int argc, char **argv) { + QByteArray const value = qgetenv("LC_ALL"); + if (value != "C") { + qputenv("LC_ALL", "C"); + } + // qputenv("XDG_RUNTIME_DIR", "/var/run/user/0"); + + openlog("ATB-DL-JSON", LOG_PERROR | LOG_PID | LOG_CONS, LOG_USER); + + QCoreApplication a(argc, argv); + QCoreApplication::setApplicationName("ATBDownloadDCJsonFiles"); + QCoreApplication::setApplicationVersion(APP_VERSION); + + if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling + atbInstallMessageHandler(atbDebugOutput); + setDebugLevel(LOG_NOTICE); + } + + int r = std::system("ls -l /proc/[0-9]*/fd/* 2>/dev/null | grep /dev/ttymxc2 > /tmp/slave-or-master.txt"); + // lrwx------ 1 root root 64 Oct 31 14:55 /proc/884/fd/18 -> /dev/ttymxc2 + + //std::ifstream ifs("/tmp/slave-or-master.txt"); + + //if (ifs.is_open()) { + // std::string line; + // if (std::getline(ifs, line)) { + // if (line.size() > 0) { + // std::cout << "SLAVE " << line << std::endl; + // } + // } else { + // } + + // ifs.close(); + + //} + + return a.exec(); +} diff --git a/DownloadDCJsonFiles/message_handler.cpp b/DownloadDCJsonFiles/message_handler.cpp new file mode 100644 index 0000000..996bd2f --- /dev/null +++ b/DownloadDCJsonFiles/message_handler.cpp @@ -0,0 +1,97 @@ +#include "message_handler.h" + +#include +#include +#include +#include +#include + + +static char const *DBG_NAME[] = { "DBG ", "WARN ", "CRIT ", "FATAL", "INFO " }; +static bool installedMsgHandler = false; +static int debugLevel = LOG_NOTICE; + +int getDebugLevel() { return debugLevel; } +void setDebugLevel(int newDebugLevel) { + debugLevel = newDebugLevel; +} + +bool messageHandlerInstalled() { + return installedMsgHandler; +} + +QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler) { + installedMsgHandler = (handler != 0); + static QtMessageHandler prevHandler = nullptr; + if (handler) { + prevHandler = qInstallMessageHandler(handler); + return prevHandler; + } else { + return qInstallMessageHandler(prevHandler); + } +} + +/// +/// \brief Print message according to given debug level. +/// +/// \note Install this function using qInstallMsgHandler(). +/// +/// int main(int argc, char **argv) { +/// installMsgHandler(atbDebugOutput); +/// QApplication app(argc, argv); +/// ... +/// return app.exec(); +/// } +/// +#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + Q_UNUSED(context); + QString const localMsg = QString(DBG_NAME[type]) + msg.toLocal8Bit(); + + switch (debugLevel) { + case LOG_DEBUG: { // debug-level message + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } break; + case LOG_INFO: { // informational message + if (type != QtDebugMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_NOTICE: { // normal, but significant, condition + if (type != QtDebugMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_WARNING: { // warning conditions + if (type != QtInfoMsg && type != QtDebugMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_ERR: { // error conditions + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_CRIT: { // critical conditions + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_ALERT: { // action must be taken immediately + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + case LOG_EMERG: { // system is unusable + if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) { + syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str()); + } + } break; + default: { + //fprintf(stderr, "%s No ErrorLevel defined! %s\n", + // datetime.toStdString().c_str(), msg.toStdString().c_str()); + } + } +} +#endif + diff --git a/DownloadDCJsonFiles/message_handler.h b/DownloadDCJsonFiles/message_handler.h new file mode 100644 index 0000000..98c4d7e --- /dev/null +++ b/DownloadDCJsonFiles/message_handler.h @@ -0,0 +1,23 @@ +#ifndef MESSAGE_HANDLER_H_INCLUDED +#define MESSAGE_HANDLER_H_INCLUDED + +#include +#ifdef __linux__ +#include +#endif + +int getDebugLevel(); +void setDebugLevel(int newDebugLevel); + +bool messageHandlerInstalled(); +QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler); + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +// typedef void (*QtMessageHandler)(QtMsgType, const char *); +void atbDebugOutput(QtMsgType type, const char *msg); +#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +// typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &); +void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg); +#endif + +#endif // MESSAGE_HANDLER_H_INCLUDED diff --git a/DownloadDCJsonFiles/plugins/interfaces.h b/DownloadDCJsonFiles/plugins/interfaces.h new file mode 100644 index 0000000..0aa4a1e --- /dev/null +++ b/DownloadDCJsonFiles/plugins/interfaces.h @@ -0,0 +1,2492 @@ +#ifndef INTERFACE_H +#define INTERFACE_H + +#include + + + +struct T_emp +{ + + // Fixdata from EMP: + uint8_t shaft; // = changer level + uint16_t countryCode; + uint8_t scale; + uint8_t decimals; + uint8_t coinValues[16]; + uint16_t routing; + + // Master specs: + uint8_t gotSetup; // 1: got specifications from master 0: no specs + uint16_t coinAccept; // bit 0 = coin1 bit H=accept + uint8_t tokenChannel; + uint16_t denomination[16]; + + // dynamic: + uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine): + /* + // 0=start command + // 1=powered, do emp ini, send reset + // 2=delay + // 3=wait for response, requesting status after response + // 4,5 through, startup + // 6: wait for status + // 7: through, startup + // 8: IDLE state. EMP is up and ready, polling is running + // 9: polling on, payment not yet on + // 10: payment, check coins + // 11: through + // 12: wait 1s for last coin + // 90: stop all, 1s delay + // 99: off, all stopped + +*/ + uint8_t pollingRunning; + uint8_t paymentRunning; + +}; + +struct Trtc_DateTime +{ + uint8_t rtc_hour; + uint8_t rtc_min; + uint8_t rtc_sec; + uint8_t rtc_dayOfMonth; + uint8_t rtc_month; + uint8_t rtc_year; + uint8_t rtc_dayOfWeek; +}; + +struct Tprn_hw_state +{ + // hardware (IO's) + bool powerRdBk; // prn pwr is on + bool rsSwOk; // serial switch (printer or modem) is set to printer + bool rsDrvOk; // RS232 converter for PTU, Printer and Modem in on + + bool ReadyLine; // HW signal from printer showing ready + bool inIdle; // powered and free from errors + bool paperNearEnd; // paper roll runs out + bool noPaper; + bool ErrorTemp; + bool HeadOpen; + bool cutterJam; + bool noResponse; // printer is not connected, cable broken, wrong baudrate + bool badResponse; +}; + + struct Tprn_currentSettings +{ + uint8_t currFont; + uint8_t currSize; + uint8_t currHeigth; + uint8_t currWidth; + bool nowBold; + bool nowInvers; + bool nowUnderlined; + uint8_t currDensity; + uint8_t currSpeed; + bool nowAligned; +}; + +// obsolete + struct T_dynDat +{ + uint8_t licensePlate[8]; + uint8_t vendingPrice[8]; + uint8_t parkingEnd[8]; + uint8_t currentTime[8]; + uint8_t currentDate[8]; + uint8_t dynDat5[8]; + uint8_t dynDat6[8]; + uint8_t dynDat7[8]; +}; + + +struct T_vaultRecord +{ + + // Kassenbeleg (Abrechnungsdatensatz = Kassenwechsel-Datensatz) + char startbuffer[4]; // Psa> // never move or change this 1st entry + uint16_t AccountingNumber; + uint16_t CUNU; + uint16_t MANU; + uint16_t resint1; + //uint16_t resint2; + + char label1buffer[4]; // tim> + uint8_t year; + uint8_t month; + uint8_t dom; + uint8_t hour; + uint8_t min; + uint8_t sec; + uint8_t DoW; + uint8_t reschar3; + + char label2buffer[4]; // abs> + uint32_t AbsIncome1; + uint32_t AbsReserve; + uint32_t AbsNrOfCuts; + + char label3buffer[4]; // mw > + + // Verkauf, Tuer zu: + uint32_t VKcoinsInserted[16]; // nur fuer Wechsler, soviel wurde eingeworfen + uint32_t VKcoinsReturned[6]; // nur fuer Wechsler, Anzahl Muenzen pro Typ, soviel wurde zurueckgegeben + + // Service, Tuer offen: + uint16_t ServCoinsInserted[16]; // nur fuer Wechsler, soviel wurde eingeworfen + uint16_t ServCoinsReturned[6]; // nur fuer Wechsler, Anzahl Muenzen pro Typ, soviel wurde zurueckgegeben + uint16_t resint3; + uint16_t resint4; + uint16_t currentTubeContent[6]; // nur fuer Wechsler, aktueller Fuellstand + uint16_t resint5; + uint16_t resint6; + + char label4buffer[4]; // box> + uint16_t coinsInVault[16]; + uint16_t billsInStacker[8]; + + char label5buffer[4]; // val> + // actually constant unless exchange rate is changed + uint16_t coinDenomination[16]; // 5..50000 (z.B. 2? sind in Ungarn 760Ft) + uint16_t billDenom[8]; + uint16_t tubeDenom[6]; + uint16_t exchangeRate; + uint16_t resint9; + + // new from 1.8.23 + uint32_t cutsSinceCBchange; + uint32_t CBcontent_cent; + uint32_t CBnrofCoins; + + char endofblock[4]; // end +// 332 bytes + + uint16_t CRC16; // Xmodem16 from startbuffer[0] to endofblock[3] + uint16_t resint11; + char endofRecord[4]; // ---- + +}; + +struct T_moduleCondition +{ + // store conditon of all system components, hold in RAM + // 0 means unknown, not yet tested/used + // 1 means OK + // 50..99 = HINT / Notification + // 100..150 = WARNING + // 200..250 = ERROR + + uint8_t ram; + uint8_t intEe; + uint8_t extEe; + + uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error + uint8_t boardHw; + uint8_t printer; + uint8_t modem; + + uint8_t signal; // 1...99 + uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime + uint8_t mdbBus; + uint8_t coinChecker; // EMP, OMP or mei-cashflow + + uint8_t coinEscrow; + uint8_t mifareReader; // 0: unknown 1=OK 200=no response 201=wrong response 202: Reader reports HW-error + uint8_t creditTerm; + uint8_t coinReject; + + uint8_t coinSafe; + uint8_t billSafe; + uint8_t voltage; // 1:11..14V + uint8_t temper; + + uint8_t poweronTest; + uint8_t doorState; // 1: alles zu 200: tuer offen + bit1(S) +bit2(CB) + bit3(CB) + uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened + uint8_t changer; // can only be tested by usage + + uint8_t coinBlocker; // can only be tested by usage + uint8_t billReader; // can only be tested by usage + uint8_t ResetReason; + uint8_t allModulesChecked; + + uint8_t alarmState; + uint8_t res11; + uint8_t res12; + uint8_t res13; +// 31 +}; + +struct T_dynamicCondition +{ + char allDoorsDebounced; + char openedAuthorized; + uint8_t CBinDebounced; // 0:fehlt 1:drin + char upperDoor; // 99: undefined 0:closed 1:open + char middleDoor; // 99: undefined 0:closed 1:open + char lowerDoor; // 99: undefined 0:closed 1:open + char reserve; + char billBox; + char modeAbrech; + char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest + char nowCardTest; + char nowPayment; // not used, always 0 + char lastMifCardType; + uint8_t lastSDoorState; + uint8_t lastVDoorState; + uint8_t lastCBstate; + char paymentInProgress; + // Version Szeged: aug2023 + // 0: stopped by timeout + // 1: running 2: wait4lastCoin + // 3: payment stopped manually, coins in Escrow + // 4: payment stopped autom, amount collected, coins in Escrow + // 5: payment stopped, escrow full, coins in Escrow + // 6: coins encashed 7:coins returned + // 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; + uint16_t U_Batt; + uint16_t Temperatur; + uint16_t nrCoinsInBox; + uint32_t amountInBox; + uint32_t totalTransVolume; + uint32_t totalNrOfVends; + char jsonValid_config; + char jsonValid_device; + char jsonValid_cash; + char jsonValid_print; + char jsonValid_serial; + char jsonValid_time; + char lastFileType; +// 44 + uint8_t MifCardHolder[8]; + uint8_t resultOfLastTemplPrint; + // 0: unknown or printing in progress + // 1: OK, doc was printed 2: error, doc was not printed + uint8_t lastPrinterStatus; + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + uint8_t startupTestIsRunning; + + //54 +}; + +struct T_extTime +{ + uint8_t Hours; + uint8_t Min; + uint8_t Sec; + uint8_t Year; + uint8_t Month; + uint8_t Day; + uint8_t DOW; + uint8_t res1; + uint16_t MinOfDay; + uint16_t res2; + uint32_t SecOfDay; + uint8_t isLeapYear; + uint8_t nxtLeapYear; + uint8_t lastLeapYear; + uint8_t hoursOfThisWeek; + uint16_t minutesOfThisWeek; + uint16_t hoursOfThisMonth; + uint16_t daysOfThisYear; + uint16_t GetHoursOfYear; + uint16_t res3; + uint32_t GetMinutesOfYear; + uint8_t getWakeIntvSec; + uint8_t res4; + uint16_t res5; + uint32_t MinutesOfMillenium; + +}; + + +typedef uint8_t UCHAR; +typedef uint16_t UINT; + +struct T_devices +{ + // set by master, used(1) or notused (0) or type 2....20 + + UCHAR kindOfPrinter; // 0:off 1:Gebe + UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza Csquare (MW) + UCHAR kindOfMifareReader; // by now only stronglink SL025 =1 + UCHAR solarPower; // 1:sleep allowed 0: no sleep + //UCHAR suppressSleepMode; // 0:sleep allowed 1: no sleep + + UCHAR kindOfModem; // 0:off 1:Sunlink + UCHAR kindOfCreditcard; // 0:off 1:Feig NFC + UCHAR CoinEscrow; + UCHAR CoinRejectUnit; + + UCHAR CoinShutter; + UCHAR BillAcceptor; + UCHAR usevaultLock; + UCHAR autoAlarm; // 1: switch on siren for 1min in doors opened unauthorized + + UCHAR autoOpen; // 1: open door covers after valid ATBcard + UCHAR printAccReceipt; // 0/1 + UCHAR printDoorReceipt; + UCHAR printTokenTicket; + + UINT VaultFullWarnLevel; + UINT VaultFullErrorLevel; + UINT BattEmptyWarnLevel; + UINT BattEmptyErrorLevel; + +}; + +struct T_chg_Tub +{ + + uint8_t tubeLevel[8]; // [0]=nr coins of lowest value + uint8_t tubeFull[8]; // 1=full 0 else + uint16_t tubeValues[8]; // in cent [0]=lowest value 5c or 10cent + uint16_t tubeFilled[8]; // nr of every coin inserted + uint16_t tubeDispens[8]; // nr of every coin dispensed + // 64 byte +}; + +struct T_changer +{ + // Fixdata from Coin Changer + uint8_t setup; // always 1 + uint8_t state; // step of state machine + // 0..12 like EMP, 13...30 for coin dispense + + uint8_t level; // mdb-level, always 3 + uint16_t countryCode; + uint8_t scale; + uint8_t decimals; + uint8_t coinSetup[16]; // [0]=lowest coin, multiply with scale + uint16_t intendedAcceptance; //bitwise 0,1 1=accept coin, came from master + uint8_t tokenChannel; + uint8_t pollingRunning; // 1: emp is polled 0:not + uint8_t paymentRunning; // 1: coins are accepted + uint16_t denomination[16]; + uint16_t availableTubes; //bitwise 0,1 1=av. bit0 = lowest coin value +}; + +struct T_bna +{ + // reported with STATUS: + uint8_t setup; // 0: not 1: got valid parameters from device + uint8_t FeatureLevel; + uint16_t countryCode; // programmed in EMP + uint16_t scalingFactor; // z.B. 5 + uint8_t decimalPlace; + uint8_t pad1; + uint16_t stackerCap; + uint16_t billSecureLevel; + uint8_t hasEscrow; + uint8_t accBillTypes[16]; // programmed in EMP z.B. (bit 0..7): 1 2 4 10 20 40 0 0 + uint16_t currentStackerLevel; // requested number of notes in billbox + + // settings from Master + uint16_t intendedAccept; // bit 0 =5€ + uint16_t pad2; + uint16_t billDenomination[16]; + +}; + +class DownloadThread; +class hwinf +{ + +public: + virtual ~hwinf() {} + + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Use serial interface and protocol stack in Cashagent-Library + // Sending Output data to DeviceController DC2b + // Sending input requests to DC2 (single or auto-batch) + // Getting input data as receiver payload + // Furthermore the Cashagent-Library answers with status strings about sending and reading result + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + + virtual bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const { + Q_UNUSED(BaudNr); + Q_UNUSED(BaudStr); + Q_UNUSED(ComName); + Q_UNUSED(connect); + return false; + } + // Command: open serial interface + // BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200 + // BaudStr: for exapmle "19200" + // ComName: for example "COM48" + // connect: 0, 1 + + virtual void dc_closeSerial(void) const {} + // Command: close serial interface in order to save power while power down + // or if another port must be used + + + virtual bool dc_isPortOpen(void) const { + return false; + } + // returns true if port open (don't send unless open. Sending to closed port will crash program) + + virtual void dc_autoRequest(bool on) const { + Q_UNUSED(on); + } + // on = true: select that all READ-Requests are sent automatically + // on = false: select that all READ-Requests are sent manually one by one + // Every input information from DC2 must be requested + // ( digital and analog sensors, get time/date, get status information ) + + virtual void dc_requTestResponse() const {} + // tell DC2 to send a test-string, useful to see if cable and baudrate is OK + + virtual bool dc_readAnswTestResponse() const { + return false; + } + // retval: true: test was successful, got right response + + virtual uint8_t dc_isRequestDone(void) const { + return 0; + } + // retval: 0: request is still in progress + // 1: answer from DC2 was OK + // 2: wrong answer from DC2 + + virtual uint16_t dc_getCompletePayLoad(uint16_t plBufSiz, uint8_t *payLoad) const { + Q_UNUSED(plBufSiz); + Q_UNUSED(payLoad); + return 0; + } + // get data back in "payLoad", max 64 byte, can be used for diagnosis + // retval = nr of bytes received. If host buffer too small then + // only plBufSiz bytes are copied to "payLoad" + // plBufSiz = size of host buffer + + virtual void dc_setWakeFrequency(uint8_t period) const { + Q_UNUSED(period); + } + // RTC wakes DC2 (and PTU) by hardware signal every 32seconds + // change wake signal period to 1...64s + + virtual void dc_OrderToReset(void) const {} + // want DC2 to reset (in order to start Bootloader) + + + virtual QString dc_getSerialState(void) const { + return QString(); + } + // get result of opening-command like "ttyS0 opened with 115200 8N1! + // or error messages like "comport not available..." + // was saved by last opening event, can be passed for 100ms + + virtual void dc_clrSerialStateText(void) const {} + // clear above text to avoid multiple repetive displaying + + + virtual void bl_sendDataDirectly(uint8_t length, uint8_t *buf) const { + Q_UNUSED(length); + Q_UNUSED(buf); + } + // send without protocol frame, needed for the DC bootloader + + virtual uint8_t getRawRecLength(void) const { + return 0; + } + // only needed if protocol stack in Cashagent-Library is bypassed + + virtual uint8_t getRawReceivedData(uint8_t *receivedData) const { + Q_UNUSED(receivedData); + return 0; + } + // only needed if protocol stack in Cashagent-Library is bypassed + + virtual QString dc_getSerialParams(void) const { + return QString(); + } + // get DC2 serial settings (not very meaningful as they will not come if different from master settings) + + virtual QString dc_getHWversion(void) const { + return QString(); + } + // get DC2 hardware version + + virtual QString dc_getSWversion(void) const { + return QString(); + } + // get DC2 software version + + virtual QString dc_getState(void) const { + return QString(); + } + // get DC2 status (every OK or any error/warning? ) + + +// ---------------------------------------------------------------------------------------------------------- +// Date and Time +// ---------------------------------------------------------------------------------------------------------- + + virtual uint8_t rtc_getDateTime(struct Trtc_DateTime *rtc_DateTime) const { + Q_UNUSED(rtc_DateTime); + return 0; + } + + virtual uint8_t rtc_setDateTime(void) const { + return 0; + } + // synch DC2 with PC or PTU system time and date + + virtual void rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const { + Q_UNUSED(hh); + Q_UNUSED(mm); + Q_UNUSED(ss); + } + // get time directly + + virtual void rtc_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) const { + Q_UNUSED(yy); + Q_UNUSED(mm); + Q_UNUSED(dd); + } + // get date directly + + virtual uint8_t rtc_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) const { + Q_UNUSED(dow); + Q_UNUSED(minOfToday); + Q_UNUSED(secOfToday); + return 0; + } + // dow=day of week, 1=monday...7 + // minOfToday: 0=midnight...1439= 23:59 + // secOfToday: 0=midnight...86399= 23:59:59 + + virtual bool rtc_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) const { + Q_UNUSED(lastLeapYear); + Q_UNUSED(NextLeapYear); + return false; + } + // retval true: this year is leap year + + virtual bool rtc_isLeapYear() const { + return false; + } + + virtual void rtc_getWeek(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) const { + Q_UNUSED(DayOfWeek); + Q_UNUSED(HoursOfWeek); + Q_UNUSED(MinutesOfWeek); + } + // DayOfWeek: 1=monday...7 + // HoursOfWeek: 0=Monday 0:00 o'clock...167=Sunday 23:00 + // MinutesOfWeek: 0=Monday 0:00 o'clock...10079=Sunday 23:59 + + virtual void rtc_getMonth(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) const { + Q_UNUSED(DayOfMonth); + Q_UNUSED(HoursOfMonth); + Q_UNUSED(MinutesOfMonth); + } + // DayOfMonth: 1...31 + // HoursOfMonth: 0 = 0:00o'clock of 1.day in month up to 743 + // MinutesOfMonth:0 = 0:00o'clock of 1.day in month up to 44639 + + virtual void rtc_getYear(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) const { + Q_UNUSED(DayOfYear); + Q_UNUSED(HoursOfYear); + Q_UNUSED(MinutesOfYear); + } + // DayOfYear: 1...366 1= 1.Jan of this current year + // HoursOfYear: 0=1.Jan 0:00o'clock ...8783=31.12 23 o'clock + // MinutesOfYear: 0=1.Jan 0:00o'clock ...527039=31.12 23:59 o'clock + + virtual QString rtc_getTimStr(void) const { + return QString(); + } + virtual QString rtc_getDatStr(void) const { + return QString(); + } + virtual QString rtc_getTimDatStr(void) const { + return QString(); + } + + + // UID - unique number, different in every DC + virtual void dc_getUID8byte(uint8_t *buf8byteUid) const { + Q_UNUSED(buf8byteUid); + } + // get 8 single bytes in buffer + + virtual QString dc_getUIDstr() const { + return QString(); + } + // get as string + + virtual uint64_t dc_getUIDnumber(void) const { + return 0; + } + // get UID as one long number + +// ---------------------------------------------------------------------------------------------------------- +// analogs +// ---------------------------------------------------------------------------------------------------------- + + // Analog values: + virtual uint32_t dc_getTemperature(void) const { + return 0; + } + // in Sax-Format 0...400 (0=-50,0degC 100=0,0degC 141=20,5degC 400=150,0degC) + + virtual QString dc_getTemperaturStr(void) const { + return QString(); + } + // as string like "-12,5degC" + + virtual uint32_t dc_getVoltage(void) const { + return 0; + } + // as value in mV, 0...65,535V + + virtual QString dc_getVoltagStr(void) const { + return QString(); + } + // as string in mV + + virtual bool dc_mainFuseIsOk(void) const { + return false; + } + // true if 12V fuse is OK + // false: fuse blown, DC will continue working but no 12V device can be used! + +// ------------------------------------------------------------------------------ +// digital outputs +// ------------------------------------------------------------------------------ + + virtual uint8_t lock_switchUpperLock(uint8_t dir) const { + Q_UNUSED(dir); + return 0; + } + // dir 0=off 1=up 2=down + // move lock until stop cmd (0) + + virtual uint8_t lock_switchLowerLock(uint8_t dir) const { + Q_UNUSED(dir); + return 0; + } + // dir 0=off 1=up 2=down + // move lock until stop cmd (0) + + virtual void lock_switchVaultDoor(void) const {} + + virtual void coin_switchRejectMotor(uint8_t dir) const { + Q_UNUSED(dir); + } + + virtual void coin_rejectCoins(void) const {} + + // LEDs + virtual void led_switchLedService(uint8_t on) const { + Q_UNUSED(on); + } + virtual void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const { + Q_UNUSED(on); + Q_UNUSED(ton); + Q_UNUSED(tof); + } + virtual void led_switchLedPinPad(uint8_t on, uint8_t ton, uint8_t tof) const { + Q_UNUSED(on); + Q_UNUSED(ton); + Q_UNUSED(tof); + } + virtual void led_switchLedStart(uint8_t on, uint8_t ton, uint8_t tof) const { + Q_UNUSED(on); + Q_UNUSED(ton); + Q_UNUSED(tof); + } + virtual void led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const { + Q_UNUSED(on); + Q_UNUSED(ton); + Q_UNUSED(tof); + } + + virtual void fan_switchFan(bool on) const { + Q_UNUSED(on); + } + virtual void alarm_switchSiren(bool on) const { + Q_UNUSED(on); + } + virtual void bar_OpenBarrier(bool open) const { + Q_UNUSED(open); + } + virtual void ptu_switchWake(bool WAKEACTIVE) const { + Q_UNUSED(WAKEACTIVE); + } + + virtual void aux_power(bool on) const { + Q_UNUSED(on); + } + virtual void aux_setUsage(uint8_t PinDirection) const { + Q_UNUSED(PinDirection); + } + virtual void aux_setOutputs(uint8_t PinIsHigh) const { + Q_UNUSED(PinIsHigh); + } + + virtual void lock_switchContactPower(bool on) const { + Q_UNUSED(on); + } + + virtual void prn_switchPower(bool on) const { + Q_UNUSED(on); + } + + virtual void mif_readerOn(bool on) const { + Q_UNUSED(on); + } + + virtual void mif_creatAtbCard(uint8_t cardType) const { + Q_UNUSED(cardType); + } + + virtual void mod_switchPower(bool on) const { + Q_UNUSED(on); + } + + virtual void mod_switchWake(bool WAKEACTIVE) const { + Q_UNUSED(WAKEACTIVE); + } + + virtual void mdb_switchPower(bool on) const { + Q_UNUSED(on); + } + + virtual void mdb_switchWake(bool WAKEACTIVE) const { + Q_UNUSED(WAKEACTIVE); + } + + virtual void credit_switchPower(bool on) const { + Q_UNUSED(on); + } + // the same as modem power + + virtual void credit_switchWake(bool WAKEACTIVE) const { + Q_UNUSED(WAKEACTIVE); + } + + virtual void shut_move(bool open) const { + Q_UNUSED(open); + } + + virtual void esc_moveFlaps(uint8_t flap ) const { + Q_UNUSED(flap); + } + // 0: close both 1: open take-flap 2: open return + + +// ------------------------------------------------------------------------------ +// door, cashbox and lock switches +// ------------------------------------------------------------------------------ + + virtual uint8_t door_getSwitches(void) const { + return 0; + } + // retval: bit0: upper door 1: low door 2:vault door + + virtual bool door_isUpperDoorOpen(void) const { + return false; + } + + virtual bool door_isLowerDoorOpen(void) const { + return false; + } + + virtual bool vault_isVaultDoorOpen(void) const { + return false; + } + + virtual uint8_t vault_getSwitches(void) const { + return 0; + } + // retval bit0: cash box, bit 1: bill box + + virtual bool vault_isCoinVaultIn(void) const { + return false; + } + + virtual bool vault_isBillVaultIn(void) const { + return false; + } + + virtual uint8_t door_getLocks(void) const { + return 0; + } + // retval bit0: upper lever is up (=open) + // bit1: upper lever is down (=locked) + // bit2: lower lever is up + // bit3: lower lever is down (=locked) + + virtual bool door_upperDoorIsLocked(void) const { + return false; + } + + virtual bool door_upperDoorIsUnlocked(void) const { + return false; + } + + virtual bool door_lowerDoorIsLocked(void) const { + return false; + } + + virtual bool door_lowerDoorIsUnlocked(void) const { + return false; + } + + virtual bool bar_optoIn1isOn(void) const { + return false; + } + + virtual bool bar_optoIn2isOn(void) const { + return false; + } + + virtual uint8_t aux_getAuxInputs(void) const { + return 0; + } + + virtual bool ptu_WakeINisActive(void) const { + return false; + } + + virtual bool mdb_WakeINisActive(void) const { + return false; + } + + virtual bool prn_readyINisActive(void) const { + return false; + } + + virtual bool coid_isAttached(void) const { + return false; + } + + virtual bool coin_escrowIsOpen(void) const { + return false; + } + + virtual bool mif_cardIsAttached(void) const { + return false; + } + +//bool hwapi::mod_WakeINisActive(void); + + virtual bool door_isContactPowerOn(void) const { + return false; + } + + virtual bool mif_isMifarePowerOn(void) const { + return false; + } + + virtual bool mdb_testIsmdbTxDon(void) const { + return false; + } + + virtual bool aux_isAuxPowerOn(void) const { + return false; + } + + virtual bool mod_isGsmPowerOn(void) const { + return false; + } + + virtual bool cred_isCreditPowerOn(void) const { + return false; + } + + virtual bool prn_isPrinterPowerOn(void) const { + return false; + } + + virtual uint8_t prn_PrnFuseIsOk(void) const { + return 0; + } + //retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off + + virtual bool mdb_isMdbPowerOn(void) const { + return false; + } + + virtual bool cash_getRejectMotorHomePos(void) const { + return false; + } + + virtual uint8_t cash_getLowPaperSensor(void) const { + return 0; + } + // 0: Sensor sees paper 1: no paper 99: off + + + // ------------------------------------------------------------------------------ + // request commands + // ------------------------------------------------------------------------------ + + // all read-requests can be sent manually by the following functions + // or automatically in background by: void hwapi::dc_autoRequest(bool on) + + + virtual void request_DC2serialConfig() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + + virtual void request_DC2_HWversion() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_SWversion() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_condition() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_UID() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_TimeAndDate() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_analogues() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_digitalInputs() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_digitalOutputs() const {} + // read-request can be sent manually by this function, not needed if auto-request is on + + // ------------------------------------------------------------------------------ + + // the following device state requests are deployed only if device is powered up: + virtual void request_PrinterHwState() const {} + virtual void request_PrinterCurrentFonts() const {} + virtual void request_PrinterStateComplete() const {} + + virtual void request_MifareReaderState() const {} + virtual void request_MifareCardType() const {} + virtual void request_MifareAtbType() const {} + virtual void request_MifareID() const {} + virtual void request_MifareData(uint8_t dataBlockNumber) const { + Q_UNUSED(dataBlockNumber); + } + //virtual void request_MifareData() const =0; + + virtual void request_MDB_Status() const {} + virtual void request_MDB_lastResponse() const {} + virtual void request_EMP_allParameters() const {} + virtual void request_EMP_lastCoin() const {} + + + // ------------------------------------------------------------------------------ + // readback digital outputs of connected devices + // these functions are not needed for normal operation + // but can be used to test and verify conditions + // ------------------------------------------------------------------------------ + + + virtual bool test_getDO_mdbRXtst(void) const { + return false; + } + // readback digital outputs of connected devices + // these functions are not needed for normal operation + // but can be used to test and verify conditions + + virtual uint8_t lock_getDO_motors(void) const { + return 0; + } + // bit0: upper lock forward bit 1 backward + // bit2: lower lock forward bit 3 backward + + virtual uint8_t test_serialState(void) const { + return 0; + } + // test on-board signals for the serials + // serial drv on/off, Serial mux1, Serial mux2 + + virtual bool test_serialIsOn(void) const { + return false; + } + + virtual bool test_serialMux1isSetToPrinter(void) const { + return false; + } + virtual bool test_serialMux1isSetToModem(void) const { + return false; + } + virtual bool test_serialMux2isSetToCredit(void) const { + return false; + } + virtual bool test_serialMux2isSetToMifare(void) const { + return false; + } + + virtual bool led_coinIsOn(void) const { + return false; + } + virtual bool led_frontIsOn(void) const { + return false; + } + virtual bool led_ticketIsOn(void) const { + return false; + } + virtual bool led_pinIsOn(void) const { + return false; + } + virtual bool led_StartIsOn(void) const { + return false; + } + virtual bool led_insideIsOn(void) const { + return false; + } + + virtual bool fan_isOn(void) const { + return false; + } + virtual bool siren_isOn(void) const { + return false; + } + virtual bool bar_relayIsOn(void) const { + return false; + } + virtual bool ptu_WakeOutIsOn(void) const { + return false; + } + + virtual bool aux_powerIsOn(void) const { + return false; + } + + virtual bool coin_shutterIsOpen(void) const { + return false; + } + virtual bool coin_shutterTestOutput(void) const { + return false; + } + + virtual uint8_t coin_escrowFlapOpened(void) const { + return 0; + } + // retval: 1:return flap is open 2:take flap is open 0:closed + + + +// ------------------------------------------------------------------------------ +// devices are operated by DC +// processes with more then one devices +// timer controlled or long term processes +// ------------------------------------------------------------------------------ + + + virtual void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, + uint8_t kindOfMifareReader, uint8_t suppressSleep, + uint8_t kindOfModem, uint8_t kindOfCredit ) const { + Q_UNUSED(kindOfPrinter); + Q_UNUSED(kindOfCoinChecker); + Q_UNUSED(kindOfMifareReader); + Q_UNUSED(suppressSleep); + Q_UNUSED(kindOfModem); + Q_UNUSED(kindOfCredit); + } + // enable hardware in device controller: + // kindOfPrinter: 0:off 1: GPT4672 (only this one implemented) + // kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: Csquare_changer + // kindOfMifareReader: 0:off 1: SL025 (only this one implemented) + // suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason + // kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented) + // kindOfCredit: 0:off 1: cVendTopp 2:cVendPin (not yet implemented) + + virtual void request_ReadbackDeviceSettings() const {} + + virtual void readback_DeviceSettings(uint8_t *length, uint8_t *data) const { + Q_UNUSED(length); + Q_UNUSED(data); + } + // refer to DC2 manual for exact content + // state 5.5.21: byte[0]=kindOfPrinter byte[1]=kindOfCoinChecker + // byte[2]=kindOfMifarereadr byte[3]=suppress sleep mode + // byte[4]=kindOfModem byte[5]=kind of cc terminal + + virtual void sendMachineID(uint16_t customerNr, uint16_t machineNr, + uint16_t borough, uint16_t zone, + uint16_t alias, char *location) const { + Q_UNUSED(customerNr); + Q_UNUSED(machineNr); + Q_UNUSED(borough); + Q_UNUSED(zone); + Q_UNUSED(alias); + Q_UNUSED(location); + } + + virtual void request_ReadbackMachineID() const =0; + + virtual void readback_machineIDdata(uint8_t *length, uint8_t *data) const { + Q_UNUSED(length); + Q_UNUSED(data); + } + // state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number + // byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name + // byte[10...41]=location + + // Locks stops automatically at end switch or by timeout + virtual uint8_t lock_openUpperDoor(void) const { + return 0; + } + virtual uint8_t lock_closeUpperDoor(void) const { + return 0; + } + + virtual uint8_t lock_openLowerDoor(void) const { + return 0; + } + virtual uint8_t lock_closeLowerDoor(void) const { + return 0; + } + + virtual void shut_openOnce(void) const {} + // and close automatic after shutter time + + virtual void shut_openForCoin(bool start) const { + Q_UNUSED(start); + } + // open flap if coin is attached + // once process is started it runs until stop command + + virtual void shut_sendOpeningTime(uint16_t timeIn_ms ) const { + Q_UNUSED(timeIn_ms); + } + // after this time without retrigger the flap is closed + + virtual void esc_takeMoney(void) const {} + // and close automatically after escrow time (1s) + + virtual void esc_returnMoney(void) const {} + // and close automatically after escrow time (1s) + + +// ---------------------------------------------------------------------------------------------------------- +// --------------------------------------------- MIFARE ----------------------------------------------------- +// ---------------------------------------------------------------------------------------------------------- + +// obsolete + virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const { + Q_UNUSED(buf); + Q_UNUSED(maxBufferSize); + return 0; + } + // retval 0=OK 1=error host buffer too small + /* data description, new fast version: + byte 0= still the same: current read state: + 0=power off 1=reader-fault 2=ready + 3=just reading 4=read complete + 5=read partial, removed too early + 6=state unknown + + byte 1: reader state 1=ok 0=nok + byte 2: card preent (0,1) + byte 3: card selected (0) + byte 4: card type: 0...5 + byte 5: card allowed (0=no 1=MifareClassic 1k or 4k) + byte 6: CardSize: 1 or 4 (kB) + byte 7: length of UID 4 or 7 (byte) + */ + + virtual bool mif_readerIsOK(void) const { + return false; + } + + virtual bool mif_cardAttached(void) const { + return false; + } + // not working! use mif_cardIsAttached() instead + + virtual uint8_t mif_readResult(void) const { + return 0; + } + // result: 0: unknown or still in progress + // 1: card read successful + // 2: reading error + // not working! + + virtual QString mif_cardUID(void) const { + return QString(); + } + // not working + + virtual uint8_t mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const { + Q_UNUSED(blkNr); + Q_UNUSED(buf); + Q_UNUSED(maxBufferSize); + return 0; + } + + virtual QString mif_getCardDataStr(uint8_t blockNumber) const =0; + // with blockNumber=0...11 + + + + // ---------------------------------------------------------------------------------------------------------- + // --------------------------------------------- PRINTER ---------------------------------------------------- + // ---------------------------------------------------------------------------------------------------------- + + // read printer condition and settings + + virtual uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const { + Q_UNUSED(prn_hw_state); + return 0; + } + // retval: status byte + // byte 0 = 0: prnter OK, >0: error + // bit0: paper low 1: no paper 2: temperature error + // 3: head open 4: paper jam in cutter + // 6: no response 7: bad response from printer + // and return struct "Tprn_hw_state" + + virtual bool prn_isUpAndReady(void) const { + return false; + } + // true: printer is powered, serial is ok, no error, printer is connected and resonding + + virtual void prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const { + Q_UNUSED(prn_fonts); + } + + + // send Commands to printer: + + virtual void prn_sendText(QByteArray *buf) const { + Q_UNUSED(buf); + } + // up to 1280 bytes + + virtual void prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) const { + Q_UNUSED(para1); + Q_UNUSED(para2); + Q_UNUSED(para3); + } + // send three byte through to printer, see printers manual + + virtual void prn_sendPrnEscCmd(uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4) const { + Q_UNUSED(para1); + Q_UNUSED(para2); + Q_UNUSED(para3); + Q_UNUSED(para4); + } + // send four byte through to printer, see printers manual + + + virtual void prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) const { + Q_UNUSED(paperSpeed); + Q_UNUSED(density); + Q_UNUSED(alignment); + Q_UNUSED(orientation); + } + // send 5 byte: byte 0,1: speed 5...250 mm/s + // byte2: density 0....(25)....50 + // byte3: alignment 'l', 'c', 'r' = left, center, right + // byte4: orientation 0, 90, 180 = 0deg, 90deg, 180deg rotation (by now not supported!) + // not batched! don't use twice within 100ms + + virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const { + Q_UNUSED(wayInMm); + Q_UNUSED(direction); + } + //direction: 1=forward 2=backward + // + virtual void prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const { + Q_UNUSED(font); + Q_UNUSED(size); + Q_UNUSED(width); + Q_UNUSED(height); + } + // font = kind of font 5...11 (0..22) + // size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge + // width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) + // heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense + + virtual void prn_setLetters(uint8_t bold, uint8_t invers, uint8_t underlined) const { + Q_UNUSED(bold); + Q_UNUSED(invers); + Q_UNUSED(underlined); + } + // bold: 0/1 + // invers: 0/1 + // underlined: 0/1 + + virtual void prn_cut(uint8_t kindof) const { + Q_UNUSED(kindof); + } + // kindof: 1=full cut 2=partial cut 3=eject (5xLF + full cut) + + virtual void prn_newLine(uint8_t nrOfLines) const { + Q_UNUSED(nrOfLines); + } + + virtual void prn_printCompleteFontTable(void) const {} + + + virtual void prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) const { + Q_UNUSED(kindOf); + Q_UNUSED(withText); + Q_UNUSED(offset); + Q_UNUSED(rotation); + Q_UNUSED(dataLeng); + Q_UNUSED(data); + } + // kind of barcode: 0=Code39 1=Code128 2=EAN13 3= 2/5interleaved 4=UPC-A 5=EAN8 + // withText: print readable text below + // offset: move by pixel from left border + // rotation + // dataLeng in byte + + virtual void prn_sendQRdata(QByteArray *buf) const { + Q_UNUSED(buf); + } + // maximal 150 alphanummeric bytes + + virtual void prn_printQRcode(void) const {} + // QRcode may have 1...150 alphanummeric data, must be transfered in advance + + + virtual void prn_printLogo(uint8_t nrOfLogo, uint8_t offset ) const { + Q_UNUSED(nrOfLogo); + Q_UNUSED(offset); + } + // nrOfLogo: 1..4 in flash 5...8 in Ram + // offset: in mm form left border + + + // ......................................................... + // Parking Ticket (print-out document) designer TD - obsolete + // ......................................................... + + + + // ---------------------------------------------------------------------------------------------------------- + // --------------------------------------------- MDB Bus ---------------------------------------------------- + // ---------------------------------------------------------------------------------------------------------- + + virtual void mdb_sendBusReset(void) const {} + + virtual void mdb_sendCommand(uint8_t toMdbDevice, uint8_t mdbCommand) const { + Q_UNUSED(toMdbDevice); + Q_UNUSED(mdbCommand); + } + // send one bus command directly over mdb bus, refer to mdb manual for commands + // this command is not needed in normal operation, just for new or special things + + virtual void mdb_sendMessage(uint8_t toMdbDevice, uint8_t mdbCommand, uint8_t nrOfData, uint8_t *dataBuffer) const { + Q_UNUSED(toMdbDevice); + Q_UNUSED(mdbCommand); + Q_UNUSED(nrOfData); + Q_UNUSED(dataBuffer); + } + // nrOfData = sizeOf(dataBuffer) maximal 34 byte according mdb specs + // same as mdb_sendCommand, just with data + + virtual bool mdb_busIsReadyToWork() const { + return false; + } + + virtual bool mdb_deviceVoltageOK() const { + return false; + } + + virtual bool mdb_busVoltageOk() const { + return false; + } + + virtual uint8_t mdb_getLastDeviceResponse(uint8_t *fromDevice, uint8_t *lastRequest, + uint8_t *responseLength, uint8_t *responseBuffer) const { + Q_UNUSED(fromDevice); + Q_UNUSED(lastRequest); + Q_UNUSED(responseLength); + Q_UNUSED(responseBuffer); + return 0; + } + // fromDevice: device nr from which data was requested 0,1,2,3 + // lastRequest: sent mdb command + // responseLength: nr of payload data (after mdb-ack) 0...34 + // responseBuffer holds payload data (answer from mdb device) + // return val: mdb result of this request: 1=got ACK 2=got 3xNAK 3=no or bad response 4:got Data (after ACK) + + + // ---------------------------------------------------------------------------------------------------------- + // ---------------------------------- Electronic Coin Validator EMP ----------------------------------------- + // ---------------------------------------------------------------------------------------------------------- + + + virtual void emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const { + Q_UNUSED(coinAcceptance); + Q_UNUSED(tokenChannel); + Q_UNUSED(coinDenomination); + } + // coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation) + // tokenChannel 0...31: if this signal comes from emp then a token was inserted + // coinDenomination = array of 16 coin values (e.g. 5, 10, 20...) + + virtual void emp_pollingOnOff(uint8_t on) const { + Q_UNUSED(on); + } + + virtual void emp_startCoinAcceptance() const {} + + virtual void emp_stopCoinAcceptance() const {} + + virtual void emp_getAllParameters(struct T_emp *emp) const { + Q_UNUSED(emp); + } + // see struct in hwapi.h + // usage example: + // hwapi *HWaccess const override; + // HWaccess = new hwapi() const override; + // struct T_emp myEmp const override; + // HWaccess->emp_getAllParameters(&myEmp) const override; + // readval=myEmp.pollingRunning const override; + + virtual uint8_t emp_chkIfCoinInserted(void) const { + return 0; + } + // retval: 0...16 coins left in FIFO + + virtual void emp_getNewCoinRecord(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) const { + Q_UNUSED(value); + Q_UNUSED(signal); + Q_UNUSED(error); + Q_UNUSED(valid); + } + // with every call ONE coin is taken out of FIFO and pointer decremented + // valid: should be 1 + // signal: comes right from coin checker, 0...15 (0=first programmed coin type) 0xFF=no signal + // error: was reported from EMP as dynamic signal right after coin insertion (instead of + // coin signal), example: 3=unknown coin 4=coin is blocked by host. 0xFF=no error + // value: of the coin. Depends on parameter "coinDenomination" in function "emp_sendSettings" + // if coinDenomination[coin 0..15] = 0 then the value programmed in coin checker is taken + // if coinDenomination > 0 then this value is taken. + // Useful in case of two currencies (adapt to local currency) or for token. + + // function gives more details as "emp getLastCoin()" but "emp getLastCoin()" is easier to use + + // alternativ to emp_getNewCoinRecord( ): + virtual uint8_t emp_giveLastCoin(uint16_t *value, uint8_t *signal) const { + Q_UNUSED(value); + Q_UNUSED(signal); + return 0; + } + // retval: 0: NO coin stored 1: valid coin 2: got wrong coin or coin denied + // value: if retval1: value of the coin if reval=2: error number + // 0xFF means NO error or NO signal (as 0 is a valid error/signal) + // signal: channel nr reported from checker 0...15 + + + virtual uint8_t emp_returnLastCoin(uint16_t *value, uint8_t *signal) const { + Q_UNUSED(value); + Q_UNUSED(signal); + return 0; + } + // use for changer + + + + virtual QString dc_getTxt4RsDiagWin(void) const { + return QString(); + } + virtual void dc_clrTxt4RsDiagWin(void) const {} + virtual QString dc_get2ndTxt4RsDiagWin(void) const { + return QString(); + } + virtual void dc_clr2ndTxt4RsDiagWin(void) const {} + virtual QString dc_getTxt4HsStateLine(void) const { + return QString(); + } + virtual void dc_clrTxt4HsStateLine(void) const {} + virtual QString dc_getTxt4masterStateLine(void) const { + return QString(); + } + virtual void dc_clrTxt4masterStateLine(void) const {} + virtual QString dc_getTxt4resultStateLine(void) const { + return QString(); + } + virtual void dc_clrTxt4resultStateLine(void) const {} + virtual QString dc_getdataStateLine(void) const { + return QString(); + } + virtual void dc_clrTxt4dataStateLine(void) const {} + virtual QString dc_getdatifLine(void) const { + return QString(); + } + virtual void dc_clrTxt4datifLine(void) const {} + + + +// ---------------------------------------------------------------------------------------------------------- +// -------- DC Bootloader 1.Version +// ---------------------------------------------------------------------------------------------------------- + + // using DC2 Bootloader + virtual void bl_iniChain() const {} + virtual bool bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const { + Q_UNUSED(readBinFile); + Q_UNUSED(fileSize); + Q_UNUSED(withDispl); + return false; + } + virtual uint8_t bl_activatBootloader(uint8_t *sendData) const { + Q_UNUSED(sendData); + return 0; + } + virtual uint8_t bl_startChain() const { + return 0; + } + virtual uint8_t bl_readBLversion(uint8_t *sendData) const { + Q_UNUSED(sendData); + return 0; + } + // minimum size of sendData-buffer: 5byte retval: length + virtual uint8_t bl_readFWversion(uint8_t *sendData) const { + Q_UNUSED(sendData); + return 0; + } + // minimum size of sendData-buffer: 5byte retval: length + + virtual uint8_t bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const { + Q_UNUSED(Cmd); + Q_UNUSED(SendDataLength); + Q_UNUSED(sendData); + Q_UNUSED(outBuf); + return 0; + } + // make BL protocol, retval = outbuf length (5...133) + // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum + // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 + // Data length = 0...64 + // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 + // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 + + virtual uint8_t bl_exitBL(uint8_t *sendData) const { + Q_UNUSED(sendData); + return 0; + } + // minimum size of sendData-buffer: 5byte retval: length + + virtual void led_switchLedIllumination(uint8_t on) const { + Q_UNUSED(on); + } + + + + +// ------------------------------------------------------------------------------------ +// 27.3.2023: Use Device-Controller's Bootloader to send hex-file +// ------------------------------------------------------------------------------------ + + virtual void bl_rebootDC(void) const {} + + virtual void bl_startBL() const {} + virtual void bl_checkBL() const {} + virtual bool bl_isUp() const { + return false; + } + // return true is bl is up and running + // also initializes "sendFile" + + virtual void bl_sendAddress(uint16_t blockNumber) const { + Q_UNUSED(blockNumber); + } + // send start address, nr of 64byte-block, start with 0 + // will be sent only for folling block-numbers: + // 0, 1024, 2048, 3072 and 4096, so basically every 64kByte + + virtual uint8_t bl_wasSendingAddOK() const { + return 0; + } + // return val: 0: no response by now 1:error 10: OK + + virtual void bl_openBinary() const {} + + virtual void bl_sendDataBlock(uint8_t length, uint8_t *buffer) const { + Q_UNUSED(length); + Q_UNUSED(buffer); + } + // send 64 byte from bin file + + virtual void bl_sendLastBlock() const {} + + virtual uint8_t bl_wasSendingDataOK() const { + return false; + } + // return val: 0: no response by now 1:error 10: OK + + virtual void bl_stopBL() const {} + + +// ------------------------------------------------------------------------------------ +// 6.4.2023: new functions for coin collection and printing +// some new system functions +// ------------------------------------------------------------------------------------ + + + virtual bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const { + Q_UNUSED(DateTime); + return false; + } + // return true if successful. could fail if more the 8 commands are waiting + + virtual bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const { + Q_UNUSED(leng); + Q_UNUSED(data); + return false; + } + + virtual bool rtc_getExtendedTime(struct T_extTime *exTime) const { + Q_UNUSED(exTime); + return false; + } + + virtual bool sys_runCompleteTest() const { + return false; + } + // warning: lasts 20s in one pace + + virtual bool sys_ready4sending() const { + return false; + } + // return true if a Json-file can be sent + + virtual bool sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8_t *content ) const { + Q_UNUSED(kindOfFile); + Q_UNUSED(nrOfTemplate); + Q_UNUSED(content); + return false; + } + // kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer + // nrOfTemplate=1...32 if kindOfFile==6 + // content = content of the Json file, max 800byte ascii signs + // file is 0-terminated! + // return false if sending is not possible, wait a second + + virtual bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const { + Q_UNUSED(dynPrnVal); + return false; + } + // dynPrnVal = array of 8 Variables with 8 byte each, come as ascii string + // like: char prn_dynPrnVal[8][8]; + // return true if sending, false if cmd-stack is full + + virtual bool prn_printTemplate(uint8_t nrOftemplate) const { + Q_UNUSED(nrOftemplate); + return false; + } + // print one of the templates loaded by Json prior + // nr = 1..32 + // return true if sending, false if cmd-stack is full + + virtual void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const { + Q_UNUSED(nrOfVals); + Q_UNUSED(accNr); + } + // returns all acc nrs of the backuped vault records + // use: uint16_t backupedAccNumbers[8] + + virtual bool log_selectVaultRecord(uint16_t accountNr ) const { + Q_UNUSED(accountNr); + return false; + } + // return true if sending, false if cmd-stack is full + // and trigger transfer + + virtual bool log_chkIfVaultRecordAvailable() const { + return false; + } + // return true if completly received + + virtual bool log_getVaultRecord(struct T_vaultRecord *retVR) const =0; + // which was selected by: log_selectVaultRecord() + // to be forwarded to Ismas + + virtual bool prn_printAccountReceipt() const { + return false; + } + // print all 8 backuped accounting receipts + // return true if sending to DC OK, false if cmd-stack is full + + virtual bool prn_printTestTicket() const { + return false; + } + // return true if sending to DC OK, false if cmd-stack is full + + + virtual bool cash_startPayment(uint32_t amount) const { + Q_UNUSED(amount); + return false; + } + // 17.4.23TS: extended to 32bit + + virtual uint8_t cash_paymentProcessing() const { + return 0; + } + // run this function periodically while coin payment process to generate necessary signals + // return value: + // 0: stopped 1: starting up 2: coin collection + // 3: finished by User (Push button) 4: finished, Max-Value collected + // 5: finished by escrow + // 10,11: error cannot start + // 12: timeout while payment, coins returned + // 13: stopped by unexpected error + + virtual uint32_t getInsertedAmount() const { + return 0; + } + + virtual uint16_t getLastInsertedCoin(void) const { + return 0; + } + + virtual bool getAllInsertedCoins(uint16_t *types, uint16_t *values) const { + Q_UNUSED(types); + Q_UNUSED(values); + return false; + } + // alle bei diesem Verkauf eingeworfenen Muenzen sind gespeichert, max 64 + + + virtual bool cash_cancelPayment() const { + return false; + } + // and return coins + + virtual bool cash_stopPayment() const { + return false; + } + // and keep coins in escrow + + + // after ticket/goods issue: + virtual bool vend_success() const { + return false; + } + // conclude payment process, encash all inserted coins to vault. Printing was successful + // if possible return change + + virtual bool vend_failed() const { + return false; + } + // conclude payment process and return all inserted coins + + + + + + virtual uint8_t mif_getCardType(QString *cardholder) const { + Q_UNUSED(cardholder); + return 0; + } + // return 1,2,3,4 = upper, lower access card, printer test, coin test + // cardholder: 7byte Name-String + + virtual uint64_t sys_getWakeSource() const { + return 0; + } + // retval: 6 bytes, bit coded, 1=event keeps DC awake + + virtual uint8_t sys_getWakeReason() const { + return 0; + } + // Master was woken by following reason: + // 1: MDB Event + // 2: Coin Event + // ( 3: Master Event) - will not set the wake line + // ( 4: 32s pulse) - will not set the wake line + // 5: Door Event + // ( 6: Diag Event) - will not set the wake line + // 7: 30min-Pulse for HB + + virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const { + Q_UNUSED(leng); + Q_UNUSED(data); + } + + virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const { + Q_UNUSED(devCond); + } + + virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const { + Q_UNUSED(leng); + Q_UNUSED(data); + } + + virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const { + Q_UNUSED(dynMachCond); + } + + + virtual uint32_t cash_getAmountInVault() const { + return 0; + } + + virtual uint16_t cash_getNrCoinsInVault() const { + return 0; + } + + virtual uint8_t prn_getPrintResult() const { + return 0; + } + // return: 0: just printing, wait + // 1: OK - last print was succesful + // 2: error - not printed + + + + virtual uint8_t prn_getCurrentPrinterState() const { + return 0; + } + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + + + virtual void sys_sendDeviceParameter(struct T_devices *deviceSettings) const { + Q_UNUSED(deviceSettings); + } + + virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const { + Q_UNUSED(deviceSettings); + } + // attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before + // cannot be used to see settings programmed by JsonFile + + virtual bool sys_areDCdataValid() const { + return false; + } + + virtual bool sys_sendingTest() const { + return false; + } + + virtual void prn_requestCurrentDynData() const {} + + virtual bool prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const { + Q_UNUSED(dynPrnVal); + return false; + } + // which was sent with: bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const =0; + + virtual bool prn_dynDataAreEqual(uint8_t *buf) const { + Q_UNUSED(buf); + return false; + } + + virtual bool prn_printKombiticket(uint8_t nrOfKombi) const { + Q_UNUSED(nrOfKombi); + return false; + } + // print four of the templates loaded by Json prior + // nr = 1..8 + + virtual void lock_triggerUpperSolenoid(void) const {} + + virtual void lock_triggerLowerSolenoid(void) const {} + + virtual bool doors_supervise() const { + return false; + } + + virtual bool dc_isAutoRequestOn() const { + return false; + } + + virtual uint16_t log_getLatestAccountNumber() const { + return 0; + } + // new function 27.6.2023 + // latest = highest of the backup's + + virtual uint8_t log_getAvailableVaultBlocks() const { + return 0; + } + // return 0x0011 1111 if all 6 blocks are loaded (one bit per block) + + virtual uint8_t log_getAnswerToLastSlaveRequest() const { + return 0; + } + // use only for ONE request/command + // return: 0xFF: result unknown by now as sending is ongoing + // 0=OK + // 1= wrong length 2=wrong start sign 5= wrong crc + // 6= slave: master cmd was wrong 7: slave: could not write/read data + // 8=timeout, got no response from slave + // 0,8 work, 1..6 not yet tested. 8 comes immed. and stays 8 until reconnect + + // use for important and extended commands (print several templates, print ticket...) + virtual void log_startSupervision() const {} + + virtual uint8_t log_getAnswerToLastCmdBatch() const { + return 0; + } + // 0xFF: no command sent by now + // 0: started, in progress + // 1: done and OK + // 2: done and error + // not working properly, always 0 + + virtual bool log_getVaultData(uint8_t *data) const { + Q_UNUSED(data); + return false; + } + // get vault record in linear 8bit buffer with 384 byte + + + + // new from 1.8.23 + virtual bool prn_printOneAccountReceipt(uint16_t accountNr) const { + Q_UNUSED(accountNr); + return false; + } + // print one out of eight stored last accounting receipts + // function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts + + virtual bool prn_printAllAvailAccountReceipts() const { + return false; + } + // same as: prn_printAccountReceipt() from line 1153 + // return true if sending to DC OK, false if cmd-stack is full + + virtual bool log_verifyVaultRecordByCrc() const { + return false; + } + // return true if CRC16 is correct, data are 100% OK. Security level 1:65536 + // verification is strongly recommended before further processing + // in case of "false"-result please reload from DC + + + virtual uint16_t log_DC_getNextAccountNumber() const { + return 0; + } + // the current cash box content will be backuped with this number on next cashbox-change + + virtual void log_DC_setNextAccountNumber(uint16_t newAccountingNumber) const { + Q_UNUSED(newAccountingNumber); + } + // the current cash box content will be backuped with this number on next cashbox-change + // use only in case of hardware replacements or errors which derailed the number + + virtual void log_DC_deleteAllVaultrecordsInDc() const {} + // use only in case of hardware replacements or errors which derailed the number + + virtual void log_DC_deleteAllTotalCounters() const {} + // use only in case of hardware replacements or errors which derailed the number + + virtual void dc_setNewCustomerNumber(uint16_t newCustNr) const { + Q_UNUSED(newCustNr); + } + + virtual void dc_setNewMachineNumber(uint16_t newMachNr) const { + Q_UNUSED(newMachNr); + } + + virtual void dc_setNewBorough(uint16_t newBorough) const { + Q_UNUSED(newBorough); + } + + virtual void dc_setNewZone(uint16_t newZone) const { + Q_UNUSED(newZone); + } + + + + // new functions from 8.9.23 + virtual QString mif_getReaderType() const { + return QString(); + } + // return "SL025" if correct reader is connected + + virtual void mif_getCardSize(uint8_t *cardSize, uint8_t *idLeng) const { + Q_UNUSED(cardSize); + Q_UNUSED(idLeng); + } + // cardSize=1k or 4kByte + // idLeng =4Byte or 7 byte + + virtual char mif_getAtbCardData(uint8_t *buf, uint8_t maxBuffSiz) const { + Q_UNUSED(buf); + Q_UNUSED(maxBuffSiz); + return 0; + } + // return complete buffer binary, just for test purpose + + virtual bool mif_isValidAtbCard() const { + return false; + } + + virtual uint32_t mif_getAtbCardCuNu() const { + return 0; + } + + virtual uint8_t mif_getAtbCardTyp() const { + return 0; + } + // return 1=upper door card 1=lower door 3=printer-test 4=coin-test + // 0: not a valid atb2020 card + + virtual QString mif_getAtbCardPerso() const { + return QString(); + } + // e.g. "PNsax001" used for personal number, name shortcode, card number + // free to use, can be set in AtbMcw23.exe tool + + virtual void mif_getAtbCardExpire(uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *minute) const { + Q_UNUSED(year); + Q_UNUSED(month); + Q_UNUSED(day); + Q_UNUSED(hour); + Q_UNUSED(minute); + } + + + // ------------------------------------------------------------------------------------ + // Device-Controller-Bootloader convenient version 21.09.2023 + // ------------------------------------------------------------------------------------ + + // use this to jump to BL: + //void hwapi::bl_rebootDC(void) const + + // use this to start BL: + // void hwapi::bl_startBL(void) const + + // call this in order to get response from BL: + //void hwapi::bl_checkBL(void) const + + // evaluate BL response: + //bool hwapi::bl_isUp(void) const + + // 29.9.23: new: "completeStart" function, replaces bl_rebootDC(), bl_startBL() and bl_checkBL() + // result can be verified with bl_isUp() as before + virtual bool bl_completeStart() const { + return false; + } + // must be used in DC's normal operation + + // select binfile-name in GUI + + // send binfile-name to BL-processor: + virtual bool bl_storeFirmware(QString fileName) const { + Q_UNUSED(fileName); + return false; + } + // load binary file 3x and compare + // return true if loaded correctly + // return false: error, could not load correctly + + // request the number of blocks for this file + virtual uint16_t bl_getNrOfFirmwareBlocks() const { + return 0; + } + // size of the loaded bin file in 64byte blocks + // call after bl_storeFirmware() + + // call the next two function's repetitive with "blockNumber"=0,1,2,3....."bl_getNrOfFirmwareBlocks()" + + virtual bool bl_blockAutoLoad(uint16_t blockNumber) const { + Q_UNUSED(blockNumber); + return false; + } + // call in loop from block number 0 up to <= "dcBL_getNrOfBlocks()" + //the last block "bl_getNrOfFirmwareBlocks()" is sent as conclusion command (important!) + // but after every call WAIT (!) for response "bl_blockAutoResponse()" !!!! + // data will be sent to DC, if neccesary addr will be sent additionally + // if neccesary sending will automatically repeat up to 3times + // retval: false if blockNumber>4095, true else + + // check out this response after every block-sending, wait until >0!!! + virtual int8_t bl_blockAutoResponse() const { + return 0; + } + // after every "bl_blockAutoLoad()" call this until response + // retval 0: wait 1: OK, blk was sent 2: OK, transfer complete + // 3: error despite repeating, cancel. probably bin file corrupted + // Max duration: 3x no response from BL = 900ms + + + // finally call: + // void hwapi::bl_stopBL(void) const + // -------------- end of bootloader --------------------------------------------------- + + + + // new from 28.9.23 and earliest from DC version 4.45 + // get all versions of the DC-Jsons + virtual void sys_requestJsonVersions(uint8_t jsonNr) const { + Q_UNUSED(jsonNr); + } + // send one request for every single version + // jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res. + // 5=printer template 1 ..... 36= template 32 + + virtual void sys_getJsonVersions(uint8_t jsonNr, char *versionString) const { + Q_UNUSED(jsonNr); + Q_UNUSED(versionString); + } + // jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res. + // 5=printer template 1 ..... 36= template 32 + // length of buffer is always 16 byte + + // ------------------------------------------------------------------------------------ + // Coin Changer + // ------------------------------------------------------------------------------------ + + // find above (same as for coin checker (EMP)): + + // mdb_switchPower(true); // power on/off + // cash_startPayment(amount_cent); // start polling, enable coins, changer turns to green + + // getInsertedAmount() + // getLastInsertedCoin() + // getAllInsertedCoins(uint16_t *types, uint16_t *values) + // all inserted coins of this past transaction are stored, max 64 + + // cash_stopPayment(); // and wait for further command (changer blinks yellow) + // cash_cancelPayment(); // and return complete paid amount + + // after ticket/goods issue: + // vend_success() + // conclude payment process, keep all coins. Printing was successful + // return change (payment above start-amount), so it works only if + // Payment was started with real vending price (pre selection). + // if payment was started with maximum price (for direct coin insertion) + // then use "changer_returnCoins()", not vend_success() + + // vend_failed() + // conclude payment process and return complete paid amount + + // also valid for changer: + // emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const =0; + // coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation) + // tokenChannel 0...31: if this signal comes from emp then a token was inserted + // coinDenomination = array of 16 coin values (e.g. 5, 10, 20...) + + virtual void changer_returnCoins(uint32_t amountInCent) const { + Q_UNUSED(amountInCent); + } + + virtual void changer_requestChangeResult() const {} + + virtual uint8_t changer_getChangeResult(uint32_t *returnedAmount) const { + Q_UNUSED(returnedAmount); + return 0; + } + // get result of coin dispensing + // receivedData[0]: 0: not yet started 1:amount returned + // 2:only partial return 3: no return possible + // receivedData[2,3,4,5]: returned amount + + virtual void changer_getAllParameters(struct T_changer *mw) const { + Q_UNUSED(mw); + } + // requested automatically with 23, same like EMP + + virtual void changer_requestTubelevel(void) const {} + + virtual void changer_getTubelevel(struct T_chg_Tub *tubLevel) const { + Q_UNUSED(tubLevel); + } + // don't use tubeDispens[], it's not yet correct! + + + + // ------------------------------------------------------------------------------------ + // bank note acceptor + // ------------------------------------------------------------------------------------ + + // already defiened functions applying for BNA as well: + // mdb_switchPower(true); // power on/off + + // bank notes are integrated in the normal transaction process, so use the usual functions to run a vending cycle: + // cash_startPayment(amount_cent); // start polling, enable bills, reader shows green + // getInsertedAmount() + // cash_stopPayment(); + // cash_cancelPayment(); + // vend_success() + // vend_failed() + + virtual void bna_sendSettings(uint16_t notesToAccept, uint16_t parameters, + uint16_t *billDenomination, + uint32_t acceptanceLimit) const { + Q_UNUSED(notesToAccept); + Q_UNUSED(parameters); + Q_UNUSED(billDenomination); + Q_UNUSED(acceptanceLimit); + + } + // notesToAccept: bit0=bill1 (lowest donomination) bitH=accept bit L = deny + // parameters: e.g. use escrow function for some notes + // billDenomination = array of 16 bill values (e.g. 5, 10, 20...) + // these can be set alternatively by Json-File DC2C_cash.json + // acceptanceLimit: device will stop acceptance once this amount is reached and + // optionally keep last bill in escrow until vend_success() + // is called (put bill to stacker) or vend_failed() is called (return bill) + + virtual void bna_setCurrentAcceptance(uint16_t notesToAccept) const { + Q_UNUSED(notesToAccept); + } + // can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid) + // only valid till next start-payment. Cannot add notes which are not activated in Json + + virtual void bna_requestParameters() const {} + // send command to DC in order to get static invariable device parameters like currency + // device must be powered and polled to get these + + virtual bool bna_getAllParameters(struct T_bna *bna) const { + Q_UNUSED(bna); + return false; + } + // get all constant data from reader (e.g. currency) + // and actual Host-Settings (sent with bna_sendSettings() or json) + // retval = true if data are valid + + virtual void bna_requestCurrentNotes() const {} + // send command to DC in order to get transaction data + + virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const + { + Q_UNUSED(latestBill); + Q_UNUSED(currentNotes); + return 0; + } + // returns number of collected bank notes since start-command (current transaction) + // return value: numbers of bills or 99 in case of error + // 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 uint16_t bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOfBills) const { + Q_UNUSED(amountInStacker); + Q_UNUSED(countOfBills); + return 0; + } + // return val: nr of bills in stacker + // countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker + // countOfBills[1] for 10€ and so on + + + // download device controller + virtual bool dcDownloadRequest(QString const &fileToDownload) const { + Q_UNUSED(fileToDownload); + return false; + } + virtual bool dcDownloadRequested() const { return false; } + virtual bool dcDownloadResetRequest() const { return false; } + virtual bool dcDownloadRequestAck() const { return false; } + virtual bool dcDownloadRunning() const { return false; } + virtual bool dcDownloadFinished() { return false; } + + virtual bool dcDownloadReportStart() const { return false; } + virtual bool dcDownloadReportRunning() const { return true; } + virtual bool dcDownloadReportFinished() { return true; } + + virtual bool dcDownloadThreadStart() { return false; } + virtual bool dcDownloadThreadRunning() const { return true; } + virtual void dcDownloadThreadFinalize(DownloadThread *) {} + virtual bool dcDownloadThreadFinished() const { return true; } + virtual bool dcDownloadReportThreadStart() { return false; } + virtual bool dcDownloadReportThreadRunning() const { return true; } + virtual void dcDownloadReportThreadFinalize() {} + virtual void dcDownloadReportThreadQuit() {} + virtual bool dcDownloadReportThreadFinished() const { return true; } + + + virtual QString dcDownloadFileName() const { return ""; } + virtual bool dcDownloadSetRequested(bool requested) { + Q_UNUSED(requested); return false; + } + virtual bool dcDownloadSetRunning(bool running) { + Q_UNUSED(running); return false; + } + virtual bool dcDownloadSetFinished(bool finished) { + Q_UNUSED(finished); return false; + } + virtual void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) { + Q_UNUSED(totalBlockNumber); + } + virtual void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) { + Q_UNUSED(currentBlockNumber); + } + virtual bool dcDownloadGetRequested() const { return false; } + virtual bool dcDownloadGetRunning() const { return false; } + virtual bool dcDownloadGetFinished() const { return false; } + virtual uint16_t dcDownloadGetTotalBlockNumber() const { return 0; } + virtual uint16_t dcDownloadGetCurrentBlockNumber() const { return 0; } + + virtual QObject const *getAPI() { return nullptr; } + + +signals: + /* + 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. + /* GH Version, bringt Fehler + void hwapi_templatePrintFinished_OK() const; + void hwapi_templatePrintFinished_Err() const; + + void hwapi_coinCollectionJustStarted() const; + void hwapi_coinCollectionAborted() const; + + void hwapi_gotNewCoin() const; + void hwapi_payStopByMax() const; + void hwapi_payStopByPushbutton() const; + + void hwapi_payStopByEscrow() const; + void hwapi_payStopByError() const; + void hwapi_payStopByTimeout() const; + void hwapi_payCancelled() const; + void hwapi_coinProcessJustStopped() const; + + void hwapi_doorServiceDoorOpened() const; + void hwapi_doorVaultDoorOpened() const; + void hwapi_doorCoinBoxRemoved() const; + void hwapi_doorCoinBoxInserted() const; + void hwapi_doorCBinAndAllDoorsClosed() const; + void hwapi_doorAllDoorsClosed() const; + */ +}; + + +// History +// 11.10.2021: V1.0 222 functions +// 23.12.2021: V1.1 added block-parameter to function "read mifare data" +// 30.12.2021: V1.2 added function: mif_clearDataBuffer(), mif_isBlockAvailable(uint8_t blkNr) and mif_getAvailableDataBlocks() +// 1.1.2022: V1.3 Mifare extended. ( background: read 16 x 48byte from card to DC, read 12 x 64byte from DC to CA) +// new: read full card with 768bytes from HWapi without block borders +// added: mif_getNrOfAvailableDataBytes mif_getCardData768byteDec(uint8_t *buf, uint16_t bufferSize) +// mif_getCardDataDec(uint16_t fromAddr, uint16_t toAddr, uint8_t *buf, uint16_t bufferSize) +// mif_getCardDataStr(bool useHexFormat, char seperator) + +// 29.03.2023: V3.1 some extensions for PSA1256_ptu5, +// V3.2 Bootloader improvement +// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging +// 14.04.2023: V3.4 new features extended: sys_getDynMachineConditions, sys_getDeviceConditions and +// rtc_getExtendedTime return struct in addition. New function to select and get VaultRecord +// +// 19.04.2023: V3.5 new function: sys_getWakeReason(); +// 17.05.2023: V3.6 new function: cash_isCollectionActive(), cash_isPayProcessActive() +// new signals: hwapi_coinCollectionJustStopped, hwapi_coinCollectionJustStarted +// getAllInsertedCoins() fixed, also in datif and storeINdata + +// 15.06.2023 V4.2 bring into same order as hwapi in order to set the THIS_IS_CA_MASTER correct +// 19.06.2023 V4.3 added some qCriticals to see emits + +// 01.08.2023 V4.4 some new values at the end of struct T_vaultRecord +// two more values in struct T_devices +// 7 new functions at the end of the file + + +//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.1" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.4" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.5" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.6" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.0" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.1" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.2" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.3" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.4" + // 8.9.2023 two new functions (end of file) for mifare test +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.5" + // 18.9.2023 major improvements for DC data exchange + // verification of door and cash box signals + // intensive verification of Json-Programming Master-Slave (PTU to DC), 100% ok +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.6" + // 20.9.2023: speeding up door and cash box signals +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.7" + // 26.09.2023: added improved DC-bootloader files +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.8" +// 28.09.2023: added version request of DC-Json-Files +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.0" + // 10.10.2023: added coin changer + +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.1" +// 20.10.2023: added bill validator + +// hier dazwischen: Umstellung ALLER Prototypen +// hier von =0 auf {} durch Gerhard + +#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.2" + // 7.11.2023: bna functions activated + + +Q_DECLARE_INTERFACE(hwinf, HWINF_iid) + + +#endif + + + diff --git a/DownloadDCJsonFiles/process/command.cpp b/DownloadDCJsonFiles/process/command.cpp new file mode 100644 index 0000000..c85c8ac --- /dev/null +++ b/DownloadDCJsonFiles/process/command.cpp @@ -0,0 +1,124 @@ +#include "command.h" + +#include +#include +#include +#include +#include + +Command::Command(QString const &command, int start_timeout, int finish_timeout) + : m_command(command.trimmed()) + , m_commandResult("") + , m_waitForStartTimeout(start_timeout) + , m_waitForFinishTimeout(finish_timeout) + , m_exitCode(-1) { +} + +QString Command::getCommandResult() const { + return m_commandResult; +} + +void Command::readyReadStandardOutput() { + QProcess *p = (QProcess *)sender(); + m_commandResult += p->readAllStandardOutput(); + // qCritical() << m_commandResult; +} + +void Command::readyReadStandardError() { + QProcess *p = (QProcess *)sender(); + QByteArray buf = p->readAllStandardError(); + qCritical() << buf; +} + +void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) { + QProcess *p = (QProcess *)sender(); + // read all remaining data sent to the process, just in case + QString d = p->readAllStandardOutput(); + if (!d.isEmpty()) { + m_commandResult += d; + } + disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardOutput())); + disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError())); +} + +bool Command::execute(QString workingDirectory, QStringList args) { + + if (!QDir::setCurrent(workingDirectory)) { + qCritical() << "SET WORKING_DIRECTORY" << workingDirectory + << "FAILED FOR" << m_command; + return false; + } + + QScopedPointer p(new QProcess(this)); + p->setWorkingDirectory(workingDirectory); + p->setProcessChannelMode(QProcess::MergedChannels); + + connect(&(*p), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput())); + connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError())); + + if (!args.isEmpty()) { + qDebug() << "START COMMAND" << m_command << "WITH ARGS" << args + << "IN" << p->workingDirectory(); + p->start(m_command, args); + } else { + qDebug() << "START COMMAND" << m_command + << "IN" << p->workingDirectory(); + p->start(m_command); + } + + qint64 const start = QDateTime::currentDateTime().toMSecsSinceEpoch(); + + if (p->waitForStarted(m_waitForStartTimeout)) { + qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory(); + if (p->state() == QProcess::ProcessState::Running) { + qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory(); + // wait forever for git/opkg-commands to finish + int wait = m_waitForFinishTimeout; + if (m_command.trimmed().startsWith("git", Qt::CaseInsensitive) || + m_command.trimmed().startsWith("opkg", Qt::CaseInsensitive)) { + wait = -1; + } + bool const no_timeout = p->waitForFinished(wait); + if (no_timeout) { + qDebug() << "PROCESS" << m_command << "FINISHED IN" << p->workingDirectory(); + if (p->exitStatus() == QProcess::NormalExit) { + if ((m_exitCode = p->exitCode()) == 0) { + qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch(); + qDebug() << "EXECUTED" << m_command + << QString("(runtime %1ms)").arg(end-start) + << "with code" << m_exitCode + << "IN" << p->workingDirectory(); + return true; + } else { + qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch(); + qCritical() << "EXECUTED" << m_command + << QString("(runtime %1ms)").arg(end-start) + << "with code" << m_exitCode + << "IN" << p->workingDirectory(); + } + } else { + qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch(); + qCritical() << "PROCESS" << m_command << "CRASHED with code" + << p->exitCode() + << QString("(after %1ms)").arg(end-start) + << "IN" << p->workingDirectory(); + } + } else { + qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch(); + qCritical() << "PROCESS" << m_command + << "DID NOT FINISH WITH" << wait + << "MS IN" << p->workingDirectory() + << QString("(runtime %1ms)").arg(end-start); + } + } else { + qCritical() << "WRONG PROCESS STATE" << p->state() + << "IN" << p->workingDirectory(); + } + } else { + qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch(); + qCritical() << "PROCESS" << m_command << "TIMEOUT AT START" + << QString("(runtime %1ms)").arg(end-start) + << "IN" << p->workingDirectory(); + } + return false; +} diff --git a/DownloadDCJsonFiles/process/command.h b/DownloadDCJsonFiles/process/command.h new file mode 100644 index 0000000..372e293 --- /dev/null +++ b/DownloadDCJsonFiles/process/command.h @@ -0,0 +1,36 @@ +#ifndef COMMAND_H_INCLUDED +#define COMMAND_H_INCLUDED + +#include +#include +#include +#include +#include + + +class Command : public QObject { + Q_OBJECT + + QString m_command; + QString m_commandResult; + int m_waitForStartTimeout; + int m_waitForFinishTimeout; + int m_exitCode; +public: + explicit Command(QString const &command, + int start_timeout = 100000, + int finish_timeout = 100000); + + QString getCommandResult() const; + QString command() const { return m_command; } + + bool execute(QString workingDirectory, QStringList args = QStringList()); + int exitCode() const { return m_exitCode; } + +private slots: + void readyReadStandardOutput(); + void readyReadStandardError(); + void finished(int exitCode, QProcess::ExitStatus exitStatus); +}; + +#endif // COMMAND_H_INCLUDED