forked from GerhardHoffmann/DCLibraries
Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
e8438f341e
|
|||
3f3911e573
|
|||
9744db7838
|
|||
b960638e91
|
|||
d93b406040
|
|||
d5585cda3f
|
|||
2c09402bbb
|
|||
cd6b1fed00
|
|||
0ea9ac9af3
|
|||
94a95eceb5
|
|||
dd29fb0762
|
|||
c9e5834e29
|
|||
8fa6d40a0c
|
|||
3e7f71899c | |||
1cc14e9a4c | |||
5c9578ebef | |||
b024e34b82 | |||
8714071a30 | |||
87bc5b5c1e | |||
ff746a45bc | |||
d540f1b467 | |||
ca2d9e1b5a | |||
4c770349bf | |||
209132054f | |||
0f7ab3c71c | |||
2b2cd25276 | |||
08bb513c7b | |||
36a8f07069 | |||
900b0ef952 | |||
26a11e6c56 | |||
6321f9068f | |||
9daa5e17cb | |||
de61de85f1
|
|||
4e58fbe4e1
|
|||
647dc9fe4b
|
@@ -90,9 +90,7 @@ HEADERS += \
|
|||||||
$${PWD}/include/sendWRcmd.h \
|
$${PWD}/include/sendWRcmd.h \
|
||||||
$${PWD}/include/storeINdata.h \
|
$${PWD}/include/storeINdata.h \
|
||||||
$${PWD}/include/tslib.h \
|
$${PWD}/include/tslib.h \
|
||||||
$${PWD}/include/shared_mem_buffer.h \
|
$${PWD}/include/shared_mem_buffer.h
|
||||||
$${PWD}/include/reporting_thread.h \
|
|
||||||
$${PWD}/include/download_thread.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$${PWD}/src/datei.cpp \
|
$${PWD}/src/datei.cpp \
|
||||||
@@ -103,9 +101,7 @@ SOURCES += \
|
|||||||
$${PWD}/src/sendWRcmd.cpp \
|
$${PWD}/src/sendWRcmd.cpp \
|
||||||
$${PWD}/src/storeINdata.cpp \
|
$${PWD}/src/storeINdata.cpp \
|
||||||
$${PWD}/src/tslib.cpp \
|
$${PWD}/src/tslib.cpp \
|
||||||
$${PWD}/src/shared_mem_buffer.cpp \
|
$${PWD}/src/shared_mem_buffer.cpp
|
||||||
$${PWD}/src/reporting_thread.cpp \
|
|
||||||
$${PWD}/src/download_thread.cpp
|
|
||||||
|
|
||||||
|
|
||||||
# INTERFACE = DeviceController
|
# INTERFACE = DeviceController
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#include "CArun.h"
|
#include "CArun.h"
|
||||||
#include "datei.h"
|
#include "datei.h"
|
||||||
|
|
||||||
#include "CCWakelineAbstraction.h"
|
#include "DigitalOutputAbstraction.h"
|
||||||
|
|
||||||
|
|
||||||
CArun::CArun(QObject *parent)
|
CArun::CArun(QObject *parent)
|
||||||
@@ -20,7 +20,11 @@ CArun::CArun(QObject *parent)
|
|||||||
|
|
||||||
this->timerChainCtrl->start();
|
this->timerChainCtrl->start();
|
||||||
|
|
||||||
this->ccWakelineAbstraction = new CCWakelineAbstraction(this->HWaccess, this);
|
|
||||||
|
this->digitalOutputAbstraction = new DigitalOutputAbstraction(this->HWaccess, this);
|
||||||
|
this->digitalOutputAbstraction->addCCWake("/sys/class/leds/wakeupctrl_cc/brightness");
|
||||||
|
this->digitalOutputAbstraction->addCCPower("/run/powerctrl_cc");
|
||||||
|
this->digitalOutputAbstraction->addCCModem("/run/powerctrl_modem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ enum class SETUP_STEP {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CCWakelineAbstraction;
|
class DigitalOutputAbstraction;
|
||||||
|
|
||||||
class CArun : public QObject
|
class CArun : public QObject
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ private:
|
|||||||
|
|
||||||
void openSerialPort();
|
void openSerialPort();
|
||||||
|
|
||||||
CCWakelineAbstraction* ccWakelineAbstraction;
|
DigitalOutputAbstraction* digitalOutputAbstraction;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@@ -1,51 +0,0 @@
|
|||||||
#include <QFileSystemWatcher>
|
|
||||||
#include <QFile>
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "CCWakelineAbstraction.h"
|
|
||||||
#include "plugin.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* this is based on a solution from:
|
|
||||||
* https://embeddeduse.com/2018/09/18/monitoring-sys-files-qfilesystemwatcher/
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
CCWakelineAbstraction::CCWakelineAbstraction(hwinf *dc, QObject *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
, dc(dc)
|
|
||||||
{
|
|
||||||
auto ccWakeMonitor = new QFileSystemWatcher(this);
|
|
||||||
|
|
||||||
ccWakeMonitor->addPath("/sys/class/leds/wakeupctrl_cc/brightness");
|
|
||||||
connect(ccWakeMonitor, &QFileSystemWatcher::fileChanged,
|
|
||||||
this, &CCWakelineAbstraction::ccWakeChanged);
|
|
||||||
|
|
||||||
qCritical() << "... init CCWakelineAbstraction";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CCWakelineAbstraction::ccWakeChanged(const QString &path)
|
|
||||||
{
|
|
||||||
QFile ccWakeFile(path);
|
|
||||||
if (!ccWakeFile.open(QIODevice::ReadOnly)) {
|
|
||||||
qWarning() << "ERROR: Could not open ccWakeFile file.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto ccWake = ccWakeFile.readAll();
|
|
||||||
if (!ccWake.isEmpty()) {
|
|
||||||
int state = ccWake.at(0);
|
|
||||||
//qCritical() << "INFO: ccWake = " << state;
|
|
||||||
switch (state) {
|
|
||||||
case 0x30: // '1'
|
|
||||||
qCritical() << "INFO: ccWake -> sleep";
|
|
||||||
this->dc->credit_switchWake(true); // switch 'sleep'
|
|
||||||
break;
|
|
||||||
case 0x31: // '0'
|
|
||||||
qCritical() << "INFO: ccWake -> wake";
|
|
||||||
this->dc->credit_switchWake(false); // switch 'wake'
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,25 +0,0 @@
|
|||||||
#ifndef CCWAKELINEABSTRACTION_H
|
|
||||||
#define CCWAKELINEABSTRACTION_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class hwinf;
|
|
||||||
class QFileSystemWatcher;
|
|
||||||
|
|
||||||
|
|
||||||
class CCWakelineAbstraction : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
CCWakelineAbstraction(hwinf *dc, QObject *parent = nullptr);
|
|
||||||
|
|
||||||
private:
|
|
||||||
hwinf *dc;
|
|
||||||
QFileSystemWatcher *ccWakeMonitor;
|
|
||||||
|
|
||||||
void ccWakeChanged(const QString &path);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CCWAKELINEABSTRACTION_H
|
|
170
dCArun/DigitalOutputAbstraction.cpp
Normal file
170
dCArun/DigitalOutputAbstraction.cpp
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
#include <QFileSystemWatcher>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "DigitalOutputAbstraction.h"
|
||||||
|
#include "plugin.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this is based on a solution from:
|
||||||
|
* https://embeddeduse.com/2018/09/18/monitoring-sys-files-qfilesystemwatcher/
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
DigitalOutputAbstraction::DigitalOutputAbstraction(hwinf *dc, QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, dc(dc)
|
||||||
|
{
|
||||||
|
this->fileMonitor = new QFileSystemWatcher(this);
|
||||||
|
|
||||||
|
connect(this->fileMonitor, &QFileSystemWatcher::fileChanged,
|
||||||
|
this, &DigitalOutputAbstraction::fileChanged);
|
||||||
|
|
||||||
|
qCritical() << "... init DigitalOutputAbstraction";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool DigitalOutputAbstraction::addCCWake(const QString file)
|
||||||
|
{
|
||||||
|
// on PTU5: "/sys/class/leds/wakeupctrl_cc/brightness"
|
||||||
|
if (!QFileInfo::exists(file)) {
|
||||||
|
qCritical() << " ... create file: " << file;
|
||||||
|
QFile(file).open(QIODevice::ReadWrite | QIODevice::Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << " ... add file: " << file;
|
||||||
|
|
||||||
|
this->ccWakePath = file;
|
||||||
|
return this->fileMonitor->addPath(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DigitalOutputAbstraction::addCCPower(const QString file)
|
||||||
|
{
|
||||||
|
if (!QFileInfo::exists(file)) {
|
||||||
|
qCritical() << " ... create file: " << file;
|
||||||
|
QFile(file).open(QIODevice::ReadWrite | QIODevice::Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << " ... add file: " << file;
|
||||||
|
|
||||||
|
this->ccPowerPath = file;
|
||||||
|
return this->fileMonitor->addPath(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DigitalOutputAbstraction::addCCModem(const QString file)
|
||||||
|
{
|
||||||
|
if (!QFileInfo::exists(file)) {
|
||||||
|
qCritical() << " ... create file: " << file;
|
||||||
|
QFile(file).open(QIODevice::ReadWrite | QIODevice::Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << " ... add file: " << file;
|
||||||
|
|
||||||
|
this->modemPowerPath = file;
|
||||||
|
return this->fileMonitor->addPath(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DigitalOutputAbstraction::fileChanged(const QString &path)
|
||||||
|
{
|
||||||
|
if (path == this->ccPowerPath) this->private_ccPowerChanged();
|
||||||
|
if (path == this->ccWakePath) this->private_ccWakeChanged();
|
||||||
|
if (path == this->modemPowerPath) this->private_modemPowerChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DigitalOutputAbstraction::private_modemPowerChanged()
|
||||||
|
{
|
||||||
|
QFile modemPowerFile(this->modemPowerPath);
|
||||||
|
if (!modemPowerFile.open(QIODevice::ReadOnly)) {
|
||||||
|
qWarning() << "ERROR: Could not open modemPowerFile " << this->modemPowerPath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto modemPower = modemPowerFile.readAll();
|
||||||
|
if (!modemPower.isEmpty()) {
|
||||||
|
int state = modemPower.at(0);
|
||||||
|
// qCritical() << "INFO: modemPower = " << state;
|
||||||
|
switch (state) {
|
||||||
|
case 0x30: // '0'
|
||||||
|
qCritical() << "INFO: modemPower -> off";
|
||||||
|
this->dc->mod_switchWake(false);
|
||||||
|
this->dc->mod_switchPower(false);
|
||||||
|
break;
|
||||||
|
case 0x31: // '1'
|
||||||
|
qCritical() << "INFO: modemPower -> on";
|
||||||
|
this->dc->mod_switchWake(true);
|
||||||
|
this->dc->mod_switchPower(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DigitalOutputAbstraction::private_ccPowerChanged()
|
||||||
|
{
|
||||||
|
QFile ccPowerFile(this->ccPowerPath);
|
||||||
|
if (!ccPowerFile.open(QIODevice::ReadOnly)) {
|
||||||
|
qWarning() << "ERROR: Could not open ccPowerFile file.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto ccPower = ccPowerFile.readAll();
|
||||||
|
if (!ccPower.isEmpty()) {
|
||||||
|
int state = ccPower.at(0);
|
||||||
|
|
||||||
|
auto lambdaOn = [this]() -> void
|
||||||
|
{
|
||||||
|
this->dc->credit_switchPower(true);
|
||||||
|
this->dc->credit_switchWake(true);
|
||||||
|
};
|
||||||
|
auto lambdaOff = [this]() -> void
|
||||||
|
{
|
||||||
|
this->dc->credit_switchPower(false);
|
||||||
|
this->dc->credit_switchWake(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//qCritical() << "INFO: ccPower = " << state;
|
||||||
|
switch (state) {
|
||||||
|
case 0x30: // '0'
|
||||||
|
qCritical() << "INFO: ccPower -> off";
|
||||||
|
lambdaOff();
|
||||||
|
break;
|
||||||
|
case 0x31: // '1'
|
||||||
|
qCritical() << "INFO: ccPower -> on";
|
||||||
|
lambdaOn();
|
||||||
|
break;
|
||||||
|
case 0x32: // '2'
|
||||||
|
qCritical() << "INFO: ccPower -> on / off";
|
||||||
|
lambdaOff();
|
||||||
|
QTimer::singleShot(500, this, lambdaOn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DigitalOutputAbstraction::private_ccWakeChanged()
|
||||||
|
{
|
||||||
|
QFile ccWakeFile(this->ccWakePath);
|
||||||
|
if (!ccWakeFile.open(QIODevice::ReadOnly)) {
|
||||||
|
qWarning() << "ERROR: Could not open ccWakeFile " << this->ccWakePath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto ccWake = ccWakeFile.readAll();
|
||||||
|
if (!ccWake.isEmpty()) {
|
||||||
|
int state = ccWake.at(0);
|
||||||
|
//qCritical() << "INFO: ccWake = " << state;
|
||||||
|
switch (state) {
|
||||||
|
case 0x30: // '0'
|
||||||
|
qCritical() << "INFO: ccWake -> sleep";
|
||||||
|
this->dc->credit_switchWake(true); // switch 'sleep'
|
||||||
|
break;
|
||||||
|
case 0x31: // '1'
|
||||||
|
qCritical() << "INFO: ccWake -> wake";
|
||||||
|
this->dc->credit_switchWake(false); // switch 'wake'
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
dCArun/DigitalOutputAbstraction.h
Normal file
37
dCArun/DigitalOutputAbstraction.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef DIGITALOUTPUTABSTRACTION_H
|
||||||
|
#define DIGITALOUTPUTABSTRACTION_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class hwinf;
|
||||||
|
class QFileSystemWatcher;
|
||||||
|
|
||||||
|
|
||||||
|
class DigitalOutputAbstraction : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DigitalOutputAbstraction(hwinf *dc, QObject *parent = nullptr);
|
||||||
|
bool addCCWake(const QString file);
|
||||||
|
bool addCCPower(const QString file);
|
||||||
|
bool addCCModem(const QString file);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
hwinf *dc;
|
||||||
|
QFileSystemWatcher *fileMonitor;
|
||||||
|
|
||||||
|
QString modemPowerPath;
|
||||||
|
QString ccPowerPath;
|
||||||
|
QString ccWakePath;
|
||||||
|
|
||||||
|
void fileChanged(const QString &path);
|
||||||
|
|
||||||
|
void private_modemPowerChanged();
|
||||||
|
void private_ccPowerChanged();
|
||||||
|
void private_ccWakeChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIGITALOUTPUTABSTRACTION_H
|
@@ -40,14 +40,14 @@ DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
CArun.cpp \
|
CArun.cpp \
|
||||||
CCWakelineAbstraction.cpp \
|
DigitalOutputAbstraction.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
tslib.cpp \
|
tslib.cpp \
|
||||||
datei.cpp
|
datei.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
CArun.h \
|
CArun.h \
|
||||||
CCWakelineAbstraction.h \
|
DigitalOutputAbstraction.h \
|
||||||
guidefs.h \
|
guidefs.h \
|
||||||
tslib.h \
|
tslib.h \
|
||||||
versionHistory.txt \
|
versionHistory.txt \
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
//#include <QString>
|
//#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QSerialPort>
|
#include <QSerialPort>
|
||||||
|
#include <QVector>
|
||||||
#include "tslib.h"
|
#include "tslib.h"
|
||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
@@ -32,6 +33,8 @@ class T_com : public QObject //, public QPlainTextEdit
|
|||||||
// QSerialPort *CatSerial = nullptr;
|
// QSerialPort *CatSerial = nullptr;
|
||||||
QSerialPort *CatSerial;
|
QSerialPort *CatSerial;
|
||||||
|
|
||||||
|
uint32_t writeCount = 0;
|
||||||
|
|
||||||
//char oeffneSerialPort();
|
//char oeffneSerialPort();
|
||||||
char open_Serial_Port();
|
char open_Serial_Port();
|
||||||
void closeSerialPort();
|
void closeSerialPort();
|
||||||
@@ -61,6 +64,7 @@ public:
|
|||||||
bool readFromSerial(QByteArray &data, uint16_t &sendLength);
|
bool readFromSerial(QByteArray &data, uint16_t &sendLength);
|
||||||
// retval: true: data available
|
// retval: true: data available
|
||||||
|
|
||||||
|
void flushPort(void);
|
||||||
/*
|
/*
|
||||||
uint8_t getAllPortPins(void);
|
uint8_t getAllPortPins(void);
|
||||||
// rs232pins: all signals bitwise coded in one byte:
|
// rs232pins: all signals bitwise coded in one byte:
|
||||||
|
@@ -168,6 +168,9 @@ class T_datif : public QObject
|
|||||||
QTimer *datif_trigger;
|
QTimer *datif_trigger;
|
||||||
uint8_t selectedSlaveAddr;
|
uint8_t selectedSlaveAddr;
|
||||||
|
|
||||||
|
bool waitForTestResponse = false;
|
||||||
|
uint32_t readCount = 0;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
char datif_cycleSend();
|
char datif_cycleSend();
|
||||||
void StoredRecData();
|
void StoredRecData();
|
||||||
|
@@ -69,6 +69,8 @@ bool dcBL_sendOneBlockCpl(uint16_t blockNumber);
|
|||||||
|
|
||||||
int8_t dcBL_getBlockResult(void);
|
int8_t dcBL_getBlockResult(void);
|
||||||
|
|
||||||
|
void dcBL_cancelSending(void);
|
||||||
|
|
||||||
char dcBL_cycle(void);
|
char dcBL_cycle(void);
|
||||||
// to be called cyclic every 100ms
|
// to be called cyclic every 100ms
|
||||||
|
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
#ifndef DOWNLOAD_THREAD_H_INCLUDED
|
|
||||||
#define DOWNLOAD_THREAD_H_INCLUDED
|
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include <QString>
|
|
||||||
#include <QByteArray>
|
|
||||||
|
|
||||||
class hwinf;
|
|
||||||
class DownloadThread : public QThread {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
|
||||||
|
|
||||||
DownloadThread(hwinf *hw);
|
|
||||||
~DownloadThread();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// download thread does not have a running event queue, and therefore
|
|
||||||
// no slots. signals work the usual way.
|
|
||||||
void run() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
DownloadResult sendStatus(int ret) const;
|
|
||||||
DownloadResult sendNextAddress(int bNum) const;
|
|
||||||
DownloadResult sendNextDataBlock(QByteArray const &binary, int bNum) const;
|
|
||||||
bool startBootloader() const;
|
|
||||||
bool stopBootloader() const;
|
|
||||||
QByteArray loadBinaryDCFile(QString dcFileName) const;
|
|
||||||
bool resetDeviceController() const;
|
|
||||||
DownloadResult dcDownloadBinary(QByteArray const &b) const;
|
|
||||||
|
|
||||||
hwinf *m_hw;
|
|
||||||
QString m_fileToDownload;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DOWNLOAD_THREAD_H_INCLUDED
|
|
@@ -41,6 +41,8 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
|||||||
several new functions for "direct ticket print", without the dueway loading jsons to DC and cmd DC to print
|
several new functions for "direct ticket print", without the dueway loading jsons to DC and cmd DC to print
|
||||||
The same rules as before apply to the json, but it can have any arbitrary length
|
The same rules as before apply to the json, but it can have any arbitrary length
|
||||||
|
|
||||||
|
8.10.2024 extension in dc_autoRequest()
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -1352,16 +1354,6 @@ public:
|
|||||||
bool dcDownloadReportRunning() const override;
|
bool dcDownloadReportRunning() const override;
|
||||||
bool dcDownloadReportFinished() override;
|
bool dcDownloadReportFinished() override;
|
||||||
|
|
||||||
bool dcDownloadThreadStart() override;
|
|
||||||
bool dcDownloadThreadRunning() const override;
|
|
||||||
void dcDownloadThreadFinalize(DownloadThread *) override;
|
|
||||||
bool dcDownloadThreadFinished() const override;
|
|
||||||
bool dcDownloadReportThreadStart() override;
|
|
||||||
bool dcDownloadReportThreadRunning() const override;
|
|
||||||
void dcDownloadReportThreadFinalize() override;
|
|
||||||
void dcDownloadReportThreadQuit() override;
|
|
||||||
bool dcDownloadReportThreadFinished() const override;
|
|
||||||
|
|
||||||
QString dcDownloadFileName() const override;
|
QString dcDownloadFileName() const override;
|
||||||
bool dcDownloadSetRequested(bool) override;
|
bool dcDownloadSetRequested(bool) override;
|
||||||
bool dcDownloadSetRunning(bool) override;
|
bool dcDownloadSetRunning(bool) override;
|
||||||
|
@@ -122,6 +122,11 @@ public:
|
|||||||
uint8_t *RdDlen, uint8_t *receivedData);
|
uint8_t *RdDlen, uint8_t *receivedData);
|
||||||
// retval: data valid, only one time true
|
// retval: data valid, only one time true
|
||||||
|
|
||||||
|
void flushPort(void);
|
||||||
|
|
||||||
|
uint16_t getReadSource() { return readSource; } // readSource contains last command sent to device controller
|
||||||
|
T_com *getSerialPort() { return mySerialPort; } // utility function
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void framerecieved(); //bool gotINdata);
|
void framerecieved(); //bool gotINdata);
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
#ifndef REPORTING_THREAD_H_INCLUDED
|
|
||||||
#define REPORTING_THREAD_H_INCLUDED
|
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
class hwapi;
|
|
||||||
class ReportingThread : public QThread {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ReportingThread(hwapi *hw);
|
|
||||||
~ReportingThread();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// reporting thread does not have a running event queue, and therefore
|
|
||||||
// no slots. signals work the usual way.
|
|
||||||
void run() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
hwapi *m_hw;
|
|
||||||
QString m_fileToDownload;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // REPORTING_THREAD_H_INCLUDED
|
|
@@ -52,6 +52,7 @@ class T_runProc : public QObject
|
|||||||
private slots:
|
private slots:
|
||||||
void runProc_slotProcess(void);
|
void runProc_slotProcess(void);
|
||||||
bool bl_performComplStart(void);
|
bool bl_performComplStart(void);
|
||||||
|
bool bl_waitForRdyMsg(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_runProc();
|
T_runProc();
|
||||||
@@ -70,9 +71,11 @@ public:
|
|||||||
void bl_rebootDC(void);
|
void bl_rebootDC(void);
|
||||||
void bl_startBL(void);
|
void bl_startBL(void);
|
||||||
void bl_checkBL(void);
|
void bl_checkBL(void);
|
||||||
bool bl_isUp(void);
|
//uint8_t bl_isUp(void); neuere Sax-Version, bisher nicht verwendet
|
||||||
|
// return 1: BL is up 2: BL error 0: stopped
|
||||||
// new from 21.5.24 ..................................................................
|
bool bl_isUp(void);
|
||||||
|
|
||||||
|
void resetBLvari(void);
|
||||||
|
|
||||||
uint16_t sys_getCustomerNumber(void);
|
uint16_t sys_getCustomerNumber(void);
|
||||||
uint16_t sys_getMachineNumber(void);
|
uint16_t sys_getMachineNumber(void);
|
||||||
|
@@ -241,6 +241,8 @@ struct SharedMem
|
|||||||
bool Sdata_coinPaymentNow;
|
bool Sdata_coinPaymentNow;
|
||||||
bool Sdata_bootloadingNow;
|
bool Sdata_bootloadingNow;
|
||||||
|
|
||||||
|
bool Sdata_ptuInSleep;
|
||||||
|
bool Sdata_dcInSleep;
|
||||||
|
|
||||||
// ------------------ Data OUTPUT --------------------------------
|
// ------------------ Data OUTPUT --------------------------------
|
||||||
|
|
||||||
|
@@ -115,6 +115,10 @@ long tslib_atol( char *AscString);
|
|||||||
// AscString must be 0-terminated!
|
// AscString must be 0-terminated!
|
||||||
// a leading '-' is ignored, a'.' or a ',' stops calculation
|
// a leading '-' is ignored, a'.' or a ',' stops calculation
|
||||||
|
|
||||||
|
void swl_returnWeekdayStr(char dow, char language, char *buf);
|
||||||
|
// dow=1...7
|
||||||
|
// always returns 10byte
|
||||||
|
// languages: 1=german 2=english
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
54
src/com.cpp
54
src/com.cpp
@@ -1,5 +1,6 @@
|
|||||||
#include "com.h"
|
#include "com.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDateTime>
|
||||||
//#include "controlBus.h"
|
//#include "controlBus.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -20,13 +21,48 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength)
|
|||||||
{
|
{
|
||||||
sendBuffer=data;
|
sendBuffer=data;
|
||||||
sendLen=sendLength;
|
sendLen=sendLength;
|
||||||
if (CatSerial->isOpen())
|
|
||||||
{
|
|
||||||
//qDebug() << "sending..." << sendBuffer;
|
|
||||||
CatSerial->write(sendBuffer);
|
|
||||||
} else
|
|
||||||
qDebug() << "error sending, port is not open";
|
|
||||||
|
|
||||||
|
// logic: exactly one command is sent to DC. no other command can be sent
|
||||||
|
// until the respond has been read from the serial line.
|
||||||
|
|
||||||
|
if (CatSerial->isOpen()) {
|
||||||
|
if (CatSerial->error() != QSerialPort::NoError) {
|
||||||
|
qCritical() << __func__ << "" << __LINE__ << "ERROR on serial line" << CatSerial->errorString();
|
||||||
|
CatSerial->clearError();
|
||||||
|
qCritical() << __func__ << "" << __LINE__ << "cleared error on serial line";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CatSerial->atEnd()) {
|
||||||
|
qCritical() << QString("ERROR %1 bytes available on serial line before write").arg(CatSerial->bytesAvailable());
|
||||||
|
qCritical() << CatSerial->readAll().toHex(':');
|
||||||
|
CatSerial->clear();
|
||||||
|
qCritical() << __func__ << "" << __LINE__ << "read all data from serial line";
|
||||||
|
}
|
||||||
|
|
||||||
|
CatSerial->clear();
|
||||||
|
|
||||||
|
QByteArray buffer(data);
|
||||||
|
int bytesWritten = CatSerial->write(buffer);
|
||||||
|
if (bytesWritten == -1) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
|
<< QString("ERROR %1 for sending %2").arg(CatSerial->errorString()).arg(data.toHex(':').constData());
|
||||||
|
CatSerial->clearError();
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "cleared error on serial line. returning ...";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CatSerial->flush();
|
||||||
|
writeCount += 1;
|
||||||
|
|
||||||
|
// only for debugging
|
||||||
|
// if ((unsigned int)data.constData()[2] == 31) { // request dynamic data
|
||||||
|
// qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
// << "write cmd" << (unsigned int)data.constData()[2];
|
||||||
|
//}
|
||||||
|
} else {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
|
<< "ERROR sending" << data.toHex(':') << "port is not open";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,6 +118,7 @@ T_com::T_com(QObject *parent) : QObject(parent)
|
|||||||
ChkConnectTimer->setSingleShot(false);
|
ChkConnectTimer->setSingleShot(false);
|
||||||
ChkConnectTimer->start(100); // in ms
|
ChkConnectTimer->start(100); // in ms
|
||||||
com_want2read=0;
|
com_want2read=0;
|
||||||
|
writeCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -342,6 +379,11 @@ bool T_com::isPortOpen(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void T_com::flushPort(void)
|
||||||
|
{
|
||||||
|
if (CatSerial->isOpen())
|
||||||
|
CatSerial->clear();
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
|
@@ -496,6 +496,31 @@ uint8_t epi_getBatchResult()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 8.10.2024 new, control power up/down
|
||||||
|
/*
|
||||||
|
void gpi_storePowerState(bool ptu_sleep, bool ptu_wake, bool dc_sleep, bool dc_wake)
|
||||||
|
{
|
||||||
|
if (ptu_sleep)
|
||||||
|
SharedMem::write()->Sdata_ptuInSleep=true;
|
||||||
|
if (ptu_wake)
|
||||||
|
SharedMem::write()->Sdata_ptuInSleep=false;
|
||||||
|
if (dc_sleep)
|
||||||
|
SharedMem::write()->Sdata_dcInSleep=true;
|
||||||
|
if (dc_wake)
|
||||||
|
SharedMem::write()->Sdata_dcInSleep=false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool epi_getPowerState_ptu()
|
||||||
|
{
|
||||||
|
return SharedMem::read()->Sdata_ptuInSleep;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool epi_getPowerState_dc()
|
||||||
|
{
|
||||||
|
return SharedMem::read()->Sdata_dcInSleep;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
167
src/datIf.cpp
167
src/datIf.cpp
@@ -6,10 +6,12 @@ History:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
#include "datIf.h"
|
#include "datIf.h"
|
||||||
|
#include "hwapi.h"
|
||||||
#include "sendWRcmd.h"
|
#include "sendWRcmd.h"
|
||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDateTime>
|
||||||
#include <datei.h>
|
#include <datei.h>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
@@ -43,6 +45,8 @@ static uint8_t datif_repeatCtr;
|
|||||||
static uint8_t datif_kindOfCmd;
|
static uint8_t datif_kindOfCmd;
|
||||||
|
|
||||||
static uint8_t datif_pNextCmd, datif_sendSlowCmd;
|
static uint8_t datif_pNextCmd, datif_sendSlowCmd;
|
||||||
|
static char testSerial;
|
||||||
|
static bool autoRequestWasOnBeforePowerDown;
|
||||||
|
|
||||||
//#define DATIF_MAXTO_WAIT4RESP 80 //20 erhöht am 17.7 geht viel besser
|
//#define DATIF_MAXTO_WAIT4RESP 80 //20 erhöht am 17.7 geht viel besser
|
||||||
// höchster gemessener Wert (bei 20ms): 6
|
// höchster gemessener Wert (bei 20ms): 6
|
||||||
@@ -120,10 +124,11 @@ T_datif::T_datif(QObject *parent) : QObject(parent)
|
|||||||
datei_clearFile(FILENAME_SHAREDDATA);
|
datei_clearFile(FILENAME_SHAREDDATA);
|
||||||
datei_writeToFile(FILENAME_SHAREDDATA, myBA);
|
datei_writeToFile(FILENAME_SHAREDDATA, myBA);
|
||||||
*/
|
*/
|
||||||
doRepeat=true;
|
doRepeat=false;
|
||||||
datif_pNextCmd=0;
|
datif_pNextCmd=0;
|
||||||
datif_sendSlowCmd=0;
|
datif_sendSlowCmd=0;
|
||||||
|
testSerial=99;
|
||||||
|
autoRequestWasOnBeforePowerDown=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_datif::resetChain(void)
|
void T_datif::resetChain(void)
|
||||||
@@ -161,22 +166,23 @@ char T_datif::datif_cycleSend()
|
|||||||
|
|
||||||
// supervise if DC data are valid
|
// supervise if DC data are valid
|
||||||
datif_noResponseCtr++; // inc every 20ms
|
datif_noResponseCtr++; // inc every 20ms
|
||||||
if (datif_noResponseCtr>50) // no life sign from device controller (DC) for about a sec
|
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about a sec
|
||||||
{
|
{ // 10.7.2025: timeout increased 50-->250 (1s-->5s)
|
||||||
epi_resetDcDataValid(3); // DC data has not updated for >=5s -> no longer valid!
|
epi_resetDcDataValid(3); // DC data has not updated for >=5s -> no longer valid!
|
||||||
datif_nowNewDyns=0;
|
datif_nowNewDyns=0;
|
||||||
datif_nowNewStats=0;
|
datif_nowNewStats=0;
|
||||||
|
testSerial=0; // New, 11.10.20TS
|
||||||
|
datif_noResponseCtr=0; // New, 11.10.20TS
|
||||||
}
|
}
|
||||||
// 24.7.24 new, data are valid if dynamic machine conditions AND dyn machine states came in
|
// 24.7.24 new, data are valid if dynamic machine conditions AND dyn machine states came in
|
||||||
if (datif_nowNewDyns && datif_nowNewStats && !epi_areDcDataValid() )
|
if (datif_nowNewDyns && datif_nowNewStats && !epi_areDcDataValid() )
|
||||||
epi_setDcDataValid();
|
epi_setDcDataValid();
|
||||||
|
|
||||||
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
|
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
|
||||||
if (gpi_wantToResetSupervision())
|
//if (gpi_wantToResetSupervision())
|
||||||
{
|
//{
|
||||||
gpi_storeOverallResult(0xFF);
|
// gpi_storeOverallResult(0xFF);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -216,16 +222,7 @@ char T_datif::datif_cycleSend()
|
|||||||
gpi_storeLastResult(8);
|
gpi_storeLastResult(8);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Unsinn, wird nie durchlaufen
|
|
||||||
if (cycl_running>=(RESPONSEWAITTIME+6)) // 3.7.24: 101-->110
|
|
||||||
{
|
|
||||||
// Antwort ist gekommen, also nach kurzer Luecke naechstes (datif_cmdWasPerformed==1)
|
|
||||||
// oder nochmal gleiches (datif_cmdWasPerformed==2) Kommando senden
|
|
||||||
//qDebug()<< "datif got any response";
|
|
||||||
cycl_running=0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// hier stoppen, weil Antwort des letzten Cmds noch nicht da
|
// hier stoppen, weil Antwort des letzten Cmds noch nicht da
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -363,19 +360,53 @@ char T_datif::datif_cycleSend()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if no direct comands need to be sent then send input requests
|
// if no direct comands need to be sent then send input requests
|
||||||
|
|
||||||
|
// new, 8.10.2024, avoid wrong messages right after wake-up
|
||||||
|
if ( testSerial==1)
|
||||||
|
{
|
||||||
|
myDCIF->setUserWriteData(0, 0,0, data);
|
||||||
|
myDCIF->setUserReadData(CMD2DC_TestSerial);
|
||||||
|
myDCIF->sendUserData(selectedSlaveAddr);
|
||||||
|
// request fixed string from DC and thus wait until DC is ready
|
||||||
|
cycl_running=1; // 1: start transmission
|
||||||
|
datif_kindOfCmd=0;
|
||||||
|
datif_repeatCtr=0;
|
||||||
|
doRepeat=false;
|
||||||
|
} else
|
||||||
|
if ( testSerial==2)
|
||||||
|
{
|
||||||
|
if (autoRequestWasOnBeforePowerDown)
|
||||||
|
epi_startEmmision(true);
|
||||||
|
testSerial++;
|
||||||
|
} else
|
||||||
|
|
||||||
if (gpi_isEmmisionOn()) // auto send button is pressed
|
if (gpi_isEmmisionOn()) // auto send button is pressed
|
||||||
{
|
{
|
||||||
//qDebug() << "auto request is on";
|
//qDebug() << "auto request is on";
|
||||||
datif_kindOfCmd=0;
|
datif_kindOfCmd=0;
|
||||||
sendINrequestsAutomatic(); // request all cyclic data sequential
|
if (testSerial==0)
|
||||||
}
|
{
|
||||||
else
|
// start with test command after wakeup
|
||||||
|
testSerial=1;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
sendINrequestsAutomatic(); // request all cyclic data sequential
|
||||||
|
autoRequestWasOnBeforePowerDown=true;
|
||||||
|
}
|
||||||
|
} else
|
||||||
{
|
{
|
||||||
|
// new: after stopping auto-request flush com port ONE time, 6.11.24TS
|
||||||
|
// why? to get boot loader response correct at first request
|
||||||
|
// without flushing we got the response of last cyclic data request in buffer
|
||||||
|
if (autoRequestWasOnBeforePowerDown)
|
||||||
|
myDCIF->flushPort();
|
||||||
|
|
||||||
dif_scanStep=0; // always start from beginning
|
dif_scanStep=0; // always start from beginning
|
||||||
epi_resetDcDataValid(4);
|
epi_resetDcDataValid(4);
|
||||||
datif_nowNewDyns=0;
|
datif_nowNewDyns=0;
|
||||||
datif_nowNewStats=0;
|
datif_nowNewStats=0;
|
||||||
|
autoRequestWasOnBeforePowerDown=false;
|
||||||
|
testSerial=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
datif_cmdWasPerformed=0; // 0: no response by now
|
datif_cmdWasPerformed=0; // 0: no response by now
|
||||||
@@ -400,8 +431,11 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
uint8_t datif_maxNrCommands=35, datif_sendNow;
|
uint8_t datif_maxNrCommands=35, datif_sendNow;
|
||||||
|
|
||||||
// send quicker while transaction is ongoing:
|
// send quicker while transaction is ongoing:
|
||||||
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,31,32,40,41,42,23,0,0};
|
//uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,31,32,40,41,42,23,0,0};
|
||||||
uint8_t datif_maxVendingCmds=13;
|
//uint8_t datif_maxVendingCmds=13;
|
||||||
|
// 30 muss drin sein um coin attach zu erkennen:
|
||||||
|
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116, 30, 31,32,40,41,42,23,0};
|
||||||
|
uint8_t datif_maxVendingCmds=14;
|
||||||
|
|
||||||
// special commands:
|
// special commands:
|
||||||
// 102: get IOs run constantly!!!
|
// 102: get IOs run constantly!!!
|
||||||
@@ -480,6 +514,76 @@ void T_datif::StoredRecData()
|
|||||||
gpi_storeLastResult(res);
|
gpi_storeLastResult(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dump(T_moduleCondition const *modCond) {
|
||||||
|
qCritical() << QString("modCond->ram %1 (%2)").arg(modCond->ram).arg(modCond->ram, 0, 16);
|
||||||
|
qCritical() << QString("modCond->intEe %1 (%2)").arg(modCond->intEe).arg(modCond->intEe, 0, 16);
|
||||||
|
qCritical() << QString("modCond->extEe %1 (%2)").arg(modCond->extEe).arg(modCond->extEe, 0, 16);
|
||||||
|
qCritical() << QString("modCond->rtc %1 (%2)").arg(modCond->rtc).arg(modCond->rtc, 0, 16);
|
||||||
|
qCritical() << QString("modCond->boardHw %1 (%2)").arg(modCond->boardHw).arg(modCond->boardHw, 0, 16);
|
||||||
|
qCritical() << QString("modCond->printer %1 (%2)").arg(modCond->printer).arg(modCond->printer, 0, 16);
|
||||||
|
qCritical() << QString("modCond->modem %1 (%2)").arg(modCond->modem).arg(modCond->modem, 0, 16);
|
||||||
|
qCritical() << QString("modCond->signal %1 (%2)").arg(modCond->signal).arg(modCond->signal, 0, 16);
|
||||||
|
|
||||||
|
qCritical() << QString("modCond->regist %1 (%2)").arg(modCond->regist).arg(modCond->regist, 0, 16);
|
||||||
|
qCritical() << QString("modCond->mdbBus %1 (%2)").arg(modCond->mdbBus).arg(modCond->mdbBus, 0, 16);
|
||||||
|
qCritical() << QString("modCond->coinChecker %1 (%2)").arg(modCond->coinChecker).arg(modCond->coinChecker, 0, 16);
|
||||||
|
qCritical() << QString("modCond->coinEscrow %1 (%2)").arg(modCond->coinEscrow).arg(modCond->coinEscrow, 0, 16);
|
||||||
|
|
||||||
|
qCritical() << QString("modCond->mifareReader %1 (%2)").arg(modCond->mifareReader).arg(modCond->mifareReader, 0, 16);
|
||||||
|
qCritical() << QString("modCond->creditTerm %1 (%2)").arg(modCond->creditTerm).arg(modCond->creditTerm, 0, 16);
|
||||||
|
qCritical() << QString("modCond->coinReject %1 (%2)").arg(modCond->coinReject).arg(modCond->coinReject, 0, 16);
|
||||||
|
qCritical() << QString("modCond->coinSafe %1 (%2)").arg(modCond->coinSafe).arg(modCond->coinSafe, 0, 16);
|
||||||
|
|
||||||
|
qCritical() << QString("modCond->billSafe %1 (%2)").arg(modCond->billSafe).arg(modCond->billSafe, 0, 16);
|
||||||
|
qCritical() << QString("modCond->voltage %1 (%2)").arg(modCond->voltage).arg(modCond->voltage, 0, 16);
|
||||||
|
qCritical() << QString("modCond->temper %1 (%2)").arg(modCond->temper).arg(modCond->temper, 0, 16);
|
||||||
|
qCritical() << QString("modCond->poweronTest %1 (%2)").arg(modCond->poweronTest).arg(modCond->poweronTest, 0, 16);
|
||||||
|
|
||||||
|
qCritical() << QString("modCond->doorState %1 (%2)").arg(modCond->doorState).arg(modCond->doorState, 0, 16);
|
||||||
|
qCritical() << QString("modCond->doorWasOpened %1 (%2)").arg(modCond->doorWasOpened).arg(modCond->doorWasOpened, 0, 16);
|
||||||
|
qCritical() << QString("modCond->changer %1 (%2)").arg(modCond->changer).arg(modCond->changer, 0, 16);
|
||||||
|
qCritical() << QString("modCond->coinBlocker %1 (%2)").arg(modCond->coinBlocker).arg(modCond->coinBlocker, 0, 16);
|
||||||
|
|
||||||
|
qCritical() << QString("modCond->billReader %1 (%2)").arg(modCond->billReader).arg(modCond->billReader, 0, 16);
|
||||||
|
qCritical() << QString("modCond->ResetReason %1 (%2)").arg(modCond->ResetReason).arg(modCond->ResetReason, 0, 16);
|
||||||
|
qCritical() << QString("modCond->allModulesChecked %1 (%2)").arg(modCond->allModulesChecked).arg(modCond->allModulesChecked, 0, 16);
|
||||||
|
qCritical() << QString("modCond->alarmState %1 (%2)").arg(modCond->alarmState).arg(modCond->alarmState, 0, 16);
|
||||||
|
qCritical() << QString("modCond->fuses %1 (%2)").arg(modCond->fuses).arg(modCond->fuses, 0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dump(T_dynamicCondition const *dynCond) {
|
||||||
|
qCritical() << QString("dynCond->allDoorsDebounced %1 (%2)").arg((unsigned char)dynCond->allDoorsDebounced).arg((unsigned char)dynCond->allDoorsDebounced, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->openedAuthorized %1 (%2)").arg((unsigned char)dynCond->openedAuthorized).arg((unsigned char)dynCond->openedAuthorized, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->CBinDebounced %1 (%2)").arg((unsigned char)dynCond->CBinDebounced).arg((unsigned char)dynCond->CBinDebounced, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->upperDoor %1 (%2)").arg((unsigned char)dynCond->upperDoor).arg((unsigned char)dynCond->upperDoor, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->middleDoor %1 (%2)").arg((unsigned char)dynCond->middleDoor).arg((unsigned char)dynCond->middleDoor, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->lowerDoor %1 (%2)").arg((unsigned char)dynCond->lowerDoor).arg((unsigned char)dynCond->lowerDoor, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->middleDoor %1 (%2)").arg((unsigned char)dynCond->middleDoor).arg((unsigned char)dynCond->middleDoor, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->coinAttached %1 (%2)").arg((unsigned char)dynCond->coinAttached).arg((unsigned char)dynCond->coinAttached, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->billBox %1 (%2)").arg((unsigned char)dynCond->billBox).arg((unsigned char)dynCond->billBox, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->modeAbrech %1 (%2)").arg((unsigned char)dynCond->modeAbrech).arg((unsigned char)dynCond->modeAbrech, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->onAlarm %1 (%2)").arg((unsigned char)dynCond->onAlarm).arg((unsigned char)dynCond->onAlarm, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->nowCardTest %1 (%2)").arg((unsigned char)dynCond->nowCardTest).arg((unsigned char)dynCond->nowCardTest, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->nowPayment %1 (%2)").arg((unsigned char)dynCond->nowPayment).arg((unsigned char)dynCond->nowPayment, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->lastMifCardType %1 (%2)").arg((unsigned char)dynCond->lastMifCardType).arg((unsigned char)dynCond->lastMifCardType, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->lastSDoorState %1 (%2)").arg(dynCond->lastSDoorState).arg(dynCond->lastSDoorState, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->lastVDoorState %1 (%2)").arg(dynCond->lastVDoorState).arg(dynCond->lastVDoorState, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->lastCBstate %1 (%2)").arg(dynCond->lastCBstate).arg(dynCond->lastCBstate, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->paymentInProgress %1 (%2)").arg((unsigned char)dynCond->paymentInProgress).arg((unsigned char)dynCond->paymentInProgress, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->U_Batt %1 (%2)").arg(dynCond->U_Batt).arg(dynCond->U_Batt, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->nrCoinsInBox %1 (%2)").arg(dynCond->nrCoinsInBox).arg(dynCond->nrCoinsInBox, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->amountInBox %1 (%2)").arg(dynCond->amountInBox).arg(dynCond->amountInBox, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->totalTransVolume %1 (%2)").arg(dynCond->totalTransVolume).arg(dynCond->totalTransVolume, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->totalNrOfVends %1 (%2)").arg(dynCond->totalNrOfVends).arg(dynCond->totalNrOfVends, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->resultOfLastTemplPrint %1 (%2)").arg((unsigned char)dynCond->resultOfLastTemplPrint).arg((unsigned char)dynCond->resultOfLastTemplPrint, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->lastPrinterStatus %1 (%2)").arg(dynCond->lastPrinterStatus).arg(dynCond->lastPrinterStatus, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->startupTestIsRunning %1 (%2)").arg(dynCond->startupTestIsRunning).arg(dynCond->startupTestIsRunning, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->totalNrOfCuts %1 (%2)").arg(dynCond->totalNrOfCuts).arg(dynCond->totalNrOfCuts, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->nextAccountNumber %1 (%2)").arg(dynCond->nextAccountNumber).arg(dynCond->nextAccountNumber, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->nrOfBillsInBox %1 (%2)").arg(dynCond->nrOfBillsInBox).arg(dynCond->nrOfBillsInBox, 0, 16);
|
||||||
|
qCritical() << QString("dynCond->UbatAtLastPrint %1 (%2)").arg(dynCond->UbatAtLastPrint).arg(dynCond->UbatAtLastPrint, 0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
char T_datif::loadRecDataFromFrame()
|
char T_datif::loadRecDataFromFrame()
|
||||||
{
|
{
|
||||||
// is called even with wrong received data in order to speed up the process (stop waiting for response)
|
// is called even with wrong received data in order to speed up the process (stop waiting for response)
|
||||||
@@ -513,6 +617,8 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(receivedData, 0x00, sizeof(receivedData));
|
||||||
|
|
||||||
ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData);
|
ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData);
|
||||||
// nur true wenn CommandState OK und readState OK
|
// nur true wenn CommandState OK und readState OK
|
||||||
|
|
||||||
@@ -545,6 +651,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
|
|
||||||
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
|
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
|
||||||
|
|
||||||
|
//sub_gerhardsDiagnose();
|
||||||
// uint8_t nn;
|
// uint8_t nn;
|
||||||
//qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress
|
//qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress
|
||||||
// << " rdlen:" << RdDleng;
|
// << " rdlen:" << RdDleng;
|
||||||
@@ -587,8 +694,11 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
ret=verifyLineTestresponse(RdDleng, receivedData);
|
ret=verifyLineTestresponse(RdDleng, receivedData);
|
||||||
gpi_storeResult_serialTestOK(ret);
|
gpi_storeResult_serialTestOK(ret);
|
||||||
if (ret==true)
|
if (ret==true)
|
||||||
|
{
|
||||||
gpi_setTxt4datifLine("correct");
|
gpi_setTxt4datifLine("correct");
|
||||||
else
|
if ( testSerial==1) testSerial=2; // nach wake kam richtige Antwort
|
||||||
|
|
||||||
|
} else
|
||||||
gpi_setTxt4datifLine("false");
|
gpi_setTxt4datifLine("false");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1017,7 +1127,10 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
uitmp=0;
|
uitmp=0;
|
||||||
uit2=0;
|
uit2=0;
|
||||||
}
|
}
|
||||||
if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )
|
//if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )
|
||||||
|
if ((newInsertedAmount != lastInsertedAmount) || uit2==3
|
||||||
|
|| uit2==5 || uit2==10 || uit2==25 || uit2==40
|
||||||
|
|| uit2==50 || uit2==100 || uit2==200 || uit2==500 )
|
||||||
{
|
{
|
||||||
gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
|
gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
|
||||||
emit datif_gotNewCoin(); // OR BILL if (uitmp & 0x8000)>0
|
emit datif_gotNewCoin(); // OR BILL if (uitmp & 0x8000)>0
|
||||||
|
132
src/dcBL.cpp
132
src/dcBL.cpp
@@ -242,11 +242,7 @@ uint8_t dcBL_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData)
|
|||||||
myBuf[2]=ulongTOuchar(startAddr, GETMIDLOWBYTE);
|
myBuf[2]=ulongTOuchar(startAddr, GETMIDLOWBYTE);
|
||||||
myBuf[3]=ulongTOuchar(startAddr, GETLOWBYTE);
|
myBuf[3]=ulongTOuchar(startAddr, GETLOWBYTE);
|
||||||
myBuf[4]=0;
|
myBuf[4]=0;
|
||||||
|
//qDebug()<<"dcBL_sendFlashStartAddr2BL "<<myBuf[0]<<" "<<myBuf[1]<<" "<<myBuf[2]<<" "<<myBuf[3];
|
||||||
|
|
||||||
qDebug()<<"dcBL_sendFlashStartAddr2BL "<<myBuf[0]<<" "<<myBuf[1]<<" "<<myBuf[2]<<" "<<myBuf[3];
|
|
||||||
|
|
||||||
|
|
||||||
return dcBL_prepareDC_BLcmd(0x21, 4, myBuf, sendData);
|
return dcBL_prepareDC_BLcmd(0x21, 4, myBuf, sendData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,9 +254,9 @@ uint8_t dcBL_writeLastPage(uint8_t *sendData)
|
|||||||
strclr(myBuf, 0, 2);
|
strclr(myBuf, 0, 2);
|
||||||
ret=dcBL_prepareDC_BLcmd(0x22, 0, myBuf, sendData);
|
ret=dcBL_prepareDC_BLcmd(0x22, 0, myBuf, sendData);
|
||||||
|
|
||||||
qDebug()<<"dcBL just sending last block command, ret: "<<ret<<" "<<sendData[0]
|
//qDebug()<<"dcBL just sending last block command, ret: "<<ret<<" "<<sendData[0]
|
||||||
<<" "<<sendData[1]<<" "<<sendData[2]<<" "<<sendData[3]<<" "<<sendData[4]
|
// <<" "<<sendData[1]<<" "<<sendData[2]<<" "<<sendData[3]<<" "<<sendData[4]
|
||||||
<<" "<<sendData[5]<<" "<<sendData[6]<<" "<<sendData[7];
|
// <<" "<<sendData[5]<<" "<<sendData[6]<<" "<<sendData[7];
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -332,7 +328,12 @@ uint8_t dcBL_getResponse(uint8_t *respBuff)
|
|||||||
//dcBL_writeText("dcBL gotResponse");
|
//dcBL_writeText("dcBL gotResponse");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (recLen>=150)
|
||||||
|
{
|
||||||
|
dcBL_writeText("dcBL rec.buff. overflow");
|
||||||
|
epi_clrRawReceivedString();
|
||||||
|
recLen=0;
|
||||||
|
}
|
||||||
return recLen;
|
return recLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,8 +403,8 @@ uint8_t dcBL_sendSuccess(uint8_t lastCommand)
|
|||||||
if (recLen==0)
|
if (recLen==0)
|
||||||
return 0; // no response by now
|
return 0; // no response by now
|
||||||
|
|
||||||
// qDebug()<<"dcBL_sendSuccess: got BL data"<< recLen <<
|
qDebug()<<"dcBL_sendSuccess: got BL data"<< recLen <<
|
||||||
// Indata[0]<< Indata[1]<< Indata[2]<< Indata[3] << Indata[4]<< Indata[5]<< Indata[6]<< Indata[7];
|
Indata[0]<< Indata[1]<< Indata[2]<< Indata[3] << Indata[4]<< Indata[5]<< Indata[6]<< Indata[7];
|
||||||
|
|
||||||
if (Indata[0]==2 && Indata[1]==(lastCommand | 0x80) )
|
if (Indata[0]==2 && Indata[1]==(lastCommand | 0x80) )
|
||||||
return 10; // OK
|
return 10; // OK
|
||||||
@@ -663,8 +664,8 @@ void dcBL_sendAddress(uint16_t blockNumber)
|
|||||||
dcBL_BlkCtr*=64;
|
dcBL_BlkCtr*=64;
|
||||||
len=dcBL_sendFlashStartAddr2BL(dcBL_BlkCtr, buf); // make command string
|
len=dcBL_sendFlashStartAddr2BL(dcBL_BlkCtr, buf); // make command string
|
||||||
|
|
||||||
//qDebug()<<"dcBL_bl_sendAddress "<<buf[0]<<" "<<buf[1]<<" "<<buf[2]<<" "<<buf[3]<<" "
|
qDebug()<<"dcBL_bl_sendAddress "<<buf[0]<<" "<<buf[1]<<" "<<buf[2]<<" "<<buf[3]<<" "
|
||||||
// <<buf[4]<<" "<<buf[5]<<" "<<buf[6]<<" ";
|
<<buf[4]<<" "<<buf[5]<<" "<<buf[6]<<" ";
|
||||||
|
|
||||||
sendWRcmd_setSendBlock160(len, buf); // send command to BL
|
sendWRcmd_setSendBlock160(len, buf); // send command to BL
|
||||||
}
|
}
|
||||||
@@ -695,7 +696,7 @@ uint8_t dcBL_getFileBlock(uint16_t blockPointer, uint8_t *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t block2beSentNow, blTimeOutCounter;
|
static uint16_t block2beSentNow, blTimeOutCounter;
|
||||||
static uint8_t blChainStep, blChainResult, blRepeatCounter;
|
static uint8_t blChainStep, blChainResult, blRepeatCounter, blRepeatOnErrorCtr;
|
||||||
|
|
||||||
bool dcBL_sendOneBlockCpl(uint16_t blockNumber)
|
bool dcBL_sendOneBlockCpl(uint16_t blockNumber)
|
||||||
{
|
{
|
||||||
@@ -712,6 +713,7 @@ bool dcBL_sendOneBlockCpl(uint16_t blockNumber)
|
|||||||
blChainResult=0;
|
blChainResult=0;
|
||||||
blTimeOutCounter=0;
|
blTimeOutCounter=0;
|
||||||
blRepeatCounter=0;
|
blRepeatCounter=0;
|
||||||
|
blRepeatOnErrorCtr=0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,10 +727,17 @@ int8_t dcBL_getBlockResult(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcBL_cancelSending(void)
|
||||||
|
{
|
||||||
|
blChainStep=99;
|
||||||
|
}
|
||||||
|
|
||||||
char dcBL_cycle(void)
|
char dcBL_cycle(void)
|
||||||
{
|
{
|
||||||
// to be called cyclic every 100ms
|
// to be called cyclic every 10ms
|
||||||
|
// this step chain sends ONE data block (64byte) and repeats if neccesary
|
||||||
|
// stop on timeout, 3xerror or success
|
||||||
|
|
||||||
uint8_t buf[70], sendBuf[160], ret, sendLen;
|
uint8_t buf[70], sendBuf[160], ret, sendLen;
|
||||||
|
|
||||||
if (blChainStep==1)
|
if (blChainStep==1)
|
||||||
@@ -737,9 +746,10 @@ char dcBL_cycle(void)
|
|||||||
if (block2beSentNow==0 || block2beSentNow==1024 || block2beSentNow==2048
|
if (block2beSentNow==0 || block2beSentNow==1024 || block2beSentNow==2048
|
||||||
|| block2beSentNow==3072 || block2beSentNow==4096 )
|
|| block2beSentNow==3072 || block2beSentNow==4096 )
|
||||||
{
|
{
|
||||||
|
epi_clrRawReceivedString();
|
||||||
dcBL_sendAddress(block2beSentNow);
|
dcBL_sendAddress(block2beSentNow);
|
||||||
blChainStep++;
|
blChainStep++;
|
||||||
|
blTimeOutCounter=0;
|
||||||
//qDebug()<<"dcBL_cycle sending address and wait for response";
|
//qDebug()<<"dcBL_cycle sending address and wait for response";
|
||||||
return 0; // continue in 100ms
|
return 0; // continue in 100ms
|
||||||
} else
|
} else
|
||||||
@@ -757,7 +767,8 @@ char dcBL_cycle(void)
|
|||||||
|
|
||||||
blChainStep=10; // OK, continue with data
|
blChainStep=10; // OK, continue with data
|
||||||
blTimeOutCounter=0;
|
blTimeOutCounter=0;
|
||||||
return 0; // continue in 100ms
|
blRepeatOnErrorCtr=0;
|
||||||
|
return 0; // continue in 10ms
|
||||||
}
|
}
|
||||||
if (ret==1)
|
if (ret==1)
|
||||||
{
|
{
|
||||||
@@ -770,28 +781,32 @@ char dcBL_cycle(void)
|
|||||||
blChainStep=1; // repeat
|
blChainStep=1; // repeat
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qDebug()<<"dcBL cancel, wrong resp. to addr";
|
||||||
blChainResult=3; // error timeout, no response from DC-BL
|
blChainResult=3; // error timeout, no response from DC-BL
|
||||||
blChainStep=99;
|
blChainStep=99;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0; // continue in 100ms
|
return 0; // continue in 100ms
|
||||||
}
|
}
|
||||||
|
// noch keine Antwort:
|
||||||
blTimeOutCounter++;
|
blTimeOutCounter++;
|
||||||
if (blTimeOutCounter>=3) // wait 3 cycles (3x100ms) for response
|
if (blTimeOutCounter>=20) // wait 5 cycles (5x10ms) for response
|
||||||
{
|
{
|
||||||
//qDebug()<<"dcBL_cycle TO";
|
blRepeatOnErrorCtr++;
|
||||||
|
if (blRepeatOnErrorCtr<5)
|
||||||
blChainResult=3; // error timeout, no response from DC-BL
|
{
|
||||||
blChainStep=99;
|
// keine Antwort, nochmal senden
|
||||||
return 0;
|
blChainStep=1; // repeat
|
||||||
} else
|
//qDebug()<<"dcBL_cycle no response";
|
||||||
{
|
return 0; // continue in 100ms
|
||||||
// ein oder zweimal keine Antwort
|
} else
|
||||||
blChainStep=1; // repeat
|
{
|
||||||
|
// 5x keine Antwort, Abbruch
|
||||||
//qDebug()<<"dcBL_cycle no response";
|
qDebug()<<"dcBL cancel, no resp. to addr";
|
||||||
|
blChainResult=3; // error timeout, no response from DC-BL
|
||||||
return 0; // continue in 100ms
|
blChainStep=99;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -799,6 +814,7 @@ char dcBL_cycle(void)
|
|||||||
if (blChainStep==10)
|
if (blChainStep==10)
|
||||||
{
|
{
|
||||||
// send data block or conclusion
|
// send data block or conclusion
|
||||||
|
epi_clrRawReceivedString();
|
||||||
if (block2beSentNow == dcBL_nrOfBlocks)
|
if (block2beSentNow == dcBL_nrOfBlocks)
|
||||||
{
|
{
|
||||||
// very last blocknumber, send conclusion
|
// very last blocknumber, send conclusion
|
||||||
@@ -808,14 +824,28 @@ char dcBL_cycle(void)
|
|||||||
{
|
{
|
||||||
// send data...
|
// send data...
|
||||||
dcBL_getFileBlock(block2beSentNow, buf);
|
dcBL_getFileBlock(block2beSentNow, buf);
|
||||||
|
|
||||||
//qDebug()<<"dcBL sending data block"<<block2beSentNow;
|
//qDebug()<<"dcBL sending data block"<<block2beSentNow;
|
||||||
|
|
||||||
sendLen=dcBL_prepareDC_BLcmd(0x22, 64, buf, sendBuf); // pack into protocol frame
|
sendLen=dcBL_prepareDC_BLcmd(0x22, 64, buf, sendBuf); // pack into protocol frame
|
||||||
|
|
||||||
|
//sendBuf[sendLen-1]=0; // testweise ETX verbiegen um Fehlerreaktion zu testen
|
||||||
|
// tested 2024.11.11: send without ETX, got no response, sending is repeated 4x, correct
|
||||||
|
|
||||||
|
// sendBuf[sendLen-2]=0; // testweise crc verbiegen
|
||||||
|
// tested 2024.11.11: send with wrong crc, got error-response, repeat 4x, OK
|
||||||
|
|
||||||
|
//if (blRepeatCounter<3)
|
||||||
|
// sendBuf[sendLen-2]=0; // testweise crc 3x verbiegen, bei 4. mal richtig senden
|
||||||
|
// tested 2024.11.11: send with wrong crc, got error-response, OK
|
||||||
|
|
||||||
|
//sendBuf[50]=0; // testweise nur die Haelft senden
|
||||||
|
// tested 2024.11.11: send incomplete, is repeated 4x then stop, everything correct
|
||||||
|
|
||||||
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send up to 140 bytes
|
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send up to 140 bytes
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blChainStep++;
|
blChainStep++;
|
||||||
|
blTimeOutCounter=0;
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (blChainStep==11)
|
if (blChainStep==11)
|
||||||
@@ -829,36 +859,44 @@ char dcBL_cycle(void)
|
|||||||
blChainResult=1; // block sent succesful
|
blChainResult=1; // block sent succesful
|
||||||
if (block2beSentNow == dcBL_nrOfBlocks)
|
if (block2beSentNow == dcBL_nrOfBlocks)
|
||||||
blChainResult=2; // transfer complete
|
blChainResult=2; // transfer complete
|
||||||
|
|
||||||
blTimeOutCounter=0;
|
blTimeOutCounter=0;
|
||||||
return 0; // continue in 100ms
|
blRepeatOnErrorCtr=0;
|
||||||
|
return 0; // continue in 10ms
|
||||||
}
|
}
|
||||||
if (ret==1)
|
if (ret==1)
|
||||||
{
|
{
|
||||||
// we got response but BL reports an error
|
// we got response but BL reports an error
|
||||||
blTimeOutCounter=0;
|
blTimeOutCounter=0;
|
||||||
blRepeatCounter++;
|
blRepeatCounter++;
|
||||||
if (blRepeatCounter<3)
|
if (blRepeatCounter<5)
|
||||||
blChainStep=10; // repeat
|
blChainStep=10; // repeat
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qDebug()<<"dcBL cancel, wrong resp to datablock";
|
||||||
blChainResult=3; // error timeout, no response from DC-BL
|
blChainResult=3; // error timeout, no response from DC-BL
|
||||||
blChainStep=99;
|
blChainStep=99;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0; // continue in 100ms
|
return 0; // continue in 10ms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// noch keine Antwort:
|
||||||
blTimeOutCounter++;
|
blTimeOutCounter++;
|
||||||
if (blTimeOutCounter>=3) // wait 3 cycles (3x100ms) for response
|
if (blTimeOutCounter>=20) // wait 200ms for response, normal value=40...70ms
|
||||||
{
|
{
|
||||||
blChainResult=3; // error timeout, no response from DC-BL
|
// no response after 50ms
|
||||||
blChainStep=99;
|
blRepeatOnErrorCtr++;
|
||||||
return 0;
|
if (blRepeatOnErrorCtr<5)
|
||||||
} else
|
{
|
||||||
{
|
blChainStep=10; // repeat
|
||||||
// ein oder zweimal keine Antwort
|
return 0; // continue in 10ms
|
||||||
blChainStep=10; // repeat
|
} else
|
||||||
return 0; // continue in 100ms
|
{
|
||||||
|
qDebug()<<"dcBL cancel, no resp to datablock";
|
||||||
|
blChainResult=3; // error timeout, no response from DC-BL
|
||||||
|
blChainStep=99;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,320 +0,0 @@
|
|||||||
#include "download_thread.h"
|
|
||||||
#include "shared_mem_buffer.h"
|
|
||||||
#include "hwapi.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
|
|
||||||
DownloadThread::DownloadThread(hwinf *hw)
|
|
||||||
: m_hw(hw)
|
|
||||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
|
||||||
// connect(this, &QThread::finished,
|
|
||||||
// dynamic_cast<QObject const *>(m_hw), &QThread::deleteLater);
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::~DownloadThread() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// USING THE DC BOOTLOADER
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
1 : bl_reboot() // send to application, want DC2 to reset (in order to
|
|
||||||
// start the bootloader)
|
|
||||||
//
|
|
||||||
// NOTE: this function is NOT reliable !!! Sometimes it
|
|
||||||
// simply does not work, in which case bl_startBL,
|
|
||||||
// bl_checkBL and bl_isUp do not work as well.
|
|
||||||
// Alas, there is no feedback if bl_reboot worked!
|
|
||||||
//
|
|
||||||
// NOTE: this function can be called only once per
|
|
||||||
// minute, because once called again, the controller
|
|
||||||
// performs some self-checks consuming some time.
|
|
||||||
//
|
|
||||||
// NOTE: after a successful bl_reboot(), the device is
|
|
||||||
// waiting about 4 seconds in the bootloader. To stay in
|
|
||||||
// the bootloader, we have to send the command
|
|
||||||
// bl_startBL(), which is kind of a misnomer, as it
|
|
||||||
// should be bl_doNotLeaveBL().
|
|
||||||
//
|
|
||||||
2 : bl_startBL(): // send within 4s after DC power-on, otherwise
|
|
||||||
// bootloader is left.
|
|
||||||
//
|
|
||||||
// NOTE: a running bootloader is a MUST for the download
|
|
||||||
// process of a device controller firmware as it does
|
|
||||||
// the actual writing of the memory (the bl_reboot()
|
|
||||||
// from above erases the available memory).
|
|
||||||
//
|
|
||||||
3 : bl_check(): // send command to verify if bl is up
|
|
||||||
//
|
|
||||||
// NOTE: this command is kind of a request that we want
|
|
||||||
// to check if the bootloader is up. The device
|
|
||||||
// (actually the bootloader) responds with its version.
|
|
||||||
//
|
|
||||||
4 : bl_isUp(): // returns true if bl is up and running
|
|
||||||
//
|
|
||||||
// NOTE: we know what the bootloader version actually is
|
|
||||||
// as the bootloader does not change. By comparing the
|
|
||||||
// string received in the previous step with this known
|
|
||||||
// version string we know if the bootloader is up.
|
|
||||||
//
|
|
||||||
// NOTE FOR ALL PREVIOUS STEPS: execute them in their
|
|
||||||
// own slots each to be sure to receive any possible
|
|
||||||
// responds from the device.
|
|
||||||
//
|
|
||||||
5 : bl_sendAddress(blockNumber)
|
|
||||||
// send start address, nr of 64-byte block, start with 0
|
|
||||||
// will be sent only for following block-numbers:
|
|
||||||
// 0, 1024, 2048, 3072 and 4096, so basically every
|
|
||||||
// 64kByte.
|
|
||||||
// for other addresses nothing happens
|
|
||||||
|
|
||||||
6 : bl_wasSendingAddOK()
|
|
||||||
// return val: 0: no response by now
|
|
||||||
// 1: error
|
|
||||||
// 10: OK
|
|
||||||
|
|
||||||
7 : bl_sendDataBlock()
|
|
||||||
// send 64 byte from bin file
|
|
||||||
|
|
||||||
8 : bl_sendLastBlock()
|
|
||||||
// send this command after all data are transferred
|
|
||||||
|
|
||||||
9 : bl_wasSendingDataOK()
|
|
||||||
// return val: 0: no response by now
|
|
||||||
// 1: error
|
|
||||||
// 10: OK
|
|
||||||
|
|
||||||
10 : bl_stopBL() // leave bl and start (the new) application
|
|
||||||
//
|
|
||||||
// NOTE: this function MUST work under all conditions.
|
|
||||||
// Alas, there is no direct result for this command, so
|
|
||||||
// the only way of knowing it was successful is to ask
|
|
||||||
// the device if the bootloader is still running.
|
|
||||||
// There is no problem to repeat this command until the
|
|
||||||
// bootloader is really not running anymore.
|
|
||||||
*/
|
|
||||||
void DownloadThread::run() {
|
|
||||||
// download thread running in ca-master sends the dc-file down to firmware
|
|
||||||
// TODO: send the json files as well
|
|
||||||
|
|
||||||
m_hw->dcDownloadRequestAck();
|
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED";
|
|
||||||
|
|
||||||
// load binary device controller file into memory
|
|
||||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
|
||||||
if (ba.size() > 0) {
|
|
||||||
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
|
|
||||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
|
||||||
|
|
||||||
// fill last block of data to be sent with 0xFF
|
|
||||||
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
|
||||||
|
|
||||||
resetDeviceController();
|
|
||||||
if (startBootloader()) {
|
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
|
||||||
|
|
||||||
int currentBlock = 0;
|
|
||||||
DownloadResult res = DownloadResult::OK;
|
|
||||||
qCritical() << "64-byte block " << currentBlock;
|
|
||||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
|
||||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
|
||||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
|
||||||
currentBlock += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
|
||||||
|
|
||||||
int const rest = ba.size() % 64;
|
|
||||||
int const offset = ba.size() - rest;
|
|
||||||
char const *startAddress = ba.constData() + offset;
|
|
||||||
|
|
||||||
if (rest > 0) {
|
|
||||||
// SHOULD NEVER HAPPEN !!!
|
|
||||||
uint8_t local[66];
|
|
||||||
memset(local, 0xFF, sizeof(local));
|
|
||||||
memcpy(local, startAddress, rest);
|
|
||||||
qCritical() << "DownloadThread::run(): ERROR SEND REMAINING" << rest << "BYTES";
|
|
||||||
m_hw->bl_sendDataBlock(64, local);
|
|
||||||
} else {
|
|
||||||
m_hw->bl_sendLastBlock();
|
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
|
||||||
}
|
|
||||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
|
||||||
}
|
|
||||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
|
||||||
} // if it was not started at all
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// test code:
|
|
||||||
uint16_t const totalBlocks = 100;
|
|
||||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
|
||||||
|
|
||||||
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
|
||||||
QThread::msleep(100);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_hw->dcDownloadSetRunning(false);
|
|
||||||
m_hw->dcDownloadSetFinished(true);
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD FINISHED";
|
|
||||||
|
|
||||||
// the object deletes itself ! This is the last line in run().
|
|
||||||
// Never touch the object after this statement
|
|
||||||
// m_hw->dcDownloadThreadFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::DownloadResult DownloadThread::sendStatus(int ret) const {
|
|
||||||
switch (ret) { // return values of dc are:
|
|
||||||
case 0: // 0: no answer by now
|
|
||||||
return DownloadResult::NOP; // 1: error
|
|
||||||
case 10: // 10: success
|
|
||||||
return DownloadResult::OK;
|
|
||||||
default:;
|
|
||||||
}
|
|
||||||
return DownloadResult::ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::DownloadResult
|
|
||||||
DownloadThread::sendNextAddress(int bNum) const {
|
|
||||||
// sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096
|
|
||||||
int noAnswerCount = 0;
|
|
||||||
int errorCount = 0;
|
|
||||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
|
||||||
// qDebug() << "addr-block" << bNum << "...";
|
|
||||||
while (noAnswerCount <= 250) {
|
|
||||||
m_hw->bl_sendAddress(bNum);
|
|
||||||
QThread::msleep(100);
|
|
||||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
|
|
||||||
if (res != DownloadResult::NOP) {
|
|
||||||
if (res == DownloadResult::ERROR) {
|
|
||||||
if (++errorCount >= 10) {
|
|
||||||
qCritical() << "addr-block" << bNum << "...FAILED";
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else { // res == DownloadResult::OK
|
|
||||||
// qInfo() << "addr-block" << bNum << "...OK";
|
|
||||||
|
|
||||||
// TODO: hier ins shared-mem schreiben
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
noAnswerCount += 1; // no answer by now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// wait max. about 3 seconds
|
|
||||||
return DownloadResult::TIMEOUT;
|
|
||||||
}
|
|
||||||
// blockNumber is not one of 0, 1024, 2048, 3072, 4096 -> do nothing
|
|
||||||
return DownloadResult::NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::DownloadResult
|
|
||||||
DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
|
||||||
uint8_t local[66];
|
|
||||||
int const bAddr = bNum * 64;
|
|
||||||
int noAnswerCount = 0;
|
|
||||||
int errorCount = 0;
|
|
||||||
|
|
||||||
memcpy(local, binary.constData() + bAddr, 64);
|
|
||||||
local[64] = local[65] = 0x00;
|
|
||||||
|
|
||||||
// QByteArray b((const char *)(&local[0]), 64);
|
|
||||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
|
||||||
|
|
||||||
while (noAnswerCount <= 250) {
|
|
||||||
m_hw->bl_sendDataBlock(64, local);
|
|
||||||
QThread::msleep(10);
|
|
||||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
|
||||||
if (res != DownloadResult::NOP) {
|
|
||||||
if (res == DownloadResult::ERROR) {
|
|
||||||
if (++errorCount >= 10) {
|
|
||||||
qCritical() << "data for block" << bNum << "...FAILED";
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// qInfo() << "data for block" << bNum << "OK";
|
|
||||||
|
|
||||||
// TODO: hier ins shared mem schreiben
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
noAnswerCount += 1; // no answer by now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// wait max. about 3 seconds
|
|
||||||
return DownloadResult::TIMEOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadThread::startBootloader() const {
|
|
||||||
qDebug() << "starting bootloader...";
|
|
||||||
int nTry = 5;
|
|
||||||
while (--nTry >= 0) {
|
|
||||||
m_hw->bl_startBL();
|
|
||||||
QThread::msleep(5000);
|
|
||||||
m_hw->bl_checkBL();
|
|
||||||
if (m_hw->bl_isUp()) {
|
|
||||||
qInfo() << "starting bootloader...OK";
|
|
||||||
QThread::msleep(5000);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
qCritical() << "bootloader not up (" << nTry << ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qCritical() << "starting bootloader...FAILED";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadThread::stopBootloader() const {
|
|
||||||
qDebug() << "stopping bootloader...";
|
|
||||||
int nTry = 5;
|
|
||||||
while (--nTry >= 0) {
|
|
||||||
m_hw->bl_stopBL();
|
|
||||||
QThread::msleep(500);
|
|
||||||
if (!m_hw->bl_isUp()) {
|
|
||||||
qInfo() << "stopping bootloader...OK";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qCritical() << "stopping bootloader...FAILED";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadThread::resetDeviceController() const {
|
|
||||||
qDebug() << "resetting device controller...";
|
|
||||||
m_hw->bl_rebootDC();
|
|
||||||
// wait maximally 3 seconds, before starting bootloader
|
|
||||||
QThread::sleep(1);
|
|
||||||
qInfo() << "resetting device controller...OK";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
|
|
||||||
qDebug() << "loading dc binary" << filename << "...";
|
|
||||||
|
|
||||||
QFile file(filename); // closed in destructor call
|
|
||||||
if (!file.exists()) {
|
|
||||||
qCritical() << file.fileName() << "does not exist";
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
|
||||||
qCritical() << "cannot open file" << file.fileName();
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
qInfo() << "loading dc binary" << filename << "...OK";
|
|
||||||
return file.readAll();
|
|
||||||
}
|
|
@@ -9,8 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hwapi.h"
|
#include "hwapi.h"
|
||||||
#include "download_thread.h"
|
|
||||||
#include "reporting_thread.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@@ -56,7 +54,7 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
|||||||
#error "SLAVE LIB COMPILED INTO MASTER"
|
#error "SLAVE LIB COMPILED INTO MASTER"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
myDatif = new T_datif(); // für die CAslave-Lib auskommentieren!
|
myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -325,7 +323,14 @@ bool hwapi::dc_isPortOpen(void) const
|
|||||||
void hwapi::dc_autoRequest(bool on) const
|
void hwapi::dc_autoRequest(bool on) const
|
||||||
{
|
{
|
||||||
// automatically request ALL digital and analog sensors, get time/date, get status information
|
// automatically request ALL digital and analog sensors, get time/date, get status information
|
||||||
|
|
||||||
|
// call this with on=false before power down !! new, 8.10.2024TS
|
||||||
|
|
||||||
epi_startEmmision(on);
|
epi_startEmmision(on);
|
||||||
|
|
||||||
|
if (!on)
|
||||||
|
gpi_storeDcDataValid(0); // new, 8.10.2024TS
|
||||||
|
// right after wake-up from power down the DC data are not yet valid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2625,6 +2630,8 @@ void hwapi::bl_stopBL(void) const // tested 26.09.2023
|
|||||||
len=dcBL_exitBL(buf);
|
len=dcBL_exitBL(buf);
|
||||||
sendWRcmd_setSendBlock160(len, buf);
|
sendWRcmd_setSendBlock160(len, buf);
|
||||||
epi_setNowIsBootload(false);
|
epi_setNowIsBootload(false);
|
||||||
|
runProcess->resetBLvari();
|
||||||
|
dcBL_cancelSending();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4441,11 +4448,6 @@ bool hwapi::dcDownloadRunning() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
|
|
||||||
delete dthread;
|
|
||||||
m_downloadThread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadFinished() {
|
bool hwapi::dcDownloadFinished() {
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
SharedMem const *data = SharedMem::getDataConst();
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -4465,73 +4467,6 @@ bool hwapi::dcDownloadFinished() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// download thread
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadThreadStart() {
|
|
||||||
m_downloadThread = new DownloadThread(this);
|
|
||||||
if (m_downloadThread) {
|
|
||||||
m_downloadThread->start();
|
|
||||||
int cnt = 10;
|
|
||||||
while (--cnt > 0 && !dcDownloadThreadRunning()) {
|
|
||||||
QThread::msleep(200);
|
|
||||||
}
|
|
||||||
return (cnt > 0);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadThreadRunning() const {
|
|
||||||
return (dcDownloadGetRunning() == true)
|
|
||||||
&& (dcDownloadGetFinished() == false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadThreadFinished() const {
|
|
||||||
return (dcDownloadThreadRunning() == false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// report thread
|
|
||||||
bool hwapi::dcDownloadReportThreadStart() { // only start reporting thread
|
|
||||||
int cnt = 10; // if download thread is running
|
|
||||||
while (--cnt > 0 && !dcDownloadRunning()) {
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
if (cnt > 0) {
|
|
||||||
m_reportingThread = new ReportingThread(this);
|
|
||||||
if (m_reportingThread) {
|
|
||||||
m_reportingThread->start();
|
|
||||||
cnt = 10;
|
|
||||||
while (--cnt > 0 && !dcDownloadReportThreadRunning()) {
|
|
||||||
QThread::msleep(200);
|
|
||||||
}
|
|
||||||
return (cnt > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportThreadRunning() const {
|
|
||||||
return m_reportingThread ? m_reportingThread->isRunning() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::dcDownloadReportThreadFinalize() {
|
|
||||||
if (m_reportingThread) {
|
|
||||||
if (m_reportingThread->isFinished()) {
|
|
||||||
delete m_reportingThread;
|
|
||||||
m_reportingThread = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::dcDownloadReportThreadQuit() {
|
|
||||||
if (m_reportingThread) {
|
|
||||||
m_reportingThread->quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportThreadFinished() const {
|
|
||||||
return m_reportingThread ? m_reportingThread->isFinished() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportStart() const {
|
bool hwapi::dcDownloadReportStart() const {
|
||||||
int cnt = 10;
|
int cnt = 10;
|
||||||
|
@@ -368,6 +368,9 @@ uint8_t recBuffer[FRAME_MAXLEN];
|
|||||||
// read from "VCP":
|
// read from "VCP":
|
||||||
mySerialPort->readFromSerial(Indata, recLength);
|
mySerialPort->readFromSerial(Indata, recLength);
|
||||||
//qDebug()<<"prot: got data " << recLength;
|
//qDebug()<<"prot: got data " << recLength;
|
||||||
|
|
||||||
|
memset(recBuffer, 0x00, sizeof(recBuffer));
|
||||||
|
|
||||||
if (recLength>FRAME_MAXLEN)
|
if (recLength>FRAME_MAXLEN)
|
||||||
recLength=FRAME_MAXLEN;
|
recLength=FRAME_MAXLEN;
|
||||||
for (int nn=0; nn<recLength; nn++)
|
for (int nn=0; nn<recLength; nn++)
|
||||||
@@ -615,8 +618,10 @@ bool T_prot::getReceivedInData(uint8_t *SlavAddr, uint16_t *readSrc, uint16_t *
|
|||||||
return INdataValid; // nur true wenn CommandState OK und readState OK
|
return INdataValid; // nur true wenn CommandState OK und readState OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void T_prot::flushPort(void)
|
||||||
|
{
|
||||||
|
mySerialPort->flushPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,155 +0,0 @@
|
|||||||
#include "reporting_thread.h"
|
|
||||||
#include "shared_mem_buffer.h"
|
|
||||||
#include "hwapi.h"
|
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
ReportingThread::ReportingThread(hwapi *hw)
|
|
||||||
: m_hw(hw)
|
|
||||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ReportingThread::~ReportingThread() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// download thread running in ca-slave sends reports of download process to
|
|
||||||
// each component which has connects for the corresponding signals.
|
|
||||||
void ReportingThread::run() {
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
|
|
||||||
|
|
||||||
static QString report("");
|
|
||||||
|
|
||||||
int cnt = 5;
|
|
||||||
while (!m_hw->dcDownloadGetRunning()) {
|
|
||||||
if (--cnt > 0) {
|
|
||||||
report = QString("%1 waiting for download to start %2")
|
|
||||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate))
|
|
||||||
.arg(cnt);
|
|
||||||
qCritical() << __LINE__ << "STATUS" << report;
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
|
||||||
QThread::sleep(1);
|
|
||||||
} else break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (cnt == 0) {
|
|
||||||
m_hw->dcDownloadResetRequest();
|
|
||||||
status = QString("%1 reset download request")
|
|
||||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
|
|
||||||
qCritical() << __LINE__ << "STATUS" << status;
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(status);
|
|
||||||
|
|
||||||
cnt = 5;
|
|
||||||
while (!m_hw->dcDownloadRunning()) {
|
|
||||||
if (--cnt > 0) {
|
|
||||||
QThread::sleep(1);
|
|
||||||
} else break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cnt == 0) {
|
|
||||||
status = QString("%1 download request failure")
|
|
||||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
|
|
||||||
qCritical() << __LINE__ << "STATUS" << status;
|
|
||||||
emit m_hw->hwapi_reportDCDownloadFailure(status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t const tnr = 1750;
|
|
||||||
uint16_t cnr = 0;
|
|
||||||
|
|
||||||
while (cnr <= tnr) {
|
|
||||||
QThread::msleep(100);
|
|
||||||
QString report("");
|
|
||||||
|
|
||||||
if (cnr > 0) {
|
|
||||||
double percent = ((double)cnr / (double)tnr) * 100.0;
|
|
||||||
report = QString(": total blocks %1, current block %2 [%3]")
|
|
||||||
.arg(tnr).arg(cnr).arg(percent, 0, 'f', 2);
|
|
||||||
} else {
|
|
||||||
report = QString(": total blocks %1, current block %2 [0]")
|
|
||||||
.arg(tnr).arg(cnr);
|
|
||||||
}
|
|
||||||
status = QDateTime::currentDateTime().toString(Qt::ISODate) + report;
|
|
||||||
|
|
||||||
qCritical() << "STATUS" << status;
|
|
||||||
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(status);
|
|
||||||
cnr += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tnr == cnr) {
|
|
||||||
m_hw->hwapi_reportDCDownloadSuccess(
|
|
||||||
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
|
|
||||||
} else {
|
|
||||||
m_hw->hwapi_reportDCDownloadFailure(
|
|
||||||
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
|
|
||||||
.arg(m_fileToDownload).arg(tnr).arg(cnr));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t const totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
|
||||||
|
|
||||||
if (totalBlocks) {
|
|
||||||
qint64 const start = QDateTime::currentMSecsSinceEpoch();
|
|
||||||
double durationMillis = 0;
|
|
||||||
uint16_t currentBlockNumber = 0;
|
|
||||||
|
|
||||||
while (m_hw->dcDownloadGetRunning()) {
|
|
||||||
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
|
||||||
|
|
||||||
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
|
|
||||||
|
|
||||||
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis;
|
|
||||||
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
|
|
||||||
|
|
||||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
|
||||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4s)")
|
|
||||||
.arg(totalBlocks)
|
|
||||||
.arg(currentBlockNumber)
|
|
||||||
.arg(percent, 0, 'f', 2)
|
|
||||||
.arg(estimatedSecondsLeft, 0, 'f', 2);
|
|
||||||
|
|
||||||
qCritical() << "RT report" << report;
|
|
||||||
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
|
||||||
QThread::msleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
QThread::msleep(100);
|
|
||||||
|
|
||||||
if (totalBlocks == currentBlockNumber) {
|
|
||||||
m_hw->hwapi_reportDCDownloadSuccess(
|
|
||||||
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
|
|
||||||
} else {
|
|
||||||
m_hw->hwapi_reportDCDownloadFailure(
|
|
||||||
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
|
|
||||||
.arg(m_fileToDownload).arg(totalBlocks).arg(currentBlockNumber));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
|
||||||
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
|
|
||||||
|
|
||||||
cnt = 10;
|
|
||||||
|
|
||||||
bool running = m_hw->dcDownloadGetRunning();
|
|
||||||
bool finished = m_hw->dcDownloadGetFinished();
|
|
||||||
|
|
||||||
while (--cnt > 0 && (running && !finished)) {
|
|
||||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
|
||||||
<< QString("line=%1 REPORT THREAD: WAIT FOR END OF DOWNLOAD THREAD %2 %3 (%4)")
|
|
||||||
.arg(__LINE__).arg(running).arg(finished).arg(cnt);
|
|
||||||
QThread::sleep(1);
|
|
||||||
running = m_hw->dcDownloadGetRunning();
|
|
||||||
finished = m_hw->dcDownloadGetFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
|
||||||
<< QString("line=%1 FINISH REPORT THREAD").arg(__LINE__);
|
|
||||||
}
|
|
191
src/runProc.cpp
191
src/runProc.cpp
@@ -9,7 +9,7 @@ static uint8_t hwapi_cash_lastCollectionState;
|
|||||||
static uint8_t hwapi_paymentStarted;
|
static uint8_t hwapi_paymentStarted;
|
||||||
static uint8_t hwapi_lastDoorState;
|
static uint8_t hwapi_lastDoorState;
|
||||||
static uint8_t bl_startupStep;
|
static uint8_t bl_startupStep;
|
||||||
|
static uint8_t runProc_BLisStarted;
|
||||||
|
|
||||||
|
|
||||||
T_runProc::T_runProc()
|
T_runProc::T_runProc()
|
||||||
@@ -643,6 +643,7 @@ void T_runProc::bl_completeStart(void)
|
|||||||
bl_startupStep=1;
|
bl_startupStep=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool T_runProc::bl_performComplStart(void)
|
bool T_runProc::bl_performComplStart(void)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
@@ -727,7 +728,12 @@ bool T_runProc::bl_performComplStart(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void T_runProc::resetBLvari(void)
|
||||||
|
{
|
||||||
|
// reset with BL-stop command
|
||||||
|
runProc_BLisStarted=0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// new from 21.5.24 ..................................................................
|
// new from 21.5.24 ..................................................................
|
||||||
@@ -1328,6 +1334,7 @@ void T_runProc::sub_changeStyle(char *valueStr)
|
|||||||
// 10th:height 1th=width
|
// 10th:height 1th=width
|
||||||
"styl":"align c" // 'l' 'c' 'r' // left center right
|
"styl":"align c" // 'l' 'c' 'r' // left center right
|
||||||
"styl":"density25"; // 0....[25]...50 0=blass
|
"styl":"density25"; // 0....[25]...50 0=blass
|
||||||
|
"styl":"csiz 12" // character size 6..20, new 26.7.2024
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
@@ -1397,7 +1404,16 @@ void T_runProc::sub_changeStyle(char *valueStr)
|
|||||||
val=uint8_t(tslib_atol(&valueStr[7]));
|
val=uint8_t(tslib_atol(&valueStr[7]));
|
||||||
runProc_prnCmdSeq[runProc_pointPrnCmd]=19;
|
runProc_prnCmdSeq[runProc_pointPrnCmd]=19;
|
||||||
runProc_prnCmdPara[runProc_pointPrnCmd++]=val;
|
runProc_prnCmdPara[runProc_pointPrnCmd++]=val;
|
||||||
|
} else
|
||||||
|
|
||||||
|
if ( memcmp(valueStr, "csiz ", 5) ==0 )
|
||||||
|
{
|
||||||
|
valueStr[7]=0;
|
||||||
|
val=uint8_t(tslib_atol(&valueStr[5]));
|
||||||
|
runProc_prnCmdSeq[runProc_pointPrnCmd]=20;
|
||||||
|
runProc_prnCmdPara[runProc_pointPrnCmd++]=val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "prn_papSped" comes with feed-cmd, not with "styl" !!
|
// "prn_papSped" comes with feed-cmd, not with "styl" !!
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1619,51 +1635,25 @@ bool T_runProc::subGetVariStr(char *valueStr, char *returnStr)
|
|||||||
|
|
||||||
if ( memcmp(valueStr, "wday eng shor", 13) ==0 )
|
if ( memcmp(valueStr, "wday eng shor", 13) ==0 )
|
||||||
{
|
{
|
||||||
switch (dow)
|
swl_returnWeekdayStr(dow, 2, returnStr);
|
||||||
{
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
returnStr[0]='m'; returnStr[1]='o';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
returnStr[0]='t'; returnStr[1]='u';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
returnStr[0]='w'; returnStr[1]='e';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
returnStr[0]='t'; returnStr[1]='h';
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
returnStr[0]='f'; returnStr[1]='r';
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
returnStr[0]='s'; returnStr[1]='a';
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
returnStr[0]='s'; returnStr[1]='u';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
returnStr[0]='-'; returnStr[1]='-';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
returnStr[2]=0;
|
returnStr[2]=0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( memcmp(valueStr, "wday eng long", 13) ==0 )
|
if ( memcmp(valueStr, "wday eng long", 13) ==0 )
|
||||||
{
|
{
|
||||||
|
swl_returnWeekdayStr(dow, 2, returnStr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( memcmp(valueStr, "wday deu shor", 13) ==0 )
|
if ( memcmp(valueStr, "wday deu shor", 13) ==0 )
|
||||||
{
|
{
|
||||||
|
swl_returnWeekdayStr(dow, 1, returnStr);
|
||||||
|
returnStr[2]=0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( memcmp(valueStr, "wday deu long", 13) ==0 )
|
if ( memcmp(valueStr, "wday deu long", 13) ==0 )
|
||||||
{
|
{
|
||||||
|
swl_returnWeekdayStr(dow, 1, returnStr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1987,7 +1977,6 @@ void T_runProc::runProc_subPerformPrintCmds(uint8_t nextCmd, uint8_t nextPara)
|
|||||||
prn_fontInv=0;
|
prn_fontInv=0;
|
||||||
sendFDcmd_set(CMD2DC_PRI_SETLETTER, 0, 0, prn_fontBold, prn_fontInv, prn_underLine, 0);
|
sendFDcmd_set(CMD2DC_PRI_SETLETTER, 0, 0, prn_fontBold, prn_fontInv, prn_underLine, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
prn_fontTyp=nextPara; // kind of font 5...11 (0..22)
|
prn_fontTyp=nextPara; // kind of font 5...11 (0..22)
|
||||||
sendFDcmd_set(CMD2DC_PRI_SETFONT, 0,0, prn_fontTyp, prn_fontSiz, prn_width, prn_hei);
|
sendFDcmd_set(CMD2DC_PRI_SETFONT, 0,0, prn_fontTyp, prn_fontSiz, prn_width, prn_hei);
|
||||||
@@ -2008,12 +1997,14 @@ void T_runProc::runProc_subPerformPrintCmds(uint8_t nextCmd, uint8_t nextPara)
|
|||||||
prn_density=nextPara;
|
prn_density=nextPara;
|
||||||
prn_sendPrnSetup(prn_papSped, prn_density, prn_alignment, prn_orient);
|
prn_sendPrnSetup(prn_papSped, prn_density, prn_alignment, prn_orient);
|
||||||
break;
|
break;
|
||||||
|
case 20:
|
||||||
|
prn_fontSiz=nextPara;
|
||||||
|
sendFDcmd_set(CMD2DC_PRI_SETFONT, 0,0, prn_fontTyp, prn_fontSiz, prn_width, prn_hei);
|
||||||
|
break;
|
||||||
case 30: // cut
|
case 30: // cut
|
||||||
// kindof = 1: full cut 2: partial cut 3=eject (5xLF + full cut)
|
// kindof = 1: full cut 2: partial cut 3=eject (5xLF + full cut)
|
||||||
sendFDcmd_set(CMD2DC_PRI_CUT, 0,0, 1,0,0,0);
|
sendFDcmd_set(CMD2DC_PRI_CUT, 0,0, 1,0,0,0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 31: // part
|
case 31: // part
|
||||||
// kindof = 1: full cut 2: partial cut 3=eject (5xLF + full cut)
|
// kindof = 1: full cut 2: partial cut 3=eject (5xLF + full cut)
|
||||||
sendFDcmd_set(CMD2DC_PRI_CUT, 0,0, 2,0,0,0);
|
sendFDcmd_set(CMD2DC_PRI_CUT, 0,0, 2,0,0,0);
|
||||||
@@ -2333,3 +2324,133 @@ char T_runProc::prn_directTicket_cycle(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// neuere TS Version, wurde aber von Gerhard nicht verwendet:
|
||||||
|
/*
|
||||||
|
bool T_runProc::bl_waitForRdyMsg(void) // vorher: bl_isUp()
|
||||||
|
{
|
||||||
|
uint8_t receivedData[160];
|
||||||
|
uint8_t LL, nn;
|
||||||
|
|
||||||
|
for (nn=0; nn<160; nn++) receivedData[nn]=0;
|
||||||
|
LL=epi_getRawRecLength();
|
||||||
|
if (LL>0)
|
||||||
|
{
|
||||||
|
epi_getRawReceivedData(receivedData);
|
||||||
|
|
||||||
|
// response to "readFWversion"
|
||||||
|
if (receivedData[0]==2 && receivedData[1]==146 && receivedData[2]==45 &&
|
||||||
|
receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
|
||||||
|
{
|
||||||
|
//qDebug() << "*** runProc, got BL response to readFWversion";
|
||||||
|
//epi_clrRawReceivedString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// response to "start BL"
|
||||||
|
if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 &&
|
||||||
|
receivedData[3]==223 && receivedData[4] ==131 )
|
||||||
|
{
|
||||||
|
//qDebug() << "runProc, got BL response to start";
|
||||||
|
//epi_clrRawReceivedString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//qDebug() << "runProc, got "<<LL<<" wrong bytes"<<receivedData[0]<<" "
|
||||||
|
// <<receivedData[1]<<" "<<receivedData[2]<<" "<<receivedData[3]<<" "
|
||||||
|
// <<receivedData[4]<<" "<<receivedData[5]<<" "<<receivedData[6];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t T_runProc::bl_isUp(void)
|
||||||
|
{
|
||||||
|
// return 1: BL is up 2: BL error 0: unknown
|
||||||
|
return runProc_BLisStarted;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool T_runProc::bl_performComplStart(void)
|
||||||
|
{
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
static uint8_t retryCtr;
|
||||||
|
|
||||||
|
if ((bl_startupStep<1) || (bl_startupStep>10))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (bl_startupStep==1)
|
||||||
|
{
|
||||||
|
dc_autoRequest(false); // and clear serial input buffer
|
||||||
|
runProc_BLisStarted=0;
|
||||||
|
bl_startupStep++;
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (bl_startupStep==2)
|
||||||
|
{
|
||||||
|
qDebug()<<"rebooting";
|
||||||
|
bl_rebootDC();
|
||||||
|
myTO->stop();
|
||||||
|
myTO->start(500);
|
||||||
|
retryCtr=0;
|
||||||
|
bl_startupStep++;
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (bl_startupStep==3)
|
||||||
|
{
|
||||||
|
if (!myTO->isActive())
|
||||||
|
{
|
||||||
|
qDebug()<<"starting BL";
|
||||||
|
epi_clrRawReceivedString();
|
||||||
|
bl_startBL();
|
||||||
|
myTO->stop();
|
||||||
|
myTO->start(500);
|
||||||
|
bl_startupStep++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (bl_startupStep==4)
|
||||||
|
{
|
||||||
|
if (!myTO->isActive())
|
||||||
|
{
|
||||||
|
qDebug()<<"checking BL";
|
||||||
|
bl_checkBL();
|
||||||
|
myTO->stop();
|
||||||
|
myTO->start(1000);
|
||||||
|
bl_startupStep++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (bl_startupStep==5)
|
||||||
|
{
|
||||||
|
result = bl_waitForRdyMsg();
|
||||||
|
if (result==true)
|
||||||
|
{
|
||||||
|
bl_startupStep++;
|
||||||
|
qDebug()<<"BL is working now..."; // BL is up and running
|
||||||
|
runProc_BLisStarted=1; // ok
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!myTO->isActive())
|
||||||
|
{
|
||||||
|
qDebug()<<"no resp. from BL"<< result;
|
||||||
|
retryCtr++; // start again
|
||||||
|
if (retryCtr>=3)
|
||||||
|
{
|
||||||
|
bl_startupStep=99;
|
||||||
|
qDebug()<<"BL error!!!";
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
bl_startupStep=3;
|
||||||
|
runProc_BLisStarted=2; // error
|
||||||
|
myTO->stop();
|
||||||
|
myTO->start(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
@@ -981,3 +981,62 @@ unsigned int tslib_ah2ui( char *AscString)
|
|||||||
return(uitmp);
|
return(uitmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *****************************************************************************************
|
||||||
|
|
||||||
|
void swl_returnWeekdayStr(char dow, char language, char *buf)
|
||||||
|
{
|
||||||
|
// dow=1...7
|
||||||
|
// always returns 10byte
|
||||||
|
// languages: 1=german 2=english
|
||||||
|
|
||||||
|
memset(buf,0,10);
|
||||||
|
switch (dow)
|
||||||
|
{
|
||||||
|
case 1: // monday
|
||||||
|
if (language==1) tslib_text2array("Montag", buf,10);
|
||||||
|
else if (language==2) tslib_text2array("Monday", buf,10);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (language==1) tslib_text2array("Dienstag", buf,10);
|
||||||
|
else if (language==2) tslib_text2array("Tuesday", buf,10);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (language==1) tslib_text2array("Mittwoch", buf,10);
|
||||||
|
else if (language==2) tslib_text2array("Wednesday", buf,10);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (language==1) tslib_text2array("Donnerstag", buf,10);
|
||||||
|
else if (language==2) tslib_text2array("Thursday", buf,10);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (language==1) tslib_text2array("Freitag", buf,10);
|
||||||
|
else if (language==2) tslib_text2array("Friday", buf,10);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (language==1) tslib_text2array("Samstag", buf,10);
|
||||||
|
else if (language==2) tslib_text2array("Saturday", buf,10);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
if (language==1) tslib_text2array("Sonntag", buf,10);
|
||||||
|
else if (language==2) tslib_text2array("Sunday", buf,10);
|
||||||
|
break;
|
||||||
|
default: tslib_text2array("----", buf,10);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user