Compare commits
1 Commits
master
...
changes-fo
Author | SHA1 | Date | |
---|---|---|---|
fb75074955 |
42
.gitignore
vendored
42
.gitignore
vendored
@ -1,41 +1 @@
|
|||||||
# C++ objects and libs
|
*.user
|
||||||
|
|
||||||
*.slo
|
|
||||||
*.lo
|
|
||||||
*.o
|
|
||||||
*.a
|
|
||||||
*.la
|
|
||||||
*.lai
|
|
||||||
*.so
|
|
||||||
*.dll
|
|
||||||
*.dylib
|
|
||||||
|
|
||||||
# Qt-es
|
|
||||||
|
|
||||||
*.pro.user
|
|
||||||
*.pro.user.*
|
|
||||||
moc_*.cpp
|
|
||||||
qrc_*.cpp
|
|
||||||
Makefile
|
|
||||||
Makefile.*
|
|
||||||
*-build-*
|
|
||||||
|
|
||||||
#
|
|
||||||
*.autosave
|
|
||||||
ui_*.h
|
|
||||||
version.h
|
|
||||||
version.txt
|
|
||||||
|
|
||||||
packages/*
|
|
||||||
*.pro.orig
|
|
||||||
Output/setup.exe
|
|
||||||
.directory
|
|
||||||
|
|
||||||
*~
|
|
||||||
resources/icons/*.png
|
|
||||||
resources/icons/*.jpg
|
|
||||||
resources/icons/*.gif
|
|
||||||
resources/style/*.qss
|
|
||||||
text/*.html
|
|
||||||
!text/*_template.html
|
|
||||||
text/*.xml
|
|
||||||
|
11
DCPlugin.pri
11
DCPlugin.pri
@ -2,7 +2,6 @@ INCLUDEPATH += $${PWD}/include
|
|||||||
DEPENDPATH += $${PWD}
|
DEPENDPATH += $${PWD}
|
||||||
|
|
||||||
HEADERS += $${PWD}/include/com.h \
|
HEADERS += $${PWD}/include/com.h \
|
||||||
$$PWD/include/datei.h \
|
|
||||||
$${PWD}/include/controlBus.h \
|
$${PWD}/include/controlBus.h \
|
||||||
$${PWD}/include/datIf.h \
|
$${PWD}/include/datIf.h \
|
||||||
$${PWD}/include/dcBL.h \
|
$${PWD}/include/dcBL.h \
|
||||||
@ -12,11 +11,11 @@ HEADERS += $${PWD}/include/com.h \
|
|||||||
$${PWD}/include/sendWRcmd.h \
|
$${PWD}/include/sendWRcmd.h \
|
||||||
$${PWD}/include/storeINdata.h \
|
$${PWD}/include/storeINdata.h \
|
||||||
$${PWD}/include/tslib.h \
|
$${PWD}/include/tslib.h \
|
||||||
$${PWD}/include/shared_mem_buffer.h
|
$${PWD}/include/shared_mem_buffer.h \
|
||||||
|
$${PWD}/include/serial_port_thread.h \
|
||||||
|
$${PWD}/include/serial_port_worker.h
|
||||||
|
|
||||||
SOURCES += $${PWD}/src/com.cpp \
|
SOURCES += $${PWD}/src/com.cpp \
|
||||||
$$PWD/src/datei.cpp \
|
|
||||||
$$PWD/src/main.cpp \
|
|
||||||
$${PWD}/src/controlBus.cpp \
|
$${PWD}/src/controlBus.cpp \
|
||||||
$${PWD}/src/datIf.cpp \
|
$${PWD}/src/datIf.cpp \
|
||||||
$${PWD}/src/dcBL.cpp \
|
$${PWD}/src/dcBL.cpp \
|
||||||
@ -25,4 +24,6 @@ SOURCES += $${PWD}/src/com.cpp \
|
|||||||
$${PWD}/src/sendWRcmd.cpp \
|
$${PWD}/src/sendWRcmd.cpp \
|
||||||
$${PWD}/src/storeINdata.cpp \
|
$${PWD}/src/storeINdata.cpp \
|
||||||
$${PWD}/src/tslib.cpp \
|
$${PWD}/src/tslib.cpp \
|
||||||
$${PWD}/src/shared_mem_buffer.cpp
|
$${PWD}/src/shared_mem_buffer.cpp \
|
||||||
|
$${PWD}/src/serial_port_thread.cpp \
|
||||||
|
$${PWD}/src/serial_port_worker.cpp
|
||||||
|
32
DCPlugin.pro
32
DCPlugin.pro
@ -15,9 +15,9 @@ QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
|||||||
ARCH = PTU5
|
ARCH = PTU5
|
||||||
|
|
||||||
contains( CONFIG, DesktopLinux ) {
|
contains( CONFIG, DesktopLinux ) {
|
||||||
# QMAKE_CC = ccache $$QMAKE_CC
|
QMAKE_CC = ccache $$QMAKE_CC
|
||||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
QMAKE_CXX = ccache $$QMAKE_CXX
|
||||||
QMAKE_CXXFLAGS += -std=c++17
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
|
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
|
||||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||||
ARCH = DesktopLinux
|
ARCH = DesktopLinux
|
||||||
@ -27,7 +27,7 @@ contains( CONFIG, DesktopLinux ) {
|
|||||||
contains( CONFIG, PTU5 ) {
|
contains( CONFIG, PTU5 ) {
|
||||||
# QMAKE_CC = ccache $$QMAKE_CC
|
# QMAKE_CC = ccache $$QMAKE_CC
|
||||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||||
QMAKE_CXXFLAGS += -std=c++17
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
ARCH = PTU5
|
ARCH = PTU5
|
||||||
@ -38,8 +38,6 @@ contains( CONFIG, PTU5 ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contains( CONFIG, PTU5_YOCTO ) {
|
contains( CONFIG, PTU5_YOCTO ) {
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
|
||||||
PTU5BASEPATH = /opt/devel/ptu5
|
|
||||||
ARCH = PTU5
|
ARCH = PTU5
|
||||||
|
|
||||||
# add qmqtt lib
|
# add qmqtt lib
|
||||||
@ -47,9 +45,7 @@ contains( CONFIG, PTU5_YOCTO ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TARGET = CashAgentLib
|
TARGET = CashAgentLib
|
||||||
#DESTDIR = ../plugins
|
DESTDIR = ../plugins
|
||||||
INTERFACE = DeviceController
|
|
||||||
INTERFACE_DEFINITION = $${PWD}/include/ATBAPP/DeviceControllerInterface.h
|
|
||||||
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
# The following define makes your compiler emit warnings if you use
|
||||||
@ -70,21 +66,3 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
#!isEmpty(target.path): INSTALLS += target
|
#!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DISTFILES += \
|
|
||||||
generate-version.sh
|
|
||||||
|
|
||||||
|
|
||||||
# Define how to create version.h
|
|
||||||
VERSION_H = $$PWD/include/version.h
|
|
||||||
version.output = $$PWD/include/version.h
|
|
||||||
version.commands = $$PWD/generate-version.sh $${ARCH} $${TARGET} $${INTERFACE} $${INTERFACE_DEFINITION} $${VERSION_H}
|
|
||||||
version.depends = FORCE
|
|
||||||
version.input = VERSION_H
|
|
||||||
version.variable_out = HEADERS
|
|
||||||
QMAKE_EXTRA_COMPILERS += version
|
|
||||||
QMAKE_CLEAN += $${PWD}/include/version.h
|
|
||||||
|
|
||||||
HEADERS +=
|
|
||||||
|
@ -1,155 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
VERSION_STRING=""
|
|
||||||
|
|
||||||
#GIT='/cygdrive/c/Program Files \(x86\)/Git/bin/git'
|
|
||||||
GIT=git
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parse_git_branch () {
|
|
||||||
$GIT branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ARCH=$1
|
|
||||||
TARGET=$2
|
|
||||||
INTERFACE=$3
|
|
||||||
INTERFACE_DEFINITION=$4
|
|
||||||
VERSION_H=$5
|
|
||||||
|
|
||||||
SCRIPT=$(readlink -f $0)
|
|
||||||
SCRIPTPATH=`dirname $SCRIPT`
|
|
||||||
OUTPUTDIR=$(pwd)
|
|
||||||
echo " current dir is : " $(pwd)
|
|
||||||
echo $SCRIPT
|
|
||||||
echo $SCRIPTPATH
|
|
||||||
|
|
||||||
echo "changing dir to script path: " $SCRIPTPATH
|
|
||||||
cd $SCRIPTPATH
|
|
||||||
|
|
||||||
# set version string ##################################################################
|
|
||||||
if [ -z $VERSION_STRING ] ; then
|
|
||||||
VERSION_STRING=$(date +%Y%m%d_%H%M)
|
|
||||||
fi
|
|
||||||
GIT_DESCRIBE=$($GIT describe)
|
|
||||||
GIT_BRANCH=$(parse_git_branch)
|
|
||||||
|
|
||||||
# extract path from branchname:
|
|
||||||
IFS='_' read -ra TMP_ARRAY <<< "${GIT_BRANCH}"
|
|
||||||
BRANCH_PATH=${TMP_ARRAY[0]}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# detect if we have a development version:
|
|
||||||
if [ ${#TMP_ARRAY[1]} -gt 0 ] ; then
|
|
||||||
DEV_SUFFIX="_dev"
|
|
||||||
else
|
|
||||||
DEV_SUFFIX=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# detect if git status is dirty
|
|
||||||
GIT_DESCRIBE_DIRTY=$($GIT describe --dirty)
|
|
||||||
if [ "${GIT_DESCRIBE_DIRTY:(-6)}" == "-dirty" ] ; then
|
|
||||||
DIRTY_SUFFIX="_dirty"
|
|
||||||
else
|
|
||||||
DIRTY_SUFFIX=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$DIRTY_SUFFIX" ] || [ -n "$DEV_SUFFIX" ] ; then
|
|
||||||
DEVDIRTY=true
|
|
||||||
else
|
|
||||||
DEVDIRTY=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# extract interface definition
|
|
||||||
|
|
||||||
#
|
|
||||||
#Q_DECLARE_INTERFACE(CCInterface,
|
|
||||||
# "eu.atb.ptu.plugin.CCInterface/2.9.0")
|
|
||||||
# -> extract whole string within quotation marks
|
|
||||||
INTERFACE_VERSION=$(grep 'eu.atb.ptu.plugin.' ${INTERFACE_DEFINITION})
|
|
||||||
# get string within quotes:
|
|
||||||
INTERFACE_VERSION=`echo ${INTERFACE_VERSION} | awk -F \" '{print $2}'`
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# write version.h
|
|
||||||
|
|
||||||
|
|
||||||
echo " TARGET is: $TARGET"
|
|
||||||
echo " ARCH is: $ARCH"
|
|
||||||
echo " "
|
|
||||||
echo " PluginName: $TARGET"
|
|
||||||
echo " Interface: $INTERFACE"
|
|
||||||
echo " InterfaceVersion: $INTERFACE_VERSION"
|
|
||||||
echo " "
|
|
||||||
echo " new version is: $VERSION_STRING"
|
|
||||||
echo " git describe is: $GIT_DESCRIBE"
|
|
||||||
echo " git branch is: $GIT_BRANCH"
|
|
||||||
echo " branch-path is: $BRANCH_PATH"
|
|
||||||
echo " "
|
|
||||||
|
|
||||||
echo " dev suffix: $DEV_SUFFIX"
|
|
||||||
echo " dirty suffix: $DIRTY_SUFFIX"
|
|
||||||
|
|
||||||
|
|
||||||
PLUGIN_VERSION=${VERSION_STRING}
|
|
||||||
#ATB_QT_GIT_DESCRIBE=${GIT_DESCRIBE}_${GIT_BRANCH}
|
|
||||||
PLUGIN_GIT_DESCRIBE=${GIT_DESCRIBE}_${BRANCH_PATH}${DEV_SUFFIX}${DIRTY_SUFFIX}
|
|
||||||
|
|
||||||
#TARGET=IngenicoZVT_CCPlugin
|
|
||||||
|
|
||||||
|
|
||||||
# build version.h #####################################################################
|
|
||||||
|
|
||||||
echo " building new version info (version.h) ..."
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "#ifndef VERSION_H" > ${VERSION_H}
|
|
||||||
echo "#define VERSION_H" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "#define INTERFACE_VERSION \"${INTERFACE_VERSION}\"" >> ${VERSION_H}
|
|
||||||
echo "#define PLUGIN_VERSION \"${PLUGIN_VERSION}\"" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "#define PLUGIN_GIT_DESCRIBE \"${PLUGIN_GIT_DESCRIBE}\"" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
|
|
||||||
cat <<EOT >> ${VERSION_H}
|
|
||||||
|
|
||||||
const std::string pluginInfoString = R"(
|
|
||||||
{
|
|
||||||
"Interface": "${INTERFACE}",
|
|
||||||
"InterfaceVersion": "${INTERFACE_VERSION}",
|
|
||||||
"PluginName": "${TARGET}",
|
|
||||||
"Version": "${PLUGIN_VERSION}",
|
|
||||||
"git-describe": "${PLUGIN_GIT_DESCRIBE}",
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
if [ ${DEVDIRTY} == "true" ] ; then
|
|
||||||
echo "#define DEVDIRTY" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
fi
|
|
||||||
echo "#define SYSTEM_ARCH \"${ARCH}\"" >> ${VERSION_H}
|
|
||||||
echo "#define ARCH_${ARCH}" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "" >> ${VERSION_H}
|
|
||||||
echo "#endif //VERSION_H" >> ${VERSION_H}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ uint8_t epi_getResultOfLastRequest();
|
|||||||
// retval: 0: in progress 1: OK 2: error
|
// retval: 0: in progress 1: OK 2: error
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t *receivedData);
|
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData);
|
||||||
// stored by Datif
|
// stored by Datif
|
||||||
|
|
||||||
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad);
|
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad);
|
||||||
|
@ -303,7 +303,6 @@ class T_datif : public QMainWindow
|
|||||||
// docNr =transmitted in WRITEADDRESS high byte
|
// docNr =transmitted in WRITEADDRESS high byte
|
||||||
// blockNr=transmitted in WRITEADDRESS low byte
|
// blockNr=transmitted in WRITEADDRESS low byte
|
||||||
|
|
||||||
int datif_noResponseCtr;
|
|
||||||
|
|
||||||
T_prot *myDCIF;
|
T_prot *myDCIF;
|
||||||
QTimer *datif_trigger;
|
QTimer *datif_trigger;
|
||||||
@ -316,6 +315,9 @@ private slots:
|
|||||||
public:
|
public:
|
||||||
T_datif(QWidget *parent = nullptr);
|
T_datif(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
T_prot *getProt() { return myDCIF; }
|
||||||
|
T_prot const *getProt() const { return myDCIF; }
|
||||||
|
|
||||||
void resetChain(void);
|
void resetChain(void);
|
||||||
char isPortOpen(void);
|
char isPortOpen(void);
|
||||||
void sendWRcommand(uint16_t nxtAsCmd);
|
void sendWRcommand(uint16_t nxtAsCmd);
|
||||||
|
202
include/datei.h
202
include/datei.h
@ -1,202 +0,0 @@
|
|||||||
#ifndef DATEI_H
|
|
||||||
#define DATEI_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QDebug>
|
|
||||||
#include "tslib.h"
|
|
||||||
#include <QString>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QJsonParseError>
|
|
||||||
|
|
||||||
// create csv file with:
|
|
||||||
#define FILESEPERATOR ','
|
|
||||||
|
|
||||||
// pasre csv with:
|
|
||||||
#define FILESEP1 ','
|
|
||||||
#define FILESEP2 ';'
|
|
||||||
|
|
||||||
#define NEWLINEINFILE '\n'
|
|
||||||
#define MAXNUMBEROFSEQUENCES 200
|
|
||||||
// only for csv files
|
|
||||||
|
|
||||||
|
|
||||||
// all generated files located in sudirectory "dynamic machine data - dmd"
|
|
||||||
|
|
||||||
#define FILENAME_SHAREDDATA "../dmd/DCshare.csv"
|
|
||||||
#define FILENAME_SHARED_UID "../dmd/DC_UID.csv"
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ create csv file -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// create array with strings and values (to be written to file)
|
|
||||||
void csv_startCreatingFile(void);
|
|
||||||
void csv_addTextToFile(QString myText);
|
|
||||||
void csv_addIntToFile(int myValue);
|
|
||||||
void csv_addUintToFile(uint myValue);
|
|
||||||
void csv_addLongvalToFile(qlonglong myValue);
|
|
||||||
void csv_addUlongvalToFile(qulonglong myValue);
|
|
||||||
//void csv_addCurrentTimeToFile(void);
|
|
||||||
//void csv_addCurrentDateToFile(void);
|
|
||||||
void csv_addNewlineToFile(void);
|
|
||||||
QByteArray csv_readbackArray(void);
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ parse csv file -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// return number of entries in the just read file (entries are seperated by
|
|
||||||
// comma or line-feed)
|
|
||||||
uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile);
|
|
||||||
|
|
||||||
// before: QByteArray sourceFile=datei_readFromFile(filename);
|
|
||||||
|
|
||||||
QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// not needed, just for test // sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
// get single entries of of the just read file:
|
|
||||||
int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr);
|
|
||||||
// sequNr: 0....(size-1)
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ create Json Record -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void json_startRecord(void);
|
|
||||||
// clear buffer and write opening curly bracket {
|
|
||||||
|
|
||||||
void json_enterIntToRecord(QString attribute, ulong i_value);
|
|
||||||
// example: "parameter":1234567890
|
|
||||||
|
|
||||||
void json_enterTextToRecord(QString attribute, QString txt_value);
|
|
||||||
// example: "parameter":"slow"
|
|
||||||
|
|
||||||
//void json_addCurrentTimeToRecord(QString attribute);
|
|
||||||
// example: if attribute=myTime: "myTime":"hh_mm_ss"
|
|
||||||
|
|
||||||
//void json_addCurrentDateToRecord(QString attribute);
|
|
||||||
// example: if attribute=myDate: "myDate":"dd.mm.yyyy"
|
|
||||||
// also / possible as seperator
|
|
||||||
// further possible forms:
|
|
||||||
// format= 0: dd.mm.yyyy (deutsch)
|
|
||||||
// 1: mm.dd.yyyy (amerika)
|
|
||||||
// 2: yyyy.mm.dd (Iran, Dubai)
|
|
||||||
// 3: dd.yyyy.mm
|
|
||||||
// 4: mm.yyyy.dd
|
|
||||||
// 5: yyyy.dd.mm
|
|
||||||
|
|
||||||
void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals);
|
|
||||||
// add array of numbers with "nrofVals" elements
|
|
||||||
|
|
||||||
void json_enterStructToRecord(QString attribute);
|
|
||||||
// every call must be concluded with an extra "json_finishFile()"
|
|
||||||
// example: "sname":{
|
|
||||||
|
|
||||||
void json_finishStruct(void);
|
|
||||||
|
|
||||||
void json_finishRecord(void);
|
|
||||||
// close curly bracket
|
|
||||||
|
|
||||||
|
|
||||||
QString json_readbackRecordStr(void);
|
|
||||||
|
|
||||||
QByteArray json_readbackRecordBa(void);
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ parse Json file -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// first: QByteArray datei_readFromFile(QString filename);
|
|
||||||
|
|
||||||
//void datei_json_readTestFile(QString filename);
|
|
||||||
|
|
||||||
int json_nrOfPairsInFile(QByteArray filename);
|
|
||||||
|
|
||||||
bool json_exists(QByteArray filename, QString searchForKey);
|
|
||||||
// look for "searchForKey" =name of the pair (left of : )
|
|
||||||
// retval true if exists
|
|
||||||
|
|
||||||
bool json_remove(QByteArray filename, QString searchFor);
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and remove the record from file
|
|
||||||
// retval true if removed
|
|
||||||
|
|
||||||
QString json_searchForStringInFile(QByteArray filename, QString searchFor);
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
|
|
||||||
int json_searchForIntInFile(QByteArray filename, QString searchFor);
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
|
|
||||||
//.......................
|
|
||||||
|
|
||||||
QJsonObject json_searchForObjectInFile(QByteArray filename, QString searchFor);
|
|
||||||
// return an object from the json file
|
|
||||||
|
|
||||||
int json_nrOfPairsInObject(QJsonObject objname);
|
|
||||||
|
|
||||||
QString json_searchForStringInObject(QJsonObject objname, QString searchFor);
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
|
|
||||||
int json_searchForIntInObject(QJsonObject objname, QString searchFor);
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
|
|
||||||
//.......................
|
|
||||||
|
|
||||||
QJsonArray json_searchForArrayInFile(QByteArray filename, QString searchFor);
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
|
|
||||||
int json_nrOfValuesInArray(QJsonArray arrayname);
|
|
||||||
|
|
||||||
bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize);
|
|
||||||
// assuming that the array consists of integers
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ read, write, copy files -------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void datei_closeFile(QString filename);
|
|
||||||
|
|
||||||
// read content of an exiting file:
|
|
||||||
QByteArray datei_readFromFile(QString filename);
|
|
||||||
|
|
||||||
bool datei_ifFileExists(QString filename);
|
|
||||||
|
|
||||||
char datei_writeToFile(QString filename, QByteArray content);
|
|
||||||
// retval=0 if successful 1: no write access allowed
|
|
||||||
// 2:cannot open to append 3:cannot create new file
|
|
||||||
|
|
||||||
bool datei_copyFile(QString currentFileName, QString newFileName);
|
|
||||||
// retval=true if successful
|
|
||||||
|
|
||||||
bool datei_clearFile(QString filename);
|
|
||||||
// retval=true if successful
|
|
||||||
|
|
||||||
#endif // DATEI_H
|
|
@ -78,7 +78,7 @@ uint8_t dcBL_getResult(void);
|
|||||||
|
|
||||||
|
|
||||||
#define RAW_BL_DATALEN 150
|
#define RAW_BL_DATALEN 150
|
||||||
void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData);
|
void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t const *receivedData);
|
||||||
|
|
||||||
uint8_t epi_getRawReceivedData(uint8_t *receivedData);
|
uint8_t epi_getRawReceivedData(uint8_t *receivedData);
|
||||||
// retval=length, will be zeroed after first reading
|
// retval=length, will be zeroed after first reading
|
||||||
|
210
include/hwapi.h
210
include/hwapi.h
@ -17,8 +17,71 @@ matching interfaces.h:
|
|||||||
//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1"
|
//#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.1"
|
||||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
||||||
|
|
||||||
|
|
||||||
|
PSA1259 hardware control using the DeviceController DC2
|
||||||
|
|
||||||
|
covering enclosure (switches and doors) and money devices,
|
||||||
|
controls mifare card to access or program
|
||||||
|
optional it can control printer, modem, bar code reader and credit card
|
||||||
|
|
||||||
|
* API to the PSA1259 Hardware
|
||||||
|
* All data come in from device controller via serial interface and will be stored
|
||||||
|
* in "PI" = peripheral image
|
||||||
|
* PI is updated every 100ms (up to 30ms possible)
|
||||||
|
* This api uses stored pi data and returns them in the following functions
|
||||||
|
* created: Q1/2020 TS
|
||||||
|
*
|
||||||
|
|
||||||
|
The devices, connected to device controller2 (DC2) can be controlled in different access levels.
|
||||||
|
Level 1:
|
||||||
|
direct connection to DC2, check versions, state and parameters
|
||||||
|
control serial interfaces
|
||||||
|
digital/analog IO's
|
||||||
|
read and write to connected devices on lowest level, this is a kind of fall-back-level
|
||||||
|
in case higher levels fail or do not support the needed (new) function
|
||||||
|
Example: send a specific printer command, several bytes that need to be conform to
|
||||||
|
printer manual. This command is routed to the printer through the DC2 without
|
||||||
|
any action of the DC. You can write your own device driver that way.
|
||||||
|
Level 1 is flexible but complicated
|
||||||
|
|
||||||
|
Level 2:
|
||||||
|
The DC controls the connected devices containing a device driver. The DC offers
|
||||||
|
usage of the device by simple commands,
|
||||||
|
Example: "Printer on", "set Font size 3" "print "hello world"", "cut"
|
||||||
|
In opposite to level 1 where you had to send a set of numbers and letters.
|
||||||
|
In other words: you "talk" to the device controller, not to the device itself.
|
||||||
|
|
||||||
|
Level 3:
|
||||||
|
start/stop complete processes.
|
||||||
|
Example: 1) print (predefined) document nr 3 with Text, letter size, font set, cut.
|
||||||
|
Also power up/down the printer, check if paper ok and so on.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Another access example: control the coin unit
|
||||||
|
|
||||||
|
Level 1): read digital inputs to detect coin,
|
||||||
|
switch digital output which opens coin slot
|
||||||
|
communicate with coin checker by certain mdb-commands (manual conform)
|
||||||
|
poll coin checker for inserted coins
|
||||||
|
close coin slot after 3seconds by setting DO to 0....
|
||||||
|
|
||||||
|
Level 2): get message of attached coin from DC
|
||||||
|
send command "initialize coin checker" to DC
|
||||||
|
send command "open slot for 3s"
|
||||||
|
poll DC for inserted coins, DC polls coin checker in right way, no need
|
||||||
|
to know the data sheet of the coin checker or mdb-bus
|
||||||
|
command to DC "open coin escrow's return flap for 1s"
|
||||||
|
|
||||||
|
Level 3): send command: "start payment process"
|
||||||
|
all coin devices are started up
|
||||||
|
coin blocker opens for 3s if a coin is attached
|
||||||
|
coin checker summarizes inserted value and reports sum
|
||||||
|
later send command "stop payment process" (puts coins to vault) or
|
||||||
|
send command "cancel payment process" (returns coins to user)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef hwapi_H
|
#ifndef hwapi_H
|
||||||
#define hwapi_H
|
#define hwapi_H
|
||||||
@ -26,13 +89,11 @@ matching interfaces.h:
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QTimer>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <../plugins/interfaces.h>
|
#include "interfaces.h"
|
||||||
#include "datIf.h"
|
#include "datIf.h"
|
||||||
|
|
||||||
|
class QSharedMemory;
|
||||||
|
|
||||||
class hwapi : public QObject,
|
class hwapi : public QObject,
|
||||||
public hwinf
|
public hwinf
|
||||||
{
|
{
|
||||||
@ -41,16 +102,32 @@ class hwapi : public QObject,
|
|||||||
Q_INTERFACES(hwinf)
|
Q_INTERFACES(hwinf)
|
||||||
private:
|
private:
|
||||||
void sub_storeSendingText(QByteArray *buf) const;
|
void sub_storeSendingText(QByteArray *buf) const;
|
||||||
QTimer *hwapi_TimerPayment;
|
|
||||||
|
|
||||||
|
DownloadResult sendNextAddress(int bNum) const;
|
||||||
|
DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const;
|
||||||
|
DownloadResult sendStatus(int ret) const;
|
||||||
|
DownloadResult dc_downloadBinary(QByteArray const &binary) const;
|
||||||
|
|
||||||
|
bool startBootloader() const;
|
||||||
|
bool stopBootloader() const;
|
||||||
|
bool openSerial(int br, QString baudrate, QString comPort) const;
|
||||||
|
bool closeSerial(QString comport) const;
|
||||||
|
bool resetDeviceController() const;
|
||||||
|
QByteArray loadBinaryDCFile(QString filename) const;
|
||||||
|
bool downloadBinaryToDC(QString const &bFile) const;
|
||||||
|
|
||||||
|
QSharedMemory *m_sharedMem;
|
||||||
public:
|
public:
|
||||||
explicit hwapi(QWidget *parent = nullptr);
|
explicit hwapi(QWidget *parent = nullptr);
|
||||||
|
virtual ~hwapi();
|
||||||
|
|
||||||
T_datif *myDatif;
|
T_datif *myDatif;
|
||||||
|
|
||||||
|
|
||||||
|
virtual QStringList dc_getStatus() const;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// commands, interface
|
// Level 0 commands, interface
|
||||||
// open, close, change serial interface
|
// open, close, change serial interface
|
||||||
// actually not neccessary as it is opened automatically on program start
|
// actually not neccessary as it is opened automatically on program start
|
||||||
// start automatic READ requests
|
// start automatic READ requests
|
||||||
@ -62,7 +139,7 @@ public:
|
|||||||
// ComName: for example "COM48"
|
// ComName: for example "COM48"
|
||||||
// connect: 0, 1
|
// connect: 0, 1
|
||||||
|
|
||||||
void dc_closeSerial(void) const override;
|
bool dc_closeSerial(void) const override;
|
||||||
|
|
||||||
bool dc_isPortOpen(void) const override ;
|
bool dc_isPortOpen(void) const override ;
|
||||||
|
|
||||||
@ -70,10 +147,21 @@ public:
|
|||||||
// select if READ-Requests are sent manually one by one or automatically
|
// select if READ-Requests are sent manually one by one or automatically
|
||||||
// automatically request ALL digital and analog sensors, get time/date, get status information
|
// automatically request ALL digital and analog sensors, get time/date, get status information
|
||||||
|
|
||||||
|
bool dc_updateDC(QString binFileName, QString baudrate,
|
||||||
|
QString comPort) const override;
|
||||||
|
|
||||||
|
bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QVector<QString> fnames,
|
||||||
|
QString br,
|
||||||
|
QString serial = QString()) const override;
|
||||||
|
|
||||||
|
bool dc_printTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QString br,
|
||||||
|
QString serial = QString()) const override;
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// control device-controller (functions of µC)
|
// Level 1, control device-controller (functions of µC)
|
||||||
// check serial connection to deviceController
|
// check serial connection to deviceController
|
||||||
// read response from DC2 (input data)
|
// read response from DC2 (input data)
|
||||||
// some test function for serial communication
|
// some test function for serial communication
|
||||||
@ -160,15 +248,8 @@ public:
|
|||||||
uint8_t bl_exitBL(uint8_t *sendData) const override;
|
uint8_t bl_exitBL(uint8_t *sendData) const override;
|
||||||
// minimum size of sendData-buffer: 5byte retval: length
|
// minimum size of sendData-buffer: 5byte retval: length
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// DC2-onboard devices
|
// Level 2 DC2-onboard devices
|
||||||
// WR: set time
|
// WR: set time
|
||||||
// RD. get time, get measure, get test results
|
// RD. get time, get measure, get test results
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
@ -242,7 +323,7 @@ public:
|
|||||||
bool dc_mainFuseIsOk(void) const override;
|
bool dc_mainFuseIsOk(void) const override;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// igital outputs and simple switching of connected devices
|
// Level 3: digital outputs and simple switching of connected devices
|
||||||
// simple processes like flashing a led or open flap for 1s
|
// simple processes like flashing a led or open flap for 1s
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -298,7 +379,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// digital inputs of connected devices
|
// Level 3: digital inputs of connected devices
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool door_isContactPowerOn(void) const override;
|
bool door_isContactPowerOn(void) const override;
|
||||||
@ -660,29 +741,29 @@ public:
|
|||||||
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
||||||
// example: print current time at this point (the time of printing not the storage time!!)
|
// example: print current time at this point (the time of printing not the storage time!!)
|
||||||
|
|
||||||
//void pri_startTicketDesign(void) const override;
|
void pri_startTicketDesign(void) const override;
|
||||||
// start for every new printer document, reseting collecting buffer
|
// start for every new printer document, reseting collecting buffer
|
||||||
|
|
||||||
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
||||||
// return val of the appending functions: true=ok false=too long, buffer full
|
// return val of the appending functions: true=ok false=too long, buffer full
|
||||||
|
|
||||||
//int pri_TD_getCurrentSize(void) const override;
|
int pri_TD_getCurrentSize(void) const override;
|
||||||
// retval: 0...1278
|
// retval: 0...1278
|
||||||
|
|
||||||
//bool pri_TD_addText(QByteArray text) const override;
|
bool pri_TD_addText(QByteArray text) const override;
|
||||||
// example: pri_TD_addText("Hello") const override;
|
// example: pri_TD_addText("Hello") const override;
|
||||||
// example: pri_TD_addText(tempStr) const override;
|
// example: pri_TD_addText(tempStr) const override;
|
||||||
// retval: true=ok false=too long, buffer full
|
// retval: true=ok false=too long, buffer full
|
||||||
|
|
||||||
//bool pri_TD_addValue(int val) const override;
|
bool pri_TD_addValue(int val) const override;
|
||||||
// +/- 0...2^(31)
|
// +/- 0...2^(31)
|
||||||
|
|
||||||
//bool pri_TD_addNewLine(void) const override;
|
bool pri_TD_addNewLine(void) const override;
|
||||||
|
|
||||||
//bool pri_TD_addSign(char sign) const override;
|
bool pri_TD_addSign(char sign) const override;
|
||||||
// example: '.' ' ' 0x20 'W' '$'
|
// example: '.' ' ' 0x20 'W' '$'
|
||||||
|
|
||||||
//bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const override;
|
bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const override;
|
||||||
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
||||||
/* complete list of possible commands:
|
/* complete list of possible commands:
|
||||||
group 50 : paper
|
group 50 : paper
|
||||||
@ -723,11 +804,11 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//char prn_clearDocument(uint8_t documentNumber) const override;
|
char prn_clearDocument(uint8_t documentNumber) const override;
|
||||||
// clear memory buffer for ONE document
|
// clear memory buffer for ONE document
|
||||||
// function takes a second! don't send right before "store doc"
|
// function takes a second! don't send right before "store doc"
|
||||||
|
|
||||||
//bool prn_store_Document(uint8_t documentNumber ) const override;
|
bool prn_store_Document(uint8_t documentNumber ) const override;
|
||||||
|
|
||||||
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
||||||
// documentNumber=0...15
|
// documentNumber=0...15
|
||||||
@ -739,7 +820,7 @@ public:
|
|||||||
// the place in the ticket layout is predefined (already in DC memory)
|
// the place in the ticket layout is predefined (already in DC memory)
|
||||||
// the dynamics are first calculated at printing time
|
// the dynamics are first calculated at printing time
|
||||||
|
|
||||||
//bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const override;
|
bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const override;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -843,7 +924,7 @@ public:
|
|||||||
void bl_rebootDC(void) const override;
|
void bl_rebootDC(void) const override;
|
||||||
|
|
||||||
void bl_startBL(void) const override;
|
void bl_startBL(void) const override;
|
||||||
void bl_checkBL(void) const override;
|
bool bl_checkBL(void) const override;
|
||||||
bool bl_isUp(void) const override;
|
bool bl_isUp(void) const override;
|
||||||
// return true is bl is up and running
|
// return true is bl is up and running
|
||||||
// also initializes "sendFile"
|
// also initializes "sendFile"
|
||||||
@ -920,7 +1001,6 @@ public:
|
|||||||
// return true if successful. could fail if more the 8 commands are waiting
|
// return true if successful. could fail if more the 8 commands are waiting
|
||||||
|
|
||||||
bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const override;
|
bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const override;
|
||||||
|
|
||||||
bool rtc_getExtendedTime(struct T_extTime *exTime) const override;
|
bool rtc_getExtendedTime(struct T_extTime *exTime) const override;
|
||||||
|
|
||||||
bool sys_runCompleteTest(void) const override;
|
bool sys_runCompleteTest(void) const override;
|
||||||
@ -967,23 +1047,9 @@ public:
|
|||||||
bool prn_printTestTicket(void) const override;
|
bool prn_printTestTicket(void) const override;
|
||||||
// return true if sending to DC OK, false if cmd-stack is full
|
// return true if sending to DC OK, false if cmd-stack is full
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cash_startPayment(uint32_t amount) const override;
|
bool cash_startPayment(uint32_t amount) const override;
|
||||||
// 17.4.23TS: extended to 32bit
|
// 17.4.23TS: extended to 32bit
|
||||||
|
|
||||||
uint8_t cash_paymentProcessing(void) const override;
|
|
||||||
// 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
|
|
||||||
|
|
||||||
|
|
||||||
bool cash_cancelPayment(void) const override;
|
bool cash_cancelPayment(void) const override;
|
||||||
// and return coins
|
// and return coins
|
||||||
|
|
||||||
@ -1017,22 +1083,11 @@ public:
|
|||||||
uint64_t sys_getWakeSource(void) const override;
|
uint64_t sys_getWakeSource(void) const override;
|
||||||
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
||||||
|
|
||||||
uint8_t sys_getWakeReason(void) const override;
|
|
||||||
// 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
|
|
||||||
|
|
||||||
void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const override;
|
void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const override;
|
||||||
|
|
||||||
void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override;
|
void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override;
|
||||||
|
|
||||||
void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override;
|
void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override;
|
||||||
|
|
||||||
void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
|
void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
|
||||||
|
|
||||||
|
|
||||||
@ -1051,58 +1106,17 @@ public:
|
|||||||
// bit5: printer not ready
|
// bit5: printer not ready
|
||||||
|
|
||||||
|
|
||||||
void sys_sendDeviceParameter(struct T_devices *deviceSettings) const override;
|
|
||||||
|
|
||||||
void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const override;
|
|
||||||
|
|
||||||
bool sys_areDCdataValid(void) const override;
|
|
||||||
|
|
||||||
bool sys_sendingTest(void) const override;
|
|
||||||
|
|
||||||
void prn_requestCurrentDynData(void) const override;
|
|
||||||
|
|
||||||
bool prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const override;
|
|
||||||
// which was sent with: bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const override;
|
|
||||||
|
|
||||||
bool prn_dynDataAreEqual(uint8_t *buf) const override;
|
|
||||||
|
|
||||||
bool prn_printKombiticket(uint8_t nrOfKombi) const override;
|
|
||||||
// print four of the templates loaded by Json prior
|
|
||||||
// nr = 1..8
|
|
||||||
|
|
||||||
void lock_triggerUpperSolenoid(void) const override;
|
|
||||||
|
|
||||||
void lock_triggerLowerSolenoid(void) const override;
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hwapi_templatePrintFinished_OK(void) const override;
|
void hwapi_templatePrintFinished_OK(void) const override;
|
||||||
void hwapi_templatePrintFinished_Err(void) const override;
|
void hwapi_templatePrintFinished_Err(void) const override;
|
||||||
|
|
||||||
void hwapi_coinCollectionJustStarted(void) const override;
|
|
||||||
void hwapi_coinCollectionAborted(void) const override;
|
|
||||||
|
|
||||||
void hwapi_gotNewCoin(void) const override;
|
void hwapi_gotNewCoin(void) const override;
|
||||||
void hwapi_payStopByMax(void) const override;
|
void hwapi_vendStopByMax(void) const override;
|
||||||
void hwapi_payStopByPushbutton(void) const override;
|
void hwapi_vendStopByPushbutton(void) const override;
|
||||||
|
|
||||||
void hwapi_payStopByEscrow(void) const override;
|
|
||||||
void hwapi_payStopByError(void) const override;
|
|
||||||
void hwapi_payStopByTimeout(void) const override;
|
|
||||||
void hwapi_payCancelled(void) const override;
|
|
||||||
|
|
||||||
void hwapi_coinProcessJustStopped(void) const override;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void hwapi_slotPrintFinished_OK(void);
|
void hwapi_slotPrintFinished_OK(void);
|
||||||
void hwapi_slotPrintFinished_Err(void);
|
void hwapi_slotPrintFinished_Err(void);
|
||||||
void hwapi_slotGotCoin(void);
|
void hwapi_slotGotCoin(void);
|
||||||
void hwapi_slotPayProc(void);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
1616
include/interfaces.h
Normal file
1616
include/interfaces.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -93,6 +93,9 @@ private slots:
|
|||||||
void analyseRecData(void);
|
void analyseRecData(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
T_com *getSerialPort() { return mySerialPort; }
|
||||||
|
T_com const *getSerialPort() const { return mySerialPort; }
|
||||||
|
|
||||||
T_prot();
|
T_prot();
|
||||||
bool isPortOpen(void);
|
bool isPortOpen(void);
|
||||||
bool isSerialFree(void);
|
bool isSerialFree(void);
|
||||||
|
@ -148,21 +148,23 @@
|
|||||||
|
|
||||||
|
|
||||||
// highest priority
|
// highest priority
|
||||||
#define CMDSTACKDEPTH 16
|
// #define CMDSTACKDEPTH 16
|
||||||
// means: up to 16 cmd can be stored. They are issued one by one every 100ms
|
// means: up to 16 cmd can be stored. They are issued one by one every 100ms
|
||||||
void sendWRcmd_clrCmdStack(void);
|
void sendWRcmd_clrCmdStack(void);
|
||||||
bool sendWRcmd_setSendCommand0(uint16_t nextCmd);
|
bool sendWRcmd_setSendCommand0(uint16_t nextCmd, uint8_t dat1=0, uint8_t dat2=0,
|
||||||
|
uint8_t dat3=0, uint8_t dat4=0);
|
||||||
// GUI or app sends a command to DC transfered by serial
|
// GUI or app sends a command to DC transfered by serial
|
||||||
|
|
||||||
uint16_t sendWRcmd_getSendCommand0(void);
|
uint16_t sendWRcmd_getSendCommand0(uint8_t *dat1=0, uint8_t *dat2=0,
|
||||||
|
uint8_t *dat3=0, uint8_t *dat4=0);
|
||||||
|
|
||||||
// lower priority
|
// lower priority
|
||||||
#define CMD4STACKDEPTH 8
|
// #define CMD4STACKDEPTH 8
|
||||||
void sendWRcmd_clrCmd4Stack(void);
|
void sendWRcmd_clrCmd4Stack(void);
|
||||||
bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
||||||
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
||||||
|
|
||||||
#define CMD8STACKDEPTH 4
|
// #define CMD8STACKDEPTH 4
|
||||||
void sendWRcmd_clrCmd8Stack(void);
|
void sendWRcmd_clrCmd8Stack(void);
|
||||||
bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint16_t dat3, uint32_t dat4);
|
bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint16_t dat3, uint32_t dat4);
|
||||||
uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4);
|
uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4);
|
||||||
@ -171,7 +173,7 @@ uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3,
|
|||||||
|
|
||||||
// lowest priority
|
// lowest priority
|
||||||
// wait for resonse before send next!
|
// wait for resonse before send next!
|
||||||
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf);
|
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t const *buf);
|
||||||
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf);
|
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf);
|
||||||
// retval = *leng
|
// retval = *leng
|
||||||
|
|
||||||
@ -179,7 +181,7 @@ void sendWRcmd_INI(void);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf);
|
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t const *buf);
|
||||||
// HWapi writes data to be forwarded to DC and further to mdb-device
|
// HWapi writes data to be forwarded to DC and further to mdb-device
|
||||||
// not batched! don't use twice within 100ms
|
// not batched! don't use twice within 100ms
|
||||||
|
|
||||||
@ -211,15 +213,8 @@ uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *
|
|||||||
// user=1: Text-Print is using this buffer
|
// user=1: Text-Print is using this buffer
|
||||||
// 2: QR-code-Printer is using this buffer
|
// 2: QR-code-Printer is using this buffer
|
||||||
|
|
||||||
|
//#define FDCMD_STACKDEPTH 16
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define FDCMD_STACKDEPTH 16
|
|
||||||
void sendFDcmd_clrStack(void);
|
void sendFDcmd_clrStack(void);
|
||||||
|
|
||||||
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
||||||
// write Command to memory, wait for transport
|
// write Command to memory, wait for transport
|
||||||
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
||||||
@ -227,35 +222,23 @@ bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, ui
|
|||||||
uint8_t check4FDshortCmd(void);
|
uint8_t check4FDshortCmd(void);
|
||||||
// returns number of waiting command, maxFDCMD_STACKDEPTH
|
// returns number of waiting command, maxFDCMD_STACKDEPTH
|
||||||
|
|
||||||
uint8_t checkNextFDcmd(void);
|
|
||||||
// return 0: no command waiting
|
|
||||||
// 1: short cmd
|
|
||||||
// 2: long cmd
|
|
||||||
|
|
||||||
uint8_t check4freeFDshortCmd(void);
|
uint8_t check4freeFDshortCmd(void);
|
||||||
// returns number of free places in short-command stack
|
// returns number of free places in short-command stack
|
||||||
|
|
||||||
//#define FDLONG_STACKDEPTH 16
|
//#define FDLONG_STACKDEPTH 16
|
||||||
//void longFDcmd_clrStack(void);
|
void longFDcmd_clrStack(void);
|
||||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data);
|
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t const *data);
|
||||||
// write Command to memory, wait for transport
|
// write Command to memory, wait for transport
|
||||||
// data buffer size always 64! data[64], padded with 0
|
// data buffer size always 64! data[64], padded with 0
|
||||||
//bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
|
||||||
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
||||||
|
|
||||||
//uint8_t check4FDlongCmd(void);
|
uint8_t check4FDlongCmd(void);
|
||||||
// returns number of waiting command
|
// returns number of waiting command
|
||||||
|
|
||||||
//uint8_t check4freeFDlongCmd(void);
|
uint8_t check4freeFDlongCmd(void);
|
||||||
// returns number of free places in long-command stack
|
// returns number of free places in long-command stack
|
||||||
|
|
||||||
|
|
||||||
uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf);
|
|
||||||
// HWapi writes data to be stored
|
|
||||||
|
|
||||||
uint8_t epi_restore64BdevParameter(uint8_t *length, uint8_t *buf);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
22
include/serial_port_thread.h
Normal file
22
include/serial_port_thread.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef SERIAL_PORT_THREAD_H_INCLUDED
|
||||||
|
#define SERIAL_PORT_THREAD_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
#include <QString>
|
||||||
|
#include <QEventLoop>
|
||||||
|
|
||||||
|
class SerialPortThread : public QThread {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QEventLoop m_loop;
|
||||||
|
public:
|
||||||
|
SerialPortThread(QObject *parent = nullptr);
|
||||||
|
virtual ~SerialPortThread();
|
||||||
|
|
||||||
|
virtual void run() override;
|
||||||
|
|
||||||
|
QEventLoop &getEventLoop() { return m_loop; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SERIAL_PORT_THREAD_H_INCLUDED
|
121
include/serial_port_worker.h
Normal file
121
include/serial_port_worker.h
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
#ifndef SERIAL_PORT_WORKER_H_INCLUDED
|
||||||
|
#define SERIAL_PORT_WORKER_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QSerialPort>
|
||||||
|
#include <QSerialPortInfo>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <mutex>
|
||||||
|
#include <queue>
|
||||||
|
#include <deque>
|
||||||
|
#include <iostream>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
|
||||||
|
struct Command {
|
||||||
|
enum : uint16_t {PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4, END_MARK};
|
||||||
|
enum : uint16_t {QUIT_SENTINEL = 0x1000, SEND_BLOCK_SIZE = 160};
|
||||||
|
uint32_t m_priority;
|
||||||
|
uint16_t m_priorityClass;
|
||||||
|
uint16_t m_cmdId;
|
||||||
|
char *m_sendBuffer;
|
||||||
|
char *m_recvBuffer;
|
||||||
|
uint8_t m_sendBufferLength;
|
||||||
|
uint8_t m_recvBufferLength; // expected result length
|
||||||
|
|
||||||
|
static std::atomic<uint8_t> m_nextSendBufferIndex;
|
||||||
|
static std::atomic<uint8_t> m_nextRecvBufferIndex;
|
||||||
|
static char m_sendBuffers[256][SEND_BLOCK_SIZE];
|
||||||
|
static char m_recvBuffers[256][SEND_BLOCK_SIZE];
|
||||||
|
|
||||||
|
static uint32_t getNextCommandPriority(uint8_t cmdType);
|
||||||
|
static char *getNextSendBuffer();
|
||||||
|
static char *getNextRecvBuffer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
Command(uint16_t cmdId, uint8_t sendBufferLength, uint8_t recvBufferLength, uint8_t priorityClass);
|
||||||
|
Command();
|
||||||
|
|
||||||
|
friend bool operator< (Command const& lhs, Command const& rhs) {
|
||||||
|
return lhs.m_priority < rhs.m_priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend std::ostream& operator<< (std::ostream& os, Command const& cmd) {
|
||||||
|
return os << "{ " << cmd.m_priority << ", '" << cmd.m_priority << "' } ";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// \brief SerialPortWorker
|
||||||
|
///
|
||||||
|
/// SerialPortWorker sends and receives data from serial port
|
||||||
|
///
|
||||||
|
class SerialPortWorker : public QThread {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/// \brief Internal serial port.
|
||||||
|
QSerialPort m_serialPort;
|
||||||
|
|
||||||
|
/// \brief Internal serial port info.
|
||||||
|
QSerialPortInfo m_serialPortInfo;
|
||||||
|
|
||||||
|
/// \brief Flag indicating if serial port is opened.
|
||||||
|
bool m_serialPortOpened;
|
||||||
|
|
||||||
|
/// \brief Port name of serial port.
|
||||||
|
QString m_portName;
|
||||||
|
|
||||||
|
/// \brief Baudrate of internal serial port.
|
||||||
|
enum QSerialPort::BaudRate m_baudRate;
|
||||||
|
|
||||||
|
std::priority_queue<Command, std::deque<Command>> m_sendQueue;
|
||||||
|
std::deque<Command> m_recvQueue;
|
||||||
|
std::mutex m_sendQueueMutex;
|
||||||
|
std::mutex m_recvQueueMutex;
|
||||||
|
std::condition_variable m_sendQueueCondVar;
|
||||||
|
std::condition_variable m_recvQueueCondVar;
|
||||||
|
|
||||||
|
std::atomic<uint32_t> m_bytesWritten;
|
||||||
|
std::atomic<uint32_t> m_bytesAvailable;
|
||||||
|
|
||||||
|
SerialPortWorker(QString portName, QSerialPort::BaudRate baudRate, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
Command getNextCommand();
|
||||||
|
void insertResult(Command const &result);
|
||||||
|
|
||||||
|
enum : uint16_t {TIMEOUT = 100, WAIT_TIME_MAX = 1000};
|
||||||
|
|
||||||
|
public:
|
||||||
|
~SerialPortWorker();
|
||||||
|
|
||||||
|
SerialPortWorker(SerialPortWorker const &) = delete;
|
||||||
|
void operator=(SerialPortWorker const &) = delete;
|
||||||
|
|
||||||
|
// serial port im plugin anlegen. erst dann kann getInstance() benutzt werden
|
||||||
|
static SerialPortWorker &getInstance(QString portName, QSerialPort::BaudRate baudRate, QObject *parent = nullptr) {
|
||||||
|
static SerialPortWorker serialPortWorker(portName, baudRate, parent);
|
||||||
|
return serialPortWorker;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool openSerialPort();
|
||||||
|
void closeSerialPort();
|
||||||
|
|
||||||
|
bool isPortOpen() const { return m_serialPortOpened; }
|
||||||
|
|
||||||
|
void insertCommand(Command const &cmd);
|
||||||
|
bool getNextResult(Command &result, int timeout = 1000);
|
||||||
|
|
||||||
|
virtual void run() override;
|
||||||
|
|
||||||
|
void quit();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void getBytesAvailable();
|
||||||
|
bool getNumberOfBytesWritten(qint64);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SERIAL_PORT_WORKER_H_INCLUDED
|
@ -6,12 +6,32 @@
|
|||||||
|
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
|
|
||||||
|
// TODO: pid eintragen und convars/mutexe eintragen
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
// PTHREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
#else
|
||||||
|
// WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
struct SharedMemBuffer {
|
struct SharedMemBuffer {
|
||||||
|
int init;
|
||||||
|
char appName[32];
|
||||||
|
pid_t pid;
|
||||||
|
pthread_condattr_t sndCndA;
|
||||||
|
pthread_cond_t sndCndV;
|
||||||
|
pthread_mutexattr_t sndMtxA;
|
||||||
|
pthread_mutex_t sndMtx;
|
||||||
|
|
||||||
|
pthread_condattr_t rcvCndA;
|
||||||
|
pthread_cond_t rcvCndV;
|
||||||
|
pthread_mutexattr_t rcvMtxA;
|
||||||
|
pthread_mutex_t rcvMtx;
|
||||||
|
|
||||||
struct rs {
|
struct rs {
|
||||||
char comportName[16]; // z.B. "COM48"
|
char comportName[16]; // z.B. "COM48"
|
||||||
@ -24,109 +44,130 @@ struct SharedMemBuffer {
|
|||||||
char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
||||||
|
|
||||||
struct datif {
|
struct datif {
|
||||||
|
#define DATIF_MAXCMDS 16
|
||||||
uint16_t sendingPeriod;
|
uint16_t sendingPeriod;
|
||||||
bool sendingPer_changed;
|
bool sendingPer_changed;
|
||||||
|
uint8_t OutCmdpara1;
|
||||||
|
uint8_t OutCmdpara2;
|
||||||
|
uint8_t OutCmdpara3;
|
||||||
|
uint8_t OutCmdpara4;
|
||||||
|
uint16_t OutCmdpara5;
|
||||||
|
uint32_t OutCmdpara6;
|
||||||
|
uint8_t dataStep;
|
||||||
|
uint8_t scanStep;
|
||||||
|
uint8_t RDBLKNR;
|
||||||
|
uint8_t cycl_running;
|
||||||
} datif;
|
} datif;
|
||||||
|
|
||||||
#if 0
|
struct txt4 {
|
||||||
// controlBus.cpp
|
char comStateLine[32];
|
||||||
char txt4comStateLine[32];
|
char HsStateLine[32];
|
||||||
char txt4HsStateLine[32];
|
char masterStateLine[32];
|
||||||
char txt4masterStateLine[32];
|
char resultStateLine[32];
|
||||||
char txt4resultStateLine[32];
|
char dataLine[32];
|
||||||
char txt4dataLine[32];
|
char datifReceive[32];
|
||||||
char txt4datifReceive[32];
|
char diagWindow[32];
|
||||||
char txt4diagWindow[32];
|
char sndDiagWindow[32];
|
||||||
char sndTxt4diagWindow[32];
|
} txt4;
|
||||||
bool Sdata_serialTestResult[32];
|
|
||||||
uint8_t Sdata_pProtResultOk[32];
|
|
||||||
uint16_t Sdata_receivedDataLength[32];
|
|
||||||
uint8_t Sdata_receivedDataBlock[64];
|
|
||||||
|
|
||||||
// datif.cpp
|
struct dcBL {
|
||||||
uint8_t dif_dataStep;
|
#define SIZEBLRESP 50
|
||||||
uint8_t dif_scanStep;
|
#define RAW_BL_DATALEN 150
|
||||||
uint8_t RDBLKNR;
|
uint8_t LastBLcmd; // stored the last sent cmd in order to analys response
|
||||||
uint8_t datif_OutCmdpara1;
|
uint8_t AtbBinFile[300000];
|
||||||
uint8_t datif_OutCmdpara2;
|
uint32_t fileSize;
|
||||||
uint8_t datif_OutCmdpara3;
|
uint16_t nrOfBlocks;
|
||||||
uint8_t datif_OutCmdpara4;
|
uint16_t fileCrc;
|
||||||
|
uint8_t myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise
|
||||||
|
char Resp[SIZEBLRESP][32];
|
||||||
|
int pResp;
|
||||||
|
uint8_t step;
|
||||||
|
uint8_t state;
|
||||||
|
uint16_t BlkCtr;
|
||||||
|
uint16_t cyclCtr;
|
||||||
|
uint16_t repeatCtr;
|
||||||
|
} dcBL;
|
||||||
|
|
||||||
uint16_t datif_OutCmdpara5;
|
struct {
|
||||||
uint32_t datif_OutCmdpara6;
|
uint16_t shutterTime;
|
||||||
uint8_t cycl_running;
|
char ticketTemplate[1024];
|
||||||
|
} hwapi;
|
||||||
|
|
||||||
// dcBL.cpp
|
struct {
|
||||||
uint8_t dcBL_LastBLcmd; // stored the last sent cmd in order to analys response
|
uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer
|
||||||
uint8_t dcBL_AtbBinFile[300000];
|
uint8_t sendAsyDatLen;
|
||||||
uint32_t dcBL_fileSize;
|
} next;
|
||||||
uint16_t dcBL_nrOfBlocks;
|
|
||||||
uint16_t dcBL_fileCrc;
|
|
||||||
uint8_t dcBL_myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise
|
|
||||||
|
|
||||||
char BlResp[50][32];
|
struct { // highest priority
|
||||||
uint8_t dcBL_step;
|
#define CMDSTACKDEPTH 16
|
||||||
uint8_t dcBL_state;
|
// up to 16 cmd can be stored. They are issued one by one every 100ms
|
||||||
uint16_t dcBL_BlkCtr;
|
uint16_t AsynchSend[CMDSTACKDEPTH];
|
||||||
uint16_t dcBL_cyclCtr;
|
uint8_t para1[CMDSTACKDEPTH]; /* used to streamline source */
|
||||||
uint16_t repeatCtr;
|
uint8_t para2[CMDSTACKDEPTH]; /* used to streamline source */
|
||||||
uint8_t Sdata_rawData[150];
|
uint8_t para3[CMDSTACKDEPTH]; /* used to streamline source */
|
||||||
uint8_t Sdata_LengthRawData;
|
uint8_t para4[CMDSTACKDEPTH]; /* used to streamline source */
|
||||||
|
uint8_t nrOfCmdsInQueue;
|
||||||
|
} Cmd0;
|
||||||
|
|
||||||
// hwapi.cpp
|
struct { // lower priority
|
||||||
uint16_t hwapi_shutterTime;
|
// Command Stack for commands with 4 parameters
|
||||||
char ticketTemplate[1024];
|
#define CMD4STACKDEPTH 8
|
||||||
|
uint16_t AsynchSend[CMD4STACKDEPTH];
|
||||||
|
uint8_t para1[CMD4STACKDEPTH];
|
||||||
|
uint8_t para2[CMD4STACKDEPTH];
|
||||||
|
uint8_t para3[CMD4STACKDEPTH];
|
||||||
|
uint8_t para4[CMD4STACKDEPTH];
|
||||||
|
uint8_t nrOfCmdsInQueue;
|
||||||
|
} Cmd4;
|
||||||
|
|
||||||
// sendWRcmd.cpp
|
struct {
|
||||||
uint16_t nextAsynchsendCmd0[16];
|
#define CMD8STACKDEPTH 4
|
||||||
uint8_t nrOfCmdsInQueue;
|
uint16_t AsynchSend[CMD8STACKDEPTH];
|
||||||
uint16_t nextAsynchsendCmd4[8];
|
uint8_t para1[CMD8STACKDEPTH];
|
||||||
uint8_t nextCmd4para1[8];
|
uint8_t para2[CMD8STACKDEPTH];
|
||||||
uint8_t nextCmd4para2[8];
|
uint16_t para3[CMD8STACKDEPTH];
|
||||||
uint8_t nextCmd4para3[8];
|
uint32_t para4[CMD8STACKDEPTH];
|
||||||
uint8_t nextCmd4para4[8];
|
uint8_t nrOfCmdsInQueue;
|
||||||
uint8_t nrOfCmds4InQueue;
|
} Cmd8;
|
||||||
uint16_t nextAsynchsendCmd8[4];
|
|
||||||
uint8_t nextCmd8para1[4];
|
|
||||||
uint8_t nextCmd8para2[4];
|
|
||||||
uint16_t nextCmd8para3[4];
|
|
||||||
uint32_t nextCmd8para4[4];
|
|
||||||
uint8_t nrOfCmds8InQueue;
|
|
||||||
uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer
|
|
||||||
uint8_t sendAsyDatLen;
|
|
||||||
uint8_t Sdata_mdbSendBuffer[64];
|
|
||||||
uint8_t Sdata_mdbSendLen;
|
|
||||||
uint8_t prnDataParameters[4];
|
|
||||||
uint8_t prnDataBufferUser;
|
|
||||||
char Sdata_PRN_TEXT[20][64];
|
|
||||||
uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
|
|
||||||
uint8_t nextFDwrCmd[16];
|
|
||||||
uint8_t nextFDrdCmd[16];
|
|
||||||
uint8_t nextFDblkNr[16];
|
|
||||||
|
|
||||||
uint8_t nextFDpara1[16];
|
struct { // short command, 4 data bytes
|
||||||
uint8_t nextFDpara2[16];
|
#define FDCMD_STACKDEPTH 16
|
||||||
uint8_t nextFDpara3[16];
|
uint8_t wrCmd[FDCMD_STACKDEPTH];
|
||||||
uint8_t nextFDpara4[16];
|
uint8_t rdCmd[FDCMD_STACKDEPTH];
|
||||||
uint8_t p_nextFDcmdsInQueue;
|
uint8_t blkNr[FDCMD_STACKDEPTH];
|
||||||
uint8_t longFDwrCmd[16];
|
uint8_t para1[FDCMD_STACKDEPTH];
|
||||||
uint8_t longFDrdCmd[16];
|
uint8_t para2[FDCMD_STACKDEPTH];
|
||||||
uint8_t longFDblkNr[16];
|
uint8_t para3[FDCMD_STACKDEPTH];
|
||||||
uint8_t longFDlength[16];
|
uint8_t para4[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t cmdsInQueue;
|
||||||
|
} FDShort;
|
||||||
|
|
||||||
uint8_t longFDpara[16][64];
|
struct { // long command, 64 data bytes
|
||||||
uint8_t p_longFDcmdsInQueue;
|
#define FDLONG_STACKDEPTH 16
|
||||||
|
uint8_t wrCmd[FDLONG_STACKDEPTH];
|
||||||
|
uint8_t rdCmd[FDLONG_STACKDEPTH];
|
||||||
|
uint8_t blkNr[FDLONG_STACKDEPTH];
|
||||||
|
uint8_t length[FDLONG_STACKDEPTH];
|
||||||
|
uint8_t para[FDLONG_STACKDEPTH][64];
|
||||||
|
uint8_t cmdsInQueue;
|
||||||
|
} FDLong;
|
||||||
|
|
||||||
// storeInData.cpp
|
struct {
|
||||||
bool indat_savePrnPwr;
|
uint8_t DataParameters[4];
|
||||||
bool indat_saveMifPwr;
|
uint8_t DataBufferUser;
|
||||||
bool indat_MdbIsOn;
|
uint8_t pDataBuff; // points to next PRINTER_BLOCK
|
||||||
#endif
|
} prn;
|
||||||
|
|
||||||
uint8_t ndbs;
|
struct {
|
||||||
uint8_t pari;
|
bool savePrnPwr;
|
||||||
uint8_t nsb;
|
bool saveMifPwr;
|
||||||
uint8_t br;
|
bool MdbIsOn;
|
||||||
|
} indat;
|
||||||
|
|
||||||
|
uint8_t ndbs;
|
||||||
|
uint8_t pari;
|
||||||
|
uint8_t nsb;
|
||||||
|
uint8_t br;
|
||||||
|
|
||||||
#define MAXNROF_GENSTR 16
|
#define MAXNROF_GENSTR 16
|
||||||
char genStrings[MAXNROF_GENSTR][64];
|
char genStrings[MAXNROF_GENSTR][64];
|
||||||
@ -176,10 +217,13 @@ struct SharedMemBuffer {
|
|||||||
#define NROFMIFSTATEBYTES 40
|
#define NROFMIFSTATEBYTES 40
|
||||||
#define PRN_STATE_ARRAY_SIZE 20
|
#define PRN_STATE_ARRAY_SIZE 20
|
||||||
#define PRN_STATE_FONT_SIZE 20
|
#define PRN_STATE_FONT_SIZE 20
|
||||||
|
#define MAXNROF_PRNBYTES 64
|
||||||
|
#define MAXNROF_PRNBLOCKS 20
|
||||||
uint8_t MIF_STATE[NROFMIFSTATEBYTES];
|
uint8_t MIF_STATE[NROFMIFSTATEBYTES];
|
||||||
uint8_t MIF_DATA[12][64];
|
uint8_t MIF_DATA[12][64];
|
||||||
uint8_t PRN_STATE[PRN_STATE_ARRAY_SIZE];
|
uint8_t PRN_STATE[PRN_STATE_ARRAY_SIZE];
|
||||||
uint8_t PRN_FONTS[PRN_STATE_FONT_SIZE];
|
uint8_t PRN_FONTS[PRN_STATE_FONT_SIZE];
|
||||||
|
char PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
|
||||||
bool mdb_busRdy;
|
bool mdb_busRdy;
|
||||||
bool mdb_V12on;
|
bool mdb_V12on;
|
||||||
bool mdb_V5on;
|
bool mdb_V5on;
|
||||||
@ -199,12 +243,15 @@ struct SharedMemBuffer {
|
|||||||
uint8_t pProtResultOk;
|
uint8_t pProtResultOk;
|
||||||
uint16_t receivedDataLength;
|
uint16_t receivedDataLength;
|
||||||
uint8_t receivedDataBlock[64];
|
uint8_t receivedDataBlock[64];
|
||||||
|
uint8_t rawData[150];
|
||||||
|
uint8_t LengthRawData;
|
||||||
|
uint8_t mdbSendBuffer[64];
|
||||||
|
uint8_t mdbSendLen;
|
||||||
} Sdata;
|
} Sdata;
|
||||||
|
|
||||||
uint8_t mif_cardType;
|
uint8_t mif_cardType;
|
||||||
uint8_t mif_cardHolder[8];
|
uint8_t mif_cardHolder[8];
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define MEMDEPTH_GOTCOINS (16)
|
#define MEMDEPTH_GOTCOINS (16)
|
||||||
struct T_coin {
|
struct T_coin {
|
||||||
uint8_t valid;
|
uint8_t valid;
|
||||||
@ -214,7 +261,6 @@ struct SharedMemBuffer {
|
|||||||
uint16_t value;
|
uint16_t value;
|
||||||
} gotCoin[MEMDEPTH_GOTCOINS];
|
} gotCoin[MEMDEPTH_GOTCOINS];
|
||||||
uint8_t ctr_gotCoin;
|
uint8_t ctr_gotCoin;
|
||||||
#endif
|
|
||||||
|
|
||||||
struct store {
|
struct store {
|
||||||
uint32_t insertedAmount;
|
uint32_t insertedAmount;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define MAXNROF_AO 3
|
#define MAXNROF_AO 3
|
||||||
#define MAXNROF_GENSTR 16
|
//#define MAXNROF_GENSTR 16
|
||||||
#define MAXNROF_CONTR_PORTS 11
|
#define MAXNROF_CONTR_PORTS 11
|
||||||
#define MAXNROF_DIports 2
|
#define MAXNROF_DIports 2
|
||||||
#define MAXNROF_DOports 2
|
#define MAXNROF_DOports 2
|
||||||
@ -32,9 +32,6 @@ bool indat_isMifareOn();
|
|||||||
void indat_storeMDBisOn(bool isOn);
|
void indat_storeMDBisOn(bool isOn);
|
||||||
bool indat_isMdbOn();
|
bool indat_isMdbOn();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
||||||
uint8_t parity, uint8_t NrStopBits);
|
uint8_t parity, uint8_t NrStopBits);
|
||||||
|
|
||||||
@ -43,29 +40,16 @@ void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
|||||||
|
|
||||||
QString epi_getSlaveParamSTR();
|
QString epi_getSlaveParamSTR();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeGenerals(uint8_t genNr, QString text);
|
void gpi_storeGenerals(uint8_t genNr, QString text);
|
||||||
// 0=HW 1=SW 2=State
|
// 0=HW 1=SW 2=State
|
||||||
|
|
||||||
QString epi_loadGenerals(uint8_t genNr);
|
QString epi_loadGenerals(uint8_t genNr);
|
||||||
// genNr=0=HW 1=SW 2=State
|
// genNr=0=HW 1=SW 2=State
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeUID(uint8_t const *buf8byteUid);
|
void gpi_storeUID(uint8_t const *buf8byteUid);
|
||||||
//void gpi_storeUID(uint8_t *buf8byteUid);
|
|
||||||
// buffer size: 8 byte
|
// buffer size: 8 byte
|
||||||
|
|
||||||
void epi_getUIDdec(uint8_t *buf8byteUid);
|
void epi_getUIDdec(uint8_t *buf8byteUid);
|
||||||
// buffer size: 8 byte
|
// buffer size: 8 byte
|
||||||
|
|
||||||
QString epi_getUIDstr();
|
QString epi_getUIDstr();
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +79,7 @@ void epi_getSpecialYearTimeDate(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint
|
|||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#define MAXNROF_AI 4
|
// #define MAXNROF_AI 4
|
||||||
|
|
||||||
void gpi_storeAIs(uint8_t aiNr, uint16_t val); // rs -> Sdata
|
void gpi_storeAIs(uint8_t aiNr, uint16_t val); // rs -> Sdata
|
||||||
|
|
||||||
@ -144,185 +128,119 @@ void gpi_storeDI_optos(uint8_t indatOpto);
|
|||||||
uint8_t epi_getDI_optos(void);
|
uint8_t epi_getDI_optos(void);
|
||||||
// bit0: opto in 1 1: opto in 2
|
// bit0: opto in 1 1: opto in 2
|
||||||
|
|
||||||
void gpi_storeDI_auxIn(uint8_t indatAuxIn);
|
uint8_t gpi_storeDI_auxIn(uint8_t indatAuxIn); // Aux0...5
|
||||||
// Aux0...5
|
uint8_t epi_getDI_auxIn(void); // bit0: auxin 1 ... 5: auxin 6
|
||||||
|
|
||||||
uint8_t epi_getDI_auxIn(void);
|
|
||||||
// bit0: auxin 1 ... 5: auxin 6
|
|
||||||
|
|
||||||
void gpi_storeDI_ptuWake(uint8_t indat);
|
|
||||||
|
|
||||||
|
bool gpi_storeDI_ptuWake(bool w);
|
||||||
bool epi_getDI_ptuWake(void);
|
bool epi_getDI_ptuWake(void);
|
||||||
|
|
||||||
void gpi_storeDI_mbdWake(uint8_t indat);
|
bool gpi_storeDI_mbdWake(bool w);
|
||||||
|
|
||||||
bool epi_getDI_mdbWake(void);
|
bool epi_getDI_mdbWake(void);
|
||||||
|
|
||||||
void gpi_storeDI_prnReady(uint8_t indat);
|
bool gpi_storeDI_prnReady(bool ready);
|
||||||
|
|
||||||
bool epi_getDI_prnReady(void);
|
bool epi_getDI_prnReady(void);
|
||||||
|
|
||||||
void gpi_storeDI_CoinAttach(uint8_t indat);
|
bool gpi_storeDI_CoinAttach(bool attach);
|
||||||
|
|
||||||
bool epi_getDI_CoinAttach(void);
|
bool epi_getDI_CoinAttach(void);
|
||||||
|
|
||||||
void gpi_storeDI_CoinEscrow(uint8_t indat);
|
bool gpi_storeDI_CoinEscrow(bool ce);
|
||||||
|
|
||||||
bool epi_getDI_CoinEscrow(void);
|
bool epi_getDI_CoinEscrow(void);
|
||||||
|
|
||||||
void gpi_storeDI_mifareCardTapped(uint8_t indat);
|
bool gpi_storeDI_mifareCardTapped(bool tapped);
|
||||||
|
|
||||||
bool epi_getDI_mifareCardTapped(void);
|
bool epi_getDI_mifareCardTapped(void);
|
||||||
|
|
||||||
void gpi_storeDI_modemWake(uint8_t indat);
|
bool gpi_storeDI_modemWake(bool w);
|
||||||
|
|
||||||
bool epi_getDI_modemWake(void);
|
bool epi_getDI_modemWake(void);
|
||||||
|
|
||||||
|
bool gpi_storeDI_contactPowerIsOn(bool on);
|
||||||
void gpi_storeDI_contactPowerIsOn(bool di_contact_PwrOn);
|
|
||||||
|
|
||||||
bool epi_getDI_contactPwr(void);
|
bool epi_getDI_contactPwr(void);
|
||||||
|
|
||||||
void gpi_storeDI_MifarePowerIsOn(bool di_mifare_PwrOn);
|
bool gpi_storeDI_MifarePowerIsOn(bool on);
|
||||||
|
|
||||||
bool epi_getDI_mifarePwr(void);
|
bool epi_getDI_mifarePwr(void);
|
||||||
|
|
||||||
void gpi_storeDI_readbackMdbTxD(bool di_rdbkMdbTxd);
|
bool gpi_storeDI_readbackMdbTxD(bool rdbkMdbTxd);
|
||||||
|
|
||||||
bool epi_getDI_mdbTxd(void);
|
bool epi_getDI_mdbTxd(void);
|
||||||
|
|
||||||
void gpi_storeDI_AuxPowerIsOn(bool di_Aux_PwrOn);
|
bool gpi_storeDI_AuxPowerIsOn(bool on);
|
||||||
|
|
||||||
bool epi_getDI_auxPwr(void);
|
bool epi_getDI_auxPwr(void);
|
||||||
|
|
||||||
void gpi_storeDI_GsmPowerIsOn(bool di_gsm_PwrOn);
|
bool gpi_storeDI_GsmPowerIsOn(bool on);
|
||||||
|
|
||||||
bool epi_getDI_gsmPwr(void);
|
bool epi_getDI_gsmPwr(void);
|
||||||
|
|
||||||
void gpi_storeDI_CreditPowerIsOn(bool di_credit_PwrOn);
|
bool gpi_storeDI_CreditPowerIsOn(bool on);
|
||||||
|
|
||||||
bool epi_getDI_creditPwr(void);
|
bool epi_getDI_creditPwr(void);
|
||||||
|
|
||||||
void gpi_storeDI_PrinterPowerIsOn(bool di_printer_PwrOn);
|
bool gpi_storeDI_PrinterPowerIsOn(bool on);
|
||||||
|
|
||||||
bool epi_getDI_printerPwr(void);
|
bool epi_getDI_printerPwr(void);
|
||||||
|
|
||||||
void gpi_storeDI_MdbPowerIsOn(bool di_mdb_PwrOn);
|
bool gpi_storeDI_MdbPowerIsOn(bool on);
|
||||||
|
|
||||||
bool epi_getDI_mdbPwr(void);
|
bool epi_getDI_mdbPwr(void);
|
||||||
|
|
||||||
|
bool gpi_storeDI_rejMot_home(bool reject);
|
||||||
void gpi_storeDI_rejMot_home(bool di);
|
|
||||||
|
|
||||||
bool epi_getDI_rejectMotor_homepos(void);
|
bool epi_getDI_rejectMotor_homepos(void);
|
||||||
|
|
||||||
void gpi_storeDI_paperLow(uint8_t di);
|
uint8_t gpi_storeDI_paperLow(uint8_t di);
|
||||||
|
|
||||||
uint8_t epi_getDI_npe_sensor(void);
|
uint8_t epi_getDI_npe_sensor(void);
|
||||||
// 0: Sensor sees paper 1: no paper 99: off
|
// 0: Sensor sees paper 1: no paper 99: off
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// readback digital outputs
|
// readback digital outputs
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void gpi_storeDO_mdbRxTst(uint8_t do_mbdRxTst);
|
uint8_t gpi_storeDO_mdbRxTst(uint8_t do_mbdRxTst);
|
||||||
|
|
||||||
bool epi_getDO_mdbRxTestOut(void);
|
bool epi_getDO_mdbRxTestOut(void);
|
||||||
|
|
||||||
|
uint8_t gpi_storeDO_motorOutputs(uint8_t Pwr);
|
||||||
void gpi_storeDO_motorOutputs(uint8_t Pwr);
|
|
||||||
|
|
||||||
uint8_t epi_getDO_motorOuts(void);
|
uint8_t epi_getDO_motorOuts(void);
|
||||||
// bit0: upper lock forward bit 1 backward
|
// bit0: upper lock forward bit 1 backward
|
||||||
// bit2: lower lock forward bit 3 backward
|
// bit2: lower lock forward bit 3 backward
|
||||||
|
|
||||||
|
uint8_t gpi_storeDO_serialSwitch(uint8_t state);
|
||||||
void gpi_storeDO_serialSwitch(uint8_t state);
|
|
||||||
// serial drv on/off, Serial mux1, Serial mux2
|
// serial drv on/off, Serial mux1, Serial mux2
|
||||||
|
|
||||||
uint8_t epi_getDO_serialSwitch(void);
|
uint8_t epi_getDO_serialSwitch(void);
|
||||||
// serial drv on/off, Serial mux1, Serial mux2
|
// serial drv on/off, Serial mux1, Serial mux2
|
||||||
|
|
||||||
bool epi_getDO_serialDriverIsOn(void);
|
bool epi_getDO_serialDriverIsOn(void);
|
||||||
|
|
||||||
bool epi_getDO_serialMux1isSetToPrinter(void);
|
bool epi_getDO_serialMux1isSetToPrinter(void);
|
||||||
// mux1 off: serial is switched to printer
|
// mux1 off: serial is switched to printer
|
||||||
|
|
||||||
bool epi_getDO_serialMux1isSetToModem(void);
|
bool epi_getDO_serialMux1isSetToModem(void);
|
||||||
// mux1 on: serial is switched to modem
|
// mux1 on: serial is switched to modem
|
||||||
|
|
||||||
bool epi_getDO_serialMux2isSetToCredit(void);
|
bool epi_getDO_serialMux2isSetToCredit(void);
|
||||||
// mux2 off: serial is switched to credit card terminal
|
// mux2 off: serial is switched to credit card terminal
|
||||||
|
|
||||||
bool epi_getDO_serialMux2isSetToMifare(void);
|
bool epi_getDO_serialMux2isSetToMifare(void);
|
||||||
// mux2 on: serial is switched to mifare reader
|
// mux2 on: serial is switched to mifare reader
|
||||||
|
|
||||||
|
uint8_t gpi_storeDO_ledsAndFan(uint8_t ledState);
|
||||||
void gpi_storeDO_ledsAndFan(uint8_t ledState);
|
|
||||||
|
|
||||||
bool epi_getDO_led_coin(void);
|
bool epi_getDO_led_coin(void);
|
||||||
|
|
||||||
bool epi_getDO_led_front(void);
|
bool epi_getDO_led_front(void);
|
||||||
|
|
||||||
bool epi_getDO_led_ticket(void);
|
bool epi_getDO_led_ticket(void);
|
||||||
|
|
||||||
bool epi_getDO_led_pin(void);
|
bool epi_getDO_led_pin(void);
|
||||||
|
|
||||||
bool epi_getDO_led_start(void);
|
bool epi_getDO_led_start(void);
|
||||||
|
|
||||||
bool epi_getDO_led_inside(void);
|
bool epi_getDO_led_inside(void);
|
||||||
|
|
||||||
bool epi_getDO_fan(void);
|
bool epi_getDO_fan(void);
|
||||||
|
|
||||||
void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay);
|
uint8_t gpi_storeDO_sirenAndRelay(uint8_t sirenRelay);
|
||||||
|
|
||||||
bool epi_getDO_sirene(void);
|
bool epi_getDO_sirene(void);
|
||||||
|
|
||||||
bool epi_getDO_relay(void);
|
bool epi_getDO_relay(void);
|
||||||
|
|
||||||
void gpi_storeDO_ptuWake(uint8_t state);
|
uint8_t gpi_storeDO_ptuWake(uint8_t state);
|
||||||
|
|
||||||
bool epi_getDO_ptuWake(void);
|
bool epi_getDO_ptuWake(void);
|
||||||
|
|
||||||
void gpi_storeDO_auxPower(uint8_t pwr);
|
uint8_t gpi_storeDO_auxPower(uint8_t pwr);
|
||||||
|
|
||||||
bool epi_getDO_auxPower(void);
|
bool epi_getDO_auxPower(void);
|
||||||
|
|
||||||
|
uint8_t gpi_storeDO_coinShutter(uint8_t state);
|
||||||
void gpi_storeDO_coinShutter(uint8_t state);
|
|
||||||
|
|
||||||
bool epi_getDO_coinShutterOpen(void);
|
bool epi_getDO_coinShutterOpen(void);
|
||||||
|
|
||||||
bool epi_getDO_coinShutterTest(void);
|
bool epi_getDO_coinShutterTest(void);
|
||||||
|
|
||||||
|
uint8_t gpi_storeDO_coinEscrow(uint8_t state);
|
||||||
void gpi_storeDO_coinEscrow(uint8_t state);
|
|
||||||
|
|
||||||
uint8_t epi_getDO_coinEscrow(void);
|
uint8_t epi_getDO_coinEscrow(void);
|
||||||
// retval: 1:return flap is open 2:take flap is open 0:closed
|
// retval: 1:return flap is open 2:take flap is open 0:closed
|
||||||
|
|
||||||
|
uint8_t gpi_storeDO_printerPwrOn(uint8_t state);
|
||||||
void gpi_storeDO_printerPwrOn(uint8_t state);
|
|
||||||
|
|
||||||
uint8_t epi_getDO_printerPwr(void);
|
uint8_t epi_getDO_printerPwr(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------
|
||||||
// counterchecks, make sure that DC-outputs are correct
|
// counterchecks, make sure that DC-outputs are correct
|
||||||
|
|
||||||
@ -369,21 +287,14 @@ bool epi_cntchk_Mot2Fon(void);
|
|||||||
|
|
||||||
uint8_t gpi_storeMdbRecData(uint8_t length, uint8_t *buf);
|
uint8_t gpi_storeMdbRecData(uint8_t length, uint8_t *buf);
|
||||||
// datif store received mdb data
|
// datif store received mdb data
|
||||||
|
|
||||||
uint8_t epi_getMdbResponse(void);
|
uint8_t epi_getMdbResponse(void);
|
||||||
// 0=no response 1=ACK 2=NAK 3=ACK with data
|
// 0=no response 1=ACK 2=NAK 3=ACK with data
|
||||||
|
|
||||||
uint8_t epi_getMdbRecLength(void);
|
uint8_t epi_getMdbRecLength(void);
|
||||||
// 0...31
|
// 0...31
|
||||||
|
|
||||||
uint8_t epi_restoreMdbRecData(uint8_t *buf);
|
uint8_t epi_restoreMdbRecData(uint8_t *buf);
|
||||||
// hwapi reads received mdb data from PI
|
// hwapi reads received mdb data from PI
|
||||||
|
|
||||||
|
uint8_t gpi_storeMifReaderStateAndCardType(uint8_t const *buf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t gpi_storeMifReaderStateAndCardType(uint8_t *buf);
|
|
||||||
|
|
||||||
/* data description:
|
/* data description:
|
||||||
byte 0: current read state: 0=power off 1=reader-fault 2=ready
|
byte 0: current read state: 0=power off 1=reader-fault 2=ready
|
||||||
@ -407,41 +318,24 @@ byte 32: result, always 0
|
|||||||
|
|
||||||
uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize);
|
uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize);
|
||||||
// retval 0=OK 1=error host buffer too small
|
// retval 0=OK 1=error host buffer too small
|
||||||
|
bool gpi_storeMifCardData(uint8_t blkNr, uint8_t const *receivedData);
|
||||||
void gpi_storeMifCardData(uint8_t blkNr, uint8_t *receivedData);
|
|
||||||
// blkNr=0...11 receivedData[64]
|
// blkNr=0...11 receivedData[64]
|
||||||
|
|
||||||
uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize);
|
uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize);
|
||||||
// blkNr=0...11 return buf[64]
|
// blkNr=0...11 return buf[64]
|
||||||
// retval: 1=error 0=OK
|
// retval: 1=error 0=OK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define pi_prnStateArraySize 20
|
|
||||||
#define pi_prnFontArraySize 20
|
|
||||||
|
|
||||||
void epi_restorePrinterState(uint8_t *buf);
|
void epi_restorePrinterState(uint8_t *buf);
|
||||||
|
void gpi_storePrinterState(uint8_t const *buf);
|
||||||
void gpi_storePrinterState(uint8_t *buf);
|
|
||||||
|
|
||||||
void epi_restorePrinterFonts(uint8_t *buf);
|
void epi_restorePrinterFonts(uint8_t *buf);
|
||||||
|
void gpi_storePrinterFonts(uint8_t const *buf);
|
||||||
|
|
||||||
void gpi_storePrinterFonts(uint8_t *buf);
|
bool gpi_storeMdbState(bool busReady, bool V12on, bool V5on);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeMdbState(uint8_t busReady, uint8_t V12on, uint8_t V5on );
|
|
||||||
|
|
||||||
bool epi_restoreMdbBusReady(void);
|
bool epi_restoreMdbBusReady(void);
|
||||||
|
|
||||||
bool epi_restoreMdbV12Ready(void);
|
bool epi_restoreMdbV12Ready(void);
|
||||||
|
|
||||||
bool epi_restoreMdbV5Ready(void);
|
bool epi_restoreMdbV5Ready(void);
|
||||||
|
|
||||||
|
void gpi_storeMdbResponse(uint8_t leng, uint8_t const *data);
|
||||||
void gpi_storeMdbResponse(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data);
|
void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data);
|
||||||
// last received mdb answer (from mdb device)
|
// last received mdb answer (from mdb device)
|
||||||
// only needed if a special command was sent directly
|
// only needed if a special command was sent directly
|
||||||
@ -450,12 +344,9 @@ void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data);
|
|||||||
// DB2: nr of received (payload) data bytes (apart from ACK, can be 0....34)
|
// DB2: nr of received (payload) data bytes (apart from ACK, can be 0....34)
|
||||||
// DB3...DB38: rec.data (payload)
|
// DB3...DB38: rec.data (payload)
|
||||||
|
|
||||||
|
void gpi_storeEmpSettings(uint8_t leng, uint8_t const *data);
|
||||||
void gpi_storeEmpSettings(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data);
|
void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data);
|
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data);
|
||||||
|
|
||||||
@ -469,108 +360,61 @@ void epi_restoreEmpCoinSignal(uint8_t *leng, uint8_t *data);
|
|||||||
void epi_clearEmpCoinSignal();
|
void epi_clearEmpCoinSignal();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MEMDEPTH_GOTCOINS 16
|
|
||||||
|
|
||||||
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data);
|
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t const *data);
|
||||||
|
|
||||||
uint8_t epi_isNewCoinLeft(void);
|
uint8_t epi_isNewCoinLeft(void);
|
||||||
// retval: 0...16 coins left in FIFO
|
// retval: 0...16 coins left in FIFO
|
||||||
|
|
||||||
void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value);
|
void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value);
|
||||||
|
|
||||||
|
void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t const *data);
|
||||||
|
|
||||||
void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data);
|
void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
void gpi_storeMachineIDsettings(uint8_t leng, uint8_t const *data);
|
||||||
void gpi_storeMachineIDsettings(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data);
|
void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void epi_clearCurrentPayment(void);
|
void epi_clearCurrentPayment(void);
|
||||||
|
|
||||||
void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue);
|
void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue);
|
||||||
|
|
||||||
uint32_t epi_CurrentPaymentGetAmount(void);
|
uint32_t epi_CurrentPaymentGetAmount(void);
|
||||||
|
|
||||||
uint16_t epi_CurrentPaymentGetLastCoin(void);
|
uint16_t epi_CurrentPaymentGetLastCoin(void);
|
||||||
|
|
||||||
bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values);
|
bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values);
|
||||||
// alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht
|
// alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht
|
||||||
|
|
||||||
|
void gpi_storeWakeSources(uint8_t const *receivedData);
|
||||||
void gpi_storeWakeSources(uint8_t *receivedData);
|
|
||||||
|
|
||||||
uint64_t epi_getWakeSources(void);
|
uint64_t epi_getWakeSources(void);
|
||||||
|
|
||||||
uint8_t epi_getWakeReason(void);
|
void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeExtendedTime(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data);
|
void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
void gpi_storeDeviceConditions(uint8_t leng, uint8_t const *data);
|
||||||
|
|
||||||
void gpi_storeDeviceConditions(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data);
|
void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data);
|
||||||
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
|
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t const *data);
|
||||||
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data);
|
|
||||||
|
|
||||||
void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs);
|
void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs);
|
||||||
// return accNrs[0..7]
|
// return accNrs[0..7]
|
||||||
|
|
||||||
|
|
||||||
void epi_iniVRstorage(void);
|
void epi_iniVRstorage(void);
|
||||||
|
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t const *data);
|
||||||
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data );
|
|
||||||
|
|
||||||
bool epi_checkIfVaultRecordAvailable(void);
|
bool epi_checkIfVaultRecordAvailable(void);
|
||||||
|
bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf);
|
||||||
bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf );
|
|
||||||
// true if completly received
|
// true if completly received
|
||||||
|
|
||||||
void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins );
|
void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins);
|
||||||
|
|
||||||
uint32_t epi_getCashBoxContent(void);
|
uint32_t epi_getCashBoxContent(void);
|
||||||
|
|
||||||
uint16_t epi_getNrOfCoinsInCashBox(void);
|
uint16_t epi_getNrOfCoinsInCashBox(void);
|
||||||
|
|
||||||
void gpi_storeNewMifareCard(uint8_t typ, uint8_t *holder );
|
void gpi_storeNewMifareCard(uint8_t typ, uint8_t const *holder);
|
||||||
|
|
||||||
uint8_t epi_mifGetCardType(uint8_t *holder);
|
uint8_t epi_mifGetCardType(uint8_t const *holder);
|
||||||
//holder[8] = name of card holder
|
//holder[8] = name of card holder
|
||||||
// retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
|
// retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
|
||||||
|
|
||||||
void gpi_storeDcDataValid(bool isVal);
|
|
||||||
|
|
||||||
bool epi_areDcDataValid();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void epi_clearDynData(void);
|
|
||||||
|
|
||||||
void gpi_storeDynData(uint8_t *DCdynDat);
|
|
||||||
// buffer size: 64 byte
|
|
||||||
|
|
||||||
bool epi_getDynPrnData(uint8_t *DCdynDat);
|
|
||||||
// buffer size: 64 byte
|
|
||||||
// return true if data are new and valid
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,21 +24,13 @@ struct T_emp
|
|||||||
|
|
||||||
// dynamic:
|
// dynamic:
|
||||||
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
||||||
// 0=start command
|
// 0=Emp & Bus power off, 1=powered, poll off 2=polling on
|
||||||
// 1=powered, do emp ini, send reset
|
// 3=device responded, requesting status
|
||||||
// 2=delay
|
// 4=waiting for status 5=have status,
|
||||||
// 3=wait for response, requesting status after response
|
// 6: IDLE, have paramters from master, polling running, ready for payment
|
||||||
// 4,5 through, startup
|
// Master can stop/start polling and acceptance
|
||||||
// 6: wait for status
|
// 7: end of transaction, polling on, accept off, reporting coins, (wait for last coin)
|
||||||
// 7: through, startup
|
// 8: transaction running, polling on, acceptance on, reporting coins,
|
||||||
// 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 pollingRunning;
|
||||||
uint8_t paymentRunning;
|
uint8_t paymentRunning;
|
||||||
@ -88,7 +80,6 @@ struct Tprn_hw_state
|
|||||||
bool nowAligned;
|
bool nowAligned;
|
||||||
};
|
};
|
||||||
|
|
||||||
// obsolete
|
|
||||||
struct T_dynDat
|
struct T_dynDat
|
||||||
{
|
{
|
||||||
uint8_t licensePlate[8];
|
uint8_t licensePlate[8];
|
||||||
@ -131,17 +122,17 @@ struct T_vaultRecord
|
|||||||
//16
|
//16
|
||||||
char label3buffer[4]; // mw >
|
char label3buffer[4]; // mw >
|
||||||
|
|
||||||
// Verkauf, Tür zu:
|
// Verkauf, Tür zu:
|
||||||
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||||
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||||
//88
|
//88
|
||||||
|
|
||||||
// Service, Tür offen:
|
// Service, Tür offen:
|
||||||
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||||
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||||
uint16_t resint3;
|
uint16_t resint3;
|
||||||
uint16_t resint4;
|
uint16_t resint4;
|
||||||
uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand
|
uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand
|
||||||
uint16_t resint5;
|
uint16_t resint5;
|
||||||
uint16_t resint6;
|
uint16_t resint6;
|
||||||
// 56
|
// 56
|
||||||
@ -176,29 +167,30 @@ struct T_moduleCondition
|
|||||||
// 100..150 = WARNING
|
// 100..150 = WARNING
|
||||||
// 200..250 = ERROR
|
// 200..250 = ERROR
|
||||||
|
|
||||||
uint8_t ram;
|
uint8_t structStart; // always first!!!
|
||||||
uint8_t intEe;
|
uint8_t ram; // v
|
||||||
uint8_t extEe;
|
uint8_t intEe; // v
|
||||||
|
uint8_t extEe; // v
|
||||||
|
|
||||||
uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error
|
uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error
|
||||||
uint8_t boardHw;
|
uint8_t boardHw; // v
|
||||||
uint8_t printer;
|
uint8_t printer; // v
|
||||||
uint8_t modem;
|
uint8_t modem; // v
|
||||||
|
|
||||||
uint8_t signal; // 1...99
|
uint8_t signal; // 1...99
|
||||||
uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime
|
uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime
|
||||||
uint8_t mdbBus;
|
uint8_t mdbBus;
|
||||||
uint8_t coinChecker; // EMP, OMP or mei-cashflow
|
uint8_t coinChecker; // EMP, OMP or mei-cashflow
|
||||||
|
|
||||||
uint8_t coinEscrow;
|
uint8_t coinEscrow; // v
|
||||||
uint8_t mifareReader;
|
uint8_t mifareReader; // v
|
||||||
uint8_t creditTerm;
|
uint8_t creditTerm; // not available
|
||||||
uint8_t coinReject;
|
uint8_t coinReject; // v
|
||||||
|
|
||||||
uint8_t coinSafe;
|
uint8_t coinSafe; // v
|
||||||
uint8_t billSafe;
|
uint8_t billSafe; // v
|
||||||
uint8_t voltage; // 1:11..14V
|
uint8_t voltage; // v // 1:11..14V
|
||||||
uint8_t temper;
|
uint8_t temper; // v
|
||||||
|
|
||||||
uint8_t poweronTest;
|
uint8_t poweronTest;
|
||||||
uint8_t doorState; // 1: alles zu 200: t?r offen + bit1(S) +bit2(CB) + bit3(CB)
|
uint8_t doorState; // 1: alles zu 200: t?r offen + bit1(S) +bit2(CB) + bit3(CB)
|
||||||
@ -219,132 +211,62 @@ struct T_moduleCondition
|
|||||||
|
|
||||||
struct T_dynamicCondition
|
struct T_dynamicCondition
|
||||||
{
|
{
|
||||||
char allDoorsDebounced;
|
// dynamic conditions, change rapidly and frequently
|
||||||
char openedAuthorized;
|
// these are values for the Heartbeat
|
||||||
uint8_t CBinDebounced; // 0:fehlt 1:drin
|
|
||||||
char upperDoor; // 99: undefined 0:closed 1:open
|
// T?rschalter entprellt:
|
||||||
char middleDoor; // 99: undefined 0:closed 1:open
|
char upperDoor; // 0:fehlt 1:drin
|
||||||
char lowerDoor; // 99: undefined 0:closed 1:open
|
char middleDoor;
|
||||||
char reserve;
|
char lowerDoor;
|
||||||
|
char coinBox;
|
||||||
|
|
||||||
char billBox;
|
char billBox;
|
||||||
char modeAbrech;
|
char modeAbrech;
|
||||||
char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest
|
char onAlarm;
|
||||||
char nowCardTest;
|
char nowCardTest;
|
||||||
char nowPayment; // not used, always 0
|
|
||||||
|
char nowPayment;
|
||||||
char lastMifCardType;
|
char lastMifCardType;
|
||||||
|
char openedAuthorized;
|
||||||
|
char allDoorsDebounced;
|
||||||
|
|
||||||
uint8_t lastSDoorState;
|
uint8_t lastSDoorState;
|
||||||
uint8_t lastVDoorState;
|
uint8_t lastVDoorState;
|
||||||
|
uint8_t CBinDebounced;
|
||||||
uint8_t lastCBstate;
|
uint8_t lastCBstate;
|
||||||
char paymentInProgress;
|
|
||||||
// 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
|
|
||||||
|
|
||||||
|
char paymentInProgress;
|
||||||
|
char res1;
|
||||||
|
char res2;
|
||||||
|
char res3;
|
||||||
|
|
||||||
char res1;
|
uint16_t U_Batt;
|
||||||
uint16_t U_Batt;
|
|
||||||
uint16_t Temperatur;
|
uint16_t Temperatur;
|
||||||
|
|
||||||
|
uint16_t cash_storedaccNumbers[8]; // List all stored accounting numbers in ext. eeprom
|
||||||
|
|
||||||
uint16_t nrCoinsInBox;
|
uint16_t nrCoinsInBox;
|
||||||
|
uint16_t resui1;
|
||||||
|
|
||||||
uint32_t amountInBox;
|
uint32_t amountInBox;
|
||||||
|
uint32_t amountJustPaid;
|
||||||
|
|
||||||
|
uint16_t lastInsCoinType; // wahrscheinlich uchar
|
||||||
|
uint16_t resui2;
|
||||||
|
|
||||||
uint32_t totalTransVolume;
|
uint32_t totalTransVolume;
|
||||||
uint32_t totalNrOfVends;
|
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 c² (MW)
|
|
||||||
UCHAR kindOfMifareReader; // by now only stronglink SL025 =1
|
|
||||||
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;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class hwinf
|
class hwinf
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||||
|
enum class FileTypeJson {CONFIG=1, DEVICE, CASH, SERIAL, TIME, PRINTER};
|
||||||
|
|
||||||
virtual ~hwinf() {}
|
virtual ~hwinf() {}
|
||||||
|
|
||||||
|
|
||||||
@ -357,18 +279,18 @@ public:
|
|||||||
// Furthermore the Cashagent-Library answers with status strings about sending and reading result
|
// 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 =0;
|
virtual bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const = 0;
|
||||||
// Command: open serial interface
|
// Command: open serial interface
|
||||||
// BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
// BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
||||||
// BaudStr: for exapmle "19200"
|
// BaudStr: for exapmle "19200"
|
||||||
// ComName: for example "COM48"
|
// ComName: for example "COM48"
|
||||||
// connect: 0, 1
|
// connect: 0, 1
|
||||||
|
|
||||||
virtual void dc_closeSerial(void) const =0;
|
virtual bool dc_closeSerial(void) const = 0;
|
||||||
// Command: close serial interface in order to save power while power down
|
// Command: close serial interface in order to save power while power down
|
||||||
// or if another port must be used
|
// or if another port must be used
|
||||||
|
|
||||||
virtual bool dc_isPortOpen(void) const =0;
|
virtual bool dc_isPortOpen(void) const =0;
|
||||||
// returns true if port open (don't send unless open. Sending to closed port will crash program)
|
// returns true if port open (don't send unless open. Sending to closed port will crash program)
|
||||||
|
|
||||||
|
|
||||||
@ -379,7 +301,21 @@ public:
|
|||||||
|
|
||||||
virtual bool test_serialIsOn(void) const =0;
|
virtual bool test_serialIsOn(void) const =0;
|
||||||
|
|
||||||
|
virtual bool dc_updateDC(QString binFileName,
|
||||||
|
QString baudrate,
|
||||||
|
QString comPort) const = 0;
|
||||||
|
// download binary file down into device controller
|
||||||
|
|
||||||
|
virtual bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QVector<QString> fnames,
|
||||||
|
QString br,
|
||||||
|
QString serial) const = 0;
|
||||||
|
|
||||||
|
virtual bool dc_printTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QString br,
|
||||||
|
QString serial) const = 0;
|
||||||
|
|
||||||
virtual void dc_autoRequest(bool on) const =0;
|
virtual void dc_autoRequest(bool on) const =0;
|
||||||
// on = true: select that all READ-Requests are sent automatically
|
// on = true: select that all READ-Requests are sent automatically
|
||||||
@ -396,7 +332,7 @@ public:
|
|||||||
// get data back in "payLoad", max 64 byte, can be used for diagnosis
|
// get data back in "payLoad", max 64 byte, can be used for diagnosis
|
||||||
// retval = nr of bytes received. If host buffer too small then
|
// retval = nr of bytes received. If host buffer too small then
|
||||||
// only plBufSiz bytes are copied to "payLoad"
|
// only plBufSiz bytes are copied to "payLoad"
|
||||||
// plBufSizz=size of host buffer
|
// plBufSizz=size of host buffer
|
||||||
|
|
||||||
virtual void dc_requTestResponse() const =0;
|
virtual void dc_requTestResponse() const =0;
|
||||||
// tell DC2 to send a test-string, useful to see if cable and baudrate is OK
|
// tell DC2 to send a test-string, useful to see if cable and baudrate is OK
|
||||||
@ -517,10 +453,10 @@ public:
|
|||||||
|
|
||||||
// Analog values:
|
// Analog values:
|
||||||
virtual uint32_t dc_getTemperature(void) const =0;
|
virtual uint32_t dc_getTemperature(void) const =0;
|
||||||
// in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
|
// in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
|
||||||
|
|
||||||
virtual QString dc_getTemperaturStr(void) const =0;
|
virtual QString dc_getTemperaturStr(void) const =0;
|
||||||
// as string like "-12,5°C"
|
// as string like "-12,5°C"
|
||||||
|
|
||||||
virtual uint32_t dc_getVoltage(void) const =0;
|
virtual uint32_t dc_getVoltage(void) const =0;
|
||||||
// as value in mV, 0...65,535V
|
// as value in mV, 0...65,535V
|
||||||
@ -675,7 +611,7 @@ public:
|
|||||||
uint8_t kindOfModem, uint8_t kindOfCredit ) const =0;
|
uint8_t kindOfModem, uint8_t kindOfCredit ) const =0;
|
||||||
// enable hardware in device controller:
|
// enable hardware in device controller:
|
||||||
// kindOfPrinter: 0:off 1: GPT4672 (only this one implemented)
|
// kindOfPrinter: 0:off 1: GPT4672 (only this one implemented)
|
||||||
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer
|
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer
|
||||||
// kindOfMifareReader: 0:off 1: SL025 (only this one implemented)
|
// kindOfMifareReader: 0:off 1: SL025 (only this one implemented)
|
||||||
// suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason
|
// suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason
|
||||||
// kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented)
|
// kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented)
|
||||||
@ -781,7 +717,7 @@ public:
|
|||||||
// send 5 byte: byte 0,1: speed 5...250 mm/s
|
// send 5 byte: byte 0,1: speed 5...250 mm/s
|
||||||
// byte2: density 0....(25)....50
|
// byte2: density 0....(25)....50
|
||||||
// byte3: alignment 'l', 'c', 'r' = left, center, right
|
// byte3: alignment 'l', 'c', 'r' = left, center, right
|
||||||
// byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!)
|
// byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!)
|
||||||
// not batched! don't use twice within 100ms
|
// not batched! don't use twice within 100ms
|
||||||
|
|
||||||
virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0;
|
virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0;
|
||||||
@ -839,36 +775,29 @@ public:
|
|||||||
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
||||||
// example: print current time at this point (the time of printing not the storage time!!)
|
// example: print current time at this point (the time of printing not the storage time!!)
|
||||||
|
|
||||||
// obsolete
|
virtual void pri_startTicketDesign(void) const =0;
|
||||||
//virtual void pri_startTicketDesign(void) const =0;
|
|
||||||
// start for every new printer document, reseting collecting buffer
|
// start for every new printer document, reseting collecting buffer
|
||||||
|
|
||||||
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
||||||
// return val of the appending functions: true=ok false=too long, buffer full
|
// return val of the appending functions: true=ok false=too long, buffer full
|
||||||
|
|
||||||
// obsolete
|
virtual int pri_TD_getCurrentSize(void) const =0;
|
||||||
//virtual int pri_TD_getCurrentSize(void) const =0;
|
|
||||||
// retval: 0...1278
|
// retval: 0...1278
|
||||||
|
|
||||||
// obsolete
|
virtual bool pri_TD_addText(QByteArray text) const =0;
|
||||||
//virtual bool pri_TD_addText(QByteArray text) const =0;
|
|
||||||
// example: pri_TD_addText("Hello") const =0;
|
// example: pri_TD_addText("Hello") const =0;
|
||||||
// example: pri_TD_addText(tempStr) const =0;
|
// example: pri_TD_addText(tempStr) const =0;
|
||||||
// retval: true=ok false=too long, buffer full
|
// retval: true=ok false=too long, buffer full
|
||||||
|
|
||||||
// obsolete
|
virtual bool pri_TD_addValue(int val) const =0;
|
||||||
//virtual bool pri_TD_addValue(int val) const =0;
|
|
||||||
// +/- 0...2^(31)
|
// +/- 0...2^(31)
|
||||||
|
|
||||||
// obsolete
|
virtual bool pri_TD_addNewLine(void) const =0;
|
||||||
//virtual bool pri_TD_addNewLine(void) const =0;
|
|
||||||
|
|
||||||
// obsolete
|
virtual bool pri_TD_addSign(char sign) const =0;
|
||||||
//virtual bool pri_TD_addSign(char sign) const =0;
|
|
||||||
// example: '.' ' ' 0x20 'W' '$'
|
// example: '.' ' ' 0x20 'W' '$'
|
||||||
|
|
||||||
// obsolete
|
virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0;
|
||||||
//virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0;
|
|
||||||
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
||||||
/* complete list of possible commands:
|
/* complete list of possible commands:
|
||||||
group 50 : paper
|
group 50 : paper
|
||||||
@ -909,13 +838,11 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// obsolete
|
virtual char prn_clearDocument(uint8_t documentNumber) const =0;
|
||||||
//virtual char prn_clearDocument(uint8_t documentNumber) const =0;
|
|
||||||
// clear memory buffer for ONE document
|
// clear memory buffer for ONE document
|
||||||
// function takes a second! don't send right before "store doc"
|
// function takes a second! don't send right before "store doc"
|
||||||
|
|
||||||
// obsolete
|
virtual bool prn_store_Document(uint8_t documentNumber ) const =0;
|
||||||
//virtual bool prn_store_Document(uint8_t documentNumber ) const =0;
|
|
||||||
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
||||||
// documentNumber=0...15
|
// documentNumber=0...15
|
||||||
// maximal 1280 bytes each
|
// maximal 1280 bytes each
|
||||||
@ -926,8 +853,7 @@ public:
|
|||||||
// the place in the ticket layout is predefined (already in DC memory)
|
// the place in the ticket layout is predefined (already in DC memory)
|
||||||
// the dynamics are first calculated at printing time
|
// the dynamics are first calculated at printing time
|
||||||
|
|
||||||
// obsolete
|
virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0;
|
||||||
//virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0;
|
|
||||||
|
|
||||||
|
|
||||||
// 36
|
// 36
|
||||||
@ -1319,10 +1245,10 @@ public:
|
|||||||
|
|
||||||
virtual void bl_rebootDC(void) const =0;
|
virtual void bl_rebootDC(void) const =0;
|
||||||
|
|
||||||
virtual void bl_startBL(void) const =0;
|
virtual void bl_startBL(void) const = 0;
|
||||||
// send command within 4s after DC power-on, otherwise bl is left
|
// send command within 4s after DC power-on, otherwise bl is left
|
||||||
|
|
||||||
virtual void bl_checkBL(void) const =0;
|
virtual bool bl_checkBL(void) const = 0;
|
||||||
// send command to verify if bl is up
|
// send command to verify if bl is up
|
||||||
|
|
||||||
virtual bool bl_isUp(void) const =0;
|
virtual bool bl_isUp(void) const =0;
|
||||||
@ -1359,7 +1285,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Komplett-schreib Funktion, noch nicht getestet
|
// Komplett-schreib Funktion, noch nicht getestet
|
||||||
// Nachteil: keine Rückmeldung wie lang's noch dauert
|
// Nachteil: keine Rückmeldung wie lang's noch dauert
|
||||||
//virtual void bl_startSending(void) const=0;
|
//virtual void bl_startSending(void) const=0;
|
||||||
// call once after BL is working and file is loaded
|
// call once after BL is working and file is loaded
|
||||||
//virtual void bl_sendFile(void) const=0;
|
//virtual void bl_sendFile(void) const=0;
|
||||||
@ -1385,7 +1311,7 @@ public:
|
|||||||
buf[4]=GlobTime.Month;
|
buf[4]=GlobTime.Month;
|
||||||
buf[5]=GlobTime.Day;
|
buf[5]=GlobTime.Day;
|
||||||
buf[6]=GlobTime.DOW;
|
buf[6]=GlobTime.DOW;
|
||||||
buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master!
|
buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master!
|
||||||
uitmp=GlobTime.MinOfDay;
|
uitmp=GlobTime.MinOfDay;
|
||||||
buf[8]=swl_getOneByteFromUint(uitmp, 0);
|
buf[8]=swl_getOneByteFromUint(uitmp, 0);
|
||||||
buf[9]=swl_getOneByteFromUint(uitmp, 1);
|
buf[9]=swl_getOneByteFromUint(uitmp, 1);
|
||||||
@ -1445,8 +1371,6 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual bool rtc_getExtendedTime(struct T_extTime *exTime) const=0;
|
|
||||||
|
|
||||||
virtual bool sys_runCompleteTest(void) const=0;
|
virtual bool sys_runCompleteTest(void) const=0;
|
||||||
// warning: lasts 20s in one pace
|
// warning: lasts 20s in one pace
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
@ -1471,18 +1395,15 @@ public:
|
|||||||
// nr = 1..32
|
// nr = 1..32
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
|
|
||||||
virtual void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const=0;
|
virtual void log_getHoldAccountNumbers(uint32_t *accNr ) const=0;
|
||||||
// returns all acc nrs of the backuped vault records
|
// returns all acc nrs of the backuped vault records
|
||||||
// use: uint16_t backupedAccNumbers[8]
|
// use: uint32_t backupedAccNumbers[8]
|
||||||
|
|
||||||
virtual bool log_selectVaultRecord(uint16_t accountNr ) const=0;
|
virtual bool log_selectVaultRecord(uint16_t accountNr ) const=0;
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
// and trigger transfer
|
|
||||||
|
|
||||||
virtual bool log_chkIfVaultRecordAvailable(void) const=0;
|
//request, isAvailable
|
||||||
// return true if completly received
|
virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||||
|
|
||||||
virtual bool log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
|
||||||
// which was selected by: log_selectVaultRecord()
|
// which was selected by: log_selectVaultRecord()
|
||||||
// to be forwarded to Ismas
|
// to be forwarded to Ismas
|
||||||
|
|
||||||
@ -1492,19 +1413,7 @@ public:
|
|||||||
virtual bool prn_printTestTicket(void) const=0;
|
virtual bool prn_printTestTicket(void) const=0;
|
||||||
// return true if sending to DC OK, false if cmd-stack is full
|
// return true if sending to DC OK, false if cmd-stack is full
|
||||||
|
|
||||||
virtual bool cash_startPayment(uint32_t amount) const=0;
|
virtual bool cash_startPayment(uint16_t amount) const=0;
|
||||||
// 17.4.23TS: extended to 32bit
|
|
||||||
|
|
||||||
virtual uint8_t cash_paymentProcessing(void) const=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(void) const=0;
|
virtual uint32_t getInsertedAmount(void) const=0;
|
||||||
|
|
||||||
@ -1528,23 +1437,18 @@ public:
|
|||||||
// conclude payment process and return all inserted coins
|
// conclude payment process and return all inserted coins
|
||||||
|
|
||||||
|
|
||||||
virtual uint8_t mif_getCardType(QString *cardholder) const=0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual uint8_t mif_getCardType(QString cardholder) const=0;
|
||||||
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
||||||
// cardholder: 7byte Name-String
|
// cardholder: 7byte Name-String
|
||||||
|
|
||||||
virtual uint64_t sys_getWakeSource(void) const =0;
|
virtual uint64_t sys_getWakeSource(void) const =0;
|
||||||
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
||||||
|
|
||||||
virtual uint8_t sys_getWakeReason(void) const=0;
|
//virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=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=0;
|
virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const=0;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -1581,9 +1485,8 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0;
|
|
||||||
|
|
||||||
|
|
||||||
|
//virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0;
|
||||||
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0;
|
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -1649,70 +1552,6 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0;
|
|
||||||
|
|
||||||
// content of Cashbox
|
|
||||||
virtual uint32_t cash_getAmountInVault(void) const=0;
|
|
||||||
|
|
||||||
virtual uint16_t cash_getNrCoinsInVault(void) const=0;
|
|
||||||
|
|
||||||
virtual uint8_t prn_getPrintResult() const=0;
|
|
||||||
// return: 0: unknown
|
|
||||||
// 1: OK - last template was printed succesful
|
|
||||||
// 2: error - last template was not printed
|
|
||||||
|
|
||||||
// in case of print-error get detailed error:
|
|
||||||
virtual uint8_t prn_getCurrentPrinterState() const=0;
|
|
||||||
// 0: printer OK
|
|
||||||
// bit0: near paper end bit1: no paper
|
|
||||||
// bit2: temperature error bit3: error head open
|
|
||||||
// bit4: paper jam in cutter
|
|
||||||
// bit6: no response bit7: serial rec. error
|
|
||||||
// bit5: printer not ready
|
|
||||||
|
|
||||||
|
|
||||||
virtual void sys_sendDeviceParameter(struct T_devices *deviceSettings) const=0;
|
|
||||||
|
|
||||||
virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const=0;
|
|
||||||
|
|
||||||
virtual bool sys_areDCdataValid(void) const=0;
|
|
||||||
|
|
||||||
virtual bool sys_sendingTest(void) const =0;
|
|
||||||
|
|
||||||
virtual void prn_requestCurrentDynData(void) const =0;
|
|
||||||
|
|
||||||
virtual bool prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const =0;
|
|
||||||
// which was sent with: bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const override;
|
|
||||||
|
|
||||||
virtual bool prn_dynDataAreEqual(uint8_t *buf) const =0;
|
|
||||||
|
|
||||||
virtual bool prn_printKombiticket(uint8_t nrOfKombi) const=0;
|
|
||||||
// print four of the templates loaded by Json prior
|
|
||||||
// nr = 1..8
|
|
||||||
|
|
||||||
|
|
||||||
virtual void lock_triggerUpperSolenoid(void) const =0;
|
|
||||||
|
|
||||||
virtual void lock_triggerLowerSolenoid(void) const =0;
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
|
||||||
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;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1730,22 +1569,10 @@ signals:
|
|||||||
// 29.03.2023: V3.1 some extensions for PSA1256_ptu5,
|
// 29.03.2023: V3.1 some extensions for PSA1256_ptu5,
|
||||||
// V3.2 Bootloader improvement
|
// V3.2 Bootloader improvement
|
||||||
// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging
|
// 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1"
|
//#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.1"
|
||||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
||||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.4"
|
|
||||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.5"
|
|
||||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.6"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
34
src/com.cpp
34
src/com.cpp
@ -93,29 +93,34 @@ T_com::~T_com()
|
|||||||
|
|
||||||
void T_com::ser_ISR100ms()
|
void T_com::ser_ISR100ms()
|
||||||
{
|
{
|
||||||
|
//qDebug() << "~~>LIB" << "ENTER...";
|
||||||
// call every 100ms to check if user(HMI) wants to connect or disconnect
|
// call every 100ms to check if user(HMI) wants to connect or disconnect
|
||||||
|
|
||||||
//qDebug() << "~~>LIB" << "checking connect button... " ;
|
|
||||||
|
|
||||||
uint8_t chkConn = gpi_getSerialConn(); // from global GUI buffer (Sdata)
|
uint8_t chkConn = gpi_getSerialConn(); // from global GUI buffer (Sdata)
|
||||||
|
|
||||||
|
//qDebug() << "~~>LIB" << "checking connect button... " << chkConn;
|
||||||
|
|
||||||
switch (chkConn)
|
switch (chkConn)
|
||||||
{
|
{
|
||||||
case 0: // 0 button "connect" was just released
|
case 0: // 0 button "connect" was just released
|
||||||
|
//qDebug() << "close serial port" << chkConn;
|
||||||
closeSerialPort();
|
closeSerialPort();
|
||||||
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
||||||
break;
|
break;
|
||||||
case 1: // 1 button "connect" was just pressed
|
case 1: // 1 button "connect" was just pressed
|
||||||
|
//qDebug() << "open serial port" << chkConn;
|
||||||
open_Serial_Port();
|
open_Serial_Port();
|
||||||
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CatSerial->isOpen())
|
if (CatSerial->isOpen()) {
|
||||||
gpi_serialIsOpen(true);
|
gpi_serialIsOpen(true);
|
||||||
else
|
} else {
|
||||||
gpi_serialIsOpen(false);
|
gpi_serialIsOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//qDebug() << "LEAVE " << chkConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
@ -124,17 +129,24 @@ void T_com::ser_ISR100ms()
|
|||||||
|
|
||||||
char T_com::open_Serial_Port()
|
char T_com::open_Serial_Port()
|
||||||
{
|
{
|
||||||
|
//qDebug() << "ENTER";
|
||||||
|
|
||||||
bool ret;
|
bool ret;
|
||||||
QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr;
|
QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr;
|
||||||
int myBaudNr;
|
int myBaudNr;
|
||||||
|
|
||||||
if (CatSerial->isOpen())
|
if (CatSerial->isOpen()) {
|
||||||
|
qDebug() << "!!!IS OPEN!!!";
|
||||||
return 0; // opening twice is not allowed
|
return 0; // opening twice is not allowed
|
||||||
|
}
|
||||||
|
|
||||||
//qDebug() << "connecting..." << myPortName;
|
//qDebug() << "connecting..." << myPortName;
|
||||||
myPortName=gpi_getComPortName(); // was selected and stored from GUI
|
myPortName=gpi_getComPortName(); // was selected and stored from GUI
|
||||||
CatSerial->setPortName(myPortName);
|
CatSerial->setPortName(myPortName);
|
||||||
myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI
|
myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI
|
||||||
|
|
||||||
|
//qDebug() << "myPortName" << myPortName << ", myBaudNr" << myBaudNr;
|
||||||
|
|
||||||
switch (myBaudNr)
|
switch (myBaudNr)
|
||||||
{
|
{
|
||||||
// 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
// 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
||||||
@ -167,6 +179,9 @@ char T_com::open_Serial_Port()
|
|||||||
myString.append(CatSerial->errorString());
|
myString.append(CatSerial->errorString());
|
||||||
qDebug() << myString;
|
qDebug() << myString;
|
||||||
gpi_setTxt4comStateLine(myString);
|
gpi_setTxt4comStateLine(myString);
|
||||||
|
|
||||||
|
//qDebug() << "LEAVE";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -182,11 +197,14 @@ char T_com::open_Serial_Port()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
//qDebug() << "LEAVE";
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_com::closeSerialPort()
|
void T_com::closeSerialPort()
|
||||||
{
|
{
|
||||||
|
//qDebug() << "ENTER";
|
||||||
|
|
||||||
if (CatSerial->isOpen())
|
if (CatSerial->isOpen())
|
||||||
{
|
{
|
||||||
qDebug() << "closing connection";
|
qDebug() << "closing connection";
|
||||||
@ -195,6 +213,8 @@ void T_com::closeSerialPort()
|
|||||||
gpi_setTxt4RsDiagWin("closed");
|
gpi_setTxt4RsDiagWin("closed");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//qDebug() << "LEAVE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,499 +1,310 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "tslib.h"
|
#include "tslib.h"
|
||||||
//#include "controlBus.h"
|
#include "shared_mem_buffer.h"
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// control serial interface gui <--> serial
|
// control serial interface gui <--> serial
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void epi_setSerial(int BaudNr,
|
||||||
|
QString BaudStr,
|
||||||
|
QString ComName,
|
||||||
|
uint8_t connect) {
|
||||||
|
memset(&SharedMemBuffer::getData()->rs.comportName[0], 0x00,
|
||||||
|
sizeof(SharedMemBuffer::getData()->rs.comportName));
|
||||||
|
strncpy(SharedMemBuffer::getData()->rs.comportName,
|
||||||
|
ComName.toStdString().c_str(),
|
||||||
|
sizeof(SharedMemBuffer::getData()->rs.comportName)-1);
|
||||||
|
|
||||||
static QString rs_comportName; // z.B. "COM48"
|
memset(&SharedMemBuffer::getData()->rs.baudStr[0], 0x00,
|
||||||
static QString rs_baudStr; // z.B. "19200"
|
sizeof(SharedMemBuffer::getData()->rs.baudStr));
|
||||||
static int rs_baudNr; //0...5 oder -1
|
strncpy(SharedMemBuffer::getData()->rs.baudStr,
|
||||||
static uint8_t rs_connect; // 0,1
|
BaudStr.toStdString().c_str(),
|
||||||
|
sizeof(SharedMemBuffer::getData()->rs.baudStr)-1);
|
||||||
void epi_setSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
|
|
||||||
{
|
|
||||||
rs_comportName = ComName;
|
|
||||||
rs_baudStr = BaudStr;
|
|
||||||
rs_baudNr = BaudNr; // 0=1200 1=9600 2=19200 3=38400 4=57600 5=115200 oder -1
|
|
||||||
rs_connect = connect; // 0/1
|
|
||||||
|
|
||||||
|
SharedMemBuffer::getData()->rs.baudNr = BaudNr;
|
||||||
|
SharedMemBuffer::getData()->rs.connect = connect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_closeSerial(void)
|
void epi_closeSerial(void) {
|
||||||
{
|
SharedMemBuffer::getData()->rs.connect = 0;
|
||||||
rs_connect=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gpi_serialChanged(void) {
|
||||||
void gpi_serialChanged(void)
|
|
||||||
{
|
|
||||||
// serial confirms that port was closed or opened
|
// serial confirms that port was closed or opened
|
||||||
rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
// rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
||||||
|
SharedMemBuffer::getData()->rs.connect = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t gpi_getSerialConn(void)
|
uint8_t gpi_getSerialConn(void) {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->rs.connect;
|
||||||
return rs_connect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gpi_getBaudNr(void) {
|
||||||
int gpi_getBaudNr(void)
|
return SharedMemBuffer::getDataConst()->rs.baudNr;
|
||||||
{
|
|
||||||
return rs_baudNr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString gpi_getComPortName(void)
|
QString gpi_getComPortName(void) {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->rs.comportName;
|
||||||
return rs_comportName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool rs_portIsOpen;
|
void gpi_serialIsOpen(bool offen) {
|
||||||
|
SharedMemBuffer::getData()->rs.portIsOpen = offen;
|
||||||
void gpi_serialIsOpen(bool offen)
|
|
||||||
{
|
|
||||||
rs_portIsOpen=offen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool epi_isSerialPortOpen()
|
bool epi_isSerialPortOpen() {
|
||||||
{
|
|
||||||
// true: port is open false: port is closed
|
// true: port is open false: port is closed
|
||||||
return rs_portIsOpen;
|
return SharedMemBuffer::getDataConst()->rs.portIsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Control transfer gui <--> serial
|
// Control transfer gui <--> serial
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void epi_startEmmision(char start) {
|
||||||
static char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
SharedMemBuffer::getData()->AutoEmissionOn = start;
|
||||||
|
|
||||||
void epi_startEmmision(char start)
|
|
||||||
{
|
|
||||||
AutoEmissionOn=start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gpi_isEmmisionOn(void)
|
bool gpi_isEmmisionOn(void) {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->AutoEmissionOn;
|
||||||
return AutoEmissionOn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
uint16_t gpi_getPeriodicSendTimeVal() {
|
||||||
|
SharedMemBuffer::getData()->datif.sendingPer_changed = 0;
|
||||||
static uint16_t datif_sendingPeriod;
|
if ((SharedMemBuffer::getDataConst()->datif.sendingPeriod < 3) ||
|
||||||
static bool datif_sendingPer_changed;
|
(SharedMemBuffer::getDataConst()->datif.sendingPeriod > 10000)) {
|
||||||
|
|
||||||
uint16_t gpi_getPeriodicSendTimeVal()
|
|
||||||
{
|
|
||||||
datif_sendingPer_changed=0;
|
|
||||||
if (datif_sendingPeriod<3 || datif_sendingPeriod>10000)
|
|
||||||
return 130; // ms, default
|
return 130; // ms, default
|
||||||
else
|
}
|
||||||
return datif_sendingPeriod;
|
return SharedMemBuffer::getDataConst()->datif.sendingPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_setPeriodicSendTimeVal(uint16_t val)
|
void epi_setPeriodicSendTimeVal(uint16_t val) {
|
||||||
{
|
if (val>=3 && val<10000) {
|
||||||
if (val>=3 && val<10000)
|
SharedMemBuffer::getData()->datif.sendingPer_changed = 1;
|
||||||
{
|
SharedMemBuffer::getData()->datif.sendingPeriod = val;
|
||||||
datif_sendingPer_changed=1;
|
|
||||||
datif_sendingPeriod=val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gpi_PeriodicSendTimeHasChanged()
|
bool gpi_PeriodicSendTimeHasChanged() {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->datif.sendingPer_changed;
|
||||||
return datif_sendingPer_changed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------
|
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Status Display gui <--> serial
|
// Status Display gui <--> serial
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// linke Spalte, über Connect Button
|
||||||
// linke Spalte, über Connect Button
|
QString epi_getTxt4comStateLine(void) {
|
||||||
static QString txt4comStateLine;
|
|
||||||
|
|
||||||
QString epi_getTxt4comStateLine(void)
|
|
||||||
{
|
|
||||||
// GUI: get Text for serial Comport-State Line
|
// GUI: get Text for serial Comport-State Line
|
||||||
return txt4comStateLine;
|
return SharedMemBuffer::getDataConst()->txt4.comStateLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_setTxt4comStateLine(QString txtline) // gpi
|
void gpi_setTxt4comStateLine(QString txtline) {
|
||||||
{
|
|
||||||
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
||||||
txt4comStateLine.clear();
|
memset(SharedMemBuffer::getData()->txt4.comStateLine,
|
||||||
if (txtline=="")
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.comStateLine));
|
||||||
txt4comStateLine.clear();
|
memcpy(SharedMemBuffer::getData()->txt4.comStateLine,
|
||||||
else
|
txtline.toStdString().c_str(),
|
||||||
txt4comStateLine=txtline;
|
sizeof(SharedMemBuffer::getData()->txt4.comStateLine)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clrTxt4comStateLine()
|
void epi_clrTxt4comStateLine() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.comStateLine,
|
||||||
txt4comStateLine.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.comStateLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// rechte Spalte, oberste Statuszeile
|
// rechte Spalte, oberste Statuszeile
|
||||||
// I) "Handshakes" (serial Control) flow.cpp
|
// I) "Handshakes" (serial Control) flow.cpp
|
||||||
// geht überhaupt was raus? kommt überhaupt was zurück?
|
// geht überhaupt was raus? kommt überhaupt was zurück?
|
||||||
static QString txt4HsStateLine;
|
QString epi_getTxt4HsStateLine(void) {
|
||||||
|
return SharedMemBuffer::getDataConst()->txt4.HsStateLine;
|
||||||
QString epi_getTxt4HsStateLine(void)
|
|
||||||
{
|
|
||||||
return txt4HsStateLine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_setTxt4HsStateLine(QString txtline)
|
void gpi_setTxt4HsStateLine(QString txtline) {
|
||||||
{
|
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
||||||
txt4HsStateLine.clear();
|
memset(SharedMemBuffer::getData()->txt4.HsStateLine,
|
||||||
if (txtline=="")
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.HsStateLine));
|
||||||
txt4HsStateLine.clear();
|
memcpy(SharedMemBuffer::getData()->txt4.HsStateLine,
|
||||||
else
|
txtline.toStdString().c_str(),
|
||||||
txt4HsStateLine=txtline;
|
sizeof(SharedMemBuffer::getData()->txt4.HsStateLine)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clrTxt4HsStateLine()
|
void epi_clrTxt4HsStateLine() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.HsStateLine,
|
||||||
txt4HsStateLine.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.HsStateLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// II) Master receive state (empfangenes Telgramm OK? crc? length? )
|
// II) Master receive state (empfangenes Telgramm OK? crc? length? )
|
||||||
// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
|
// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
|
||||||
static QString txt4masterStateLine;
|
QString epi_getTxt4masterStateLine(void) {
|
||||||
|
return SharedMemBuffer::getDataConst()->txt4.masterStateLine;
|
||||||
QString epi_getTxt4masterStateLine(void)
|
|
||||||
{
|
|
||||||
return txt4masterStateLine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_setTxt4masterStateLine(QString txtline)
|
void gpi_setTxt4masterStateLine(QString txtline) {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.masterStateLine,
|
||||||
txt4masterStateLine.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.masterStateLine));
|
||||||
if (txtline=="")
|
memcpy(SharedMemBuffer::getData()->txt4.masterStateLine,
|
||||||
txt4masterStateLine.clear();
|
txtline.toStdString().c_str(),
|
||||||
else
|
sizeof(SharedMemBuffer::getData()->txt4.masterStateLine)-1);
|
||||||
txt4masterStateLine=txtline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clrTxt4masterStateLine()
|
void epi_clrTxt4masterStateLine() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.masterStateLine,
|
||||||
txt4masterStateLine.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.masterStateLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// III Slave receive (from Master) OK? if then show results, if not then show errors
|
// III Slave receive (from Master) OK? if then show results, if not then show errors
|
||||||
// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR
|
// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR
|
||||||
// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch
|
// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch
|
||||||
// nicht verwenden und nichts ausgeben oder einlesen
|
// nicht verwenden und nichts ausgeben oder einlesen
|
||||||
|
QString epi_getTxt4resultStateLine(void) {
|
||||||
static QString txt4resultStateLine;
|
return SharedMemBuffer::getDataConst()->txt4.resultStateLine;
|
||||||
|
|
||||||
QString epi_getTxt4resultStateLine(void)
|
|
||||||
{
|
|
||||||
return txt4resultStateLine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_setTxt4resultStateLine(QString txtline)
|
void gpi_setTxt4resultStateLine(QString txtline) {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.resultStateLine,
|
||||||
txt4resultStateLine.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.resultStateLine));
|
||||||
if (txtline=="")
|
memcpy(SharedMemBuffer::getData()->txt4.resultStateLine,
|
||||||
txt4resultStateLine.clear();
|
txtline.toStdString().c_str(),
|
||||||
else
|
sizeof(SharedMemBuffer::getData()->txt4.resultStateLine)-1);
|
||||||
txt4resultStateLine=txtline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clrTxt4resultStateLine()
|
void epi_clrTxt4resultStateLine() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.resultStateLine,
|
||||||
txt4resultStateLine.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.resultStateLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// IV Statuszeile Empfangsdaten
|
// IV Statuszeile Empfangsdaten
|
||||||
static QString txt4dataLine;
|
QString epi_getTxt4dataStateLine(void) {
|
||||||
|
|
||||||
QString epi_getTxt4dataStateLine(void)
|
|
||||||
{
|
|
||||||
// GUI: get Text for serial Comport-State Line
|
// GUI: get Text for serial Comport-State Line
|
||||||
return txt4dataLine;
|
return SharedMemBuffer::getDataConst()->txt4.dataLine;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_setTxt4dataStateLine(QString txtline)
|
void gpi_setTxt4dataStateLine(QString txtline) {
|
||||||
{
|
|
||||||
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
||||||
txt4dataLine.clear();
|
memset(SharedMemBuffer::getData()->txt4.dataLine,
|
||||||
if (txtline=="")
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.dataLine));
|
||||||
txt4dataLine.clear();
|
memcpy(SharedMemBuffer::getData()->txt4.dataLine,
|
||||||
else
|
txtline.toStdString().c_str(),
|
||||||
txt4dataLine=txtline;
|
sizeof(SharedMemBuffer::getData()->txt4.dataLine)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clrTxt4dataStateLine()
|
void epi_clrTxt4dataStateLine() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.dataLine,
|
||||||
txt4dataLine.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.dataLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// 5. Zeile: Datif Ergebnis, Daten brauchbar?
|
// 5. Zeile: Datif Ergebnis, Daten brauchbar?
|
||||||
|
QString epi_getTxt4datifLine(void) {
|
||||||
static QString txt4datifReceive;
|
return SharedMemBuffer::getDataConst()->txt4.datifReceive;
|
||||||
|
|
||||||
QString epi_getTxt4datifLine(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
return txt4datifReceive;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_setTxt4datifLine(QString txtline)
|
void gpi_setTxt4datifLine(QString txtline) {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.datifReceive,
|
||||||
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.datifReceive));
|
||||||
txt4datifReceive.clear();
|
memcpy(SharedMemBuffer::getData()->txt4.datifReceive,
|
||||||
if (txtline=="")
|
txtline.toStdString().c_str(),
|
||||||
txt4datifReceive.clear();
|
sizeof(SharedMemBuffer::getData()->txt4.datifReceive)-1);
|
||||||
else
|
|
||||||
txt4datifReceive=txtline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clrTxt4datifLine()
|
void epi_clrTxt4datifLine() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.datifReceive,
|
||||||
txt4datifReceive.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.datifReceive));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
QString epi_getTxt4RsDiagWin(void) {
|
||||||
//---------------------------------------------------------------------------------------------
|
return SharedMemBuffer::getDataConst()->txt4.diagWindow;
|
||||||
|
|
||||||
static QString txt4diagWindow;
|
|
||||||
|
|
||||||
QString epi_getTxt4RsDiagWin(void)
|
|
||||||
{
|
|
||||||
return txt4diagWindow;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_setTxt4RsDiagWin(QString txtline)
|
void gpi_setTxt4RsDiagWin(QString txtline) {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.diagWindow,
|
||||||
txt4diagWindow.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.diagWindow));
|
||||||
if (txtline=="")
|
memcpy(SharedMemBuffer::getData()->txt4.diagWindow,
|
||||||
txt4diagWindow.clear();
|
txtline.toStdString().c_str(),
|
||||||
else
|
sizeof(SharedMemBuffer::getData()->txt4.diagWindow)-1);
|
||||||
txt4diagWindow=txtline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clrTxt4RsDiagWin()
|
void epi_clrTxt4RsDiagWin() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.diagWindow,
|
||||||
txt4diagWindow.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.diagWindow));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
QString epi_get2ndTxt4RsDiagWin(void) {
|
||||||
|
return SharedMemBuffer::getDataConst()->txt4.sndDiagWindow;
|
||||||
static QString sndTxt4diagWindow;
|
|
||||||
|
|
||||||
QString epi_get2ndTxt4RsDiagWin(void)
|
|
||||||
{
|
|
||||||
return sndTxt4diagWindow;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_set2ndTxt4RsDiagWin(QString txtline)
|
void gpi_set2ndTxt4RsDiagWin(QString txtline) {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.sndDiagWindow,
|
||||||
sndTxt4diagWindow.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.sndDiagWindow));
|
||||||
if (txtline=="")
|
memcpy(SharedMemBuffer::getData()->txt4.sndDiagWindow,
|
||||||
sndTxt4diagWindow.clear();
|
txtline.toStdString().c_str(),
|
||||||
else
|
sizeof(SharedMemBuffer::getData()->txt4.sndDiagWindow)-1);
|
||||||
sndTxt4diagWindow=txtline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_clr2ndTxt4RsDiagWin()
|
void epi_clr2ndTxt4RsDiagWin() {
|
||||||
{
|
memset(SharedMemBuffer::getData()->txt4.sndDiagWindow,
|
||||||
sndTxt4diagWindow.clear();
|
0x00, sizeof(SharedMemBuffer::getData()->txt4.sndDiagWindow));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Memory for Slave responses, common data
|
// Memory for Slave responses, common data
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void gpi_storeResult_serialTestOK(bool wasOk) {
|
||||||
|
SharedMemBuffer::getData()->Sdata.serialTestResult = wasOk;
|
||||||
static bool Sdata_serialTestResult;
|
|
||||||
|
|
||||||
void gpi_storeResult_serialTestOK(bool wasOk)
|
|
||||||
{
|
|
||||||
Sdata_serialTestResult=wasOk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool epi_getResult_serialTestOK()
|
bool epi_getResult_serialTestOK() {
|
||||||
{
|
|
||||||
// retval: true: test was successful, got right response
|
// retval: true: test was successful, got right response
|
||||||
return Sdata_serialTestResult;
|
return SharedMemBuffer::getDataConst()->Sdata.serialTestResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Store received data for hwapi
|
// Store received data for hwapi
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void gpi_startNewRequest() {
|
||||||
|
SharedMemBuffer::getData()->Sdata.pProtResultOk = 0;
|
||||||
|
|
||||||
static uint8_t Sdata_pProtResultOk;
|
|
||||||
|
|
||||||
void gpi_startNewRequest()
|
|
||||||
{
|
|
||||||
Sdata_pProtResultOk=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_storeResultOfLastRequest(bool answisok)
|
void gpi_storeResultOfLastRequest(bool answisok) {
|
||||||
{
|
SharedMemBuffer::getData()->Sdata.pProtResultOk = answisok ? 1 : 2;
|
||||||
if (answisok)
|
|
||||||
Sdata_pProtResultOk=1;
|
|
||||||
else
|
|
||||||
Sdata_pProtResultOk=2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t epi_getResultOfLastRequest()
|
uint8_t epi_getResultOfLastRequest() {
|
||||||
{
|
|
||||||
// retval: 0: in progress 1: OK 2: error
|
// retval: 0: in progress 1: OK 2: error
|
||||||
return Sdata_pProtResultOk;
|
return SharedMemBuffer::getDataConst()->Sdata.pProtResultOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData) {
|
||||||
|
SharedMemBuffer::getData()->Sdata.receivedDataLength
|
||||||
|
= std::min(RdDlen, (uint8_t)(64));
|
||||||
static uint16_t Sdata_receivedDataLength;
|
memset((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
|
||||||
static uint8_t Sdata_receivedDataBlock[64];
|
0x00, sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock));
|
||||||
|
strncpy((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
|
||||||
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t *receivedData)
|
(char const *)receivedData,
|
||||||
{
|
sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock)-1);
|
||||||
Sdata_receivedDataLength=uint16_t(RdDlen);
|
|
||||||
if (Sdata_receivedDataLength>64)
|
|
||||||
Sdata_receivedDataLength=64;
|
|
||||||
tslib_strclr(Sdata_receivedDataBlock,0,64);
|
|
||||||
tslib_strcpy(receivedData, Sdata_receivedDataBlock, Sdata_receivedDataLength);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad)
|
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad) {
|
||||||
{
|
|
||||||
// get data back in *pl, max 64 byte
|
// get data back in *pl, max 64 byte
|
||||||
// retval = nr of bytes received. If host buffer too small then
|
// retval = nr of bytes received. If host buffer too small then
|
||||||
// only plBufSíz bytes are copied to pl
|
// only plBufSíz bytes are copied to pl
|
||||||
// plBufSíz=size of host buffer
|
// plBufSíz=size of host buffer
|
||||||
|
|
||||||
uint16_t ml=plBufSiz;
|
uint16_t ml = std::min(plBufSiz, (uint16_t)(64));
|
||||||
if (ml>64) ml=64;
|
if (SharedMemBuffer::getDataConst()->Sdata.receivedDataLength < ml) {
|
||||||
if (Sdata_receivedDataLength<ml)
|
ml = SharedMemBuffer::getDataConst()->Sdata.receivedDataLength;
|
||||||
ml=Sdata_receivedDataLength;
|
|
||||||
tslib_strcpy(Sdata_receivedDataBlock, payLoad, ml);
|
|
||||||
return Sdata_receivedDataLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t ndbs, pari, nsb, br;
|
|
||||||
|
|
||||||
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
|
||||||
uint8_t parity, uint8_t NrStopBits)
|
|
||||||
{
|
|
||||||
// store numbers
|
|
||||||
ndbs=NrDataBits;
|
|
||||||
pari=parity;
|
|
||||||
nsb=NrStopBits;
|
|
||||||
br=slaveBaudRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
|
||||||
uint8_t *parity, uint8_t *NrStopBits)
|
|
||||||
{
|
|
||||||
*NrDataBits=ndbs;
|
|
||||||
*parity=pari;
|
|
||||||
*NrStopBits=nsb;
|
|
||||||
*slaveBaudRate=br;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
|
||||||
uint8_t parity, uint8_t NrStopBits) {
|
|
||||||
// store numbers
|
|
||||||
SharedMemBuffer::write()->ndbs = NrDataBits;
|
|
||||||
SharedMemBuffer::write()->pari = parity;
|
|
||||||
SharedMemBuffer::write()->nsb = NrStopBits;
|
|
||||||
SharedMemBuffer::write()->br = slaveBaudRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
|
||||||
uint8_t *parity, uint8_t *NrStopBits) {
|
|
||||||
|
|
||||||
*NrDataBits = SharedMemBuffer::read()->ndbs;
|
|
||||||
*parity = SharedMemBuffer::read()->pari;
|
|
||||||
*NrStopBits = SharedMemBuffer::read()->nsb;
|
|
||||||
*slaveBaudRate = SharedMemBuffer::read()->br;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
QString epi_getSlaveParamSTR()
|
|
||||||
{
|
|
||||||
QString mySt;
|
|
||||||
char ctmp;
|
|
||||||
// uint8_t ndbs;
|
|
||||||
// uint8_t pari;
|
|
||||||
// uint8_t nsb;
|
|
||||||
// uint8_t br;
|
|
||||||
|
|
||||||
mySt.clear();
|
|
||||||
// br=SharedMemBuffer::read()->br;
|
|
||||||
// ndbs=SharedMemBuffer::read()->ndbs;
|
|
||||||
// pari =SharedMemBuffer::read()->pari;
|
|
||||||
// nsb=SharedMemBuffer::read()->nsb;
|
|
||||||
|
|
||||||
switch (br)
|
|
||||||
{
|
|
||||||
case 1: mySt="1200 ";break;
|
|
||||||
case 2: mySt="9600 ";break;
|
|
||||||
case 3: mySt="19200 ";break;
|
|
||||||
case 4: mySt="38400 ";break;
|
|
||||||
case 5: mySt="57600 ";break;
|
|
||||||
case 6: mySt="115200 ";break;
|
|
||||||
}
|
}
|
||||||
|
strncpy((char *)payLoad,
|
||||||
|
(char const *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
|
||||||
|
ml);
|
||||||
|
|
||||||
|
return SharedMemBuffer::getDataConst()->Sdata.receivedDataLength;
|
||||||
ctmp=ndbs;
|
|
||||||
ctmp+=0x30;
|
|
||||||
mySt.append(ctmp);
|
|
||||||
ctmp=pari;
|
|
||||||
mySt.append(ctmp);
|
|
||||||
ctmp=nsb;
|
|
||||||
ctmp+=0x30;
|
|
||||||
mySt.append(ctmp);
|
|
||||||
//mySt="Hallo";
|
|
||||||
return mySt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
746
src/datIf.cpp
746
src/datIf.cpp
File diff suppressed because it is too large
Load Diff
943
src/datei.cpp
943
src/datei.cpp
@ -1,943 +0,0 @@
|
|||||||
// written by Thomas Sax, Jan.2022
|
|
||||||
#include "datei.h"
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ create csv file -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
QByteArray datei_writeArray, datei_tempArray;
|
|
||||||
|
|
||||||
void csv_startCreatingFile(void)
|
|
||||||
{
|
|
||||||
datei_writeArray.clear();
|
|
||||||
datei_tempArray.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void csv_addTextToFile(QString myText)
|
|
||||||
{
|
|
||||||
datei_writeArray.append(myText.toLatin1());
|
|
||||||
datei_writeArray.append(FILESEPERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void csv_addIntToFile(int myValue)
|
|
||||||
{
|
|
||||||
//qulonglong ullt=12345678901234567890; // max 1,844 x10^19
|
|
||||||
datei_tempArray.setNum(myValue,10); // accepted types: short, ushort, int, uint,
|
|
||||||
// qlonglong, qulonglong, float, double
|
|
||||||
// numerbase can be 2...36(!),10=dec
|
|
||||||
|
|
||||||
datei_writeArray.append(datei_tempArray);
|
|
||||||
datei_writeArray.append(FILESEPERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void csv_addUintToFile(uint myValue)
|
|
||||||
{
|
|
||||||
datei_tempArray.setNum(myValue,10);
|
|
||||||
datei_writeArray.append(datei_tempArray);
|
|
||||||
datei_writeArray.append(FILESEPERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void csv_addLongvalToFile(qlonglong myValue)
|
|
||||||
{
|
|
||||||
datei_tempArray.setNum(myValue,10);
|
|
||||||
datei_writeArray.append(datei_tempArray);
|
|
||||||
datei_writeArray.append(FILESEPERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void csv_addUlongvalToFile(qulonglong myValue)
|
|
||||||
{
|
|
||||||
datei_tempArray.setNum(myValue,10);
|
|
||||||
datei_writeArray.append(datei_tempArray);
|
|
||||||
datei_writeArray.append(FILESEPERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void csv_addCurrentTimeToFile(void)
|
|
||||||
{
|
|
||||||
uint8_t hour, minute, sec, ui8buf[20];
|
|
||||||
char buf[20];
|
|
||||||
|
|
||||||
config_getSysTime(&hour, &minute, &sec);
|
|
||||||
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
|
||||||
for (uint8_t nn=0; nn<20; nn++)
|
|
||||||
buf[nn]=char(ui8buf[nn]);
|
|
||||||
datei_writeArray.append(buf,8); // time string
|
|
||||||
datei_writeArray.append(FILESEPERATOR);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void csv_addCurrentDateToFile(void)
|
|
||||||
{
|
|
||||||
uint16_t year;
|
|
||||||
uint8_t month, day, ui8buf[20];
|
|
||||||
char buf[20];
|
|
||||||
|
|
||||||
config_getSystemDate(&year, &month, &day);
|
|
||||||
//qDebug()<<"date year: "<<year;
|
|
||||||
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
|
||||||
for (uint8_t nn=0; nn<20; nn++)
|
|
||||||
buf[nn]=char(ui8buf[nn]);
|
|
||||||
datei_writeArray.append(buf, 10); // date string
|
|
||||||
datei_writeArray.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void csv_addNewlineToFile(void)
|
|
||||||
{
|
|
||||||
datei_writeArray.chop(1); // Komma weg
|
|
||||||
datei_writeArray.append(NEWLINEINFILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray csv_readbackArray(void)
|
|
||||||
{
|
|
||||||
return datei_writeArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
QByteArray csv_writeContent_testValues(void)
|
|
||||||
{
|
|
||||||
QByteArray myBA, tmpBA;
|
|
||||||
uint8_t modCount=5, modAddr=23;
|
|
||||||
uint8_t hour, minute, sec, month, day, ui8buf[20];
|
|
||||||
uint16_t year, modType=45678;
|
|
||||||
char buf[20];
|
|
||||||
uint32_t modNrDIs=1234567890;
|
|
||||||
uint8_t modNrAIs=4, modNrCtr=2, modNrDOs=8;
|
|
||||||
int modNrAOs=-2;
|
|
||||||
|
|
||||||
myBA.clear();
|
|
||||||
tmpBA.clear();
|
|
||||||
myBA.append("scan time");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
|
|
||||||
datei_getSysTime(&hour, &minute, &sec);
|
|
||||||
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
|
||||||
for (uint8_t nn=0; nn<20; nn++)
|
|
||||||
buf[nn]=char(ui8buf[nn]);
|
|
||||||
myBA.append(buf,8); // time string
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
|
|
||||||
datei_getSystemDate(&year, &month, &day);
|
|
||||||
//qDebug()<<"date year: "<<year;
|
|
||||||
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
|
||||||
for (uint8_t nn=0; nn<20; nn++)
|
|
||||||
buf[nn]=char(ui8buf[nn]);
|
|
||||||
myBA.append(buf, 10); // date string
|
|
||||||
myBA.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
myBA.append("number of modules");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
tmpBA.setNum(modCount,10); //2nd para = number base 2, 8, 10 or 16 (bin, oct, dec, hex)
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
myBA.append("busaddr");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
myBA.append("type");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
myBA.append("NrOfDI");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
myBA.append("NrOfAI");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
myBA.append("NrOfCtrIn");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
myBA.append("NrOfDO");
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
myBA.append("NrOfAO");
|
|
||||||
myBA.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
tmpBA.setNum(modAddr,10);
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
tmpBA.setNum(modType,10);
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
tmpBA.setNum(modNrDIs,10);
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
tmpBA.setNum(modNrAIs,10);
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
tmpBA.setNum(modNrCtr,10);
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
tmpBA.setNum(modNrDOs,10);
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(FILESEPERATOR);
|
|
||||||
tmpBA.setNum(modNrAOs,10);
|
|
||||||
myBA.append(tmpBA);
|
|
||||||
myBA.append(NEWLINEINFILE);
|
|
||||||
return myBA;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ parse csv file -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// first: QByteArray datei_readFromFile(QString filename);
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile)
|
|
||||||
{
|
|
||||||
// count sequences between FILESEPERATOR and NEWLINEINFILE
|
|
||||||
uint32_t filSize=0, pp=0;
|
|
||||||
char oneByt=0;
|
|
||||||
|
|
||||||
int filLen=readFromFile.size();
|
|
||||||
if(filLen>1)
|
|
||||||
filSize=uint32_t(filLen);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// 1) find position of seperators
|
|
||||||
for (uint32_t ii=0; ii<filSize; ii++)
|
|
||||||
{
|
|
||||||
oneByt=readFromFile[ii];
|
|
||||||
if (oneByt==FILESEP1 || oneByt==FILESEP2 || oneByt==NEWLINEINFILE)
|
|
||||||
pp++;
|
|
||||||
}
|
|
||||||
// now: pp = number of seperators
|
|
||||||
// oneByt = last byte in file. If it's not a seperator then
|
|
||||||
// there's one more entry (last entry without termination)
|
|
||||||
if (oneByt !=FILESEP1 && oneByt !=FILESEP2 && oneByt !=NEWLINEINFILE)
|
|
||||||
pp++;
|
|
||||||
//qDebug()<<"csv: nr of sequences="<< pp;
|
|
||||||
return pp;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
// seperate file content in single sequences between FILESEPERATOR and NEWLINEINFILE
|
|
||||||
// and return "entryNr" - entry
|
|
||||||
// for this first step leave data type QByteArray
|
|
||||||
// 2nd step can change in numbers and strings
|
|
||||||
QByteArray sequence;
|
|
||||||
uint32_t sepPos[MAXNUMBEROFSEQUENCES];
|
|
||||||
uint32_t filSize=0, pp=0, ii, start=0, ende=0;
|
|
||||||
char oneByt;
|
|
||||||
int filLen, mm;
|
|
||||||
|
|
||||||
filLen=sourceFile.size();
|
|
||||||
//qDebug()<<"fillen="<< filLen;
|
|
||||||
if(filLen<10)
|
|
||||||
return "";
|
|
||||||
filSize=uint32_t(filLen);
|
|
||||||
|
|
||||||
if (sequNr>MAXNUMBEROFSEQUENCES)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
// 1) find position of seperators
|
|
||||||
for (ii=0; ii<filSize; ii++)
|
|
||||||
{
|
|
||||||
oneByt=sourceFile[ii];
|
|
||||||
if (oneByt==FILESEP1 || oneByt==FILESEP2 || oneByt==NEWLINEINFILE)
|
|
||||||
{
|
|
||||||
sepPos[pp++]=ii;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// now: pp = number of entries
|
|
||||||
//qDebug()<<"nr of seperators="<< pp;
|
|
||||||
|
|
||||||
if (sequNr>=pp)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
// 2) get sequence
|
|
||||||
if (sequNr==0)
|
|
||||||
{
|
|
||||||
start=0;
|
|
||||||
ende=sepPos[sequNr];
|
|
||||||
} else
|
|
||||||
if (sequNr>0)
|
|
||||||
{
|
|
||||||
start=sepPos[sequNr-1]+1;
|
|
||||||
ende=sepPos[sequNr];
|
|
||||||
}
|
|
||||||
|
|
||||||
//qDebug()<<"datei getOneFileSequence start/ende: "<<start << " " << ende;
|
|
||||||
if (start>=ende)
|
|
||||||
return "";
|
|
||||||
//return "-err3-";
|
|
||||||
sequence.clear();
|
|
||||||
//batmp.clear();
|
|
||||||
pp=0;
|
|
||||||
for (ii=start; ii<ende; ii++)
|
|
||||||
{
|
|
||||||
mm=int(ii);
|
|
||||||
if (mm>=int(filSize))
|
|
||||||
mm=0;
|
|
||||||
oneByt=sourceFile.at(mm);
|
|
||||||
sequence.append(oneByt);
|
|
||||||
}
|
|
||||||
return sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
QByteArray myBA, myVA;
|
|
||||||
int entry=0;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
myVA.clear();
|
|
||||||
myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
|
||||||
//qDebug()<<"datei getEntryAsInt, sequence: " << myBA;
|
|
||||||
|
|
||||||
entry=myBA.toInt(&ok,16);
|
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
//qDebug()<<"datei getEntryAsInt, number: " << entry;
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
//qDebug()<<"datei getEntryAsInt, error " << myBA;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
|
||||||
long entry=0;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
entry=myBA.toLong(&ok,10);
|
|
||||||
if (ok)
|
|
||||||
return entry;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
|
||||||
uint8_t entry=0;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
entry=uint8_t(myBA.toUShort(&ok,10));
|
|
||||||
if (ok)
|
|
||||||
return entry;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
|
||||||
uint16_t entry=0;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
entry=uint16_t(myBA.toUInt(&ok,10));
|
|
||||||
if (ok)
|
|
||||||
return entry;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
|
||||||
uint32_t entry=0;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
entry=myBA.toULong(&ok,10);
|
|
||||||
if (ok)
|
|
||||||
return entry;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
|
||||||
uint64_t entry=0;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
entry=myBA.toULongLong(&ok,10);
|
|
||||||
if (ok)
|
|
||||||
return entry;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr)
|
|
||||||
{
|
|
||||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
|
||||||
QString entry;
|
|
||||||
|
|
||||||
//qDebug()<<"datei getEntryAsString, sequence: " << myBA;
|
|
||||||
entry=myBA.toStdString().c_str();
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ create Json file -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*
|
|
||||||
example
|
|
||||||
QString str = "{"
|
|
||||||
" \"Herausgeber\": \"Xema\","
|
|
||||||
" \"Nummer\": \"1234-5678-9012-3456\","
|
|
||||||
" \"Deckung\": 2e+6,"
|
|
||||||
" \"Währung\": \"EURO\","
|
|
||||||
" \"Inhaber\": {"
|
|
||||||
" \"Name\": \"Mustermann\","
|
|
||||||
" \"Vorname\": \"Max\","
|
|
||||||
" \"männlich\": true,"
|
|
||||||
" \"Hobbys\": [ \"Reiten\", \"Golfen\", \"Lesen\" ],"
|
|
||||||
" \"Alter\": 42,"
|
|
||||||
" \"Kinder\": [],"
|
|
||||||
" \"Partner\": null"
|
|
||||||
" }"
|
|
||||||
"}";
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
QString myJsonCon;
|
|
||||||
QString tmpStr;
|
|
||||||
|
|
||||||
void json_startRecord(void)
|
|
||||||
{
|
|
||||||
myJsonCon.clear();
|
|
||||||
tmpStr.clear();
|
|
||||||
myJsonCon.append('{');
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_enterIntToRecord(QString attribute, ulong i_value)
|
|
||||||
{
|
|
||||||
tmpStr.clear();
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(attribute);
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(':');
|
|
||||||
tmpStr.setNum(i_value);
|
|
||||||
myJsonCon.append(tmpStr);
|
|
||||||
myJsonCon.append(',');
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_enterTextToRecord(QString attribute, QString txt_value)
|
|
||||||
{
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(attribute);
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(':');
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(txt_value);
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(',');
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
void json_addCurrentTimeToRecord(QString attribute)
|
|
||||||
{
|
|
||||||
uint8_t hour, minute, sec, ui8buf[20];
|
|
||||||
//char buf[20];
|
|
||||||
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(attribute);
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(':');
|
|
||||||
myJsonCon.append('"');
|
|
||||||
|
|
||||||
datei_getSysTime(&hour, &minute, &sec);
|
|
||||||
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
|
||||||
for (uint8_t nn=0; nn<8; nn++)
|
|
||||||
myJsonCon.append(ui8buf[nn]);
|
|
||||||
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(',');
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_addCurrentDateToRecord(QString attribute)
|
|
||||||
{
|
|
||||||
uint16_t year;
|
|
||||||
uint8_t month, day, ui8buf[20];
|
|
||||||
//char buf[20];
|
|
||||||
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(attribute);
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(':');
|
|
||||||
myJsonCon.append('"');
|
|
||||||
|
|
||||||
datei_getSystemDate(&year, &month, &day);
|
|
||||||
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
|
||||||
for (uint8_t nn=0; nn<10; nn++)
|
|
||||||
myJsonCon.append(ui8buf[nn]);
|
|
||||||
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(',');
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals)
|
|
||||||
{
|
|
||||||
// add array of numbers with "nrofVals" elements
|
|
||||||
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(attribute);
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(':');
|
|
||||||
myJsonCon.append('['); // eckig!!!
|
|
||||||
for (ulong ul=0; ul<nrofVals; ul++)
|
|
||||||
{
|
|
||||||
tmpStr.setNum(buf[ul]);
|
|
||||||
myJsonCon.append(tmpStr);
|
|
||||||
myJsonCon.append(',');
|
|
||||||
}
|
|
||||||
myJsonCon.chop(1); // Komma weg
|
|
||||||
myJsonCon.append(']'); // eckig!!!
|
|
||||||
myJsonCon.append(',');
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_enterStructToRecord(QString attribute)
|
|
||||||
{
|
|
||||||
// every call must be concluded with "json_finishFile()"
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(attribute);
|
|
||||||
myJsonCon.append('"');
|
|
||||||
myJsonCon.append(':');
|
|
||||||
myJsonCon.append('{'); // geschweift!!
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_finishStruct(void)
|
|
||||||
{
|
|
||||||
myJsonCon.chop(2); // remove , and \r from the end
|
|
||||||
myJsonCon.append('}');
|
|
||||||
myJsonCon.append(',');
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_finishRecord(void)
|
|
||||||
{
|
|
||||||
myJsonCon.chop(2); // remove , and \r from the end
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
myJsonCon.append('}');
|
|
||||||
myJsonCon.append(NEWLINEINFILE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString json_readbackRecordStr(void)
|
|
||||||
{
|
|
||||||
return myJsonCon;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray json_readbackRecordBa(void)
|
|
||||||
{
|
|
||||||
return myJsonCon.toLatin1();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ parse Json file -------------------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*
|
|
||||||
example Json File:
|
|
||||||
{"temperature":28,
|
|
||||||
"snow":"no",
|
|
||||||
"Zeit":"16_21_45",
|
|
||||||
"sunny":"12h",
|
|
||||||
"humidity":75,
|
|
||||||
"wann ":"24.01.2022",
|
|
||||||
"unterstruktur":{
|
|
||||||
"day of week":"tuesday",
|
|
||||||
"year":22,
|
|
||||||
"month":1,
|
|
||||||
"day":24},
|
|
||||||
"fast am":"Ende",
|
|
||||||
"Puffer":[8,3,9,2,10]
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// first: QByteArray datei_readFromFile(QString filename);
|
|
||||||
|
|
||||||
|
|
||||||
int json_nrOfPairsInFile(QByteArray filename)
|
|
||||||
{
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
|
|
||||||
// key value pair consisting of key (unique string) and value (QJsonValue)
|
|
||||||
int nrOfPairs=jobj.size();
|
|
||||||
|
|
||||||
qDebug() << "my Json file has got: " << nrOfPairs<< "pairs";
|
|
||||||
return nrOfPairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_exists(QByteArray filename, QString searchForKey)
|
|
||||||
{
|
|
||||||
// look for "searchForKey" =name of the pair (left of : )
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
|
|
||||||
if (jobj.contains(searchForKey))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_remove(QByteArray filename, QString searchFor)
|
|
||||||
{
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and remove the record from file
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
|
|
||||||
if (jobj.contains(searchFor))
|
|
||||||
{
|
|
||||||
jobj.remove(searchFor);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString json_searchForStringInFile(QByteArray filename, QString searchFor)
|
|
||||||
{
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
|
|
||||||
if (jobj.contains(searchFor))
|
|
||||||
{
|
|
||||||
return jobj[searchFor].toString(); // toObject(); toArray();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//qDebug() << "pairname not found in Json file";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int json_searchForIntInFile(QByteArray filename, QString searchFor)
|
|
||||||
{
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
|
|
||||||
if (jobj.contains(searchFor))
|
|
||||||
{
|
|
||||||
return jobj[searchFor].toInt(); // toObject(); toArray();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//qDebug() << "number not found in Json file";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_searchForObjectInFile(QByteArray filename, QString searchFor, QJsonObject *oneObject)
|
|
||||||
{
|
|
||||||
// return an object from the json file
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
|
|
||||||
if (jobj.contains(searchFor))
|
|
||||||
{
|
|
||||||
*oneObject = jobj[searchFor].toObject();
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//qDebug() << "Object not found in Json file";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int json_nrOfPairsInObject(QJsonObject objname)
|
|
||||||
{
|
|
||||||
int nrOfPairs=objname.size();
|
|
||||||
qDebug() << "my Json Object has got: " << nrOfPairs<< "pairs";
|
|
||||||
return nrOfPairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString json_searchForStringInObject(QJsonObject objname, QString searchFor)
|
|
||||||
{
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
|
|
||||||
if (objname.contains(searchFor))
|
|
||||||
{
|
|
||||||
return objname[searchFor].toString();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//qDebug() << "string not found in Json object";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int json_searchForIntInObject(QJsonObject objname, QString searchFor)
|
|
||||||
{
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
|
|
||||||
if (objname.contains(searchFor))
|
|
||||||
{
|
|
||||||
return objname[searchFor].toInt();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//qDebug() << "number not found in Json file";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_searchForArrayInFile(QByteArray filename, QString searchFor, QJsonArray *oneArray)
|
|
||||||
{
|
|
||||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
|
|
||||||
if (jobj.contains(searchFor))
|
|
||||||
{
|
|
||||||
*oneArray = jobj[searchFor].toArray();
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//qDebug() << "Array not found in Json file";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int json_nrOfValuesInArray(QJsonArray arrayname)
|
|
||||||
{
|
|
||||||
int nrOfPairs=arrayname.size();
|
|
||||||
qDebug() << "my Json Array has got: " << nrOfPairs<< "values";
|
|
||||||
return nrOfPairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize)
|
|
||||||
{
|
|
||||||
// assuming that the array consists of integers
|
|
||||||
|
|
||||||
/* copy to local buffer:
|
|
||||||
#define MAXNROFARRAYVALUES 100
|
|
||||||
int buf[MAXNROFARRAYVALUES], ii;
|
|
||||||
int nrOfPairs=arrayname.size();
|
|
||||||
|
|
||||||
if (nrOfPairs>MAXNROFARRAYVALUES)
|
|
||||||
nrOfPairs=MAXNROFARRAYVALUES;
|
|
||||||
|
|
||||||
for (ii=0; ii<nrOfPairs; ii++)
|
|
||||||
buf[ii]=arrayname[ii].toInt();
|
|
||||||
*/
|
|
||||||
// copy to host buffer:
|
|
||||||
bool ok=true;
|
|
||||||
int nrOfPairs=arrayname.size();
|
|
||||||
|
|
||||||
if (nrOfPairs>MaxBufferSize)
|
|
||||||
{
|
|
||||||
ok=false; // got not all
|
|
||||||
nrOfPairs=MaxBufferSize;
|
|
||||||
}
|
|
||||||
for (int ii=0; ii<nrOfPairs; ii++)
|
|
||||||
buf[ii]=arrayname[ii].toInt();
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void datei_json_readTestFile(QString filename)
|
|
||||||
{
|
|
||||||
QByteArray my2Ba;
|
|
||||||
QString my2Str;
|
|
||||||
|
|
||||||
my2Str.clear();
|
|
||||||
my2Ba=datei_readFromFile(filename);
|
|
||||||
|
|
||||||
QJsonDocument jdoc = QJsonDocument::fromJson(my2Ba);
|
|
||||||
QJsonObject jobj = jdoc.object();
|
|
||||||
//QJsonParseError jerror;
|
|
||||||
QJsonObject myObj;
|
|
||||||
QJsonArray myArray;
|
|
||||||
|
|
||||||
// key value pair consisting of key (unique string) and value (QJsonValue)
|
|
||||||
int nrOfPairs=jobj.size();
|
|
||||||
qDebug() << "my Json file has got: " << nrOfPairs<< "pairs";
|
|
||||||
|
|
||||||
if (jobj.contains("Zeit"))
|
|
||||||
qDebug() << "my Json file: " << jobj["Zeit"].toString(); // toObject(); toArray();
|
|
||||||
else
|
|
||||||
qDebug() << "my Json file contains no Zeit";
|
|
||||||
|
|
||||||
if (jobj.contains("Humidity"))
|
|
||||||
qDebug() << "my Json file: " << jobj["humidity"].toInt();
|
|
||||||
else
|
|
||||||
qDebug() << "my Json file contains no Humidity";
|
|
||||||
|
|
||||||
if (jobj.contains("month"))
|
|
||||||
qDebug() << "my Json file: " << jobj["month"].toObject(); // anzeige QJsonObject()
|
|
||||||
else
|
|
||||||
qDebug() << "my Json file contains no month";
|
|
||||||
|
|
||||||
|
|
||||||
myObj=jobj["unterstruktur"].toObject();
|
|
||||||
qDebug() << "my unterstruktur: " << myObj["month"].toInt();
|
|
||||||
qDebug() << "my unterstruktur: " << myObj["day of week"].toString();
|
|
||||||
//if (jerror.error == QJsonParseError::NoError)
|
|
||||||
// qDebug() << "no error";
|
|
||||||
|
|
||||||
qDebug() << "my Month: " << myObj["Month"].toInt();
|
|
||||||
//if (myObj["Month"] == QJsonValue::Undefined)
|
|
||||||
// qDebug() << "no found"; geht nicht
|
|
||||||
|
|
||||||
//if (jerror.error != QJsonParseError::NoError)
|
|
||||||
// qDebug() << "no found";
|
|
||||||
|
|
||||||
myArray=jobj["Puffer"].toArray();
|
|
||||||
qDebug() << "my array " <<myArray[2].toInt();
|
|
||||||
//if (jerror.error != QJsonParseError::NoError)
|
|
||||||
// qDebug() << "no found";
|
|
||||||
|
|
||||||
if ( !jobj.contains("Puffer"))
|
|
||||||
qDebug() << "no Puffer found";
|
|
||||||
|
|
||||||
if ( !myArray.contains(20))
|
|
||||||
qDebug() << "no entry found";
|
|
||||||
} */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// ------------------------------------------------------ read, write, copy files -------------------
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void datei_closeFile(QString filename)
|
|
||||||
{
|
|
||||||
QFile file(filename);
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray datei_readFromFile(QString filename)
|
|
||||||
{
|
|
||||||
//QFile file("/own/H2B/dc2.hex");
|
|
||||||
//QFile file(FILENAME_STRUCTURE);
|
|
||||||
QFile file;
|
|
||||||
file.setFileName(filename);
|
|
||||||
QByteArray myBA;
|
|
||||||
|
|
||||||
myBA.clear();
|
|
||||||
if (!file.exists())
|
|
||||||
{
|
|
||||||
qDebug()<<"file not exists";
|
|
||||||
return myBA;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if (!file.open(QIODevice::ReadOnly) )
|
|
||||||
{
|
|
||||||
qDebug()<<"cannot open";
|
|
||||||
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//qDebug()<<"loading file with " << file.size() <<"byte";
|
|
||||||
myBA = file.readAll();
|
|
||||||
//qDebug()<<"datei read: " << myBA;
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return myBA;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool datei_ifFileExists(QString filename)
|
|
||||||
{
|
|
||||||
|
|
||||||
QFile file;
|
|
||||||
file.setFileName(filename);
|
|
||||||
|
|
||||||
if (file.exists())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char datei_writeToFile(QString filename, QByteArray content)
|
|
||||||
{
|
|
||||||
// retval=0 if successful 1: no write access allowed 2:cannot open to append 3:cannot create new file
|
|
||||||
QFile file(filename);
|
|
||||||
QFileInfo myFI(filename);
|
|
||||||
|
|
||||||
//if (!myFI.isWritable()) //geht nur bei NTFS, weg.
|
|
||||||
//{
|
|
||||||
//file.setPermissions(filename, QFile::WriteOther); geht nicht :(
|
|
||||||
// qDebug()<<"datei_writeToFile: writing not allowed. set attributes first!";
|
|
||||||
// return 1;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
if (!file.open(QIODevice::Append))
|
|
||||||
{
|
|
||||||
qDebug()<<"datei_writeToFile cannot open to append";
|
|
||||||
return 2;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
// add new object to the end of the file
|
|
||||||
file.write(content);
|
|
||||||
file.close();
|
|
||||||
return 0; // OK
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if (!file.open(QIODevice::WriteOnly))
|
|
||||||
{
|
|
||||||
qDebug()<<"datei_writeToFile cannot open new";
|
|
||||||
return 3;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
qDebug()<<"create new file";
|
|
||||||
// write first lines into file
|
|
||||||
file.write(content);
|
|
||||||
file.close();
|
|
||||||
return 0; // OK
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool datei_copyFile(QString currentFileName, QString newFileName)
|
|
||||||
{
|
|
||||||
// retval=true if successful
|
|
||||||
QFile file;
|
|
||||||
file.setFileName(currentFileName);
|
|
||||||
return file.copy(newFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool datei_clearFile(QString filename)
|
|
||||||
{
|
|
||||||
// retval=true if successful
|
|
||||||
QFile file;
|
|
||||||
file.setFileName(filename);
|
|
||||||
|
|
||||||
file.remove(); // 3.2.22 erst ganz löschen wegen Schreibrechten
|
|
||||||
if (!file.open(QIODevice::WriteOnly))
|
|
||||||
{
|
|
||||||
qDebug()<<"datei_clearFile cannot open file to delete";
|
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
file.write(0);
|
|
||||||
file.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
750
src/dcBL.cpp
750
src/dcBL.cpp
File diff suppressed because it is too large
Load Diff
994
src/hwapi.cpp
994
src/hwapi.cpp
File diff suppressed because it is too large
Load Diff
1018
src/sendWRcmd.cpp
1018
src/sendWRcmd.cpp
File diff suppressed because it is too large
Load Diff
15
src/serial_port_thread.cpp
Normal file
15
src/serial_port_thread.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "serial_port_thread.h"
|
||||||
|
|
||||||
|
|
||||||
|
SerialPortThread::SerialPortThread(QObject *parent)
|
||||||
|
: QThread(parent) {
|
||||||
|
this->setObjectName("SerialPortThread");
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialPortThread::~SerialPortThread() {
|
||||||
|
m_loop.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerialPortThread::run() {
|
||||||
|
m_loop.exec();
|
||||||
|
}
|
244
src/serial_port_worker.cpp
Normal file
244
src/serial_port_worker.cpp
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
#include "serial_port_worker.h"
|
||||||
|
#include "serial_port_thread.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
std::atomic<uint8_t> Command::m_nextSendBufferIndex{0};
|
||||||
|
std::atomic<uint8_t> Command::m_nextRecvBufferIndex{0};
|
||||||
|
char Command::m_sendBuffers[256][SEND_BLOCK_SIZE]{{0}};
|
||||||
|
char Command::m_recvBuffers[256][SEND_BLOCK_SIZE]{{0}};
|
||||||
|
|
||||||
|
uint32_t Command::getNextCommandPriority(uint8_t priorityClass) {
|
||||||
|
static std::atomic<std::uint32_t> priority_1{0};
|
||||||
|
static std::atomic<std::uint32_t> priority_2{1000000000};
|
||||||
|
static std::atomic<std::uint32_t> priority_3{2000000000};
|
||||||
|
static std::atomic<std::uint32_t> priority_4{3000000000};
|
||||||
|
switch (priorityClass) {
|
||||||
|
case PRIORITY_1:
|
||||||
|
return priority_1.fetch_add(1);
|
||||||
|
case PRIORITY_2:
|
||||||
|
return priority_2.fetch_add(1);
|
||||||
|
case PRIORITY_3:
|
||||||
|
return priority_3.fetch_add(1);
|
||||||
|
case PRIORITY_4:
|
||||||
|
return priority_4.fetch_add(1);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *Command::getNextSendBuffer() {
|
||||||
|
uint8_t const nextIndex = m_nextSendBufferIndex.fetch_add(1);
|
||||||
|
return &m_sendBuffers[nextIndex][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
char *Command::getNextRecvBuffer() {
|
||||||
|
uint8_t const nextIndex = m_nextRecvBufferIndex.fetch_add(1);
|
||||||
|
return &m_recvBuffers[nextIndex][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
Command::Command(uint16_t cmdId, uint8_t sendBufferLength,
|
||||||
|
uint8_t recvBufferLength, uint8_t priorityClass)
|
||||||
|
: m_priority(getNextCommandPriority(priorityClass))
|
||||||
|
, m_priorityClass(priorityClass)
|
||||||
|
, m_cmdId(cmdId)
|
||||||
|
, m_sendBuffer(Command::getNextSendBuffer())
|
||||||
|
, m_recvBuffer(Command::getNextRecvBuffer())
|
||||||
|
, m_sendBufferLength(sendBufferLength)
|
||||||
|
, m_recvBufferLength(recvBufferLength) {
|
||||||
|
memset(m_sendBuffer, 0x00, sizeof(m_sendBuffers[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
Command::Command()
|
||||||
|
: m_priority(0)
|
||||||
|
, m_priorityClass(0)
|
||||||
|
, m_cmdId(0)
|
||||||
|
, m_sendBuffer(0)
|
||||||
|
, m_recvBuffer(0)
|
||||||
|
, m_sendBufferLength(0)
|
||||||
|
, m_recvBufferLength(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Constructor for SerialPort
|
||||||
|
*
|
||||||
|
* @date 08.11.2022 – first draft.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SerialPortWorker::SerialPortWorker(QString portName, enum QSerialPort::BaudRate baudRate, QObject *parent)
|
||||||
|
: QThread(parent)
|
||||||
|
, m_serialPort()
|
||||||
|
, m_serialPortOpened(false)
|
||||||
|
, m_portName(portName)
|
||||||
|
, m_baudRate(baudRate)
|
||||||
|
, m_bytesWritten(0) {
|
||||||
|
this->setObjectName("SerialPortWorker");
|
||||||
|
|
||||||
|
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
|
||||||
|
if (!info.isNull()) {
|
||||||
|
qDebug() << "Name .......... " << info.portName();
|
||||||
|
qDebug() << "Description ... " << info.description();
|
||||||
|
qDebug() << "Manufacturer .. " << info.manufacturer();
|
||||||
|
qDebug() << "SerialNumber .. " << info.serialNumber();
|
||||||
|
if (info.hasProductIdentifier()) {
|
||||||
|
qDebug() << "Product-ID .... " << info.productIdentifier();
|
||||||
|
}
|
||||||
|
if (info.hasVendorIdentifier()) {
|
||||||
|
qDebug() << "Vendor-ID ..... " << info.vendorIdentifier();
|
||||||
|
}
|
||||||
|
qDebug() << "Location ...... " << info.systemLocation();
|
||||||
|
|
||||||
|
if (info.portName() == m_portName) {
|
||||||
|
m_serialPortInfo = info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_serialPortInfo.portName() == m_portName) {
|
||||||
|
m_serialPort.setPort(m_serialPortInfo);
|
||||||
|
m_serialPort.setPortName(m_portName);
|
||||||
|
m_serialPort.setDataBits(QSerialPort::Data8);
|
||||||
|
m_serialPort.setParity(QSerialPort::NoParity);
|
||||||
|
m_serialPort.setStopBits(QSerialPort::OneStop);
|
||||||
|
m_serialPort.setFlowControl(QSerialPort::NoFlowControl);
|
||||||
|
m_serialPortOpened = m_serialPort.open(QIODevice::ReadWrite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialPortWorker::~SerialPortWorker() {
|
||||||
|
closeSerialPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerialPortWorker::run() {
|
||||||
|
SerialPortThread serialPortThread;
|
||||||
|
this->moveToThread(&serialPortThread); // not really necessary
|
||||||
|
|
||||||
|
// Note: because this thread is moved to serialPortThread, the event loop
|
||||||
|
// used will be the one of serialPortThread (this-thread does not even have one).
|
||||||
|
// This is the only purpose of serialPortThread.
|
||||||
|
serialPortThread.start();
|
||||||
|
|
||||||
|
connect(&m_serialPort, SIGNAL(readyRead()), this, SLOT(getBytesAvailable()));
|
||||||
|
connect(&m_serialPort, SIGNAL(bytesWritten(qint64)), this, SLOT(getNumberOfBytesWritten(qint64)));
|
||||||
|
|
||||||
|
while (m_serialPortOpened) {
|
||||||
|
Command nextCmd = getNextCommand();
|
||||||
|
if (nextCmd.m_cmdId == Command::QUIT_SENTINEL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
QByteArray data(nextCmd.getNextSendBuffer(), nextCmd.m_sendBufferLength);
|
||||||
|
m_bytesWritten = 0;
|
||||||
|
m_serialPort.write(data);
|
||||||
|
// process events in event loop of associated thread
|
||||||
|
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||||
|
int maxWaitTime = WAIT_TIME_MAX;
|
||||||
|
|
||||||
|
while (maxWaitTime > 0 && m_bytesWritten < (uint32_t)data.size()) {
|
||||||
|
if (!m_serialPort.waitForBytesWritten(100)) { // wait timeout-ms for the bytes to be written
|
||||||
|
// process events in event loop of associated thread
|
||||||
|
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||||
|
maxWaitTime -= TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_bytesWritten == (uint32_t)data.size()) { // data written, wait for result
|
||||||
|
if (nextCmd.m_recvBufferLength > 0) {
|
||||||
|
// process events in event loop of associated thread
|
||||||
|
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||||
|
maxWaitTime = WAIT_TIME_MAX;
|
||||||
|
while (maxWaitTime > 0 && m_bytesAvailable < nextCmd.m_recvBufferLength) {
|
||||||
|
if (!m_serialPort.waitForReadyRead(100)) {
|
||||||
|
// process events in event loop of associated thread
|
||||||
|
serialPortThread.getEventLoop().processEvents(QEventLoop::ExcludeUserInputEvents, TIMEOUT);
|
||||||
|
maxWaitTime -= TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32_t const bytesAvailable = m_bytesAvailable;
|
||||||
|
if (bytesAvailable == nextCmd.m_recvBufferLength) {
|
||||||
|
QByteArray result = m_serialPort.read(bytesAvailable);
|
||||||
|
if (!result.isEmpty() && ((uint32_t)result.size() == bytesAvailable)) {
|
||||||
|
memcpy(nextCmd.m_recvBuffer, result.data(), bytesAvailable);
|
||||||
|
insertResult(nextCmd);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// error
|
||||||
|
}
|
||||||
|
} // while (m_serialPortOpened)
|
||||||
|
|
||||||
|
serialPortThread.quit();
|
||||||
|
serialPortThread.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SerialPortWorker::openSerialPort() {
|
||||||
|
if (!m_serialPortOpened) {
|
||||||
|
return m_serialPort.open(QIODevice::ReadWrite);
|
||||||
|
}
|
||||||
|
return false; // opening twice is not allowed
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerialPortWorker::closeSerialPort() {
|
||||||
|
if (m_serialPortOpened) {
|
||||||
|
m_serialPort.close();
|
||||||
|
m_serialPortOpened = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerialPortWorker::quit() {
|
||||||
|
Command cmd(Command::QUIT_SENTINEL, 0, 0, Command::PRIORITY_1);
|
||||||
|
insertCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerialPortWorker::insertCommand(Command const &cmd) {
|
||||||
|
{ std::lock_guard<std::mutex> lock(m_sendQueueMutex);
|
||||||
|
m_sendQueue.push(cmd);
|
||||||
|
} // release lock
|
||||||
|
m_sendQueueCondVar.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
Command SerialPortWorker::getNextCommand() {
|
||||||
|
Command nextCmd;
|
||||||
|
{ std::unique_lock<std::mutex> lock(m_sendQueueMutex);
|
||||||
|
m_sendQueueCondVar.wait(lock, [this]{ return !this->m_sendQueue.empty(); });
|
||||||
|
nextCmd = m_sendQueue.top();
|
||||||
|
m_sendQueue.pop();
|
||||||
|
} // release lock
|
||||||
|
return nextCmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerialPortWorker::insertResult(Command const &result) {
|
||||||
|
{ std::lock_guard<std::mutex> lock(m_recvQueueMutex);
|
||||||
|
m_recvQueue.push_back(result);
|
||||||
|
} // release lock
|
||||||
|
m_recvQueueCondVar.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SerialPortWorker::getNextResult(Command &nextResult, int timeout) {
|
||||||
|
bool timed_out = false;
|
||||||
|
{ std::unique_lock<std::mutex> lock(m_recvQueueMutex);
|
||||||
|
if (m_recvQueueCondVar.wait_for(lock, std::chrono::milliseconds(timeout),
|
||||||
|
[this]{ return !this->m_recvQueue.empty(); })) {
|
||||||
|
nextResult = m_recvQueue.front();
|
||||||
|
m_recvQueue.pop_front();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
timed_out = true;
|
||||||
|
}
|
||||||
|
} // release lock
|
||||||
|
return (timed_out == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerialPortWorker::getBytesAvailable() {
|
||||||
|
m_bytesAvailable += m_serialPort.bytesAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SerialPortWorker::getNumberOfBytesWritten(qint64 bytesWritten) {
|
||||||
|
if (bytesWritten > 0) {
|
||||||
|
m_bytesWritten += (uint32_t)bytesWritten;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
#include "shared_mem_buffer.h"
|
#include "shared_mem_buffer.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#ifdef QT_POSIX_IPC
|
#ifdef QT_POSIX_IPC
|
||||||
@ -9,26 +10,102 @@
|
|||||||
// macro will be defined. -> we use SystemV shared memory
|
// macro will be defined. -> we use SystemV shared memory
|
||||||
#error "QT_POSIX_IPC defined"
|
#error "QT_POSIX_IPC defined"
|
||||||
#else
|
#else
|
||||||
#ifdef __linux__
|
|
||||||
#include <sys/ipc.h> // ftok
|
#include <sys/ipc.h> // ftok
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PROCESS_SHARED (PTHREAD_PROCESS_SHARED)
|
||||||
|
|
||||||
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
||||||
|
|
||||||
QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||||
static QSharedMemory shMem;
|
static QSharedMemory shMem;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
#ifdef __linux__
|
|
||||||
static const long nativeKey = ftok("/etc/os-release", 'H');
|
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||||
static const QString fkey = std::to_string(nativeKey).c_str();
|
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||||
#else
|
|
||||||
static const QString fkey = "0123456?000=9";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
shMem.setKey(fkey);
|
shMem.setKey(fkey);
|
||||||
if (!shMem.isAttached()) {
|
if (!shMem.isAttached()) {
|
||||||
if (shMem.create(size)) {
|
if (shMem.create(size)) {
|
||||||
|
// the creator is the owner of the shared-memory segment
|
||||||
|
SharedMemBuffer *shm = (SharedMemBuffer *)(shMem.data());
|
||||||
|
if (shm) {
|
||||||
|
shm->init = 0;
|
||||||
|
// mark the shm
|
||||||
|
memset(shm->appName, 0x00, sizeof(shm->appName));
|
||||||
|
strncpy(shm->appName,
|
||||||
|
QCoreApplication::applicationName().toLocal8Bit().constData(),
|
||||||
|
sizeof(shm->appName)-1);
|
||||||
|
shm->pid = getpid();
|
||||||
|
|
||||||
|
// create condition variables plus associated mutexes for
|
||||||
|
// sending/receiving commands to dc
|
||||||
|
int r = 0;
|
||||||
|
if ((r = pthread_mutexattr_init(&shm->sndMtxA)) != 0) {
|
||||||
|
qCritical() << "init mutex attribute"
|
||||||
|
<< strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_mutexattr_setpshared(
|
||||||
|
&shm->sndMtxA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||||
|
qCritical() << "set s-mutex attribute to process shared"
|
||||||
|
<< strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_mutex_init(&shm->sndMtx,
|
||||||
|
&shm->sndMtxA) != 0)) {
|
||||||
|
qCritical() << "init s-mutex" << strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_condattr_init(&shm->sndCndA) != 0)) {
|
||||||
|
qCritical() << "init s-mutex" << strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_condattr_setpshared(
|
||||||
|
&shm->sndCndA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||||
|
qCritical() << "init s-cond attribute to process shared"
|
||||||
|
<< strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_cond_init(&shm->sndCndV,
|
||||||
|
&shm->sndCndA) != 0)) {
|
||||||
|
qCritical() << "init s-condvar" << strerror(errno) << r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((r = pthread_mutexattr_init(&shm->rcvMtxA)) != 0) {
|
||||||
|
qCritical() << "init r-mutex attribute"
|
||||||
|
<< strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_mutexattr_setpshared(
|
||||||
|
&shm->rcvMtxA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||||
|
qCritical() << "set r-mutex attribute to process shared"
|
||||||
|
<< strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_mutex_init(&shm->rcvMtx,
|
||||||
|
&shm->rcvMtxA) != 0)) {
|
||||||
|
qCritical() << "init r-mutex" << strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_condattr_init(&shm->rcvCndA) != 0)) {
|
||||||
|
qCritical() << "init r-mutex" << strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_condattr_setpshared(
|
||||||
|
&shm->rcvCndA, PTHREAD_PROCESS_SHARED) != 0)) {
|
||||||
|
qCritical() << "init r-cond attribute to process shared"
|
||||||
|
<< strerror(errno) << r;
|
||||||
|
}
|
||||||
|
if ((r == 0) &&
|
||||||
|
(r = pthread_cond_init(&shm->rcvCndV,
|
||||||
|
&shm->rcvCndA) != 0)) {
|
||||||
|
qCritical() << "init s-condvar" << strerror(errno) << r;
|
||||||
|
}
|
||||||
|
shm->init = 1;
|
||||||
|
}
|
||||||
return &shMem;
|
return &shMem;
|
||||||
} else {
|
} else {
|
||||||
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||||
|
1780
src/storeINdata.cpp
1780
src/storeINdata.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user