Compare commits
65 Commits
75acd1e3ec
...
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 | |||
ed037b99c9 | |||
e4a2f8fce3 | |||
19befc2c58 | |||
7f23e3ea46 | |||
49396c22ee | |||
0b87f44e64 | |||
66b22a4233 | |||
ba5d23d8be |
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# 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}
|
||||
|
||||
HEADERS += $${PWD}/include/com.h \
|
||||
$$PWD/include/datei.h \
|
||||
$${PWD}/include/controlBus.h \
|
||||
$${PWD}/include/datIf.h \
|
||||
$${PWD}/include/dcBL.h \
|
||||
@@ -10,9 +11,12 @@ HEADERS += $${PWD}/include/com.h \
|
||||
$${PWD}/include/prot.h \
|
||||
$${PWD}/include/sendWRcmd.h \
|
||||
$${PWD}/include/storeINdata.h \
|
||||
$${PWD}/include/tslib.h
|
||||
$${PWD}/include/tslib.h \
|
||||
$${PWD}/include/shared_mem_buffer.h
|
||||
|
||||
SOURCES += $${PWD}/src/com.cpp \
|
||||
$$PWD/src/datei.cpp \
|
||||
$$PWD/src/main.cpp \
|
||||
$${PWD}/src/controlBus.cpp \
|
||||
$${PWD}/src/datIf.cpp \
|
||||
$${PWD}/src/dcBL.cpp \
|
||||
@@ -20,4 +24,5 @@ SOURCES += $${PWD}/src/com.cpp \
|
||||
$${PWD}/src/prot.cpp \
|
||||
$${PWD}/src/sendWRcmd.cpp \
|
||||
$${PWD}/src/storeINdata.cpp \
|
||||
$${PWD}/src/tslib.cpp
|
||||
$${PWD}/src/tslib.cpp \
|
||||
$${PWD}/src/shared_mem_buffer.cpp
|
||||
|
90
DCPlugin.pro
Normal file
90
DCPlugin.pro
Normal file
@@ -0,0 +1,90 @@
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
#CONFIG += c++11 console
|
||||
#CONFIG -= app_bundle
|
||||
#QT += widgets
|
||||
QT -= gui
|
||||
QT += widgets serialport
|
||||
|
||||
INCLUDEPATH += $${PWD}/plugins
|
||||
INCLUDEPATH += $${PWD}/include
|
||||
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
|
||||
# default
|
||||
ARCH = PTU5
|
||||
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
# QMAKE_CC = ccache $$QMAKE_CC
|
||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||
QMAKE_CXXFLAGS += -std=c++17
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
|
||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||
ARCH = DesktopLinux
|
||||
include(DCPlugin.pri)
|
||||
}
|
||||
|
||||
contains( CONFIG, PTU5 ) {
|
||||
# QMAKE_CC = ccache $$QMAKE_CC
|
||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||
QMAKE_CXXFLAGS += -std=c++17
|
||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||
CONFIG += link_pkgconfig
|
||||
ARCH = PTU5
|
||||
|
||||
# NOTE: include contents of DCPlugin.pri. Also used by ATBQT.
|
||||
# Add new files in DCPlugin.pri.
|
||||
include(DCPlugin.pri)
|
||||
}
|
||||
|
||||
contains( CONFIG, PTU5_YOCTO ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
|
||||
# add qmqtt lib
|
||||
#LIBS += -lQt5Qmqtt
|
||||
}
|
||||
|
||||
TARGET = CashAgentLib
|
||||
#DESTDIR = ../plugins
|
||||
INTERFACE = DeviceController
|
||||
INTERFACE_DEFINITION = $${PWD}/include/ATBAPP/DeviceControllerInterface.h
|
||||
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
|
||||
# Default rules for deployment.
|
||||
#qnx: target.path = /tmp/$${TARGET}/bin
|
||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
#!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}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -33,7 +33,7 @@ class T_com : public QMainWindow //, public QPlainTextEdit
|
||||
//char oeffneSerialPort();
|
||||
char open_Serial_Port();
|
||||
void closeSerialPort();
|
||||
|
||||
void receiveByLength(void);
|
||||
|
||||
private slots:
|
||||
void readSomeBytes(void);
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
|
||||
void writeToSerial(const QByteArray &data, uint16_t sendLength);
|
||||
|
||||
void receiveFixLen(int64_t nrOfbytesToReceive);
|
||||
|
||||
bool readFromSerial(QByteArray &data, uint16_t &sendLength);
|
||||
// retval: true: data available
|
||||
|
||||
|
121
include/datIf.h
121
include/datIf.h
@@ -21,6 +21,115 @@
|
||||
#include <QTime>
|
||||
|
||||
|
||||
|
||||
#define CMD2DC_sendTime 20
|
||||
#define CMD2DC_setWakeFrequ 112
|
||||
#define CMD2DC_MOV_UPLOCK 113
|
||||
#define CMD2DC_MOV_DNLOCK 114
|
||||
#define CMD2DC_UPPER_DOOR 115
|
||||
#define CMD2DC_LOWER_DOOR 116
|
||||
#define CMD2DC_VAULT_DOOR 117
|
||||
#define CMD2DC_REJMOT_ON 118
|
||||
#define CMD2DC_REJMOT_RUN 119
|
||||
#define CMD2DC_LED_COIN 100
|
||||
#define CMD2DC_LED_ILLU 101
|
||||
#define CMD2DC_LED_TICKET 102
|
||||
#define CMD2DC_LED_START 104
|
||||
#define CMD2DC_LED_PIN 103
|
||||
#define CMD2DC_LED_IN 105
|
||||
#define CMD2DC_FAN 106
|
||||
#define CMD2DC_SIREN 107
|
||||
#define CMD2DC_BARRIER 108
|
||||
#define CMD2DC_WAKEPTU 109
|
||||
#define CMD2DC_SWITCHAUXPWR 110
|
||||
#define CMD2DC_SWITCHAUXDDR 18
|
||||
#define CMD2DC_SWITCHAUXOUT 19
|
||||
#define CMD2DC_UCONTACTON 111
|
||||
#define CMD2DC_DEVICE_PARAM 23
|
||||
#define CMD2DC_SEND_MACH_ID 11
|
||||
#define CMD2DC_RDBK_DEV_PARA 14
|
||||
|
||||
#define CMD2DC_RDBK_MACH_ID 15
|
||||
|
||||
#define CMD2DC_MDB_ON 120
|
||||
#define CMD2DC_MDB_GET_STATE 107 // REQ
|
||||
#define CMD2DC_MDB_DORESET 121
|
||||
#define CMD2DC_MDB_SETWAK 122
|
||||
//#define CMD2DC_MDB_GETWAK 0x2812 // REQ not nec.
|
||||
#define CMD2DC_MDB_SENDCMD 123
|
||||
#define CMD2DC_MDB_SENDMSG 12
|
||||
#define CMD2DC_MDB_GETRESP 22 // REQ
|
||||
|
||||
#define CMD2DC_EMP_SET 24
|
||||
#define CMD2DC_EMP_GET_ALL 23 // REQ
|
||||
#define CMD2DC_EMP_STARTPOLL 124
|
||||
#define CMD2DC_EMP_STARTPAY 125
|
||||
#define CMD2DC_EMP_STOPPAY 126
|
||||
#define CMD2DC_EMP_GOTCOIN 108 // REQ
|
||||
#define CMD2DC_SHUTTER_OPEN 129
|
||||
#define CMD2DC_ESCR_OPEN 132
|
||||
#define CMD2DC_ESCR_TAKE 133
|
||||
#define CMD2DC_ESCR_RETURN 134
|
||||
#define CMD2DC_MOD_ON 135
|
||||
#define CMD2DC_MOD_WAK 136
|
||||
#define CMD2DC_CRED_ON 137
|
||||
#define CMD2DC_CRED_WAK 138
|
||||
|
||||
// READ Commands ((e.g. get input)
|
||||
#define CMD2DC_TestSerial 10
|
||||
#define CMD2DC_GetSerialConfig 105
|
||||
#define CMD2DC_RdBkHWversion 11
|
||||
#define CMD2DC_RdBkSWversion 12
|
||||
#define CMD2DC_RdBkDCstate 101
|
||||
#define CMD2DC_RdBkUID 18
|
||||
#define CMD2DC_RdBkTime 104
|
||||
#define CMD2DC_RdBkAnalog 106
|
||||
#define CMD2DC_GetAllInputs 102
|
||||
#define CMD2DC_RdBkAllOutputs 103
|
||||
#define CMD2DC_MIFREADERON 127
|
||||
#define CMD2DC_ATB_CREATE 128
|
||||
|
||||
|
||||
|
||||
|
||||
// Mif read data:
|
||||
#define CMD2DC_RdBk_MifState 109
|
||||
#define CMD2DC_RdBk_MifData 24
|
||||
|
||||
|
||||
|
||||
|
||||
#define CMD2DC_RdBk_AtbCardType 25
|
||||
#define CMD2DC_SHUTTER_COIN 131
|
||||
#define CMD2DC_SHUTTER_OPEN3S 130
|
||||
#define CMD2DC_SEND_SHUT_TIME 0x2915
|
||||
#define CMD2DC_ESCR_TAKE 133
|
||||
#define CMD2DC_ESCR_RETURN 134
|
||||
#define CMD2DC_PRINTERON 139
|
||||
#define CMD2DC_RdBk_PrnState 110
|
||||
#define CMD2DC_RdBk_PrnFonts 26
|
||||
#define CMD2DC_RdBk_AllPrnData 27
|
||||
// nr of params:
|
||||
#define CMD2DC_PRI_SYS_CMD 25 // 3
|
||||
#define CMD2DC_PRI_ESC_CMD 26 // 4
|
||||
#define CMD2DC_PRI_SETUP 27 // 5
|
||||
#define CMD2DC_PRI_MOVE 140 // 2
|
||||
#define CMD2DC_PRI_SETFONT 141 // 4
|
||||
#define CMD2DC_PRI_SETLETTER 142 // 3
|
||||
#define CMD2DC_PRI_CUT 143 // 1
|
||||
#define CMD2DC_PRI_PRINT_TXT 13 // 64
|
||||
#define CMD2DC_PRI_LF 144 // 1
|
||||
#define CMD2DC_PRI_PRIFONTTABLE 145
|
||||
#define CMD2DC_PRI_BARCODE 14 // ca 15...25
|
||||
#define CMD2DC_STOR_QR_DATA 15 // 150
|
||||
#define CMD2DC_PRI_QR_CODE 146 // 0
|
||||
#define CMD2DC_PRI_LOGOFROMFLASH 147 // 2
|
||||
#define CMD2DC_PRI_STORE_DOC 16 // 1
|
||||
#define CMD2DC_PRI_DOCUMENT_NR 17 // 1 + 64
|
||||
#define CMD2DC_PRI_CLEAR_DOC 148 // 1
|
||||
|
||||
|
||||
/*
|
||||
// WRITE Commands (e.g. switch relay)
|
||||
#define CMD2DC_sendTime 0x1310
|
||||
#define CMD2DC_setWakeFrequ 0x1320
|
||||
@@ -110,8 +219,8 @@
|
||||
#define CMD2DC_MIFREADERON 0x2900
|
||||
#define CMD2DC_ATB_CREATE 0x2907
|
||||
// Mif read data:
|
||||
#define CMD2DC_RdBk_MifReader 0x2902
|
||||
#define CMD2DC_RdBk_Mifcard 0x2903
|
||||
#define CMD2DC_RdBk_MifState 0x2902
|
||||
#define CMD2DC_RdBk_MifData 0x2903
|
||||
#define CMD2DC_RdBk_AtbCardType 0x2905
|
||||
//#define CMD2DC_RdBk_CardData 0x2906
|
||||
|
||||
@@ -157,7 +266,7 @@
|
||||
#define CMD2DC_PRI_DOCUMENT_NR 0x2A42 // 1 + 64
|
||||
#define CMD2DC_PRI_CLEAR_DOC 0x2A43 // 1
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -194,6 +303,7 @@ class T_datif : public QMainWindow
|
||||
// docNr =transmitted in WRITEADDRESS high byte
|
||||
// blockNr=transmitted in WRITEADDRESS low byte
|
||||
|
||||
int datif_noResponseCtr;
|
||||
|
||||
T_prot *myDCIF;
|
||||
QTimer *datif_trigger;
|
||||
@@ -218,6 +328,11 @@ signals:
|
||||
//the requested data are stored in peripheral image
|
||||
// can be loaded with epi
|
||||
|
||||
void datif_templatePrintFinished_OK();
|
||||
void datif_templatePrintFinished_Err();
|
||||
|
||||
void datif_gotNewCoin();
|
||||
|
||||
};
|
||||
|
||||
#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
|
@@ -62,6 +62,12 @@ uint8_t dcBL_startChain(void);
|
||||
|
||||
uint8_t dcBL_runChain(void);
|
||||
|
||||
void dcBL_iniLoading(void);
|
||||
|
||||
void dcBL_startLoading(void);
|
||||
|
||||
uint8_t dcBL_sendHexfile(void);
|
||||
|
||||
|
||||
uint8_t dcBL_getResult(void);
|
||||
// call after every step to what's going on....
|
||||
@@ -85,8 +91,11 @@ QString epi_getRawReceivedString();
|
||||
void epi_clrRawReceivedString();
|
||||
|
||||
|
||||
uint8_t dcBL_sendSuccess(uint8_t lastCommand);
|
||||
// return val: 0: no response by now 1:error 10: OK
|
||||
// lastCommand=0x21 for sendAddr or 0x22 for send data
|
||||
|
||||
|
||||
char dcBL_loadBinary(char withDisplay);
|
||||
|
||||
|
||||
|
||||
|
2427
include/hwapi.h
2427
include/hwapi.h
File diff suppressed because it is too large
Load Diff
@@ -1,850 +0,0 @@
|
||||
#ifndef INTERFACE_H
|
||||
#define INTERFACE_H
|
||||
|
||||
//#include <QtPlugin>
|
||||
|
||||
|
||||
struct Tprn_hw_state
|
||||
{
|
||||
// hardware (IO's)
|
||||
bool powerRdBk; // prn pwr is on
|
||||
bool rsSwOk; // serial switch (printer or modem) is set to printer
|
||||
bool rsDrvOk; // RS232 converter for PTU, Printer and Modem in on
|
||||
|
||||
bool ReadyLine; // HW signal from printer showing ready
|
||||
bool inIdle; // powered and free from errors
|
||||
bool paperNearEnd; // paper roll runs out
|
||||
bool noPaper;
|
||||
bool ErrorTemp;
|
||||
bool HeadOpen;
|
||||
bool cutterJam;
|
||||
bool noResponse; // printer is not connected, cable broken, wrong baudrate
|
||||
bool badResponse;
|
||||
};
|
||||
|
||||
struct Tprn_currentSettings
|
||||
{
|
||||
uint8_t currFont;
|
||||
uint8_t currSize;
|
||||
uint8_t currHeigth;
|
||||
uint8_t currWidth;
|
||||
bool nowBold;
|
||||
bool nowInvers;
|
||||
bool nowUnderlined;
|
||||
uint8_t currDensity;
|
||||
uint8_t currSpeed;
|
||||
bool nowAligned;
|
||||
};
|
||||
|
||||
struct T_dynDat
|
||||
{
|
||||
uint8_t licensePlate[8];
|
||||
uint8_t vendingPrice[8];
|
||||
uint8_t parkingEnd[8];
|
||||
uint8_t currentTime[8];
|
||||
uint8_t currentDate[8];
|
||||
uint8_t dynDat5[8];
|
||||
uint8_t dynDat6[8];
|
||||
uint8_t dynDat7[8];
|
||||
};
|
||||
|
||||
|
||||
struct T_emp
|
||||
{
|
||||
|
||||
// Fixdata from EMP:
|
||||
uint8_t shaft; // = changer level
|
||||
uint16_t countryCode;
|
||||
uint8_t scale;
|
||||
uint8_t decimals;
|
||||
uint8_t coinValues[16];
|
||||
uint16_t routing;
|
||||
|
||||
// Master specs:
|
||||
uint8_t gotSetup; // 1: got specifications from master 0: no specs
|
||||
uint16_t coinAccept; // bit 0 = coin1 bit H=accept
|
||||
uint8_t tokenChannel;
|
||||
uint16_t denomination[16];
|
||||
|
||||
// dynamic:
|
||||
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
||||
// 0=Emp & Bus power off, 1=powered, poll off 2=polling on
|
||||
// 3=device responded, requesting status
|
||||
// 4=waiting for status 5=have status,
|
||||
// 6: IDLE, have paramters from master, polling running, ready for payment
|
||||
// Master can stop/start polling and acceptance
|
||||
// 7: end of transaction, polling on, accept off, reporting coins, (wait for last coin)
|
||||
// 8: transaction running, polling on, acceptance on, reporting coins,
|
||||
|
||||
uint8_t pollingRunning;
|
||||
uint8_t paymentRunning;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class hwinf
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~hwinf() {}
|
||||
|
||||
virtual void dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const =0;
|
||||
|
||||
virtual void dc_closeSerial(void) const =0;
|
||||
|
||||
virtual bool dc_isPortOpen(void) const =0;
|
||||
|
||||
virtual void dc_autoRequest(bool on) const =0;
|
||||
// select if READ-Requests are sent manually one by one or automatically
|
||||
// automatically request ALL digital and analog sensors, get time/date, get status information
|
||||
|
||||
virtual void dc_requTestResponse() const =0;
|
||||
|
||||
|
||||
virtual bool dc_readAnswTestResponse() const =0;
|
||||
// retval: true: test was successful, got right response
|
||||
|
||||
virtual uint8_t dc_isRequestDone(void) const =0;
|
||||
// retval: 0: request is still in progress
|
||||
// 1: answer from DC2 was OK
|
||||
// 2: wrong answer from DC2
|
||||
|
||||
virtual uint16_t dc_getCompletePayLoad(uint16_t plBufSiz, uint8_t *payLoad) const =0;
|
||||
// get data back in *pl, max 64 byte, can be used for diagnosis
|
||||
// retval = nr of bytes received. If host buffer too small then
|
||||
// only plBufSíz bytes are copied to pl
|
||||
// plBufSíz=size of host buffer
|
||||
|
||||
virtual void dc_setWakeFrequency(uint8_t period) const =0;
|
||||
// RTC wakes DC2 (and PTU) by hardware signal every 32seconds
|
||||
// change wake signal period to 1...64s
|
||||
|
||||
virtual void dc_OrderToReset(void) const =0;
|
||||
// want DC2 to reset (in order to start Bootloader)
|
||||
|
||||
virtual QString dc_getSerialState(void) const =0;
|
||||
virtual void dc_clrSerialStateText(void) const =0;
|
||||
|
||||
virtual void bl_sendDataDirectly(uint8_t length, uint8_t *buf) const =0;
|
||||
// send without protocol frame, needed for the DC bootloader
|
||||
|
||||
virtual uint8_t getRawRecLength(void) const =0;
|
||||
|
||||
virtual uint8_t getRawReceivedData(uint8_t *receivedData) const =0;
|
||||
|
||||
virtual QString dc_getSerialParams(void) const =0;
|
||||
|
||||
virtual QString dc_getHWversion(void) const =0;
|
||||
|
||||
virtual QString dc_getSWversion(void) const =0;
|
||||
|
||||
virtual QString dc_getState(void) const =0;
|
||||
|
||||
virtual QString dc_getTxt4RsDiagWin(void) const =0;
|
||||
virtual void dc_clrTxt4RsDiagWin(void) const =0;
|
||||
virtual QString dc_get2ndTxt4RsDiagWin(void) const =0;
|
||||
virtual void dc_clr2ndTxt4RsDiagWin(void) const =0;
|
||||
virtual QString dc_getTxt4HsStateLine(void) const =0;
|
||||
virtual void dc_clrTxt4HsStateLine(void) const =0;
|
||||
virtual QString dc_getTxt4masterStateLine(void) const =0;
|
||||
virtual void dc_clrTxt4masterStateLine(void) const =0;
|
||||
virtual QString dc_getTxt4resultStateLine(void) const =0;
|
||||
virtual void dc_clrTxt4resultStateLine(void) const =0;
|
||||
virtual QString dc_getdataStateLine(void) const =0;
|
||||
virtual void dc_clrTxt4dataStateLine(void) const =0;
|
||||
virtual QString dc_getdatifLine(void) const =0;
|
||||
virtual void dc_clrTxt4datifLine(void) const =0;
|
||||
|
||||
// using DC2 Bootloader
|
||||
virtual void bl_iniChain(void) const =0;
|
||||
virtual bool bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const =0;
|
||||
virtual uint8_t bl_activatBootloader(uint8_t *sendData) const =0;
|
||||
virtual uint8_t bl_startChain(void) const =0;
|
||||
virtual uint8_t bl_readBLversion(uint8_t *sendData) const =0;
|
||||
// minimum size of sendData-buffer: 5byte retval: length
|
||||
virtual uint8_t bl_readFWversion(uint8_t *sendData) const =0;
|
||||
// minimum size of sendData-buffer: 5byte retval: length
|
||||
|
||||
virtual uint8_t bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const =0;
|
||||
// make BL protocol, retval = outbuf length (5...133)
|
||||
// bring data in correct form: start always with 0x02 finish with 0x03 and append checksum
|
||||
// 0x02 Cmd < ...sendData ..> CRC CRC 0x03
|
||||
// Data length = 0...64
|
||||
// special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80
|
||||
// so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64
|
||||
|
||||
virtual uint8_t bl_exitBL(uint8_t *sendData) const =0;
|
||||
// minimum size of sendData-buffer: 5byte retval: length
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 2 DC2-onboard devices
|
||||
// WR: set time
|
||||
// RD. get time, get measure, get test results
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
// get UID, get time/date test results memory, RTC analog values
|
||||
|
||||
struct Trtc_DateTime
|
||||
{
|
||||
uint8_t rtc_hour;
|
||||
uint8_t rtc_min;
|
||||
uint8_t rtc_sec;
|
||||
uint8_t rtc_dayOfMonth;
|
||||
uint8_t rtc_month;
|
||||
uint8_t rtc_year;
|
||||
uint8_t rtc_dayOfWeek;
|
||||
};
|
||||
|
||||
virtual uint8_t rtc_getDateTime(struct Trtc_DateTime *rtc_DateTime) const =0;
|
||||
|
||||
virtual uint8_t rtc_setDateTime(void) const =0;
|
||||
// synch DC2 with PC or PTU system time and date
|
||||
|
||||
virtual void rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const =0;
|
||||
// get time directly
|
||||
|
||||
virtual void rtc_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) const =0;
|
||||
// get date directly
|
||||
|
||||
virtual uint8_t rtc_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) const =0;
|
||||
// dow=day of week, 1=monday...7
|
||||
// minOfToday: 0=midnight...1439= 23:59
|
||||
// secOfToday: 0=midnight...86399= 23:59:59
|
||||
|
||||
virtual bool rtc_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) const =0;
|
||||
// retval true: this year is leap year
|
||||
|
||||
virtual bool rtc_isLeapYear() const =0;
|
||||
|
||||
virtual void rtc_getWeek(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) const =0;
|
||||
// DayOfWeek: 1=monday...7
|
||||
// HoursOfWeek: 0=Monday 0:00 o'clock...167=Sunday 23:00
|
||||
// MinutesOfWeek: 0=Monday 0:00 o'clock...10079=Sunday 23:59
|
||||
|
||||
virtual void rtc_getMonth(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) const =0;
|
||||
// DayOfMonth: 1...31
|
||||
// HoursOfMonth: 0 = 0:00o'clock of 1.day in month up to 743
|
||||
// MinutesOfMonth:0 = 0:00o'clock of 1.day in month up to 44639
|
||||
|
||||
virtual void rtc_getYear(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) const =0;
|
||||
// DayOfYear: 1...366 1= 1.Jan of this current year
|
||||
// HoursOfYear: 0=1.Jan 0:00o'clock ...8783=31.12 23 o'clock
|
||||
// MinutesOfYear: 0=1.Jan 0:00o'clock ...527039=31.12 23:59 o'clock
|
||||
|
||||
virtual QString rtc_getTimStr(void) const =0;
|
||||
virtual QString rtc_getDatStr(void) const =0;
|
||||
virtual QString rtc_getTimDatStr(void) const =0;
|
||||
|
||||
// UID
|
||||
virtual void dc_getUID8byte(uint8_t *buf8byteUid) const =0;
|
||||
virtual QString dc_getUIDstr() const =0;
|
||||
virtual uint64_t dc_getUIDnumber(void) const =0;
|
||||
|
||||
|
||||
// Analog inputs:
|
||||
virtual uint32_t dc_getTemperature(void) const =0; // in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
|
||||
virtual QString dc_getTemperaturStr(void) const =0;
|
||||
|
||||
virtual uint32_t dc_getVoltage(void) const =0; // in mV, 0...65,535V
|
||||
virtual QString dc_getVoltagStr(void) const =0;
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 3: digital outputs and simple switching of connected devices
|
||||
// simple processes like flashing a led or open flap for 1s
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
virtual void lock_switchContactPower(bool on) const =0;
|
||||
|
||||
// Locks move until stop cmd (0)
|
||||
virtual uint8_t lock_switchUpperLock(uint8_t dir) const =0;
|
||||
// dir 0=off 1=up 2=down
|
||||
virtual uint8_t lock_switchLowerLock(uint8_t dir) const =0;
|
||||
// dir 0=off 1=up 2=down
|
||||
|
||||
// LEDs
|
||||
virtual void led_switchLedIllumination(uint8_t on) const =0;
|
||||
virtual void led_switchLedService(uint8_t on) const =0;
|
||||
virtual void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const =0;
|
||||
virtual void led_switchLedPinPad(uint8_t on, uint8_t ton, uint8_t tof) const =0;
|
||||
virtual void led_switchLedStart(uint8_t on, uint8_t ton, uint8_t tof) const =0;
|
||||
virtual void led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const =0;
|
||||
|
||||
virtual void fan_switchFan(bool on) const =0;
|
||||
virtual void laerm_switchSiren(bool on) const =0;
|
||||
virtual void bar_OpenBarrier(bool open) const =0;
|
||||
virtual void ptu_switchWake(bool WAKEACTIVE) const =0;
|
||||
|
||||
virtual void prn_switchPower(bool on) const =0;
|
||||
|
||||
virtual void mif_readerOn(bool on) const =0;
|
||||
|
||||
virtual void shut_move(bool open) const =0;
|
||||
virtual void esc_moveFlaps(uint8_t flap ) const =0;
|
||||
// 0: close both 1: open take-flap 2: open return
|
||||
|
||||
virtual void mdb_switchPower(bool on) const =0;
|
||||
virtual void mdb_switchWake(bool WAKEACTIVE) const =0;
|
||||
|
||||
virtual void mod_switchPower(bool on) const =0;
|
||||
virtual void credit_switchPower(bool on) const =0;
|
||||
|
||||
virtual void aux_power(bool on) const =0;
|
||||
virtual void aux_setUsage(uint8_t PinDirection) const =0;
|
||||
virtual void aux_setOutputs(uint8_t PinIsHigh) const =0;
|
||||
|
||||
|
||||
virtual void mod_switchWake(bool WAKEACTIVE) const =0;
|
||||
|
||||
virtual void credit_switchWake(bool WAKEACTIVE) const =0;
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 3: digital inputs of connected devices
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
virtual bool door_isContactPowerOn(void) const =0;
|
||||
|
||||
virtual uint8_t door_getSwitches(void) const =0;
|
||||
// retval: bit0: upper door 1: low door 2:vault door
|
||||
|
||||
virtual bool door_isUpperDoorOpen(void) const =0;
|
||||
|
||||
virtual bool door_isLowerDoorOpen(void) const =0;
|
||||
|
||||
virtual bool vault_isVaultDoorOpen(void) const =0;
|
||||
|
||||
virtual uint8_t vault_getSwitches(void) const =0;
|
||||
// retval bit0: cash box, bit 1: bill box
|
||||
|
||||
virtual bool vault_isCoinVaultIn(void) const =0;
|
||||
|
||||
virtual bool vault_isBillVaultIn(void) const =0;
|
||||
|
||||
virtual uint8_t door_getLocks(void) const =0;
|
||||
// retval bit0: upper lever is up
|
||||
// bit1: upper lever is down
|
||||
// bit2: lower lever is up
|
||||
// bit3: lower lever is down
|
||||
|
||||
virtual bool door_upperDoorIsLocked(void) const =0;
|
||||
|
||||
virtual bool door_upperDoorIsUnlocked(void) const =0;
|
||||
|
||||
virtual bool door_lowerDoorIsLocked(void) const =0;
|
||||
|
||||
virtual bool door_lowerDoorIsUnlocked(void) const =0;
|
||||
|
||||
virtual bool bar_optoIn1isOn(void) const =0;
|
||||
|
||||
virtual bool bar_optoIn2isOn(void) const =0;
|
||||
|
||||
virtual bool ptu_WakeINisActive(void) const =0;
|
||||
|
||||
virtual bool prn_isPrinterPowerOn(void) const =0;
|
||||
virtual bool prn_readyINisActive(void) const =0;
|
||||
|
||||
virtual bool mif_cardIsAttached(void) const =0;
|
||||
virtual bool mif_isMifarePowerOn(void) const =0;
|
||||
|
||||
virtual bool mdb_WakeINisActive(void) const =0;
|
||||
virtual bool mdb_testIsmdbTxDon(void) const =0;
|
||||
virtual bool mdb_isMdbPowerOn(void) const =0;
|
||||
|
||||
virtual bool coid_isAttached(void) const =0;
|
||||
virtual bool coin_escrowIsOpen(void) const =0;
|
||||
|
||||
virtual bool aux_isAuxPowerOn(void) const =0;
|
||||
|
||||
virtual uint8_t aux_getAuxInputs(void) const =0;
|
||||
|
||||
virtual bool mod_isGsmPowerOn(void) const =0;
|
||||
|
||||
virtual bool cred_isCreditPowerOn(void) const =0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level1,2,3 RD request commands
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
// all read-requests can be sent manually by the following functions
|
||||
// or automatically in background by: void hwapi::dc_autoRequest(bool on)
|
||||
// in other words:
|
||||
// if automatic-reading is on, then there's no need to send any of these commands,
|
||||
// but it's allowed to send them in order to speed up the refreshing of the inputs
|
||||
|
||||
virtual void request_DC2serialConfig() const =0;
|
||||
virtual void request_DC2_HWversion() const =0;
|
||||
virtual void request_DC2_SWversion() const =0;
|
||||
virtual void request_DC2_condition() const =0;
|
||||
virtual void request_DC2_UID() const =0;
|
||||
virtual void request_DC2_TimeAndDate() const =0;
|
||||
virtual void request_DC2_analogues() const =0;
|
||||
virtual void request_DC2_digitalInputs() const =0;
|
||||
virtual void request_DC2_digitalOutputs() const =0;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// the folowing device state requests are deploed only if device is powered up:
|
||||
virtual void request_PrinterHwState() const =0;
|
||||
virtual void request_PrinterCurrentFonts() const =0;
|
||||
virtual void request_PrinterStateComplete() const =0;
|
||||
|
||||
virtual void request_MifareReaderState() const =0;
|
||||
virtual void request_MifareCardType() const =0;
|
||||
virtual void request_MifareAtbType() const =0;
|
||||
virtual void request_MifareData() const =0;
|
||||
|
||||
virtual void request_MDB_Status() const =0;
|
||||
virtual void request_MDB_lastResponse() const =0;
|
||||
virtual void request_EMP_allParameters() const =0;
|
||||
virtual void request_EMP_lastCoin() const =0;
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level 3: readback digital outputs of connected devices
|
||||
// these functions are not needed for normal operation
|
||||
// but can be used to test and verify conditions
|
||||
|
||||
// There are two options:
|
||||
// 1) the important things like power-outputs and wake lines are
|
||||
// measured at DC2-terminals (after transistors) and come as input to DC-board
|
||||
// 2) others like Leds are read from µC-pins by DC-board
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
virtual bool test_getDO_mdbRXtst(void) const =0;
|
||||
|
||||
virtual uint8_t lock_getDO_motors(void) const =0;
|
||||
// bit0: upper lock forward bit 1 backward
|
||||
// bit2: lower lock forward bit 3 backward
|
||||
|
||||
virtual uint8_t test_serialState(void) const =0;
|
||||
// test on-board signals for the serials
|
||||
// serial drv on/off, Serial mux1, Serial mux2
|
||||
virtual bool test_serialIsOn(void) const =0;
|
||||
virtual bool test_serialMux1isSetToPrinter(void) const =0;
|
||||
virtual bool test_serialMux1isSetToModem(void) const =0;
|
||||
virtual bool test_serialMux2isSetToCredit(void) const =0;
|
||||
virtual bool test_serialMux2isSetToMifare(void) const =0;
|
||||
|
||||
virtual bool led_coinIsOn(void) const =0;
|
||||
virtual bool led_frontIsOn(void) const =0;
|
||||
virtual bool led_ticketIsOn(void) const =0;
|
||||
virtual bool led_pinIsOn(void) const =0;
|
||||
virtual bool led_StartIsOn(void) const =0;
|
||||
virtual bool led_insideIsOn(void) const =0;
|
||||
|
||||
virtual bool fan_isOn(void) const =0;
|
||||
virtual bool siren_isOn(void) const =0;
|
||||
virtual bool bar_relayIsOn(void) const =0;
|
||||
virtual bool ptu_WakeOutIsOn(void) const =0;
|
||||
|
||||
virtual bool aux_powerIsOn(void) const =0;
|
||||
|
||||
virtual bool coin_shutterIsOpen(void) const =0;
|
||||
virtual bool coin_shutterTestOutput(void) const =0;
|
||||
|
||||
virtual uint8_t coin_escrowFlapOpened(void) const =0;
|
||||
// retval: 1:return flap is open 2:take flap is open 0:closed
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Level4 ( Timer processes, device supervision by DC, processes with more then one devices
|
||||
// WRITE
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
virtual void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker,
|
||||
uint8_t kindOfMifareReader, uint8_t suppressSleep,
|
||||
uint8_t kindOfModem, uint8_t kindOfCredit ) const =0;
|
||||
|
||||
virtual void request_ReadbackDeviceSettings() const =0;
|
||||
|
||||
virtual void readback_DeviceSettings(uint8_t *length, uint8_t *data) const =0;
|
||||
// refer to DC2 manual for exact content
|
||||
// state 5.5.21: byte[0]=kindOfPrinter byte[1]=kindOfCoinChecker
|
||||
// byte[2]=kindOfMifarereadr byte[3]=suppress sleep mode
|
||||
// byte[4]=kindOfModem byte[5]=kind of cc terminal
|
||||
|
||||
virtual uint8_t emp_returnLastCoin(uint16_t *value, uint8_t *signal) const =0;
|
||||
// use for changer
|
||||
|
||||
virtual void sendMachineID(uint16_t customerNr, uint16_t machineNr,
|
||||
uint16_t borough, uint16_t zone,
|
||||
uint16_t alias, char *location) const =0;
|
||||
|
||||
virtual void request_ReadbackMachineID() const =0;
|
||||
|
||||
virtual void readback_machineIDdata(uint8_t *length, uint8_t *data) const =0;
|
||||
// state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number
|
||||
// byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name
|
||||
// byte[10...41]=location
|
||||
|
||||
|
||||
// Locks stops automatically at end switch or by timeout
|
||||
virtual uint8_t lock_openUpperDoor(void) const =0;
|
||||
virtual uint8_t lock_closeUpperDoor(void) const =0;
|
||||
|
||||
virtual uint8_t lock_openLowerDoor(void) const =0;
|
||||
virtual uint8_t lock_closeLowerDoor(void) const =0;
|
||||
|
||||
|
||||
virtual void shut_openOnce(void) const =0;
|
||||
// and close automatic after shutter time
|
||||
|
||||
virtual void shut_openForCoin(bool start) const =0;
|
||||
// open flap if coin is attached
|
||||
// once process is started it runs until stop command
|
||||
|
||||
virtual void shut_sendOpeningTime(uint16_t timeIn_ms ) const =0;
|
||||
// after this time without retrigger the flap is closed
|
||||
|
||||
virtual void esc_takeMoney(void) const =0;
|
||||
// and close automatically after escrow time (1s)
|
||||
|
||||
virtual void esc_returnMoney(void) const =0;
|
||||
// and close automatically after escrow time (1s)
|
||||
|
||||
virtual void mif_creatAtbCard(uint8_t cardType) const =0;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// read response from DC2 (input data)
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
/* data description:
|
||||
byte 0: current read state: 0=power off 1=reader-fault 2=ready
|
||||
3=just reading 4=read complete
|
||||
5=read partial, removed too early
|
||||
6=state unknown
|
||||
byte 1,2: read data length from card
|
||||
3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader
|
||||
4...15: reader version, expected "ATB25-1.8"
|
||||
byte16: 1=card is present 0:not
|
||||
17: 0
|
||||
18: card type reported from reader
|
||||
19: 1=allowed card type 0=not
|
||||
20: card size: 1 or 4 (dec) = card size
|
||||
21: LengthOfUID: 4 or 7 (dec) (byte)
|
||||
22: UID 8 byte in hex
|
||||
byte 30: sector logged: 0
|
||||
byte 31: current sector: 0
|
||||
byte 32: result, always 0
|
||||
*/
|
||||
virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const =0;
|
||||
// retval 0=OK 1=error host buffer too small
|
||||
|
||||
virtual bool mif_readerIsOK(void) const =0;
|
||||
|
||||
virtual bool mif_cardAttached(void) const =0;
|
||||
|
||||
virtual uint8_t mif_readResult(void) const =0;
|
||||
// result: 0: unknown or still in progress
|
||||
// 1: card read successful
|
||||
// 2: reading error
|
||||
|
||||
virtual QString mif_cardUID(void) const =0;
|
||||
|
||||
virtual uint8_t mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const =0;
|
||||
|
||||
virtual QString mif_getCardDataStr(uint8_t blockNumber) const =0;
|
||||
// with blockNumber=0...11
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// --------------------------------------------- PRINTER ----------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
|
||||
// read printer condition and settings
|
||||
|
||||
virtual uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const =0;
|
||||
// retval: status byte
|
||||
// byte 0 = 0: prnter OK, >0: error
|
||||
// bit0: paper low 1: no paper 2: temperature error
|
||||
// 3: head open 4: paper jam in cutter
|
||||
// 6: no response 7: bad response from printer
|
||||
// and return struct "Tprn_hw_state"
|
||||
|
||||
virtual bool prn_isUpAndReady(void) const =0;
|
||||
// true: printer is powered, serial is ok, no error, printer is connected and resonding
|
||||
|
||||
virtual void prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const =0;
|
||||
|
||||
|
||||
// send Commands to printer:
|
||||
|
||||
virtual void prn_sendText(QByteArray *buf) const =0;
|
||||
// up to 1280 bytes
|
||||
|
||||
virtual void prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) const =0;
|
||||
// send three byte through to printer, see printers manual
|
||||
|
||||
virtual void prn_sendPrnEscCmd(uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4) const =0;
|
||||
// send four byte through to printer, see printers manual
|
||||
|
||||
|
||||
virtual void prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) const =0;
|
||||
// send 5 byte: byte 0,1: speed 5...250 mm/s
|
||||
// byte2: density 0....(25)....50
|
||||
// byte3: alignment 'l', 'c', 'r' = left, center, right
|
||||
// byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!)
|
||||
// not batched! don't use twice within 100ms
|
||||
|
||||
virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0;
|
||||
//direction: 1=forward 2=backward
|
||||
//
|
||||
virtual void prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const =0;
|
||||
// font = kind of font 5...11 (0..22)
|
||||
// size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge
|
||||
// width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense)
|
||||
// heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense
|
||||
|
||||
virtual void prn_setLetters(uint8_t bold, uint8_t invers, uint8_t underlined) const =0;
|
||||
// bold: 0/1
|
||||
// invers: 0/1
|
||||
// underlined: 0/1
|
||||
|
||||
virtual void prn_cut(uint8_t kindof) const =0;
|
||||
// kindof: 1=full cut 2=partial cut 3=eject (5xLF + full cut)
|
||||
|
||||
virtual void prn_newLine(uint8_t nrOfLines) const =0;
|
||||
|
||||
virtual void prn_printCompleteFontTable(void) const =0;
|
||||
|
||||
|
||||
virtual void prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) const =0;
|
||||
// kind of barcode: 0=Code39 1=Code128 2=EAN13 3= 2/5interleaved 4=UPC-A 5=EAN8
|
||||
// withText: print readable text below
|
||||
// offset: move by pixel from left border
|
||||
// rotation
|
||||
// dataLeng in byte
|
||||
|
||||
virtual void prn_sendQRdata(QByteArray *buf) const =0;
|
||||
// maximal 150 alphanummeric bytes
|
||||
|
||||
virtual void prn_printQRcode(void) const =0;
|
||||
// QRcode may have 1...150 alphanummeric data, must be transfered in advance
|
||||
|
||||
|
||||
virtual void prn_printLogo(uint8_t nrOfLogo, uint8_t offset ) const =0;
|
||||
// nrOfLogo: 1..4 in flash 5...8 in Ram
|
||||
// offset: in mm form left border
|
||||
|
||||
|
||||
|
||||
// .........................................................
|
||||
// Parking Ticket (print-out document) designer TD
|
||||
// .........................................................
|
||||
|
||||
// Predefine document Layout (e.g. parking ticket) in advance and stroe it for quick and easy use
|
||||
// in opposite to the above "single" commands you need only one or a few commands at vending time.
|
||||
// Stored text is just send to printer once the printing command is issued
|
||||
// stored commands within the text are interpreted and executed right at the place (in ticket) they are
|
||||
// example: start bold, <text in bold>, stop bold
|
||||
// Predefinition of up to 16 ticket Layouts is possible, 0...1280 byte each
|
||||
// Number 0..15, al keept non-volatile
|
||||
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
||||
// example: print current time at this point (the time of printing not the storage time!!)
|
||||
|
||||
virtual void pri_startTicketDesign(void) const =0;
|
||||
// start for every new printer document, reseting collecting buffer
|
||||
|
||||
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
||||
// return val of the appending functions: true=ok false=too long, buffer full
|
||||
|
||||
virtual int pri_TD_getCurrentSize(void) const =0;
|
||||
// retval: 0...1278
|
||||
|
||||
virtual bool pri_TD_addText(QByteArray text) const =0;
|
||||
// example: pri_TD_addText("Hello") const =0;
|
||||
// example: pri_TD_addText(tempStr) const =0;
|
||||
// retval: true=ok false=too long, buffer full
|
||||
|
||||
virtual bool pri_TD_addValue(int val) const =0;
|
||||
// +/- 0...2^(31)
|
||||
|
||||
virtual bool pri_TD_addNewLine(void) const =0;
|
||||
|
||||
virtual bool pri_TD_addSign(char sign) const =0;
|
||||
// example: '.' ' ' 0x20 'W' '$'
|
||||
|
||||
virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0;
|
||||
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
||||
/* complete list of possible commands:
|
||||
group 50 : paper
|
||||
attribute 10 : move forward
|
||||
p1: wayInMm p2: direction
|
||||
attribute 11 : cut
|
||||
p1: kind of, 1=full 2=partial, 3=eject
|
||||
attribute 12 : new line(s)
|
||||
p1: nr of lines 1...100
|
||||
|
||||
group 51 : fonts
|
||||
attribute 10 : kind of font see description above
|
||||
p1: 0...8
|
||||
attribute 11 : font size
|
||||
p1: 6...20
|
||||
attribute 12 : font width
|
||||
p1: 0...4
|
||||
attribute 13 : font heigth
|
||||
p1: 0...7
|
||||
attribute 14 : switch bold print on/off
|
||||
p1: 0=off 1=on
|
||||
attribute 15 : switch invers print on/off
|
||||
p1: 0=off 1=on
|
||||
attribute 16 : switch underlined print on/off
|
||||
p1: 0=off 1=on
|
||||
|
||||
group 52 : print graphics
|
||||
attribute 10 : print barcode with dynamic data 6 and 7
|
||||
p1...p5 = kindOf, withText, offset, rotation, dataLeng, see description above
|
||||
attribute 11 : print QRcode with preset data
|
||||
|
||||
attribute 12 : print Logo
|
||||
p1=nrOfLogo, p2=offset
|
||||
|
||||
group 53 : print dynamics
|
||||
attribute 10 :
|
||||
p1: 1...8 = print dynData 0..7 at this place
|
||||
|
||||
*/
|
||||
|
||||
virtual char prn_clearDocument(uint8_t documentNumber) const =0;
|
||||
// clear memory buffer for ONE document
|
||||
// function takes a second! don't send right before "store doc"
|
||||
|
||||
virtual bool prn_store_Document(uint8_t documentNumber ) const =0;
|
||||
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
||||
// documentNumber=0...15
|
||||
// maximal 1280 bytes each
|
||||
// allowed: 0x20...0xFF, 0x0A, 0x0C, 0x1B (LF, CR, Esc)
|
||||
// 0x1B=start of embedded command (next 7bytes = command)
|
||||
|
||||
// with a print command a set of 8 dynamic strings can be sent
|
||||
// the place in the ticket layout is predefined (already in DC memory)
|
||||
// the dynamics are first calculated at printing time
|
||||
|
||||
virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// --------------------------------------------- MDB Bus ----------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
|
||||
//void mdb_switchPower(bool on) const =0; defined above
|
||||
//void mdb_switchWake(bool WAKEACTIVE) const =0; defined above
|
||||
// bool mdb_WakeINisActive(void) const =0;
|
||||
// bool mdb_testIsmdbTxDon(void) const =0;
|
||||
// bool mdb_isMdbPowerOn(void) const =0;
|
||||
// void request_MDB_Status() const =0;
|
||||
// void request_MDB_lastResponse() const =0;
|
||||
|
||||
|
||||
virtual void mdb_sendBusReset(void) const =0;
|
||||
|
||||
virtual void mdb_sendCommand(uint8_t toMdbDevice, uint8_t mdbCommand) const =0;
|
||||
// send one bus command directly over mdb bus, refer to mdb manual for commands
|
||||
// this command is not needed in normal operation, just for new or special things
|
||||
|
||||
virtual void mdb_sendMessage(uint8_t toMdbDevice, uint8_t mdbCommand, uint8_t nrOfData, uint8_t *dataBuffer) const =0;
|
||||
// nrOfData = sizeOf(dataBuffer) maximal 34 byte according mdb specs
|
||||
// same as mdb_sendCommand, just with data
|
||||
|
||||
virtual bool mdb_busIsReadyToWork() const =0;
|
||||
|
||||
virtual bool mdb_deviceVoltageOK() const =0;
|
||||
|
||||
virtual bool mdb_busVoltageOk() const =0;
|
||||
|
||||
virtual uint8_t mdb_getLastDeviceResponse(uint8_t *fromDevice, uint8_t *lastRequest,
|
||||
uint8_t *responseLength, uint8_t *responseBuffer) const =0;
|
||||
// fromDevice: device nr from which data was requested 0,1,2,3
|
||||
// lastRequest: sent mdb command
|
||||
// responseLength: nr of payload data (after mdb-ack) 0...34
|
||||
// responseBuffer holds payload data (answer from mdb device)
|
||||
// return val: mdb result of this request: 1=got ACK 2=got 3xNAK 3=no or bad response 4:got Data (after ACK)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// ---------------------------------- Electronic Coin Validator EMP -----------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
virtual void emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const =0;
|
||||
// coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation)
|
||||
// tokenChannel 0...31: if this signal comes from emp then a token was inserted
|
||||
// coinDenomination = array of 16 coin values (e.g. 5, 10, 20...)
|
||||
|
||||
virtual void emp_pollingOnOff(uint8_t on) const =0;
|
||||
|
||||
virtual void emp_startCoinAcceptance(void) const =0;
|
||||
|
||||
virtual void emp_stopCoinAcceptance(void) const =0;
|
||||
|
||||
virtual void emp_getAllParameters(struct T_emp *emp) const =0;
|
||||
// see struct in hwapi.h
|
||||
// usage example:
|
||||
// hwapi *HWaccess const =0;
|
||||
// HWaccess = new hwapi() const =0;
|
||||
// struct T_emp myEmp const =0;
|
||||
// HWaccess->emp_getAllParameters(&myEmp) const =0;
|
||||
// readval=myEmp.pollingRunning const =0;
|
||||
|
||||
virtual uint8_t emp_chkIfCoinInserted(void) const =0;
|
||||
// retval: 0...16 coins left in FIFO
|
||||
|
||||
virtual void emp_getNewCoinRecord(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) const =0;
|
||||
// with every call ONE coin is taken out of FIFO and pointer decremented
|
||||
// valid: should be 1
|
||||
// signal: comes right from coin checker, 0...15 (0=first programmed coin type) 0xFF=no signal
|
||||
// error: was reported from EMP as dynamic signal right after coin insertion (instead of
|
||||
// coin signal), example: 3=unknown coin 4=coin is blocked by host. 0xFF=no error
|
||||
// value: of the coin. Depends on parameter "coinDenomination" in function "emp_sendSettings"
|
||||
// if coinDenomination[coin 0..15] = 0 then the value programmed in coin checker is taken
|
||||
// if coinDenomination > 0 then this value is taken.
|
||||
// Useful in case of two currencies (adapt to local currency) or for token.
|
||||
|
||||
// function gives more details as "emp getLastCoin()" but "emp getLastCoin()" is easier to use
|
||||
|
||||
// alternativ to emp_getNewCoinRecord( ):
|
||||
virtual uint8_t emp_giveLastCoin(uint16_t *value, uint8_t *signal) const =0;
|
||||
// retval: 0: NO coin stored 1: valid coin 2: got wrong coin or coin denied
|
||||
// value: if retval1: value of the coin if reval=2: error number
|
||||
// 0xFF means NO error or NO signal (as 0 is a valid error/signal)
|
||||
// signal: channel nr reported from checker 0...15
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -26,6 +26,23 @@
|
||||
#define FRAME_MAXLEN FRAME_DATALEN+20
|
||||
#define BL_DATA_LEN 150
|
||||
|
||||
#define DATALEN_SEND_FAST 4
|
||||
#define DATALEN_SEND_LONG 64
|
||||
#define HEADERLEN_SEND 4
|
||||
#define TELEGRAMLEN_SEND_FAST 12
|
||||
#define TELEGRAMLEN_SEND_LONG 70
|
||||
#define STARTSIGN_SEND_FAST 0x3F
|
||||
#define STARTSIGN_SEND_LONG 0x3D
|
||||
|
||||
#define DATALEN_RECEIVE_FAST 8
|
||||
#define DATALEN_RECEIVE_LONG 64
|
||||
#define HEADERLEN_RECEIVE 2
|
||||
#define TELEGRAMLEN_RECEIVE_FAST 12
|
||||
#define TELEGRAMLEN_RECEIVE_LONG 68
|
||||
#define STARTSIGN_RECEIVE_FAST 0x5F
|
||||
#define STARTSIGN_RECEIVE_LONG 0x5D
|
||||
|
||||
|
||||
class T_prot : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -62,9 +79,15 @@ class T_prot : public QMainWindow
|
||||
T_com *mySerialPort;
|
||||
|
||||
void startPacking(void);
|
||||
void startFastPacking(void);
|
||||
uint8_t FramecheckInData(uint8_t *Inbuf, uint16_t LL);
|
||||
uint8_t FastCheckInData(uint8_t *Inbuf, uint16_t LL);
|
||||
|
||||
uint8_t CheckInResult(uint8_t *Inbuf);
|
||||
uint8_t CheckInData(uint8_t *recBuffer);
|
||||
|
||||
uint8_t ShowFastInData(uint8_t *recBuffer);
|
||||
uint8_t ShowInData(uint8_t *recBuffer); // was CheckInData
|
||||
void setRecLen(uint16_t WriteCmd);
|
||||
|
||||
private slots:
|
||||
void analyseRecData(void);
|
||||
@@ -87,6 +110,8 @@ public:
|
||||
|
||||
void setBLsendData( uint8_t len, uint8_t *buf);
|
||||
|
||||
void receiveFixLen(int64_t nrOfbytesToReceive);
|
||||
|
||||
void sendUserData(uint16_t slaveAdr);
|
||||
bool ifDataReceived();
|
||||
bool getReceivedInData(uint8_t *SlavAddr, uint16_t *readSrc, uint16_t *readAddr,
|
||||
|
@@ -73,10 +73,10 @@
|
||||
#define SEND_REQU_PRN_FONTS 121
|
||||
#define SEND_REQU_PRN_ALL 122
|
||||
|
||||
#define SEND_REQU_MIFREADER 123
|
||||
#define SEND_REQU_MIFSTATE 123
|
||||
// Type and state of reader
|
||||
|
||||
#define SEND_REQU_MIFCARD 124
|
||||
#define SEND_REQU_MIFDATA 124
|
||||
// Type, UID, Header of card
|
||||
// read one card sector
|
||||
// sectors must be addressed by RD_ADD
|
||||
@@ -212,6 +212,50 @@ uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *
|
||||
// 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
|
||||
|
||||
|
||||
|
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
|
||||
|
||||
|
||||
void gpi_storeUID(uint8_t *buf8byteUid);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void gpi_storeUID(uint8_t const *buf8byteUid);
|
||||
//void gpi_storeUID(uint8_t *buf8byteUid);
|
||||
// buffer size: 8 byte
|
||||
|
||||
void epi_getUIDdec(uint8_t *buf8byteUid);
|
||||
@@ -73,7 +79,7 @@ QString epi_getUIDstr();
|
||||
uint8_t epi_getSquareMode();
|
||||
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_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd);
|
||||
void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday);
|
||||
@@ -210,10 +216,10 @@ void gpi_storeDI_rejMot_home(bool di);
|
||||
|
||||
bool epi_getDI_rejectMotor_homepos(void);
|
||||
|
||||
void gpi_storeDI_paperLow(bool di);
|
||||
|
||||
bool epi_getDI_npe_sensor(void);
|
||||
void gpi_storeDI_paperLow(uint8_t di);
|
||||
|
||||
uint8_t epi_getDI_npe_sensor(void);
|
||||
// 0: Sensor sees paper 1: no paper 99: off
|
||||
|
||||
|
||||
|
||||
@@ -407,7 +413,7 @@ void gpi_storeMifCardData(uint8_t blkNr, uint8_t *receivedData);
|
||||
|
||||
uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize);
|
||||
// blkNr=0...11 return buf[64]
|
||||
|
||||
// retval: 1=error 0=OK
|
||||
|
||||
|
||||
|
||||
@@ -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 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
|
||||
|
||||
|
||||
|
@@ -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 ulong2uchar(uint32_t ulval, uint8_t getBytNr);
|
||||
// getBytNr: 0=LSB 3=MSB
|
||||
|
||||
|
||||
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(uint8_t *buf);
|
||||
|
||||
void tslib_strclr(char *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);
|
||||
// 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
|
||||
|
1758
plugins/interfaces.h
Normal file
1758
plugins/interfaces.h
Normal file
File diff suppressed because it is too large
Load Diff
48
src/com.cpp
48
src/com.cpp
@@ -8,7 +8,7 @@
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static int64_t com_want2read;
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
// --------- PUBLIC --------------------------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
@@ -78,7 +78,7 @@ T_com::T_com(QWidget *parent) : QMainWindow(parent)
|
||||
connect(ChkConnectTimer, SIGNAL(timeout()), this, SLOT(ser_ISR100ms()));
|
||||
ChkConnectTimer->setSingleShot(false);
|
||||
ChkConnectTimer->start(100); // in ms
|
||||
|
||||
com_want2read=0;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,9 +202,48 @@ void T_com::readSomeBytes(void)
|
||||
{
|
||||
// called by serial-read-detection
|
||||
// restart off-time as input flow is ongoing
|
||||
serRecTime->stop();
|
||||
serRecTime->start(20); // in ms
|
||||
|
||||
// timer for slow receive
|
||||
// and serves as timeout for fast receive is msg is shorter as expected
|
||||
serRecTime->stop();
|
||||
serRecTime->start(20); // in ms
|
||||
|
||||
//qDebug()<< "com-rec read some bytes";
|
||||
|
||||
this->receiveByLength(); // since 14.12.21: fast receive
|
||||
}
|
||||
|
||||
void T_com::receiveFixLen(int64_t nrOfbytesToReceive)
|
||||
{
|
||||
// call this before sending a request to slave
|
||||
// then we know exactly when reception is complete -> much faster
|
||||
com_want2read=nrOfbytesToReceive;
|
||||
// since 14.12.21: FastDevice Protocol has two lengthen:
|
||||
// fast: 12byte reception long: 68byte
|
||||
}
|
||||
|
||||
void T_com::receiveByLength(void)
|
||||
{
|
||||
|
||||
if (CatSerial->isOpen())
|
||||
{
|
||||
QString myString=nullptr, tmpStr=nullptr;
|
||||
int64_t nrOfBytesreceived = CatSerial->bytesAvailable(); // nr of received bytes
|
||||
|
||||
//qDebug()<< "com-rec current Len: "<< nrOfBytesreceived;
|
||||
|
||||
if (nrOfBytesreceived >= com_want2read)
|
||||
{
|
||||
QByteArray data = CatSerial->readAll(); // erst auslesen wenn alles da! löscht den Empfangspuffer
|
||||
serRecTime->stop(); // stop timeout to avoid 2nd emit
|
||||
rawInLen=uint16_t (nrOfBytesreceived);
|
||||
rawInput.clear();
|
||||
rawInput.append(data);
|
||||
// report "new data received" to other objects
|
||||
//qDebug()<< "com-recFinished by Len "<< rawInLen;
|
||||
emit receivingFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void T_com::receiveTO(void)
|
||||
@@ -252,6 +291,7 @@ void T_com::receiveTO(void)
|
||||
//gpi_set2ndTxt4RsDiagWin(myString);
|
||||
|
||||
// report "new data received" to other objects
|
||||
//qDebug()<< "com-recFinished by TO";
|
||||
emit receivingFinished();
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1024
src/datIf.cpp
1024
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
322
src/dcBL.cpp
322
src/dcBL.cpp
@@ -283,24 +283,28 @@ uint8_t dcBL_restartDC(uint8_t *sendData)
|
||||
uint8_t dcBL_activatBootloader(uint8_t *sendData)
|
||||
{
|
||||
// minimum size of sendData-buffer: 20 byte retval: length
|
||||
|
||||
uint8_t nn=0;
|
||||
|
||||
//sendData[nn++]='U'; nötig??
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
|
||||
sendData[nn++]=2;
|
||||
sendData[nn++]='c';
|
||||
sendData[nn++]='4';
|
||||
sendData[nn++]='5';
|
||||
sendData[nn++]='b';
|
||||
sendData[nn++]='3';
|
||||
sendData[nn++]=3;
|
||||
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]='U';
|
||||
sendData[nn++]=0;
|
||||
sendData[nn++]=0;
|
||||
return nn;
|
||||
}
|
||||
@@ -315,9 +319,11 @@ uint8_t dcBL_getResponse(uint8_t *respBuff, bool display)
|
||||
{
|
||||
epi_getRawReceivedData(respBuff);
|
||||
epi_clrRawReceivedString();
|
||||
dcBL_writeText("dcBL gotResponse");
|
||||
|
||||
if (display)
|
||||
{
|
||||
/*
|
||||
// Antwort ins Fenster schreiben:
|
||||
QString tmpStr="", myStr="~~> ";
|
||||
|
||||
@@ -332,8 +338,8 @@ uint8_t dcBL_getResponse(uint8_t *respBuff, bool display)
|
||||
myStr.append(" ");
|
||||
}
|
||||
dcBL_writeText(myStr);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
return recLen;
|
||||
}
|
||||
@@ -355,6 +361,10 @@ uint8_t dcBL_ChkResponse()
|
||||
recLen=dcBL_getResponse(buf,0);
|
||||
if (recLen==0)
|
||||
return 0; // no response by now
|
||||
|
||||
//qDebug()<<" DCBL_chkResp got answer " << recLen ;
|
||||
//dcBL_writeText("DCBL_chkResp got answer");
|
||||
|
||||
if (buf[0]==2 && buf[1]==(dcBL_LastBLcmd | 0x80) )
|
||||
return 10; // OK
|
||||
|
||||
@@ -365,24 +375,28 @@ uint8_t dcBL_ChkResponse()
|
||||
{
|
||||
dcBL_writeText("error wrong length");
|
||||
//exactError=1;
|
||||
qDebug()<<" DCBL_chkResp wrong length ";
|
||||
return 10; // OK
|
||||
}
|
||||
if (buf[0] !=2)
|
||||
{
|
||||
dcBL_writeText("error wrong start");
|
||||
//exactError=2;
|
||||
qDebug()<<" DCBL_chkResp wrong start ";
|
||||
return 10; // OK
|
||||
}
|
||||
if (buf[0]==2 && buf[1]=='e' && buf[2]=='0' )
|
||||
{
|
||||
dcBL_writeText("error wrong crc");
|
||||
//exactError=3; // DC reports wrong crc
|
||||
qDebug()<<" DCBL_chkResp wrong crc";
|
||||
return 1; // error
|
||||
}
|
||||
if (buf[0]==2 && buf[1]==dcBL_LastBLcmd )
|
||||
{
|
||||
dcBL_writeText("error wrong cmd");
|
||||
//exactError=4; // wrong cmd
|
||||
qDebug()<<" DCBL_chkResp wrong cmd";
|
||||
return 10; // OK
|
||||
}
|
||||
//tmpStr.clear();
|
||||
@@ -393,6 +407,21 @@ uint8_t dcBL_ChkResponse()
|
||||
|
||||
|
||||
|
||||
uint8_t dcBL_sendSuccess(uint8_t lastCommand)
|
||||
{
|
||||
// return val: 0: no response by now 1:error 10: OK
|
||||
|
||||
uint8_t buf[152], recLen;
|
||||
|
||||
recLen=dcBL_getResponse(buf,0);
|
||||
if (recLen==0)
|
||||
return 0; // no response by now
|
||||
|
||||
if (buf[0]==2 && buf[1]==(lastCommand | 0x80) )
|
||||
return 10; // OK
|
||||
return 1;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// --- ATB Bin-File Handling ---------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
@@ -445,9 +474,8 @@ char dcBL_loadBinary(char withDisplay)
|
||||
uint32_t ultmp, fileLen;
|
||||
QString tmpStr="", s2tmp="";
|
||||
|
||||
//QFile file("/own/H2B/dc2.hex"); // laesst sich genauso oeffnen
|
||||
QFile file("/own/H2B/dc2.bin");
|
||||
|
||||
qDebug()<<"dcBL loading DC2c binary...";
|
||||
QFile file("../dc2c4.bin");
|
||||
if (!file.exists())
|
||||
{
|
||||
//qDebug()<<"file _own_H2B_dc2.bin does not exist";
|
||||
@@ -502,7 +530,8 @@ static QByteArray dcBL_AtbBinFile;
|
||||
static uint32_t dcBL_fileSize;
|
||||
static uint16_t dcBL_nrOfBlocks;
|
||||
static uint16_t dcBL_fileCrc;
|
||||
static uint8_t dcBL_myBuf[257000]; // same content like "dcBL_AtbBinFile" but bytewise
|
||||
//static uint8_t dcBL_myBuf[2570000]; // same content like "dcBL_AtbBinFile" but bytewise
|
||||
static uint8_t dcBL_myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise
|
||||
|
||||
bool dcBL_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl)
|
||||
{
|
||||
@@ -514,7 +543,10 @@ bool dcBL_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDisp
|
||||
dcBL_AtbBinFile=readBinFile;
|
||||
dcBL_fileSize=fileSize;
|
||||
|
||||
if (dcBL_fileSize>258048)
|
||||
//if (dcBL_fileSize>258048) // 27.3.23TS woher kommt die Zahl???
|
||||
// das hex file hat 278kB
|
||||
// hex file nicht erlaubt???
|
||||
if (dcBL_fileSize>=300000)
|
||||
return false; // keep last file
|
||||
ultmp=dcBL_fileSize;
|
||||
ultmp %=64;
|
||||
@@ -718,7 +750,7 @@ uint8_t dcBL_getFileBlock(uint16_t blockPointer, uint8_t *buf)
|
||||
|
||||
/*
|
||||
// Kontrolle:
|
||||
qDebug()<<"dcBL_getFileBlock myBuf: ";
|
||||
qDebug()<<"dcBL getFileBlock myBuf: ";
|
||||
int ii=0;
|
||||
do
|
||||
{
|
||||
@@ -729,7 +761,7 @@ uint8_t dcBL_getFileBlock(uint16_t blockPointer, uint8_t *buf)
|
||||
|
||||
} while (ii<64);
|
||||
|
||||
qDebug()<<"dcBL_getFileBlock myBuf: ";
|
||||
qDebug()<<"dcBL getFileBlock myBuf: ";
|
||||
ii=0;
|
||||
do
|
||||
{
|
||||
@@ -809,7 +841,6 @@ QString dcBL_readText(void)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
static uint8_t dcBL_step, dcBL_state;
|
||||
static uint16_t dcBL_BlkCtr, dcBL_cyclCtr, repeatCtr;
|
||||
|
||||
@@ -826,8 +857,8 @@ void dcBL_iniChain(void)
|
||||
pBlResp=0;
|
||||
for (nn=0;nn<SIZEBLRESP; nn++)
|
||||
BlResp[nn]="";
|
||||
dcBL_writeText("**CLEAR**");
|
||||
|
||||
//dcBL_writeText("**CLEAR**");
|
||||
dcBL_writeText("bl chain ini");
|
||||
}
|
||||
|
||||
uint8_t dcBL_startChain(void)
|
||||
@@ -836,13 +867,15 @@ uint8_t dcBL_startChain(void)
|
||||
{
|
||||
dcBL_iniChain();
|
||||
dcBL_step=1;
|
||||
epi_clrRawReceivedString();
|
||||
//epi_clrRawReceivedString();
|
||||
qDebug()<<"starting chain...";
|
||||
//qDebug()<<pBlResp;
|
||||
dcBL_writeText("bl chain start");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint8_t dcBL_runChain(void)
|
||||
{
|
||||
// starting BL
|
||||
@@ -857,17 +890,14 @@ uint8_t dcBL_runChain(void)
|
||||
|
||||
QString tmpStr="";
|
||||
|
||||
uint8_t buf[70], sendBuf[160], len, sendLen, gotResp; //, uit8tmp; //, recLen; recBuff[160], ii,
|
||||
uint8_t buf[70], sendBuf[160], len, sendLen, gotResp, ii, uit8tmp;
|
||||
//static uint8_t lastBlkLength;
|
||||
QString stemp=" ";
|
||||
uint32_t ultmp;
|
||||
bool ret;
|
||||
//uint8_t recLen, recBuff[160], ;
|
||||
|
||||
//recLen=dcBL_getResponse(recBuff, (dcBL_step<=11)?1:0); // reads all responses
|
||||
// Antwort nur bis step 11 anzeigen
|
||||
// wird schon in dcBL_responseOK() gelesen
|
||||
|
||||
gotResp=dcBL_ChkResponse();
|
||||
gotResp=dcBL_ChkResponse(); //zum test hier raus, unten gehts nicht, darf nur 1x
|
||||
|
||||
switch (dcBL_step)
|
||||
{
|
||||
@@ -904,6 +934,7 @@ uint8_t dcBL_runChain(void)
|
||||
|
||||
case 5: // wait for answer: 2 99 52 53 98 51 3
|
||||
// Problem: kommt von app, nicht vom BL. Also wenn BL schon aktiv ist dann gehts nicht
|
||||
|
||||
/*
|
||||
dcBL_cyclCtr++;
|
||||
if (recLen>6 && recBuff[0]==2 && recBuff[1]==99 && recBuff[2]==52)
|
||||
@@ -922,7 +953,7 @@ uint8_t dcBL_runChain(void)
|
||||
dcBL_state=3;
|
||||
dcBL_step=0; // stop chain
|
||||
return 0;
|
||||
}*/
|
||||
} */
|
||||
|
||||
dcBL_step++;
|
||||
repeatCtr=0;
|
||||
@@ -1002,49 +1033,15 @@ uint8_t dcBL_runChain(void)
|
||||
dcBL_step=0; // stop chain
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case 10: // send length and crc
|
||||
len=dcBL_getAtbFileHeader(buf);
|
||||
sendWRcmd_setSendBlock160(len, buf);
|
||||
dcBL_writeText("sending header");
|
||||
|
||||
dcBL_BlkCtr=0; // normal 0
|
||||
|
||||
dcBL_cyclCtr=0;
|
||||
dcBL_step++;
|
||||
break;
|
||||
|
||||
case 11: // wait for answer 2 178 102 105 3
|
||||
|
||||
if (gotResp==ISOK)
|
||||
{
|
||||
dcBL_step++;
|
||||
repeatCtr=0;
|
||||
return 0;
|
||||
} else
|
||||
if (gotResp==ISWRONG)
|
||||
{
|
||||
if (++repeatCtr<3)
|
||||
{
|
||||
dcBL_step--;
|
||||
} else
|
||||
{
|
||||
dcBL_step=0; // stop chain
|
||||
}
|
||||
}
|
||||
if (++dcBL_cyclCtr>10)
|
||||
{
|
||||
dcBL_writeText("cancel");
|
||||
dcBL_step=0; // stop chain
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case 12: // send binary 64 byte wise
|
||||
|
||||
len=dcBL_getFileBlock(dcBL_BlkCtr, buf); // read from file, len = 0...64
|
||||
//lastBlkLength=len; // recognize last block or end
|
||||
sendLen=dcBL_prepareDC_BLcmd(0x22, len, buf, sendBuf); // pack into protocol frame
|
||||
/*
|
||||
|
||||
|
||||
// Kontrolle:
|
||||
qDebug()<<"dcBL sending: ";
|
||||
ii=0;
|
||||
@@ -1056,7 +1053,7 @@ uint8_t dcBL_runChain(void)
|
||||
qDebug() << stemp << " "; // Anzeige in hex
|
||||
|
||||
} while (ii<100);
|
||||
*/
|
||||
|
||||
|
||||
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
|
||||
delay(100);
|
||||
@@ -1174,12 +1171,202 @@ uint8_t dcBL_runChain(void)
|
||||
case 18:
|
||||
dcBL_step=0;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void dcBL_iniLoading(void)
|
||||
{
|
||||
dcBL_iniChain();
|
||||
}
|
||||
|
||||
|
||||
// nicht verwendet
|
||||
void dcBL_startLoading(void)
|
||||
{
|
||||
if (dcBL_step==0 || dcBL_step>17)
|
||||
{
|
||||
//dcBL_iniChain();
|
||||
dcBL_step=1;
|
||||
//epi_clrRawReceivedString();
|
||||
qDebug()<<"DCBL start sending hexfile...";
|
||||
dcBL_writeText("DCBL start sending hexfile...");
|
||||
dcBL_BlkCtr=0;
|
||||
dcBL_cyclCtr=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// nicht verwendet
|
||||
uint8_t dcBL_sendHexfile(void)
|
||||
{
|
||||
QString tmpStr="";
|
||||
uint8_t buf[70], sendBuf[160], len, sendLen, gotResp; //, recLen; recBuff[160], ii,
|
||||
QString stemp=" ";
|
||||
uint32_t ultmp;
|
||||
//uint8_t uit8tmp, ii;
|
||||
|
||||
|
||||
gotResp=dcBL_ChkResponse();
|
||||
|
||||
switch (dcBL_step)
|
||||
{
|
||||
case 1: // send start address
|
||||
if (dcBL_BlkCtr==0 || dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096)
|
||||
{
|
||||
ultmp=uint32_t(dcBL_BlkCtr);
|
||||
ultmp*=64;
|
||||
len=dcBL_sendFlashStartAddr2BL(ultmp, buf);
|
||||
sendWRcmd_setSendBlock160(len, buf);
|
||||
qDebug()<<" DCBL_CYCL_sending HexFile address ";
|
||||
dcBL_writeText("sending addr");
|
||||
dcBL_step++;
|
||||
return 0;
|
||||
} else
|
||||
dcBL_step=12;
|
||||
break;
|
||||
|
||||
case 2: // wait for answer 2 161 68 59 3
|
||||
if (gotResp==ISOK)
|
||||
{
|
||||
dcBL_step=12; // Header nicht senden, unnötig
|
||||
dcBL_BlkCtr=0; // 0
|
||||
repeatCtr=0;
|
||||
return 0;
|
||||
} else
|
||||
if (gotResp==ISWRONG)
|
||||
{
|
||||
if (++repeatCtr<3)
|
||||
{
|
||||
dcBL_step--;
|
||||
} else
|
||||
{
|
||||
dcBL_step=0; // stop chain
|
||||
qDebug()<<" DCBL_CYCL_got wrong resp to addr";
|
||||
dcBL_writeText("wrong resp");
|
||||
}
|
||||
}
|
||||
if (++dcBL_cyclCtr>100)
|
||||
{
|
||||
dcBL_writeText("cancel");
|
||||
qDebug()<<" DCBL_CYCL_step 2 got NO resp to addr";
|
||||
dcBL_step=0; // stop chain
|
||||
}
|
||||
break;
|
||||
|
||||
case 12: // send binary 64 byte wise
|
||||
|
||||
len=dcBL_getFileBlock(dcBL_BlkCtr, buf); // read from file, len = 0...64
|
||||
//lastBlkLength=len; // recognize last block or end
|
||||
sendLen=dcBL_prepareDC_BLcmd(0x22, len, buf, sendBuf); // pack into protocol frame
|
||||
/*
|
||||
// Kontrolle:
|
||||
qDebug()<<"dcBL sending: ";
|
||||
ii=0;
|
||||
do
|
||||
{
|
||||
uit8tmp=(uint8_t)sendBuf[ii++];
|
||||
//qDebug() << uit8tmp << " "; // Anzeige in dez
|
||||
stemp.setNum(uit8tmp,16);
|
||||
qDebug() << stemp << " "; // Anzeige in hex
|
||||
|
||||
} while (ii<100);
|
||||
*/
|
||||
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
|
||||
delay(100);
|
||||
dcBL_writeText("blk nr: ");
|
||||
tmpStr.setNum(dcBL_BlkCtr);
|
||||
dcBL_writeText(tmpStr);
|
||||
delay(100);
|
||||
qDebug()<<"DCBL sending blk nr: " << dcBL_BlkCtr;
|
||||
dcBL_cyclCtr=0;
|
||||
dcBL_BlkCtr++;
|
||||
dcBL_step++;
|
||||
break;
|
||||
|
||||
case 13: // wait for answer 2 162 116 88 3
|
||||
|
||||
if (gotResp==ISOK)
|
||||
{
|
||||
// check if next address is needed (every 1024Blocks = 65536bytes)
|
||||
if (dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096)
|
||||
{
|
||||
dcBL_step=8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check for EOF:
|
||||
if (dcBL_BlkCtr >= dcBL_nrOfBlocks)
|
||||
{
|
||||
dcBL_writeText("last block successful sent...");
|
||||
dcBL_step++; // stop chain
|
||||
dcBL_state=3; // transmission SUCCESSFUL
|
||||
return 0;
|
||||
}
|
||||
dcBL_state=2; // transmission started
|
||||
dcBL_step--; // send next data block
|
||||
repeatCtr=0;
|
||||
return 0;
|
||||
}
|
||||
if (gotResp==ISWRONG)
|
||||
{
|
||||
if (++repeatCtr<3)
|
||||
{
|
||||
dcBL_writeText("error");
|
||||
dcBL_BlkCtr--;
|
||||
dcBL_step--; // send same block again
|
||||
} else
|
||||
{
|
||||
dcBL_step=0; // stop chain
|
||||
}
|
||||
}
|
||||
if (++dcBL_cyclCtr>30) // longer TO due to flashing
|
||||
{
|
||||
dcBL_writeText("cancel");
|
||||
dcBL_step=0; // stop chain
|
||||
}
|
||||
break;
|
||||
|
||||
case 14: //
|
||||
dcBL_writeText("finish writing flash");
|
||||
len=dcBL_writeLastPage(buf); // nur zur Sicherheit
|
||||
sendWRcmd_setSendBlock160(len, buf);
|
||||
dcBL_step++;
|
||||
break;
|
||||
|
||||
case 15: // wait for answer
|
||||
if (gotResp==ISOK)
|
||||
{
|
||||
dcBL_step++;
|
||||
repeatCtr=0;
|
||||
return 0;
|
||||
} else
|
||||
if (gotResp==ISWRONG)
|
||||
{
|
||||
if (++repeatCtr>3)
|
||||
{
|
||||
dcBL_step--;
|
||||
}
|
||||
}
|
||||
if (++dcBL_cyclCtr>10)
|
||||
{
|
||||
dcBL_writeText("cancel");
|
||||
dcBL_step=0; // stop chain
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t dcBL_getResult(void)
|
||||
{
|
||||
// call after every step to what's going on....
|
||||
@@ -1190,6 +1377,9 @@ uint8_t dcBL_getResult(void)
|
||||
return dcBL_state;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
static uint8_t Sdata_rawData[RAW_BL_DATALEN];
|
||||
@@ -1204,6 +1394,8 @@ void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData)
|
||||
Sdata_LengthRawData=RAW_BL_DATALEN;
|
||||
for (nn=0; nn<Sdata_LengthRawData; nn++)
|
||||
Sdata_rawData[nn]=receivedData[nn];
|
||||
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
||||
|
||||
}
|
||||
|
||||
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
|
||||
@@ -1230,8 +1422,8 @@ QString epi_getRawReceivedString()
|
||||
QString myString=nullptr, tmpStr=nullptr;
|
||||
|
||||
myString.clear();
|
||||
//if (Sdata_LengthRawData==0)
|
||||
// return myString;
|
||||
if (Sdata_LengthRawData==0)
|
||||
return myString;
|
||||
|
||||
for (nn=0; nn<Sdata_LengthRawData; nn++)
|
||||
{
|
||||
|
6326
src/hwapi.cpp
6326
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();
|
||||
}
|
285
src/prot.cpp
285
src/prot.cpp
@@ -9,9 +9,33 @@ T_prot::T_prot()
|
||||
|
||||
mySerialPort = new T_com();
|
||||
connect(mySerialPort, SIGNAL(receivingFinished()), this, SLOT( analyseRecData() ));
|
||||
//connect(mySerialPort, SIGNAL(receivingFinished()), this, SLOT( receivFin() ));
|
||||
//connect(mySerialPort, SIGNAL(sendingFinished()), this, SLOT(sendeFin()));
|
||||
kindOfData=0; // 0: binaries, 1:text
|
||||
|
||||
for (int nn=0; nn<FRAME_DATALEN; nn++)
|
||||
{
|
||||
chOut_Data[nn]=0;
|
||||
ui8OutputData[nn]=0;
|
||||
InputData[nn]=0;
|
||||
}
|
||||
for (int nn=0; nn<BL_DATA_LEN; nn++)
|
||||
{
|
||||
ui8BLsendData[nn]=0;
|
||||
}
|
||||
WriteCommand=0;
|
||||
WriteAddr=0;
|
||||
WrDataLength=0;
|
||||
SendDataValid=0;
|
||||
kindOfData=0;
|
||||
slaveAddr=0;
|
||||
ReadCommand=0;
|
||||
ReadAddr=0;
|
||||
reserve =0;
|
||||
RecSlaveAddr =0;
|
||||
INdataValid=0;
|
||||
readSource =0;
|
||||
readAddress=0;
|
||||
RdDataLength=0;
|
||||
BLsendDataLength=0;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +54,19 @@ bool T_prot::isSerialFree(void)
|
||||
return true; // ohne HS's kann er nicht blockiert sein
|
||||
}
|
||||
|
||||
void T_prot::setRecLen(uint16_t WriteCmd)
|
||||
{
|
||||
if (WriteCmd<100)
|
||||
{
|
||||
RdDataLength=DATALEN_RECEIVE_LONG; // store here already because it's no longer
|
||||
// returned from slave
|
||||
mySerialPort->receiveFixLen(TELEGRAMLEN_RECEIVE_LONG);
|
||||
} else
|
||||
{
|
||||
RdDataLength=DATALEN_RECEIVE_FAST;
|
||||
mySerialPort->receiveFixLen(TELEGRAMLEN_RECEIVE_FAST);
|
||||
}
|
||||
}
|
||||
|
||||
void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, uint8_t *data)
|
||||
{
|
||||
@@ -43,6 +80,8 @@ void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDat
|
||||
ui8OutputData[nn]=data[nn];
|
||||
SendDataValid=1; // always set WR first
|
||||
kindOfData=0; // 0: binaries, 1:text
|
||||
this->setRecLen(WriteCmd);
|
||||
|
||||
}
|
||||
|
||||
void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr)
|
||||
@@ -54,6 +93,8 @@ void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr)
|
||||
ui8OutputData[nn]=0;
|
||||
SendDataValid=1; // always set WR first
|
||||
kindOfData=0; // 0: binaries, 1:text
|
||||
this->setRecLen(WriteCmd);
|
||||
|
||||
}
|
||||
|
||||
void T_prot::setUserWriteData(uint16_t WriteCmd)
|
||||
@@ -65,6 +106,8 @@ void T_prot::setUserWriteData(uint16_t WriteCmd)
|
||||
ui8OutputData[nn]=0;
|
||||
SendDataValid=1; // always set WR first
|
||||
kindOfData=0; // 0: binaries, 1:text
|
||||
this->setRecLen(WriteCmd);
|
||||
|
||||
}
|
||||
|
||||
void T_prot::setUserWrite1DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val)
|
||||
@@ -76,6 +119,8 @@ void T_prot::setUserWrite1DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val)
|
||||
ui8OutputData[0]=val;
|
||||
SendDataValid=1; // always set WR first
|
||||
kindOfData=0; // 0: binaries, 1:text
|
||||
this->setRecLen(WriteCmd);
|
||||
|
||||
}
|
||||
|
||||
void T_prot::setUserWrite2DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, uint8_t val1)
|
||||
@@ -87,6 +132,8 @@ void T_prot::setUserWrite2DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, u
|
||||
ui8OutputData[1]=val1;
|
||||
SendDataValid=1; // always set WR first
|
||||
kindOfData=0; // 0: binaries, 1:text
|
||||
this->setRecLen(WriteCmd);
|
||||
|
||||
}
|
||||
|
||||
void T_prot::setUserWriteText(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, char *data)
|
||||
@@ -101,6 +148,8 @@ void T_prot::setUserWriteText(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDat
|
||||
chOut_Data[nn]=data[nn];
|
||||
SendDataValid=1; // always set WR first
|
||||
kindOfData=1; // 0: binaries, 1:text
|
||||
this->setRecLen(WriteCmd);
|
||||
|
||||
}
|
||||
|
||||
void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reserv)
|
||||
@@ -109,6 +158,8 @@ void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reser
|
||||
ReadAddr=RdAddr;
|
||||
reserve=reserv;
|
||||
SendDataValid |=2;
|
||||
readAddress=RdAddr; // store here already because it's no longer returned from slave
|
||||
readSource=ReadCmd;
|
||||
}
|
||||
|
||||
void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr)
|
||||
@@ -117,6 +168,8 @@ void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr)
|
||||
ReadAddr=RdAddr;
|
||||
reserve=0;
|
||||
SendDataValid |=2;
|
||||
readAddress=RdAddr; // store here already because it's no longer returned from slave
|
||||
readSource=ReadCmd;
|
||||
}
|
||||
|
||||
void T_prot::setUserReadData( uint16_t ReadCmd)
|
||||
@@ -125,6 +178,8 @@ void T_prot::setUserReadData( uint16_t ReadCmd)
|
||||
ReadAddr=0;
|
||||
reserve=0;
|
||||
SendDataValid |=2;
|
||||
readAddress=0; // store here already because it's no longer returned from slave
|
||||
readSource=ReadCmd;
|
||||
}
|
||||
|
||||
void T_prot::setBLsendData( uint8_t len, uint8_t *buf)
|
||||
@@ -137,8 +192,14 @@ void T_prot::setBLsendData( uint8_t len, uint8_t *buf)
|
||||
for (int nn=0; nn<BLsendDataLength; nn++)
|
||||
ui8BLsendData[nn]=buf[nn];
|
||||
WriteCommand=0xFFFF;
|
||||
this->setRecLen(100); // how many??
|
||||
//readAddress= // needed??
|
||||
|
||||
//qDebug()<<"prot: got BL data " << len << "bytes, ";
|
||||
//for (int i=0; i<len; ++i) {
|
||||
// printf("%02x ", (unsigned char)buf[i]);
|
||||
//} printf("\n");
|
||||
|
||||
qDebug()<<"prot: got BL data " << len << "bytes, ";
|
||||
/*
|
||||
qDebug()<<buf[0] <<buf[1] <<buf[2] <<buf[3] <<buf[4] <<buf[5] <<buf[6] <<buf[7];
|
||||
qDebug() <<buf[8] <<buf[9] <<buf[10] <<buf[11] <<buf[12] <<buf[13]<<buf[14]<<buf[15];
|
||||
@@ -153,6 +214,11 @@ qDebug() <<buf[72] <<buf[73] <<buf[74] <<buf[75] <<buf[76] <<buf[77] <<buf[78]<<
|
||||
*/
|
||||
}
|
||||
|
||||
void T_prot::receiveFixLen(int64_t nrOfbytesToReceive)
|
||||
{
|
||||
mySerialPort->receiveFixLen(nrOfbytesToReceive);
|
||||
}
|
||||
|
||||
void T_prot::sendUserData(uint16_t slaveAdr)
|
||||
{
|
||||
// man könnte hier noch "SendDataValid" abfragen,
|
||||
@@ -167,14 +233,90 @@ void T_prot::sendUserData(uint16_t slaveAdr)
|
||||
// Bypass for bootloader, no protocol frame but send as is...
|
||||
packBuf_2.clear();
|
||||
for (int nn=0; nn<BLsendDataLength; nn++)
|
||||
packBuf_2[nn]=char(ui8BLsendData[nn]);
|
||||
packBuf_2[nn]=char(ui8BLsendData[nn]);
|
||||
mySerialPort->writeToSerial(packBuf_2, BLsendDataLength);
|
||||
|
||||
|
||||
} else
|
||||
startPacking();
|
||||
startFastPacking(); // quicker since 15.12.21TS
|
||||
//startPacking();
|
||||
}
|
||||
|
||||
void T_prot::startFastPacking(void)
|
||||
{
|
||||
uint16_t mycrc;
|
||||
uint16_t sendLen;
|
||||
uint8_t uctmp, nn, pp, CrcLp;
|
||||
char sendBuffer[FRAME_MAXLEN], ctmp;
|
||||
|
||||
//qDebug() << "prot start fast packing "<<slaveAddr;
|
||||
|
||||
for (int nn=0; nn<FRAME_MAXLEN; nn++)
|
||||
sendBuffer[nn]=0;
|
||||
|
||||
if (WriteCommand>9 && WriteCommand<100)
|
||||
{
|
||||
// long command 10...99
|
||||
// WriteCommand==0 if only read request, then use short sending
|
||||
sendBuffer[0]=STARTSIGN_SEND_LONG;
|
||||
WrDataLength=DATALEN_SEND_LONG; // immer
|
||||
//qDebug() << "send long cmd, len: " << WrDataLength;
|
||||
} else
|
||||
{
|
||||
// fast command
|
||||
sendBuffer[0]=STARTSIGN_SEND_FAST;
|
||||
WrDataLength=DATALEN_SEND_FAST; // immer
|
||||
//qDebug() << "send fast cmd, len: " << WrDataLength;
|
||||
}
|
||||
sendBuffer[1]= uint8_t(WriteCommand);
|
||||
sendBuffer[2]= uint8_t(ReadCommand);
|
||||
if (WriteAddr>0)
|
||||
sendBuffer[3]= char(WriteAddr); // bei fast nur EINE adresse, wr hat Vorrang
|
||||
else
|
||||
sendBuffer[3]= char(ReadAddr);
|
||||
// beim Fast prot. ist das reserve dann ists egal was drin steht
|
||||
|
||||
if (kindOfData) // 0: binaries, 1:text
|
||||
{
|
||||
for (nn=0; nn<WrDataLength; nn++)
|
||||
{
|
||||
pp=HEADERLEN_SEND+nn;
|
||||
ctmp=(chOut_Data[nn]); // text
|
||||
sendBuffer[pp]= char(ctmp);
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
for (nn=0; nn<WrDataLength; nn++)
|
||||
{
|
||||
pp=HEADERLEN_SEND+nn;
|
||||
uctmp=(ui8OutputData[nn]); // bin
|
||||
sendBuffer[pp]= char(uctmp);
|
||||
}
|
||||
}
|
||||
|
||||
CrcLp= HEADERLEN_SEND + WrDataLength;
|
||||
mycrc=0;
|
||||
for (nn=0; nn<CrcLp; nn++)
|
||||
{
|
||||
uctmp=sendBuffer[nn];
|
||||
mycrc+=uint16_t(uctmp);
|
||||
//qDebug() << mycrc;
|
||||
}
|
||||
sendBuffer[CrcLp]=char(mycrc);
|
||||
mycrc>>=8;
|
||||
sendBuffer[CrcLp+1]=char(mycrc);
|
||||
sendLen=CrcLp+2;
|
||||
|
||||
// send to VCP:
|
||||
QByteArray packBuff;
|
||||
packBuff.clear();
|
||||
packBuff.append(sendBuffer, sendLen); // ohne sendLen wird beim ersten \0 abgeschnitten!!!
|
||||
mySerialPort->writeToSerial(packBuff, sendLen);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void T_prot::startPacking(void)
|
||||
{
|
||||
uint16_t mycrc;
|
||||
@@ -262,10 +404,8 @@ void T_prot::startPacking(void)
|
||||
packBuff.append(sendBuffer, sendLen); // ohne sendLen wird beim ersten \0 abgeschnitten!!!
|
||||
mySerialPort->writeToSerial(packBuff, sendLen);
|
||||
// void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength)
|
||||
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
// receiving.....
|
||||
@@ -293,7 +433,7 @@ uint8_t recBuffer[FRAME_MAXLEN];
|
||||
|
||||
// read from "VCP":
|
||||
mySerialPort->readFromSerial(Indata, recLength);
|
||||
|
||||
//qDebug()<<"prot: got data " << recLength;
|
||||
if (recLength>FRAME_MAXLEN)
|
||||
recLength=FRAME_MAXLEN;
|
||||
for (int nn=0; nn<recLength; nn++)
|
||||
@@ -301,10 +441,11 @@ uint8_t recBuffer[FRAME_MAXLEN];
|
||||
|
||||
myString.clear();
|
||||
tempStr.clear();
|
||||
uint8_t result=FramecheckInData(recBuffer, recLength); // check input data (response from slave)
|
||||
//uint8_t result=FramecheckInData(recBuffer, recLength); // check input data (response from slave)
|
||||
uint8_t result=FastCheckInData(recBuffer, recLength); // check input data (response from slave)
|
||||
if (result>0)
|
||||
{
|
||||
// dann anzeigen und ende
|
||||
// dann anzeige
|
||||
switch (result)
|
||||
{
|
||||
case 1: gpi_setTxt4masterStateLine("wrong length received"); break;
|
||||
@@ -316,6 +457,7 @@ uint8_t recBuffer[FRAME_MAXLEN];
|
||||
}
|
||||
myString.setNum(result);
|
||||
|
||||
// Daten abspeichern, könnten vom BL sein:
|
||||
gpi_storeRawReceivedData(uint8_t(recLength), recBuffer);
|
||||
emit rawDataRecieved();
|
||||
|
||||
@@ -328,16 +470,59 @@ uint8_t recBuffer[FRAME_MAXLEN];
|
||||
// konnte der Slave die geforderten Daten ausgeben (DOs, AOs)?
|
||||
// konnte der Slave die geforderten Daten einlesen (AIs, DIs)?
|
||||
|
||||
CheckInResult(recBuffer); // Ergebnisse des Slaves anzeigen
|
||||
//CheckInResult(recBuffer); // Ergebnisse des Slaves anzeigen
|
||||
// stimmt nicht mehr bei FastProt
|
||||
|
||||
CheckInData(recBuffer); // Eingangs-Daten des Slaves anzeigen
|
||||
ShowFastInData(recBuffer); // Eingangs-Daten des Slaves anzeigen
|
||||
}
|
||||
emit framerecieved();
|
||||
//qDebug() << "framereceived emitted";
|
||||
}
|
||||
|
||||
|
||||
uint8_t T_prot::FastCheckInData(uint8_t *Inbuf, uint16_t LL)
|
||||
{
|
||||
|
||||
uint16_t rawInLen=LL, crcL_Addr, recCrc, myCrc, nn, datalen, nxt;
|
||||
|
||||
if (Inbuf[0]!=STARTSIGN_RECEIVE_FAST && Inbuf[0]!=STARTSIGN_RECEIVE_LONG)
|
||||
{
|
||||
//qDebug() << "prot: got wrong start sign: " << Inbuf[0];
|
||||
return 2; // wrong start sign
|
||||
}
|
||||
if ( (rawInLen<TELEGRAMLEN_RECEIVE_FAST && Inbuf[0]==STARTSIGN_RECEIVE_FAST) ||
|
||||
(rawInLen<TELEGRAMLEN_RECEIVE_LONG && Inbuf[0]==STARTSIGN_RECEIVE_LONG) )
|
||||
{
|
||||
//qDebug("prot: got %d bytes only", rawInLen);
|
||||
return 1; // wrong length
|
||||
}
|
||||
if (Inbuf[0]==0x5F)
|
||||
datalen=DATALEN_RECEIVE_FAST;
|
||||
else
|
||||
datalen=DATALEN_RECEIVE_LONG;
|
||||
|
||||
crcL_Addr=datalen+HEADERLEN_RECEIVE; // weil im definierten protocol 2 bytes vor den Daten stehen
|
||||
recCrc=0;
|
||||
recCrc=uchar2uint(uint8_t(Inbuf[crcL_Addr+1]), uint8_t(Inbuf[crcL_Addr]));
|
||||
myCrc=0;
|
||||
for (nn=0; nn<crcL_Addr; nn++)
|
||||
{
|
||||
nxt=uint16_t (Inbuf[nn]);
|
||||
nxt &=0x00FF; // the casting makes 0xFFFF out of 0xFF !!!!!!!!!
|
||||
myCrc+=nxt;
|
||||
//qDebug("CRC: nxt: %d sum: %d", nxt, myCrc);
|
||||
}
|
||||
|
||||
if (myCrc != recCrc)
|
||||
{
|
||||
//qDebug() << "crc does not match: mycrc=" << myCrc<< " receivedCRC=" << recCrc;
|
||||
//qDebug("calculated over %d bytes", crcL_Addr);
|
||||
return 5; // crc wrong
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
uint8_t T_prot::FramecheckInData(uint8_t *Inbuf, uint16_t LL)
|
||||
{
|
||||
|
||||
@@ -385,7 +570,7 @@ uint8_t T_prot::FramecheckInData(uint8_t *Inbuf, uint16_t LL)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
uint8_t T_prot::CheckInResult(uint8_t *Inbuf)
|
||||
{
|
||||
@@ -438,24 +623,27 @@ uint8_t T_prot::CheckInResult(uint8_t *Inbuf)
|
||||
|
||||
|
||||
|
||||
uint8_t T_prot::CheckInData(uint8_t *recBuffer)
|
||||
uint8_t T_prot::ShowFastInData(uint8_t *recBuffer)
|
||||
{
|
||||
QString myString=nullptr, tempStr=nullptr;
|
||||
uint8_t result;
|
||||
|
||||
RecSlaveAddr=recBuffer[1];
|
||||
if (recBuffer[2]==0 && recBuffer[4]==0) // comand result=OK und read result =OK,
|
||||
// dann sind die Eingangsdaten gültig
|
||||
RecSlaveAddr=0;
|
||||
result=recBuffer[1]; // total result
|
||||
result &=0x60; // only read result (bit 5,6)
|
||||
|
||||
if (result==0) // read result =OK,
|
||||
// dann sind die Eingangsdaten gültig
|
||||
{
|
||||
myString.append("valid INdata: ");
|
||||
INdataValid=true;
|
||||
readSource=uchar2uint(recBuffer[6],recBuffer[5]);
|
||||
readAddress=uchar2uint(recBuffer[8],recBuffer[7]);
|
||||
//lastWakeSrc=uint8_t(recBuffer[4]);
|
||||
RdDataLength=uint8_t(recBuffer[9]);
|
||||
//readSource already set with sending
|
||||
readAddress=0;
|
||||
// RdDataLength already set with sending
|
||||
if (RdDataLength>FRAME_DATALEN)
|
||||
RdDataLength=FRAME_DATALEN;
|
||||
for (int ii=0; ii<RdDataLength; ii++)
|
||||
InputData[ii]=uint8_t(recBuffer[ii+10]);
|
||||
InputData[ii]=uint8_t(recBuffer[ii+HEADERLEN_RECEIVE]);
|
||||
|
||||
tempStr.setNum(readSource,16);
|
||||
myString.append(tempStr);
|
||||
@@ -486,6 +674,57 @@ uint8_t T_prot::CheckInData(uint8_t *recBuffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
uint8_t T_prot::ShowInData(uint8_t *recBuffer)
|
||||
{
|
||||
QString myString=nullptr, tempStr=nullptr;
|
||||
|
||||
RecSlaveAddr=recBuffer[1];
|
||||
if (recBuffer[2]==0 && recBuffer[4]==0) // comand result=OK und read result =OK,
|
||||
// dann sind die Eingangsdaten gültig
|
||||
{
|
||||
myString.append("valid INdata: ");
|
||||
INdataValid=true;
|
||||
readSource=uchar2uint(recBuffer[6],recBuffer[5]);
|
||||
readAddress=uchar2uint(recBuffer[8],recBuffer[7]);
|
||||
//lastWakeSrc=uint8_t(recBuffer[4]);
|
||||
RdDataLength=uint8_t(recBuffer[9]);
|
||||
if (RdDataLength>FRAME_DATALEN)
|
||||
RdDataLength=FRAME_DATALEN;
|
||||
for (int ii=0; ii<RdDataLength; ii++)
|
||||
InputData[ii]=uint8_t(recBuffer[ii+10]);
|
||||
|
||||
tempStr.setNum(readSource,16);
|
||||
myString.append(tempStr);
|
||||
myString.append(" add:");
|
||||
|
||||
tempStr.setNum(readAddress);
|
||||
myString.append(tempStr);
|
||||
//myString.append(" wakeSrc:");
|
||||
//tempStr.setNum(lastWakeSrc);
|
||||
//myString.append(tempStr);
|
||||
myString.append(" Dlen:");
|
||||
tempStr.setNum(RdDataLength);
|
||||
myString.append(tempStr);
|
||||
|
||||
} else
|
||||
{
|
||||
myString=" "; // Eingangsdaten nicht gültig, sieht man aber weiter oben schon
|
||||
|
||||
}
|
||||
|
||||
gpi_setTxt4dataStateLine(myString);
|
||||
//qDebug() << myString;
|
||||
//qDebug("prot_checkInData_bindata: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ",
|
||||
// InputData[0], InputData[1], InputData[2], InputData[3],
|
||||
// InputData[4], InputData[5], InputData[6], InputData[7],
|
||||
// InputData[8], InputData[9], InputData[10], InputData[11],
|
||||
// InputData[12], InputData[13], InputData[14], InputData[15]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
bool T_prot::ifDataReceived()
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@ void sendWRcmd_INI(void)
|
||||
|
||||
sendWRcmd_clrCmdStack();
|
||||
sendWRcmd_clrCmd4Stack();
|
||||
sendFDcmd_clrStack();
|
||||
|
||||
}
|
||||
|
||||
@@ -53,23 +54,29 @@ bool sendWRcmd_setSendCommand0(uint16_t nextCmd)
|
||||
return false; // not possible
|
||||
}
|
||||
nextAsynchsendCmd0[nrOfCmdsInQueue++]=nextCmd;
|
||||
qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue;
|
||||
//qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue;
|
||||
return true; // ok, will be sent
|
||||
}
|
||||
|
||||
uint16_t sendWRcmd_getSendCommand0(void)
|
||||
{
|
||||
uint16_t nxtAsynchCmd;
|
||||
uint8_t nn;
|
||||
uint8_t nn, ll;
|
||||
if (nrOfCmdsInQueue==0 || nrOfCmdsInQueue>CMDSTACKDEPTH)
|
||||
return 0; // error
|
||||
nxtAsynchCmd=nextAsynchsendCmd0[0];
|
||||
|
||||
// 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];
|
||||
|
||||
if (nrOfCmdsInQueue>0)
|
||||
nrOfCmdsInQueue--;
|
||||
qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
|
||||
//qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
|
||||
return nxtAsynchCmd;
|
||||
}
|
||||
|
||||
@@ -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 nxtAsynchCmd;
|
||||
uint8_t nn;
|
||||
uint8_t nn, ll;
|
||||
|
||||
if (nrOfCmds4InQueue==0 || nrOfCmds4InQueue>CMD4STACKDEPTH)
|
||||
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];
|
||||
|
||||
// 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];
|
||||
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 nxtAsynchCmd;
|
||||
uint8_t nn;
|
||||
uint8_t nn, ll;
|
||||
|
||||
if (nrOfCmds8InQueue==0 || nrOfCmds8InQueue>CMD4STACKDEPTH)
|
||||
if (nrOfCmds8InQueue==0 || nrOfCmds8InQueue>CMD8STACKDEPTH)
|
||||
return 0; // error
|
||||
nxtAsynchCmd=nextAsynchsendCmd8[0];
|
||||
*dat1=nextCmd8para1[0];
|
||||
@@ -222,7 +233,11 @@ uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3,
|
||||
*dat4=nextCmd8para4[0];
|
||||
|
||||
// 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];
|
||||
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 "storeINdata.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
|
||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||
|
||||
|
||||
|
||||
|
||||
// store power on/off condition of the devices to control the data request
|
||||
|
||||
static bool indat_savePrnPwr;
|
||||
@@ -15,6 +19,9 @@ static bool indat_savePrnPwr;
|
||||
void indat_storePrinterPower(bool isOn)
|
||||
{
|
||||
indat_savePrnPwr=isOn;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool indat_isPrinterOn()
|
||||
@@ -49,63 +56,14 @@ 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[3];
|
||||
static QString genStrings[MAXNROF_GENSTR];
|
||||
// 0=HW 1=SW 2=State
|
||||
|
||||
void gpi_storeGenerals(uint8_t genNr, QString text)
|
||||
{
|
||||
// 0=HW 1=SW 2=State
|
||||
if (genNr<3)
|
||||
if (genNr<MAXNROF_GENSTR)
|
||||
{
|
||||
genStrings[genNr]=text;
|
||||
//qDebug() << "store gen's: " << genNr << " " <<text;
|
||||
@@ -116,7 +74,13 @@ void gpi_storeGenerals(uint8_t genNr, QString text)
|
||||
QString epi_loadGenerals(uint8_t genNr)
|
||||
{
|
||||
if (genNr<MAXNROF_GENSTR)
|
||||
{
|
||||
if (genNr==2) // DC2 State is shorter (8byte, not 64)
|
||||
//genStrings[2][8]=0;
|
||||
genStrings[2].chop(8);
|
||||
|
||||
return genStrings[genNr];
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
|
||||
@@ -125,26 +89,69 @@ QString epi_loadGenerals(uint8_t genNr)
|
||||
|
||||
// -------------------------------
|
||||
|
||||
/*
|
||||
static uint64_t Sdata_slaveUID;
|
||||
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)
|
||||
{
|
||||
uint64_t udltmp=0;
|
||||
QString myStr;
|
||||
|
||||
//qDebug()<< "store UID ";
|
||||
|
||||
for (int ii=0; ii<8; ii++)
|
||||
{
|
||||
//qDebug()<< buf8byteUid[ii] << " ";
|
||||
|
||||
Sdata_UIDstr[ii]=buf8byteUid[ii];
|
||||
udltmp|=buf8byteUid[ii];
|
||||
udltmp<<=8;
|
||||
}
|
||||
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)
|
||||
{
|
||||
//qDebug()<< "get UID ";
|
||||
for (int ii=0; ii<8; ii++)
|
||||
{
|
||||
//qDebug()<<Sdata_UIDstr[ii] << " ";
|
||||
buf8byteUid[ii]=Sdata_UIDstr[ii];
|
||||
}
|
||||
}
|
||||
@@ -156,17 +163,77 @@ QString epi_getUIDstr()
|
||||
|
||||
QString myStr;
|
||||
for (int ii=0;ii<8; ii++)
|
||||
{
|
||||
|
||||
myStr+=QString::number(Sdata_UIDstr[ii],16);
|
||||
return myStr;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -232,6 +299,7 @@ uint8_t epi_getSquareMode()
|
||||
|
||||
void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng)
|
||||
{
|
||||
/*
|
||||
// Daten kommen in gleicher Reihenfolge vom Slave
|
||||
uint8_t *pTime;
|
||||
pTime=&getGlobalTime.hour;
|
||||
@@ -239,7 +307,20 @@ void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng)
|
||||
for (int nn=0; nn<Leng; nn++)
|
||||
{
|
||||
*pTime++=timeBuffer[nn];
|
||||
}
|
||||
}*/
|
||||
|
||||
// new, FastProt: 0=dayOfWeek 1=min 2=sec 3=hours 4=year 5=month 6=dayOfMonth
|
||||
getGlobalTime.second=Leng; // nur damit CompilerWarnung weg ist
|
||||
|
||||
getGlobalTime.DayOfWeek=timeBuffer[0];
|
||||
getGlobalTime.minute=timeBuffer[1];
|
||||
getGlobalTime.second=timeBuffer[2];
|
||||
getGlobalTime.hour=timeBuffer[3];
|
||||
getGlobalTime.Year=timeBuffer[4];
|
||||
getGlobalTime.Month=timeBuffer[5];
|
||||
getGlobalTime.DayOfMonth=timeBuffer[6];
|
||||
|
||||
|
||||
}
|
||||
|
||||
void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss)
|
||||
@@ -604,6 +685,9 @@ void gpi_storeDI_doorSwitches(uint8_t upperDoor, uint8_t lowerDoor, uint8_t vaul
|
||||
if (lowerDoor) di_doorSwitch |=2;
|
||||
if (vaultDoor) di_doorSwitch |=4;
|
||||
|
||||
// qDebug()<<"storeINdata: "<<upperDoor << lowerDoor << vaultDoor;
|
||||
// qDebug()<<"storeINdata: "<<di_doorSwitch;
|
||||
|
||||
}
|
||||
|
||||
uint8_t epi_getDI_doorSwitches(void)
|
||||
@@ -897,14 +981,15 @@ bool epi_getDI_rejectMotor_homepos(void)
|
||||
return di_rejMot_home;
|
||||
}
|
||||
|
||||
static bool di_npe_sensor;
|
||||
static uint8_t di_npe_sensor;
|
||||
|
||||
void gpi_storeDI_paperLow(bool di)
|
||||
void gpi_storeDI_paperLow(uint8_t di)
|
||||
{
|
||||
// 0: Sensor sees paper 1: no paper 99: off
|
||||
di_npe_sensor=di;
|
||||
}
|
||||
|
||||
bool epi_getDI_npe_sensor(void)
|
||||
uint8_t epi_getDI_npe_sensor(void)
|
||||
{
|
||||
return di_npe_sensor;
|
||||
}
|
||||
@@ -966,8 +1051,8 @@ uint8_t epi_getDO_motorOuts(void)
|
||||
|
||||
|
||||
|
||||
static uint8_t do_serialSwitch; // serial drv on/off, Serial mux1, Serial mux2
|
||||
void gpi_storeDO_serialSwitch(uint8_t state)// serial drv on/off, Serial mux1, Serial mux2
|
||||
static uint8_t do_serialSwitch; // serial drv on/off, Serial mux1, Serial mux2
|
||||
void gpi_storeDO_serialSwitch(uint8_t state) // serial drv on/off, Serial mux1, Serial mux2
|
||||
{
|
||||
do_serialSwitch=state;
|
||||
}
|
||||
@@ -1026,6 +1111,7 @@ bool epi_getDO_serialMux2isSetToMifare(void)
|
||||
static uint8_t do_ledsAndFan;
|
||||
void gpi_storeDO_ledsAndFan(uint8_t ledState)
|
||||
{
|
||||
// bit0: coinled 1:front_illu 2: paper-led 3:pinpad-led 4:start-led 5:service-led 6:fan
|
||||
do_ledsAndFan=ledState;
|
||||
}
|
||||
|
||||
@@ -1083,6 +1169,7 @@ bool epi_getDO_fan(void)
|
||||
static uint8_t do_laermUndRelay;
|
||||
void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay)
|
||||
{
|
||||
// bit0: siren 1:relay
|
||||
do_laermUndRelay=sirenRelay;
|
||||
}
|
||||
|
||||
@@ -1190,11 +1277,31 @@ uint8_t gpi_storeMifReaderStateAndCardType(uint8_t *buf)
|
||||
{
|
||||
// retval 0=OK 1=error host buffer too small
|
||||
for (uint8_t nn=0; nn<NROFMIFSTATEBYTES; nn++)
|
||||
Sdata_MIF_STATE[nn]=0;
|
||||
for (uint8_t nn=0; nn<8; nn++)
|
||||
Sdata_MIF_STATE[nn]=buf[nn];
|
||||
return 0; // OK
|
||||
}
|
||||
|
||||
/* data description:
|
||||
|
||||
new fast version:
|
||||
byte 0= still the same: current read state:
|
||||
0=power off 1=reader-fault 2=ready
|
||||
3=just reading 4=read complete
|
||||
5=read partial, removed too early
|
||||
6=state unknown
|
||||
|
||||
byte 1: reader state 1=ok 0=nok
|
||||
byte 2: card preent (0,1)
|
||||
byte 3: card selected (0)
|
||||
byte 4: card type: 0...5
|
||||
byte 5: card allowed (0=no 1=MifareClassic 1k or 4k)
|
||||
byte 6: CardSize: 1 or 4 (kB)
|
||||
byte 7: length of UID 4 or 7 (byte)
|
||||
|
||||
|
||||
old long version
|
||||
byte 0: current read state: 0=power off 1=reader-fault 2=ready
|
||||
3=just reading 4=read complete
|
||||
5=read partial, removed too early
|
||||
@@ -1217,10 +1324,10 @@ byte 32: result, always 0
|
||||
uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize)
|
||||
{
|
||||
// HWapi can read States from DC
|
||||
if (maxBufferSize<NROFMIFSTATEBYTES)
|
||||
if (maxBufferSize<8)
|
||||
return 1; // error
|
||||
|
||||
for (uint8_t nn=0; nn<NROFMIFSTATEBYTES; nn++)
|
||||
for (uint8_t nn=0; nn<8; nn++)
|
||||
buf[nn]=Sdata_MIF_STATE[nn];
|
||||
return 0; // OK
|
||||
|
||||
@@ -1251,6 +1358,27 @@ uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1425,15 +1553,15 @@ void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data)
|
||||
uint8_t LL=leng; // nr of coin records
|
||||
uint16_t vv, pp=0;
|
||||
|
||||
qDebug()<<"store emp data, len: "<<LL;
|
||||
//qDebug()<<"store emp data, len: "<<LL;
|
||||
|
||||
while (LL>0)
|
||||
//while (LL>0) // with FastProtocol only one coin
|
||||
{
|
||||
vv=uchar2uint(data[pp+4], data[pp+3]);
|
||||
sub_enterData(data[pp], data[pp+1], data[pp+2], vv );
|
||||
|
||||
qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1]
|
||||
<< " " <<data[pp+2] <<" " <<data[pp+3] <<" " <<data[pp+4] <<" ";
|
||||
//qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1]
|
||||
// << " " <<data[pp+2] <<" " <<data[pp+3] <<" " <<data[pp+4] <<" ";
|
||||
|
||||
pp+=5;
|
||||
LL--;
|
||||
@@ -1456,30 +1584,27 @@ void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, u
|
||||
*error=gotCoin[ctr_gotCoin].error;
|
||||
*value=gotCoin[ctr_gotCoin].value;
|
||||
}
|
||||
|
||||
/*
|
||||
qDebug()<<"read emp data, nr "<<ctr_gotCoin << "valid: " << *valid
|
||||
<< "signal: " << *signal
|
||||
<< "error: " << *error
|
||||
<< "value: " << *value;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t Sdata_NrOfDeviceSetting;
|
||||
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;
|
||||
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;
|
||||
@@ -1507,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)
|
||||
{
|
||||
QThread::msleep(uint32_t(MilliSec));
|
||||
@@ -344,6 +361,15 @@ uint16_t tslib_strlen(char *buf)
|
||||
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)
|
||||
{
|
||||
@@ -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