Compare commits
57 Commits
ed037b99c9
...
master
Author | SHA1 | Date | |
---|---|---|---|
60726093df | |||
777fabe95d | |||
a03df50881 | |||
06333c792f
|
|||
1ee1242a4c
|
|||
e318e606c6
|
|||
a67ff36c68
|
|||
21fb07b81c
|
|||
d992ee3fad | |||
b7d8fabfd0 | |||
7129805f4e | |||
01140c523b | |||
c99d0730ce | |||
81c610c48b | |||
6ae7c06d42 | |||
1eb2ac3a1d | |||
f3adba2f0f | |||
652ad9b43d | |||
c85b090306 | |||
87a6ed0795 | |||
99c88c7825 | |||
712ea0fc6e | |||
86311de486 | |||
cb4412779f | |||
a95e174356 | |||
c724b5b9fb | |||
ef7932102f | |||
a7aa75ae5f | |||
dc00c69b82 | |||
eeb35190e1 | |||
30338e24cc | |||
58fdea45f0 | |||
df760f1a52 | |||
3e3e1efe7d | |||
e5a8cfd1cd | |||
5e6e6017b3 | |||
f3d9c690b7 | |||
3f10469b8f | |||
d92bdbfb3e | |||
60c48588b0 | |||
ef48301dad | |||
5f7d34ef12 | |||
863e4b23a9 | |||
37f0012ce9 | |||
82accc4b1a | |||
c1b945225b | |||
debade9942 | |||
ffbe0dfc2e | |||
8f7d4a203d | |||
defe492ec6 | |||
002d58ba7b | |||
76f54cdc0c | |||
591fd89cb5 | |||
e7723f669f | |||
d0e1be11b6 | |||
f63798727f | |||
898f0a4af8 |
42
.gitignore
vendored
42
.gitignore
vendored
@@ -1 +1,41 @@
|
|||||||
*.user
|
# C++ objects and libs
|
||||||
|
|
||||||
|
*.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
|
||||||
|
@@ -2,6 +2,7 @@ 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 \
|
||||||
@@ -10,9 +11,12 @@ HEADERS += $${PWD}/include/com.h \
|
|||||||
$${PWD}/include/prot.h \
|
$${PWD}/include/prot.h \
|
||||||
$${PWD}/include/sendWRcmd.h \
|
$${PWD}/include/sendWRcmd.h \
|
||||||
$${PWD}/include/storeINdata.h \
|
$${PWD}/include/storeINdata.h \
|
||||||
$${PWD}/include/tslib.h
|
$${PWD}/include/tslib.h \
|
||||||
|
$${PWD}/include/shared_mem_buffer.h
|
||||||
|
|
||||||
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 \
|
||||||
@@ -20,4 +24,5 @@ SOURCES += $${PWD}/src/com.cpp \
|
|||||||
$${PWD}/src/prot.cpp \
|
$${PWD}/src/prot.cpp \
|
||||||
$${PWD}/src/sendWRcmd.cpp \
|
$${PWD}/src/sendWRcmd.cpp \
|
||||||
$${PWD}/src/storeINdata.cpp \
|
$${PWD}/src/storeINdata.cpp \
|
||||||
$${PWD}/src/tslib.cpp
|
$${PWD}/src/tslib.cpp \
|
||||||
|
$${PWD}/src/shared_mem_buffer.cpp
|
||||||
|
41
DCPlugin.pro
41
DCPlugin.pro
@@ -1,5 +1,5 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += plugin PTU5
|
CONFIG += plugin
|
||||||
#CONFIG += c++11 console
|
#CONFIG += c++11 console
|
||||||
#CONFIG -= app_bundle
|
#CONFIG -= app_bundle
|
||||||
#QT += widgets
|
#QT += widgets
|
||||||
@@ -15,17 +15,19 @@ 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++11
|
QMAKE_CXXFLAGS += -std=c++17
|
||||||
|
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
|
||||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||||
ARCH = DesktopLinux
|
ARCH = DesktopLinux
|
||||||
|
include(DCPlugin.pri)
|
||||||
}
|
}
|
||||||
|
|
||||||
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++11
|
QMAKE_CXXFLAGS += -std=c++17
|
||||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
ARCH = PTU5
|
ARCH = PTU5
|
||||||
@@ -33,10 +35,11 @@ contains( CONFIG, PTU5 ) {
|
|||||||
# NOTE: include contents of DCPlugin.pri. Also used by ATBQT.
|
# NOTE: include contents of DCPlugin.pri. Also used by ATBQT.
|
||||||
# Add new files in DCPlugin.pri.
|
# Add new files in DCPlugin.pri.
|
||||||
include(DCPlugin.pri)
|
include(DCPlugin.pri)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -44,7 +47,9 @@ 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
|
||||||
@@ -65,3 +70,21 @@ 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 +=
|
||||||
|
155
generate-version.sh
Executable file
155
generate-version.sh
Executable file
@@ -0,0 +1,155 @@
|
|||||||
|
#!/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}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -303,6 +303,7 @@ 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;
|
||||||
@@ -327,6 +328,11 @@ signals:
|
|||||||
//the requested data are stored in peripheral image
|
//the requested data are stored in peripheral image
|
||||||
// can be loaded with epi
|
// can be loaded with epi
|
||||||
|
|
||||||
|
void datif_templatePrintFinished_OK();
|
||||||
|
void datif_templatePrintFinished_Err();
|
||||||
|
|
||||||
|
void datif_gotNewCoin();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CI_H
|
#endif // CI_H
|
||||||
|
202
include/datei.h
Normal file
202
include/datei.h
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
#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
|
2478
include/hwapi.h
2478
include/hwapi.h
File diff suppressed because it is too large
Load Diff
1115
include/interfaces.h
1115
include/interfaces.h
File diff suppressed because it is too large
Load Diff
@@ -212,6 +212,50 @@ uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *
|
|||||||
// 2: QR-code-Printer is using this buffer
|
// 2: QR-code-Printer is using this buffer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define FDCMD_STACKDEPTH 16
|
||||||
|
void sendFDcmd_clrStack(void);
|
||||||
|
|
||||||
|
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
||||||
|
// write Command to memory, wait for transport
|
||||||
|
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
||||||
|
|
||||||
|
uint8_t check4FDshortCmd(void);
|
||||||
|
// returns number of waiting command, maxFDCMD_STACKDEPTH
|
||||||
|
|
||||||
|
uint8_t checkNextFDcmd(void);
|
||||||
|
// return 0: no command waiting
|
||||||
|
// 1: short cmd
|
||||||
|
// 2: long cmd
|
||||||
|
|
||||||
|
uint8_t check4freeFDshortCmd(void);
|
||||||
|
// returns number of free places in short-command stack
|
||||||
|
|
||||||
|
//#define FDLONG_STACKDEPTH 16
|
||||||
|
//void longFDcmd_clrStack(void);
|
||||||
|
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data);
|
||||||
|
// write Command to memory, wait for transport
|
||||||
|
// data buffer size always 64! data[64], padded with 0
|
||||||
|
//bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
||||||
|
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
||||||
|
|
||||||
|
//uint8_t check4FDlongCmd(void);
|
||||||
|
// returns number of waiting command
|
||||||
|
|
||||||
|
//uint8_t check4freeFDlongCmd(void);
|
||||||
|
// 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
|
||||||
|
|
||||||
|
|
||||||
|
301
include/shared_mem_buffer.h
Normal file
301
include/shared_mem_buffer.h
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
#ifndef SHARED_MEM_BUFFER_INCLUDED_H
|
||||||
|
#define SHARED_MEM_BUFFER_INCLUDED_H
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#include <QSharedMemory>
|
||||||
|
|
||||||
|
struct SharedMemBuffer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct rs {
|
||||||
|
char comportName[16]; // z.B. "COM48"
|
||||||
|
char baudStr[16]; // z.B. "19200"
|
||||||
|
int baudNr; // 0...5 oder -1
|
||||||
|
uint8_t connect; // 0,1
|
||||||
|
bool portIsOpen;
|
||||||
|
} rs;
|
||||||
|
|
||||||
|
char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
||||||
|
|
||||||
|
struct datif {
|
||||||
|
uint16_t sendingPeriod;
|
||||||
|
bool sendingPer_changed;
|
||||||
|
} datif;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// controlBus.cpp
|
||||||
|
char txt4comStateLine[32];
|
||||||
|
char txt4HsStateLine[32];
|
||||||
|
char txt4masterStateLine[32];
|
||||||
|
char txt4resultStateLine[32];
|
||||||
|
char txt4dataLine[32];
|
||||||
|
char txt4datifReceive[32];
|
||||||
|
char txt4diagWindow[32];
|
||||||
|
char sndTxt4diagWindow[32];
|
||||||
|
bool Sdata_serialTestResult[32];
|
||||||
|
uint8_t Sdata_pProtResultOk[32];
|
||||||
|
uint16_t Sdata_receivedDataLength[32];
|
||||||
|
uint8_t Sdata_receivedDataBlock[64];
|
||||||
|
|
||||||
|
// datif.cpp
|
||||||
|
uint8_t dif_dataStep;
|
||||||
|
uint8_t dif_scanStep;
|
||||||
|
uint8_t RDBLKNR;
|
||||||
|
uint8_t datif_OutCmdpara1;
|
||||||
|
uint8_t datif_OutCmdpara2;
|
||||||
|
uint8_t datif_OutCmdpara3;
|
||||||
|
uint8_t datif_OutCmdpara4;
|
||||||
|
|
||||||
|
uint16_t datif_OutCmdpara5;
|
||||||
|
uint32_t datif_OutCmdpara6;
|
||||||
|
uint8_t cycl_running;
|
||||||
|
|
||||||
|
// dcBL.cpp
|
||||||
|
uint8_t dcBL_LastBLcmd; // stored the last sent cmd in order to analys response
|
||||||
|
uint8_t dcBL_AtbBinFile[300000];
|
||||||
|
uint32_t dcBL_fileSize;
|
||||||
|
uint16_t dcBL_nrOfBlocks;
|
||||||
|
uint16_t dcBL_fileCrc;
|
||||||
|
uint8_t dcBL_myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise
|
||||||
|
|
||||||
|
char BlResp[50][32];
|
||||||
|
uint8_t dcBL_step;
|
||||||
|
uint8_t dcBL_state;
|
||||||
|
uint16_t dcBL_BlkCtr;
|
||||||
|
uint16_t dcBL_cyclCtr;
|
||||||
|
uint16_t repeatCtr;
|
||||||
|
uint8_t Sdata_rawData[150];
|
||||||
|
uint8_t Sdata_LengthRawData;
|
||||||
|
|
||||||
|
// hwapi.cpp
|
||||||
|
uint16_t hwapi_shutterTime;
|
||||||
|
char ticketTemplate[1024];
|
||||||
|
|
||||||
|
// sendWRcmd.cpp
|
||||||
|
uint16_t nextAsynchsendCmd0[16];
|
||||||
|
uint8_t nrOfCmdsInQueue;
|
||||||
|
uint16_t nextAsynchsendCmd4[8];
|
||||||
|
uint8_t nextCmd4para1[8];
|
||||||
|
uint8_t nextCmd4para2[8];
|
||||||
|
uint8_t nextCmd4para3[8];
|
||||||
|
uint8_t nextCmd4para4[8];
|
||||||
|
uint8_t nrOfCmds4InQueue;
|
||||||
|
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];
|
||||||
|
uint8_t nextFDpara2[16];
|
||||||
|
uint8_t nextFDpara3[16];
|
||||||
|
uint8_t nextFDpara4[16];
|
||||||
|
uint8_t p_nextFDcmdsInQueue;
|
||||||
|
uint8_t longFDwrCmd[16];
|
||||||
|
uint8_t longFDrdCmd[16];
|
||||||
|
uint8_t longFDblkNr[16];
|
||||||
|
uint8_t longFDlength[16];
|
||||||
|
|
||||||
|
uint8_t longFDpara[16][64];
|
||||||
|
uint8_t p_longFDcmdsInQueue;
|
||||||
|
|
||||||
|
// storeInData.cpp
|
||||||
|
bool indat_savePrnPwr;
|
||||||
|
bool indat_saveMifPwr;
|
||||||
|
bool indat_MdbIsOn;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t ndbs;
|
||||||
|
uint8_t pari;
|
||||||
|
uint8_t nsb;
|
||||||
|
uint8_t br;
|
||||||
|
|
||||||
|
#define MAXNROF_GENSTR 16
|
||||||
|
char genStrings[MAXNROF_GENSTR][64];
|
||||||
|
|
||||||
|
#define MAXNROF_AI 4
|
||||||
|
uint16_t AI_val[MAXNROF_AI];
|
||||||
|
|
||||||
|
struct DigitalInputs {
|
||||||
|
uint8_t doorSwitch;
|
||||||
|
uint8_t vaultSwitch;
|
||||||
|
uint8_t lockSwitch;
|
||||||
|
uint8_t opto;
|
||||||
|
uint8_t aux;
|
||||||
|
bool wakeFromPtu;
|
||||||
|
bool wakeFromMdb;
|
||||||
|
bool wakeFromModem;
|
||||||
|
bool PrnReady;
|
||||||
|
bool CoinAttach;
|
||||||
|
bool CoinEscrowOpen;
|
||||||
|
bool mifCardTap;
|
||||||
|
bool contactPwrOn;
|
||||||
|
bool mifarePwrOn;
|
||||||
|
bool rdbk_mdbTxd;
|
||||||
|
bool AuxPwrOn;
|
||||||
|
bool gsmPwrOn;
|
||||||
|
bool creditPwrOn;
|
||||||
|
bool printerPwrOn;
|
||||||
|
bool mdbPwrOn;
|
||||||
|
bool rejMot_home;
|
||||||
|
uint8_t npe_sensor;
|
||||||
|
} din;
|
||||||
|
|
||||||
|
struct DigitalOutputs {
|
||||||
|
uint8_t mbdRxTst;
|
||||||
|
uint8_t motorBits;
|
||||||
|
uint8_t serialSwitch; // serial drv on/off, Serial mux1, Serial mux2
|
||||||
|
uint8_t ledsAndFan;
|
||||||
|
uint8_t laermUndRelay;
|
||||||
|
uint8_t ptuWake;
|
||||||
|
uint8_t auxPower;
|
||||||
|
uint8_t coinShutter;
|
||||||
|
uint8_t coinEscrow;
|
||||||
|
uint8_t printerPower;
|
||||||
|
} dout;
|
||||||
|
|
||||||
|
struct Sdata {
|
||||||
|
#define NROFMIFSTATEBYTES 40
|
||||||
|
#define PRN_STATE_ARRAY_SIZE 20
|
||||||
|
#define PRN_STATE_FONT_SIZE 20
|
||||||
|
uint8_t MIF_STATE[NROFMIFSTATEBYTES];
|
||||||
|
uint8_t MIF_DATA[12][64];
|
||||||
|
uint8_t PRN_STATE[PRN_STATE_ARRAY_SIZE];
|
||||||
|
uint8_t PRN_FONTS[PRN_STATE_FONT_SIZE];
|
||||||
|
bool mdb_busRdy;
|
||||||
|
bool mdb_V12on;
|
||||||
|
bool mdb_V5on;
|
||||||
|
uint8_t mdbNrOfRecData;
|
||||||
|
uint8_t RecBuff[40];
|
||||||
|
uint8_t empNrOfsettings;
|
||||||
|
uint8_t emp_settingsBuff[66];
|
||||||
|
uint8_t NrOfDeviceSetting;
|
||||||
|
uint8_t DeviceSettingBuff[66];
|
||||||
|
uint8_t NrOfMachineIDSetting;
|
||||||
|
uint8_t NrOfMachineIDBuff[66];
|
||||||
|
uint64_t slaveUID;
|
||||||
|
uint8_t UIDstr[8];
|
||||||
|
#define MAXNROF_MEASURE 4
|
||||||
|
uint32_t measurement[MAXNROF_MEASURE];
|
||||||
|
bool serialTestResult;
|
||||||
|
uint8_t pProtResultOk;
|
||||||
|
uint16_t receivedDataLength;
|
||||||
|
uint8_t receivedDataBlock[64];
|
||||||
|
} Sdata;
|
||||||
|
|
||||||
|
uint8_t mif_cardType;
|
||||||
|
uint8_t mif_cardHolder[8];
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define MEMDEPTH_GOTCOINS (16)
|
||||||
|
struct T_coin {
|
||||||
|
uint8_t valid;
|
||||||
|
uint8_t signal;
|
||||||
|
uint8_t error;
|
||||||
|
uint8_t pad;
|
||||||
|
uint16_t value;
|
||||||
|
} gotCoin[MEMDEPTH_GOTCOINS];
|
||||||
|
uint8_t ctr_gotCoin;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct store {
|
||||||
|
uint32_t insertedAmount;
|
||||||
|
uint16_t lastCoinType[64];
|
||||||
|
uint16_t lastCoinValue[64];
|
||||||
|
uint64_t wakeSrc;
|
||||||
|
uint8_t rbDevParamLen;
|
||||||
|
uint8_t rbDevParams[66];
|
||||||
|
uint8_t deviceCondLen;
|
||||||
|
uint8_t deviceCond[66];
|
||||||
|
uint8_t machCondLen;
|
||||||
|
uint8_t machCond[66];
|
||||||
|
uint8_t DcBackupNrOfAccNr;
|
||||||
|
uint16_t DcBackupAccNr[16]; // z.Z. nur 8
|
||||||
|
uint8_t gotNrBlocksOfVaultRec;
|
||||||
|
uint8_t vaultrecord[360];
|
||||||
|
uint32_t amount;
|
||||||
|
uint16_t nrOfCoins;
|
||||||
|
} store;
|
||||||
|
|
||||||
|
struct T_globTime {
|
||||||
|
// Reihenfolge nicht vertauschen!!!!!
|
||||||
|
uint8_t hour;
|
||||||
|
uint8_t minute;
|
||||||
|
uint8_t second;
|
||||||
|
uint8_t Year;
|
||||||
|
uint8_t Month;
|
||||||
|
uint8_t DayOfMonth;
|
||||||
|
uint8_t DayOfWeek; // 1=monday...7
|
||||||
|
uint8_t reserve1;
|
||||||
|
|
||||||
|
uint16_t MinutesOfToday;
|
||||||
|
uint16_t reserve2;
|
||||||
|
|
||||||
|
uint32_t SecondsOfToday;
|
||||||
|
|
||||||
|
uint8_t IsLeapyear;
|
||||||
|
uint8_t nextLeap;
|
||||||
|
uint8_t lastLeap;
|
||||||
|
uint8_t hoursOfWeek;
|
||||||
|
|
||||||
|
uint16_t minOfWeek;
|
||||||
|
uint16_t hoursOfMonth;
|
||||||
|
uint16_t minOfMonth;
|
||||||
|
uint16_t dayOfYear;
|
||||||
|
uint16_t hoursOfYear;
|
||||||
|
uint16_t reserve3;
|
||||||
|
|
||||||
|
uint32_t minOfYear;
|
||||||
|
|
||||||
|
uint8_t squareOutMode;
|
||||||
|
uint8_t free1;
|
||||||
|
uint16_t reserve4;
|
||||||
|
uint32_t minOfMillenium;
|
||||||
|
// bis hierher 44byts
|
||||||
|
uint32_t free2;
|
||||||
|
uint32_t free3;
|
||||||
|
uint32_t free4;
|
||||||
|
} getGlobalTime;
|
||||||
|
|
||||||
|
static QSharedMemory *getShm(std::size_t s = 0);
|
||||||
|
static SharedMemBuffer *getData() {
|
||||||
|
return (SharedMemBuffer *)getShm()->data();
|
||||||
|
}
|
||||||
|
static SharedMemBuffer const *getDataConst() {
|
||||||
|
return (SharedMemBuffer const *)getShm()->data();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static std::atomic<bool> __sharedMemLocked;
|
||||||
|
|
||||||
|
static bool sharedMemLocked() {
|
||||||
|
return __sharedMemLocked;
|
||||||
|
}
|
||||||
|
static void setSharedMemLocked() {
|
||||||
|
__sharedMemLocked = true;
|
||||||
|
}
|
||||||
|
static void setSharedMemUnlocked() {
|
||||||
|
__sharedMemLocked = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SHARED_MEM_BUFFER_INCLUDED_H
|
@@ -54,7 +54,13 @@ 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 *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);
|
||||||
@@ -73,7 +79,7 @@ QString epi_getUIDstr();
|
|||||||
uint8_t epi_getSquareMode();
|
uint8_t epi_getSquareMode();
|
||||||
void gpi_backupSquareMode(uint8_t squMode);
|
void gpi_backupSquareMode(uint8_t squMode);
|
||||||
|
|
||||||
void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng);
|
void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng); // 104, <=8byte
|
||||||
void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss);
|
void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss);
|
||||||
void epi_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd);
|
void epi_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd);
|
||||||
void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday);
|
void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday);
|
||||||
@@ -474,15 +480,97 @@ void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, u
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeDeviceSettings(uint8_t leng, uint8_t *data);
|
void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t *data);
|
||||||
|
|
||||||
|
void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
void epi_restoreDeviceSettings(uint8_t *leng, uint8_t *data);
|
|
||||||
|
|
||||||
void gpi_storeMachineIDsettings(uint8_t leng, uint8_t *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 gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue);
|
||||||
|
|
||||||
|
uint32_t epi_CurrentPaymentGetAmount(void);
|
||||||
|
|
||||||
|
uint16_t epi_CurrentPaymentGetLastCoin(void);
|
||||||
|
|
||||||
|
bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values);
|
||||||
|
// alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeWakeSources(uint8_t *receivedData);
|
||||||
|
|
||||||
|
uint64_t epi_getWakeSources(void);
|
||||||
|
|
||||||
|
uint8_t epi_getWakeReason(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeExtendedTime(uint8_t leng, uint8_t *data);
|
||||||
|
|
||||||
|
void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeDeviceConditions(uint8_t leng, uint8_t *data);
|
||||||
|
|
||||||
|
void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data);
|
||||||
|
|
||||||
|
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data);
|
||||||
|
|
||||||
|
void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs);
|
||||||
|
// return accNrs[0..7]
|
||||||
|
|
||||||
|
|
||||||
|
void epi_iniVRstorage(void);
|
||||||
|
|
||||||
|
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data );
|
||||||
|
|
||||||
|
bool epi_checkIfVaultRecordAvailable(void);
|
||||||
|
|
||||||
|
bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf );
|
||||||
|
// true if completly received
|
||||||
|
|
||||||
|
void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins );
|
||||||
|
|
||||||
|
uint32_t epi_getCashBoxContent(void);
|
||||||
|
|
||||||
|
uint16_t epi_getNrOfCoinsInCashBox(void);
|
||||||
|
|
||||||
|
void gpi_storeNewMifareCard(uint8_t typ, uint8_t *holder );
|
||||||
|
|
||||||
|
uint8_t epi_mifGetCardType(uint8_t *holder);
|
||||||
|
//holder[8] = name of card holder
|
||||||
|
// 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
|
||||||
|
|
||||||
|
|
||||||
|
@@ -13,6 +13,9 @@ uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t L
|
|||||||
|
|
||||||
uint8_t uint2uchar(uint16_t uival, bool getHighB);
|
uint8_t uint2uchar(uint16_t uival, bool getHighB);
|
||||||
|
|
||||||
|
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr);
|
||||||
|
// getBytNr: 0=LSB 3=MSB
|
||||||
|
|
||||||
|
|
||||||
void delay(uint16_t MilliSec);
|
void delay(uint16_t MilliSec);
|
||||||
|
|
||||||
@@ -59,6 +62,7 @@ void GetShortDateString(uint8_t day, uint8_t month, uint8_t yearlow, uint8_t for
|
|||||||
|
|
||||||
|
|
||||||
uint16_t tslib_strlen(char *buf);
|
uint16_t tslib_strlen(char *buf);
|
||||||
|
uint16_t tslib_strlen(uint8_t *buf);
|
||||||
|
|
||||||
void tslib_strclr(char *buf, char clrsign, uint16_t len);
|
void tslib_strclr(char *buf, char clrsign, uint16_t len);
|
||||||
void tslib_strclr(uint8_t *buf, char clrsign, uint16_t len);
|
void tslib_strclr(uint8_t *buf, char clrsign, uint16_t len);
|
||||||
@@ -79,6 +83,8 @@ int tslib_getMinimum(int val1, int val2);
|
|||||||
void tslib_text2array(QByteArray text, char *aray, uint16_t maxArayLen);
|
void tslib_text2array(QByteArray text, char *aray, uint16_t maxArayLen);
|
||||||
// usage: tslib_text2array("my text", ctmp, 50);
|
// usage: tslib_text2array("my text", ctmp, 50);
|
||||||
|
|
||||||
|
void biox_CopyBlock(uint8_t *src, uint16_t srcPos, uint8_t *dest, uint16_t destPos, uint16_t len);
|
||||||
|
// both buffers starting from pos 0
|
||||||
|
|
||||||
|
|
||||||
#endif // TSLIB_H
|
#endif // TSLIB_H
|
||||||
|
2873
plugins/interfaces.h
2873
plugins/interfaces.h
File diff suppressed because it is too large
Load Diff
@@ -412,4 +412,88 @@ uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ctmp=ndbs;
|
||||||
|
ctmp+=0x30;
|
||||||
|
mySt.append(ctmp);
|
||||||
|
ctmp=pari;
|
||||||
|
mySt.append(ctmp);
|
||||||
|
ctmp=nsb;
|
||||||
|
ctmp+=0x30;
|
||||||
|
mySt.append(ctmp);
|
||||||
|
//mySt="Hallo";
|
||||||
|
return mySt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
654
src/datIf.cpp
654
src/datIf.cpp
File diff suppressed because it is too large
Load Diff
943
src/datei.cpp
Normal file
943
src/datei.cpp
Normal file
@@ -0,0 +1,943 @@
|
|||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
6570
src/hwapi.cpp
6570
src/hwapi.cpp
File diff suppressed because it is too large
Load Diff
9
src/main.cpp
Normal file
9
src/main.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include <QCoreApplication>
|
||||||
|
#include "tslib.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
@@ -13,6 +13,7 @@ void sendWRcmd_INI(void)
|
|||||||
|
|
||||||
sendWRcmd_clrCmdStack();
|
sendWRcmd_clrCmdStack();
|
||||||
sendWRcmd_clrCmd4Stack();
|
sendWRcmd_clrCmd4Stack();
|
||||||
|
sendFDcmd_clrStack();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,13 +61,19 @@ bool sendWRcmd_setSendCommand0(uint16_t nextCmd)
|
|||||||
uint16_t sendWRcmd_getSendCommand0(void)
|
uint16_t sendWRcmd_getSendCommand0(void)
|
||||||
{
|
{
|
||||||
uint16_t nxtAsynchCmd;
|
uint16_t nxtAsynchCmd;
|
||||||
uint8_t nn;
|
uint8_t nn, ll;
|
||||||
if (nrOfCmdsInQueue==0 || nrOfCmdsInQueue>CMDSTACKDEPTH)
|
if (nrOfCmdsInQueue==0 || nrOfCmdsInQueue>CMDSTACKDEPTH)
|
||||||
return 0; // error
|
return 0; // error
|
||||||
nxtAsynchCmd=nextAsynchsendCmd0[0];
|
nxtAsynchCmd=nextAsynchsendCmd0[0];
|
||||||
|
|
||||||
// move Puffer down by one element
|
// move Puffer down by one element
|
||||||
for (nn=0; nn<CMDSTACKDEPTH; nn++)
|
if (CMDSTACKDEPTH>0)
|
||||||
|
ll=CMDSTACKDEPTH-1;
|
||||||
|
else
|
||||||
|
ll=0;
|
||||||
|
for (nn=0; nn<ll; nn++)
|
||||||
nextAsynchsendCmd0[nn]=nextAsynchsendCmd0[nn+1];
|
nextAsynchsendCmd0[nn]=nextAsynchsendCmd0[nn+1];
|
||||||
|
|
||||||
if (nrOfCmdsInQueue>0)
|
if (nrOfCmdsInQueue>0)
|
||||||
nrOfCmdsInQueue--;
|
nrOfCmdsInQueue--;
|
||||||
//qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
|
//qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
|
||||||
@@ -138,7 +145,7 @@ bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uin
|
|||||||
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)
|
||||||
{
|
{
|
||||||
uint16_t nxtAsynchCmd;
|
uint16_t nxtAsynchCmd;
|
||||||
uint8_t nn;
|
uint8_t nn, ll;
|
||||||
|
|
||||||
if (nrOfCmds4InQueue==0 || nrOfCmds4InQueue>CMD4STACKDEPTH)
|
if (nrOfCmds4InQueue==0 || nrOfCmds4InQueue>CMD4STACKDEPTH)
|
||||||
return 0; // error
|
return 0; // error
|
||||||
@@ -152,7 +159,11 @@ uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3,
|
|||||||
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
|
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
|
||||||
|
|
||||||
// move Puffer down by one element
|
// move Puffer down by one element
|
||||||
for (nn=0; nn<CMD4STACKDEPTH; nn++)
|
if (CMD4STACKDEPTH>0)
|
||||||
|
ll=CMD4STACKDEPTH-1;
|
||||||
|
else
|
||||||
|
ll=0;
|
||||||
|
for (nn=0; nn<ll; nn++)
|
||||||
{
|
{
|
||||||
nextAsynchsendCmd4[nn]=nextAsynchsendCmd4[nn+1];
|
nextAsynchsendCmd4[nn]=nextAsynchsendCmd4[nn+1];
|
||||||
nextCmd4para1[nn]=nextCmd4para1[nn+1];
|
nextCmd4para1[nn]=nextCmd4para1[nn+1];
|
||||||
@@ -211,9 +222,9 @@ bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uin
|
|||||||
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)
|
||||||
{
|
{
|
||||||
uint16_t nxtAsynchCmd;
|
uint16_t nxtAsynchCmd;
|
||||||
uint8_t nn;
|
uint8_t nn, ll;
|
||||||
|
|
||||||
if (nrOfCmds8InQueue==0 || nrOfCmds8InQueue>CMD4STACKDEPTH)
|
if (nrOfCmds8InQueue==0 || nrOfCmds8InQueue>CMD8STACKDEPTH)
|
||||||
return 0; // error
|
return 0; // error
|
||||||
nxtAsynchCmd=nextAsynchsendCmd8[0];
|
nxtAsynchCmd=nextAsynchsendCmd8[0];
|
||||||
*dat1=nextCmd8para1[0];
|
*dat1=nextCmd8para1[0];
|
||||||
@@ -222,7 +233,11 @@ uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3,
|
|||||||
*dat4=nextCmd8para4[0];
|
*dat4=nextCmd8para4[0];
|
||||||
|
|
||||||
// move buffer down by one element
|
// move buffer down by one element
|
||||||
for (nn=0; nn<CMD8STACKDEPTH; nn++)
|
if (CMD8STACKDEPTH>0)
|
||||||
|
ll=CMD8STACKDEPTH-1;
|
||||||
|
else
|
||||||
|
ll=0;
|
||||||
|
for (nn=0; nn<ll; nn++)
|
||||||
{
|
{
|
||||||
nextAsynchsendCmd8[nn]=nextAsynchsendCmd8[nn+1];
|
nextAsynchsendCmd8[nn]=nextAsynchsendCmd8[nn+1];
|
||||||
nextCmd8para1[nn]=nextCmd8para1[nn+1];
|
nextCmd8para1[nn]=nextCmd8para1[nn+1];
|
||||||
@@ -433,3 +448,384 @@ uint8_t gpi_chk4remainingText(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------
|
||||||
|
// 11.4.23 neu, Kommando direkt an "FastDevice"-protokoll senden, nicht mehr umsetzen
|
||||||
|
// ---------------------------------------------------------------------------------
|
||||||
|
// header
|
||||||
|
static uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t nextFDshort[FDCMD_STACKDEPTH];
|
||||||
|
|
||||||
|
// short data
|
||||||
|
static uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
||||||
|
// lon data:
|
||||||
|
static uint8_t longFDlength[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t longFDpara[FDCMD_STACKDEPTH][64];
|
||||||
|
|
||||||
|
static uint8_t p_nextFDcmdsInQueue;
|
||||||
|
|
||||||
|
/* convention: use simple (not rotating) FIFO Stack:
|
||||||
|
Example: nrOfCmdsInQueue=4 then
|
||||||
|
nextAsynchsendCmd0[0]=cmd1 // was stored as first
|
||||||
|
nextAsynchsendCmd0[1]=cmd2
|
||||||
|
nextAsynchsendCmd0[2]=cmd3
|
||||||
|
nextAsynchsendCmd0[3]=cmd4 // came in as last
|
||||||
|
|
||||||
|
Send: [0] first, then move buffer 1 down:
|
||||||
|
nextAsynchsendCmd0[0]=cmd2
|
||||||
|
nextAsynchsendCmd0[1]=cmd3
|
||||||
|
nextAsynchsendCmd0[2]=cmd4
|
||||||
|
nextAsynchsendCmd0[3]=0;
|
||||||
|
nrOfCmdsInQueue=3 now
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void sendFDcmd_clrStack(void)
|
||||||
|
{
|
||||||
|
uint8_t nn;
|
||||||
|
for (nn=0; nn<FDCMD_STACKDEPTH; nn++)
|
||||||
|
{
|
||||||
|
nextFDwrCmd[nn]=0;
|
||||||
|
nextFDrdCmd[nn]=0;
|
||||||
|
nextFDblkNr[nn]=0;
|
||||||
|
nextFDshort[nn]=0;
|
||||||
|
nextFDpara1[nn]=0;
|
||||||
|
nextFDpara2[nn]=0;
|
||||||
|
nextFDpara3[nn]=0;
|
||||||
|
nextFDpara4[nn]=0;
|
||||||
|
longFDlength[nn]=0;
|
||||||
|
memset(&longFDpara[nn][0],0,64);
|
||||||
|
}
|
||||||
|
|
||||||
|
p_nextFDcmdsInQueue=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4)
|
||||||
|
{
|
||||||
|
|
||||||
|
// write Command to memory, wait for transport
|
||||||
|
if (p_nextFDcmdsInQueue>=FDCMD_STACKDEPTH)
|
||||||
|
{
|
||||||
|
qDebug() << "cannot save cmd because stack is full";
|
||||||
|
return false; // not possible
|
||||||
|
}
|
||||||
|
nextFDwrCmd[p_nextFDcmdsInQueue]=nextWrCmd;
|
||||||
|
nextFDrdCmd[p_nextFDcmdsInQueue]=nextRdCmd;
|
||||||
|
nextFDblkNr[p_nextFDcmdsInQueue]=blockNum;
|
||||||
|
nextFDpara1[p_nextFDcmdsInQueue]=dat1;
|
||||||
|
nextFDpara2[p_nextFDcmdsInQueue]=dat2;
|
||||||
|
nextFDpara3[p_nextFDcmdsInQueue]=dat3;
|
||||||
|
nextFDpara4[p_nextFDcmdsInQueue]=dat4;
|
||||||
|
//qDebug() << "data with 4 data byte saved, pp=" << nrOfCmds4InQueue;
|
||||||
|
//qDebug() << " dat1=" << nextCmd4para1[nrOfCmds4InQueue] << " dat2=" << nextCmd4para2[nrOfCmds4InQueue]
|
||||||
|
// << " dat3=" << nextCmd4para3[nrOfCmds4InQueue] << " dat4=" << nextCmd4para4[nrOfCmds4InQueue];
|
||||||
|
nextFDshort[p_nextFDcmdsInQueue]=1; // 1=short
|
||||||
|
p_nextFDcmdsInQueue++;
|
||||||
|
/*
|
||||||
|
int nn;
|
||||||
|
if (p_nextFDcmdsInQueue==2)
|
||||||
|
{
|
||||||
|
qDebug() << "sendFDcmd_set, stack has 2 elements: " << p_nextFDcmdsInQueue;
|
||||||
|
for (nn=0; nn<16; nn++)
|
||||||
|
{
|
||||||
|
qDebug() << "header: " << nextFDwrCmd[nn] << " / " << nextFDrdCmd[nn] << " / "<< nextFDblkNr[nn] << " / " << nextFDshort[nn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
if (p_nextFDcmdsInQueue>15)
|
||||||
|
{
|
||||||
|
qDebug() << "sendFDcmd_set, stack is full now: " << p_nextFDcmdsInQueue;
|
||||||
|
for (nn=0; nn<16; nn++)
|
||||||
|
{
|
||||||
|
qDebug() << "header: " << nextFDwrCmd[nn] << " / " << nextFDrdCmd[nn] << " / "<< nextFDblkNr[nn] << " / " << nextFDpara1[nn] << " / " << nextFDpara2[nn] << " / " << nextFDpara3[nn] << " / " << nextFDpara4[nn];
|
||||||
|
|
||||||
|
qDebug() << " long data: " << nextFDshort[nn] << " / "<< longFDlength[nn] << " / "<< longFDpara[nn][0] << " / "<< longFDpara[nn][1]
|
||||||
|
<< " / "<< longFDpara[nn][2] << " / "<< longFDpara[nn][3] << " / "<< longFDpara[nn][4];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return true; // ok, will be sent
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data)
|
||||||
|
{
|
||||||
|
// write Command to memory, wait for transport
|
||||||
|
// data buffer size always 64! data[64], padded with 0
|
||||||
|
uint8_t nn;
|
||||||
|
if (p_nextFDcmdsInQueue>=FDCMD_STACKDEPTH)
|
||||||
|
{
|
||||||
|
qDebug() << "cannot save cmd because stack is full";
|
||||||
|
return false; // not possible
|
||||||
|
}
|
||||||
|
nextFDwrCmd[p_nextFDcmdsInQueue]=nextWrCmd;
|
||||||
|
nextFDrdCmd[p_nextFDcmdsInQueue]=nextRdCmd;
|
||||||
|
nextFDblkNr[p_nextFDcmdsInQueue]=blockNum;
|
||||||
|
|
||||||
|
longFDlength[p_nextFDcmdsInQueue]=length;
|
||||||
|
|
||||||
|
for (nn=0; nn<64; nn++)
|
||||||
|
longFDpara[p_nextFDcmdsInQueue][nn]=data[nn];
|
||||||
|
|
||||||
|
nextFDshort[p_nextFDcmdsInQueue]=2;
|
||||||
|
|
||||||
|
p_nextFDcmdsInQueue++;
|
||||||
|
return true; // ok, will be sent
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
|
||||||
|
{
|
||||||
|
uint8_t nn, ll, mm;
|
||||||
|
|
||||||
|
if (p_nextFDcmdsInQueue==0 || p_nextFDcmdsInQueue>FDCMD_STACKDEPTH)
|
||||||
|
return false; // not possible
|
||||||
|
|
||||||
|
*nextWrCmd=nextFDwrCmd[0];
|
||||||
|
*nextRdCmd=nextFDrdCmd[0];
|
||||||
|
*blockNum=nextFDblkNr[0];
|
||||||
|
*dat1=nextFDpara1[0];
|
||||||
|
*dat2=nextFDpara2[0];
|
||||||
|
*dat3=nextFDpara3[0];
|
||||||
|
*dat4=nextFDpara4[0];
|
||||||
|
//qDebug() << "sendFDcmd_get [0]; pp=" << p_nextFDcmdsInQueue;
|
||||||
|
//qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] <<
|
||||||
|
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
|
||||||
|
|
||||||
|
// move Puffer down by one element
|
||||||
|
if (FDCMD_STACKDEPTH>0)
|
||||||
|
ll=FDCMD_STACKDEPTH-1;
|
||||||
|
else
|
||||||
|
ll=0;
|
||||||
|
for (nn=0; nn<ll; nn++)
|
||||||
|
{
|
||||||
|
nextFDwrCmd[nn]=nextFDwrCmd[nn+1];
|
||||||
|
nextFDrdCmd[nn]=nextFDrdCmd[nn+1];
|
||||||
|
nextFDblkNr[nn]=nextFDblkNr[nn+1];
|
||||||
|
|
||||||
|
nextFDpara1[nn]=nextFDpara1[nn+1];
|
||||||
|
nextFDpara2[nn]=nextFDpara2[nn+1];
|
||||||
|
nextFDpara3[nn]=nextFDpara3[nn+1];
|
||||||
|
nextFDpara4[nn]=nextFDpara4[nn+1];
|
||||||
|
|
||||||
|
nextFDshort[nn] = nextFDshort[nn+1];
|
||||||
|
|
||||||
|
longFDlength[nn] = longFDlength[nn+1];
|
||||||
|
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm] = longFDpara[nn+1][mm];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_nextFDcmdsInQueue>0)
|
||||||
|
p_nextFDcmdsInQueue--;
|
||||||
|
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
|
||||||
|
|
||||||
|
// clear released buffer:
|
||||||
|
for (nn=p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH; nn++)
|
||||||
|
{
|
||||||
|
nextFDwrCmd[nn]=0;
|
||||||
|
nextFDrdCmd[nn]=0;
|
||||||
|
nextFDblkNr[nn]=0;
|
||||||
|
|
||||||
|
nextFDpara1[nn]=0;
|
||||||
|
nextFDpara2[nn]=0;
|
||||||
|
nextFDpara3[nn]=0;
|
||||||
|
nextFDpara4[nn]=0;
|
||||||
|
|
||||||
|
nextFDshort[nn]=0;
|
||||||
|
|
||||||
|
longFDlength[nn]=0;
|
||||||
|
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
qDebug() << "sendFDcmd_set, stack now: " << p_nextFDcmdsInQueue;
|
||||||
|
for (nn=0; nn<16; nn++)
|
||||||
|
{
|
||||||
|
qDebug() << "header: " << nextFDwrCmd[nn] << " / " << nextFDrdCmd[nn] << " / "<< nextFDblkNr[nn] << " / " << nextFDshort[nn];
|
||||||
|
|
||||||
|
qDebug() << " short data: " << nextFDpara1[nn] << " / "<< nextFDpara2[nn] << " / "<< nextFDpara3[nn]<< " / "<< nextFDpara4[nn];
|
||||||
|
|
||||||
|
qDebug() << " long data: " << longFDlength[nn] << " / "<< longFDpara[nn][0] << " / "<< longFDpara[nn][1]
|
||||||
|
<< " / "<< longFDpara[nn][2] << " / "<< longFDpara[nn][3] << " / "<< longFDpara[nn][4];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return true; // ok, will be sent
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t checkNextFDcmd(void)
|
||||||
|
{
|
||||||
|
// return 0: no command waiting
|
||||||
|
// 1: short cmd
|
||||||
|
// 2: long cmd
|
||||||
|
//qDebug() << "chk nxt fd cmd: "<<p_nextFDcmdsInQueue<<" "<<nextFDshort[0]<<" "<<nextFDshort[1]<<" "<<nextFDshort[2]<<" "<<nextFDshort[3];
|
||||||
|
if (p_nextFDcmdsInQueue==0)
|
||||||
|
return 0;
|
||||||
|
if (nextFDshort[0]==1)
|
||||||
|
return 1;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t check4FDshortCmd(void)
|
||||||
|
{
|
||||||
|
// returns number of waiting command, max FDCMD_STACKDEPTH
|
||||||
|
return p_nextFDcmdsInQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t check4freeFDshortCmd(void)
|
||||||
|
{
|
||||||
|
// returns number of free places in short-command stack
|
||||||
|
return FDCMD_STACKDEPTH - p_nextFDcmdsInQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// long command, 64 data bytes
|
||||||
|
//static uint8_t longFDwrCmd[FDLONG_STACKDEPTH];
|
||||||
|
//static uint8_t longFDrdCmd[FDLONG_STACKDEPTH];
|
||||||
|
//static uint8_t longFDblkNr[FDLONG_STACKDEPTH];
|
||||||
|
//static uint8_t longFDlength[FDLONG_STACKDEPTH];
|
||||||
|
|
||||||
|
//static uint8_t longFDpara[FDLONG_STACKDEPTH][64];
|
||||||
|
//static uint8_t p_longFDcmdsInQueue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
void longFDcmd_clrStack(void)
|
||||||
|
{
|
||||||
|
uint8_t nn, mm;
|
||||||
|
for (nn=0; nn<FDLONG_STACKDEPTH; nn++)
|
||||||
|
{
|
||||||
|
longFDwrCmd[nn]=0;
|
||||||
|
longFDrdCmd[nn]=0;
|
||||||
|
longFDblkNr[nn]=0;
|
||||||
|
longFDlength[nn]=0;
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm]=0;
|
||||||
|
}
|
||||||
|
p_longFDcmdsInQueue=0;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data)
|
||||||
|
{
|
||||||
|
uint8_t nn, mm, ll;
|
||||||
|
//p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH
|
||||||
|
if (p_nextFDcmdsInQueue==0 || p_nextFDcmdsInQueue>FDCMD_STACKDEPTH)
|
||||||
|
return false; // not possible
|
||||||
|
|
||||||
|
*nextWrCmd=nextFDwrCmd[0];
|
||||||
|
*nextRdCmd=nextFDrdCmd[0];
|
||||||
|
*blockNum=nextFDblkNr[0];
|
||||||
|
|
||||||
|
*length = longFDlength[0];
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
data[mm] = longFDpara[0][mm];
|
||||||
|
|
||||||
|
// move Puffer down by one element
|
||||||
|
if (FDCMD_STACKDEPTH>0)
|
||||||
|
ll=FDCMD_STACKDEPTH-1;
|
||||||
|
else
|
||||||
|
ll=0;
|
||||||
|
for (nn=0; nn<ll; nn++)
|
||||||
|
{
|
||||||
|
nextFDwrCmd[nn]=nextFDwrCmd[nn+1];
|
||||||
|
nextFDrdCmd[nn]=nextFDrdCmd[nn+1];
|
||||||
|
nextFDblkNr[nn]=nextFDblkNr[nn+1];
|
||||||
|
|
||||||
|
nextFDpara1[nn]=nextFDpara1[nn+1];
|
||||||
|
nextFDpara2[nn]=nextFDpara2[nn+1];
|
||||||
|
nextFDpara3[nn]=nextFDpara3[nn+1];
|
||||||
|
nextFDpara4[nn]=nextFDpara4[nn+1];
|
||||||
|
|
||||||
|
nextFDshort[nn] = nextFDshort[nn+1];
|
||||||
|
|
||||||
|
longFDlength[nn] = longFDlength[nn+1];
|
||||||
|
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm] = longFDpara[nn+1][mm];
|
||||||
|
|
||||||
|
}
|
||||||
|
if (p_nextFDcmdsInQueue>0)
|
||||||
|
p_nextFDcmdsInQueue--;
|
||||||
|
|
||||||
|
// clear released buffer:
|
||||||
|
for (nn=p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH; nn++)
|
||||||
|
{
|
||||||
|
nextFDwrCmd[nn]=0;
|
||||||
|
nextFDrdCmd[nn]=0;
|
||||||
|
nextFDblkNr[nn]=0;
|
||||||
|
|
||||||
|
nextFDpara1[nn]=0;
|
||||||
|
nextFDpara2[nn]=0;
|
||||||
|
nextFDpara3[nn]=0;
|
||||||
|
nextFDpara4[nn]=0;
|
||||||
|
|
||||||
|
nextFDshort[nn]=0;
|
||||||
|
|
||||||
|
longFDlength[nn]=0;
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true; // ok, will be sent
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
uint8_t check4FDlongCmd(void)
|
||||||
|
{
|
||||||
|
// returns number of waiting command
|
||||||
|
return p_longFDcmdsInQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t check4freeFDlongCmd(void)
|
||||||
|
{
|
||||||
|
// returns number of free places in command stack
|
||||||
|
return FDLONG_STACKDEPTH - p_longFDcmdsInQueue;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t Sdata_DeviceParameter[64];
|
||||||
|
static uint8_t Sdata_DevParaLen;
|
||||||
|
|
||||||
|
uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf)
|
||||||
|
{
|
||||||
|
// HWapi writes data to be stored
|
||||||
|
uint8_t nn;
|
||||||
|
for (nn=0; nn<length; nn++)
|
||||||
|
Sdata_DeviceParameter[nn]=buf[nn];
|
||||||
|
for (nn=length; nn<64; nn++)
|
||||||
|
Sdata_DeviceParameter[nn]=0;
|
||||||
|
|
||||||
|
Sdata_DevParaLen=length;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t epi_restore64BdevParameter(uint8_t *length, uint8_t *buf)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (uint8_t nn=0; nn<Sdata_DevParaLen; nn++)
|
||||||
|
buf[nn]=Sdata_DeviceParameter[nn];
|
||||||
|
*length=Sdata_DevParaLen;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
46
src/shared_mem_buffer.cpp
Normal file
46
src/shared_mem_buffer.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#include "shared_mem_buffer.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#ifdef QT_POSIX_IPC
|
||||||
|
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
||||||
|
// option to the Qt configure script. If it is enabled, the QT_POSIX_IPC
|
||||||
|
// macro will be defined. -> we use SystemV shared memory
|
||||||
|
#error "QT_POSIX_IPC defined"
|
||||||
|
#else
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <sys/ipc.h> // ftok
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
||||||
|
|
||||||
|
QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||||
|
static QSharedMemory shMem;
|
||||||
|
if (size > 0) {
|
||||||
|
#ifdef __linux__
|
||||||
|
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||||
|
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||||
|
#else
|
||||||
|
static const QString fkey = "0123456?000=9";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
shMem.setKey(fkey);
|
||||||
|
if (!shMem.isAttached()) {
|
||||||
|
if (shMem.create(size)) {
|
||||||
|
return &shMem;
|
||||||
|
} else {
|
||||||
|
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||||
|
if (shMem.attach()) {
|
||||||
|
return &shMem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||||
|
<< shMem.error() << shMem.errorString();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &shMem;
|
||||||
|
}
|
@@ -3,11 +3,15 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
#include "tslib.h"
|
#include "tslib.h"
|
||||||
|
#include "shared_mem_buffer.h"
|
||||||
|
#include "datei.h"
|
||||||
|
|
||||||
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
||||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// store power on/off condition of the devices to control the data request
|
// store power on/off condition of the devices to control the data request
|
||||||
|
|
||||||
static bool indat_savePrnPwr;
|
static bool indat_savePrnPwr;
|
||||||
@@ -15,6 +19,9 @@ static bool indat_savePrnPwr;
|
|||||||
void indat_storePrinterPower(bool isOn)
|
void indat_storePrinterPower(bool isOn)
|
||||||
{
|
{
|
||||||
indat_savePrnPwr=isOn;
|
indat_savePrnPwr=isOn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool indat_isPrinterOn()
|
bool indat_isPrinterOn()
|
||||||
@@ -49,55 +56,6 @@ bool indat_isMdbOn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString epi_getSlaveParamSTR()
|
|
||||||
{
|
|
||||||
QString mySt;
|
|
||||||
mySt.clear();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
mySt.append(ndbs+0x30);
|
|
||||||
|
|
||||||
mySt.append(pari);
|
|
||||||
mySt.append(nsb+0x30);
|
|
||||||
//mySt="Hallo";
|
|
||||||
return mySt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static QString genStrings[MAXNROF_GENSTR];
|
static QString genStrings[MAXNROF_GENSTR];
|
||||||
// 0=HW 1=SW 2=State
|
// 0=HW 1=SW 2=State
|
||||||
@@ -131,12 +89,39 @@ QString epi_loadGenerals(uint8_t genNr)
|
|||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
static uint64_t Sdata_slaveUID;
|
static uint64_t Sdata_slaveUID;
|
||||||
static uint8_t Sdata_UIDstr[8];
|
static uint8_t Sdata_UIDstr[8];
|
||||||
|
static QString Sdata_DcUidStr;
|
||||||
|
|
||||||
|
|
||||||
|
void write2file_UID(void)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
csv_startCreatingFile();
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[0]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[1]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[2]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[3]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[4]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[5]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[6]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[7]);
|
||||||
|
csv_addNewlineToFile();
|
||||||
|
csv_addUlongvalToFile(Sdata_slaveUID);
|
||||||
|
csv_addNewlineToFile();
|
||||||
|
csv_addTextToFile(Sdata_DcUidStr);
|
||||||
|
csv_addNewlineToFile();
|
||||||
|
myBA=csv_readbackArray();
|
||||||
|
datei_clearFile(FILENAME_SHARED_UID);
|
||||||
|
datei_writeToFile(FILENAME_SHARED_UID, myBA);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void gpi_storeUID(uint8_t *buf8byteUid)
|
void gpi_storeUID(uint8_t *buf8byteUid)
|
||||||
{
|
{
|
||||||
uint64_t udltmp=0;
|
uint64_t udltmp=0;
|
||||||
|
QString myStr;
|
||||||
|
|
||||||
//qDebug()<< "store UID ";
|
//qDebug()<< "store UID ";
|
||||||
|
|
||||||
@@ -149,6 +134,16 @@ void gpi_storeUID(uint8_t *buf8byteUid)
|
|||||||
udltmp<<=8;
|
udltmp<<=8;
|
||||||
}
|
}
|
||||||
Sdata_slaveUID=udltmp;
|
Sdata_slaveUID=udltmp;
|
||||||
|
|
||||||
|
Sdata_DcUidStr.clear();
|
||||||
|
for (int ii=0;ii<8; ii++)
|
||||||
|
{
|
||||||
|
|
||||||
|
Sdata_DcUidStr+=QString::number(Sdata_UIDstr[ii],16);
|
||||||
|
Sdata_DcUidStr+=" ";
|
||||||
|
}
|
||||||
|
|
||||||
|
write2file_UID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_getUIDdec(uint8_t *buf8byteUid)
|
void epi_getUIDdec(uint8_t *buf8byteUid)
|
||||||
@@ -175,14 +170,70 @@ QString epi_getUIDstr()
|
|||||||
}
|
}
|
||||||
return myStr;
|
return myStr;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* read from file:
|
||||||
|
void epi_getUIDfromFile(uint8_t *buf8byteUid)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
int nn;
|
||||||
|
|
||||||
|
myBA=datei_readFromFile(FILENAME_SHARED_UID);
|
||||||
|
for (nn=0; nn<8; nn++)
|
||||||
|
buf8byteUid[nn]=csv_getEntryAsUshort(myBA, nn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t epi_getUIDnumberFromFile(void)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
|
||||||
|
myBA=datei_readFromFile(FILENAME_SHARED_UID);
|
||||||
|
return csv_getEntryAs2Ulong(myBA, 8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString epi_getUIDstrFromFile(void)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
|
||||||
|
myBA=datei_readFromFile(FILENAME_SHARED_UID);
|
||||||
|
return csv_getEntryAsString(myBA, 9);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// the same with shared memory :
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeUID(uint8_t const *buf8byteUid) {
|
||||||
|
uint64_t udltmp=0;
|
||||||
|
|
||||||
|
for (int ii=0; ii<8; ii++) {
|
||||||
|
SharedMemBuffer::getData()->Sdata.UIDstr[ii] = buf8byteUid[ii];
|
||||||
|
udltmp |= buf8byteUid[ii];
|
||||||
|
udltmp <<= 8;
|
||||||
|
}
|
||||||
|
SharedMemBuffer::getData()->Sdata.slaveUID = udltmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_getUIDdec(uint8_t *buf8byteUid) {
|
||||||
|
for (int ii=0; ii<8; ii++) {
|
||||||
|
buf8byteUid[ii] = SharedMemBuffer::getDataConst()->Sdata.UIDstr[ii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString epi_getUIDstr() {
|
||||||
|
// die UID besteht aus 8 bytes (8 dezimalzahlen)
|
||||||
|
// -> umformen in hexstring
|
||||||
|
|
||||||
|
QString myStr;
|
||||||
|
for (int ii=0;ii<8; ii++) {
|
||||||
|
myStr += QString::number(SharedMemBuffer::getDataConst()->Sdata.UIDstr[ii], 16);
|
||||||
|
myStr += " ";
|
||||||
|
}
|
||||||
|
return myStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1307,6 +1358,27 @@ uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize)
|
|||||||
return 0; // ois OK
|
return 0; // ois OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t mif_cardType;
|
||||||
|
static uint8_t mif_cardHolder[8];
|
||||||
|
|
||||||
|
void gpi_storeNewMifareCard(uint8_t typ, uint8_t *holder )
|
||||||
|
{
|
||||||
|
mif_cardType=typ;
|
||||||
|
tslib_strcpy(holder, mif_cardHolder, 7);
|
||||||
|
mif_cardHolder[7]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t epi_mifGetCardType(uint8_t *holder)
|
||||||
|
{
|
||||||
|
//holder[8] = name of card holder
|
||||||
|
// retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
|
||||||
|
|
||||||
|
tslib_strcpy(mif_cardHolder, holder, 7);
|
||||||
|
holder[7]=0;
|
||||||
|
return mif_cardType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1522,20 +1594,17 @@ qDebug()<<"read emp data, nr "<<ctr_gotCoin << "valid: " << *valid
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t Sdata_NrOfDeviceSetting;
|
static uint8_t Sdata_NrOfDeviceSetting;
|
||||||
static uint8_t Sdata_DeviceSettingBuff[66];
|
static uint8_t Sdata_DeviceSettingBuff[66];
|
||||||
|
|
||||||
void gpi_storeDeviceSettings(uint8_t leng, uint8_t *data)
|
void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t *data) // getestet am 12.4.23TS
|
||||||
{
|
{
|
||||||
if (leng>64) leng=64;
|
if (leng>64) leng=64;
|
||||||
Sdata_NrOfDeviceSetting=leng;
|
Sdata_NrOfDeviceSetting=leng;
|
||||||
tslib_strcpy(data, Sdata_DeviceSettingBuff, leng);
|
tslib_strcpy(data, Sdata_DeviceSettingBuff, leng); // getestet am 12.4.23TS
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_restoreDeviceSettings(uint8_t *leng, uint8_t *data)
|
void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data) // getestet am 12.4.23TS
|
||||||
{
|
{
|
||||||
|
|
||||||
*leng=Sdata_NrOfDeviceSetting;
|
*leng=Sdata_NrOfDeviceSetting;
|
||||||
@@ -1563,7 +1632,305 @@ void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t store_insertedAmount;
|
||||||
|
static uint16_t store_lastCoinType[64];
|
||||||
|
static uint16_t store_lastCoinValue[64];
|
||||||
|
static uint8_t p_lastCoin;
|
||||||
|
static char store_curPayNewCoin;
|
||||||
|
|
||||||
|
void epi_clearCurrentPayment(void)
|
||||||
|
{
|
||||||
|
// call at beginning of coin collection
|
||||||
|
int nn;
|
||||||
|
|
||||||
|
store_insertedAmount=0;
|
||||||
|
p_lastCoin=0;
|
||||||
|
|
||||||
|
// 17.5.23TS: ergänzt:
|
||||||
|
for (nn=0; nn<64; nn++)
|
||||||
|
{
|
||||||
|
store_lastCoinType[nn]=0;
|
||||||
|
store_lastCoinValue[nn]=0;
|
||||||
|
}
|
||||||
|
store_curPayNewCoin=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue)
|
||||||
|
{
|
||||||
|
store_insertedAmount=insertedAmount;
|
||||||
|
store_lastCoinType[p_lastCoin]=lastCoinType;
|
||||||
|
store_lastCoinValue[p_lastCoin]=lastCoinValue;
|
||||||
|
p_lastCoin++;
|
||||||
|
store_curPayNewCoin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t epi_CurrentPaymentGetAmount(void)
|
||||||
|
{
|
||||||
|
return store_insertedAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t epi_CurrentPaymentGetLastCoin(void)
|
||||||
|
{
|
||||||
|
uint8_t pp;
|
||||||
|
|
||||||
|
//if (store_curPayNewCoin)
|
||||||
|
//{
|
||||||
|
pp=p_lastCoin;
|
||||||
|
if (pp==0)
|
||||||
|
return 0; // noch keine Münze erhalten
|
||||||
|
if (pp>0) pp--;
|
||||||
|
//store_curPayNewCoin=0; // nur 1x melden
|
||||||
|
return store_lastCoinValue[pp];
|
||||||
|
//} else
|
||||||
|
// return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values)
|
||||||
|
{
|
||||||
|
// alle bei diesem Verkauf eingeworfenen Münzen sind gespeichert falls die jmd. braucht
|
||||||
|
uint8_t nn;
|
||||||
|
if (p_lastCoin==0)
|
||||||
|
return false;
|
||||||
|
for (nn=0; nn<64; nn++)
|
||||||
|
{
|
||||||
|
types[nn]=store_lastCoinType[nn];
|
||||||
|
values[nn]=store_lastCoinValue[nn];
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t stor_wakSrc;
|
||||||
|
uint8_t stor_reason;
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeWakeSources(uint8_t *receivedData)
|
||||||
|
{
|
||||||
|
uint8_t uctmp;
|
||||||
|
int nn;
|
||||||
|
stor_wakSrc=0;
|
||||||
|
for (nn=5; nn>=0; nn--)
|
||||||
|
{
|
||||||
|
uctmp=receivedData[nn];
|
||||||
|
stor_wakSrc |=uctmp;
|
||||||
|
stor_wakSrc<<=8;
|
||||||
|
}
|
||||||
|
stor_reason=receivedData[6];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t epi_getWakeSources(void)
|
||||||
|
{
|
||||||
|
return stor_wakSrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t epi_getWakeReason(void)
|
||||||
|
{
|
||||||
|
return stor_reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t store_rbDevParamLen;
|
||||||
|
static uint8_t store_rbDevParams[66];
|
||||||
|
|
||||||
|
void gpi_storeExtendedTime(uint8_t leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
if (leng>64) leng=64;
|
||||||
|
store_rbDevParamLen=leng;
|
||||||
|
tslib_strcpy(data, store_rbDevParams, leng);
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
|
||||||
|
*leng=store_rbDevParamLen;
|
||||||
|
tslib_strcpy(store_rbDevParams, data, store_rbDevParamLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// store device conditions
|
||||||
|
static uint8_t store_deviceCondLen;
|
||||||
|
static uint8_t store_deviceCond[66];
|
||||||
|
|
||||||
|
void gpi_storeDeviceConditions(uint8_t leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
if (leng>64) leng=64;
|
||||||
|
store_deviceCondLen=leng;
|
||||||
|
tslib_strcpy(data, store_deviceCond, leng);
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
|
||||||
|
*leng=store_deviceCondLen;
|
||||||
|
tslib_strcpy(store_deviceCond, data, store_deviceCondLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// store dynamic machine conditions
|
||||||
|
static uint8_t store_machCondLen;
|
||||||
|
static uint8_t store_machCond[66];
|
||||||
|
|
||||||
|
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
if (leng>64) leng=64;
|
||||||
|
store_machCondLen=leng;
|
||||||
|
tslib_strcpy(data, store_machCond, leng);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
|
||||||
|
*leng=store_machCondLen;
|
||||||
|
tslib_strcpy(store_machCond, data, store_machCondLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t store_DcBackupNrOfAccNr;
|
||||||
|
static uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
|
||||||
|
|
||||||
|
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
if (leng>32) leng=32;
|
||||||
|
store_DcBackupAccNr[0]=uchar2uint(data[1], data[0]);
|
||||||
|
store_DcBackupAccNr[1]=uchar2uint(data[3], data[2]);
|
||||||
|
store_DcBackupAccNr[2]=uchar2uint(data[5], data[4]);
|
||||||
|
store_DcBackupAccNr[3]=uchar2uint(data[7], data[6]);
|
||||||
|
store_DcBackupAccNr[4]=uchar2uint(data[9], data[8]);
|
||||||
|
store_DcBackupAccNr[5]=uchar2uint(data[11], data[10]);
|
||||||
|
store_DcBackupAccNr[6]=uchar2uint(data[13], data[12]);
|
||||||
|
store_DcBackupAccNr[7]=uchar2uint(data[15], data[14]);
|
||||||
|
store_DcBackupNrOfAccNr=8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs)
|
||||||
|
{
|
||||||
|
// return accNrs[0..7]
|
||||||
|
uint8_t nn;
|
||||||
|
|
||||||
|
*leng=store_DcBackupNrOfAccNr;
|
||||||
|
for (nn=0; nn<8; nn++)
|
||||||
|
accNrs[nn]=store_DcBackupAccNr[nn];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t store_gotNrBlocksOfVaultRec;
|
||||||
|
static uint8_t store_vaultrecord[360];
|
||||||
|
|
||||||
|
void epi_iniVRstorage(void)
|
||||||
|
{
|
||||||
|
tslib_strclr(store_vaultrecord, 0, 360);
|
||||||
|
store_gotNrBlocksOfVaultRec=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data )
|
||||||
|
{
|
||||||
|
uint16_t start=blkNr, ii;
|
||||||
|
|
||||||
|
store_gotNrBlocksOfVaultRec |= (1<<start); // setze pro Block ein bit, wir brauchen block 0...4
|
||||||
|
// also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen
|
||||||
|
start<<=6;
|
||||||
|
for (ii=0; ii<64; ii++)
|
||||||
|
store_vaultrecord[start+ii]=data[ii];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool epi_checkIfVaultRecordAvailable(void)
|
||||||
|
{
|
||||||
|
if (store_gotNrBlocksOfVaultRec==0x1F)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf )
|
||||||
|
{
|
||||||
|
*length=0;
|
||||||
|
if (store_gotNrBlocksOfVaultRec==0x1F)
|
||||||
|
{
|
||||||
|
*length=320;
|
||||||
|
tslib_strcpy(store_vaultrecord, buf, 320);
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t store_amount;
|
||||||
|
static uint16_t store_nrOfCoins;
|
||||||
|
|
||||||
|
void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins )
|
||||||
|
{
|
||||||
|
store_amount=amount;
|
||||||
|
store_nrOfCoins=nrOfCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t epi_getCashBoxContent(void)
|
||||||
|
{
|
||||||
|
return store_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t epi_getNrOfCoinsInCashBox(void)
|
||||||
|
{
|
||||||
|
return store_nrOfCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool store_DcDataAreValid;
|
||||||
|
|
||||||
|
void gpi_storeDcDataValid(bool isVal)
|
||||||
|
{
|
||||||
|
store_DcDataAreValid = isVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool epi_areDcDataValid()
|
||||||
|
{
|
||||||
|
return store_DcDataAreValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ....................................................................................
|
||||||
|
// 24.5.2023
|
||||||
|
|
||||||
|
static uint8_t storeDCdynPrinterData[64];
|
||||||
|
static uint8_t DCdynPrinterDataActual;
|
||||||
|
|
||||||
|
void epi_clearDynData(void)
|
||||||
|
{
|
||||||
|
DCdynPrinterDataActual=0;
|
||||||
|
memset(storeDCdynPrinterData,0, sizeof(storeDCdynPrinterData));
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpi_storeDynData(uint8_t *DCdynDat)
|
||||||
|
{
|
||||||
|
// buffer size: 64 byte
|
||||||
|
memcpy(storeDCdynPrinterData, DCdynDat, 64);
|
||||||
|
DCdynPrinterDataActual=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool epi_getDynPrnData(uint8_t *DCdynDat)
|
||||||
|
{
|
||||||
|
// buffer size: 64 byte
|
||||||
|
// return true if data are new and valid
|
||||||
|
|
||||||
|
if (DCdynPrinterDataActual)
|
||||||
|
{
|
||||||
|
memcpy(DCdynDat, storeDCdynPrinterData, 64);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -76,6 +76,23 @@ uint8_t uint2uchar(uint16_t uival, bool getHighB)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr)
|
||||||
|
{
|
||||||
|
// getBytNr: 0=LSB 3=MSB
|
||||||
|
uint32_t ultmp=ulval;
|
||||||
|
if (getBytNr==0)
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
ultmp>>=8;
|
||||||
|
if (getBytNr==1)
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
ultmp>>=8;
|
||||||
|
if (getBytNr==2)
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
ultmp>>=8;
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void delay(uint16_t MilliSec)
|
void delay(uint16_t MilliSec)
|
||||||
{
|
{
|
||||||
QThread::msleep(uint32_t(MilliSec));
|
QThread::msleep(uint32_t(MilliSec));
|
||||||
@@ -344,6 +361,15 @@ uint16_t tslib_strlen(char *buf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t tslib_strlen(uint8_t *buf)
|
||||||
|
{
|
||||||
|
uint16_t nn;
|
||||||
|
|
||||||
|
for (nn=0; nn<0xFFF0; nn++)
|
||||||
|
if (buf[nn]==0)
|
||||||
|
return nn;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void tslib_strclr(char *buf, char clrsign, uint16_t len)
|
void tslib_strclr(char *buf, char clrsign, uint16_t len)
|
||||||
{
|
{
|
||||||
@@ -555,3 +581,18 @@ uint8_t tslib_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData)
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void biox_CopyBlock(uint8_t *src, uint16_t srcPos, uint8_t *dest, uint16_t destPos, uint16_t len)
|
||||||
|
{
|
||||||
|
// both buffers starting from pos 0
|
||||||
|
uint16_t xx,yy,zz,ii;
|
||||||
|
|
||||||
|
xx = srcPos;
|
||||||
|
yy = destPos;
|
||||||
|
zz = len;
|
||||||
|
|
||||||
|
for (ii = 0; ii < zz; ++ii)
|
||||||
|
{
|
||||||
|
dest[yy + ii] = src[xx + ii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user