Compare commits
27 Commits
proposal_s
...
master
Author | SHA1 | Date | |
---|---|---|---|
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 |
@ -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,8 @@ public:
|
|||||||
bool readFromSerial(QByteArray &data, uint16_t &sendLength);
|
bool readFromSerial(QByteArray &data, uint16_t &sendLength);
|
||||||
// retval: true: data available
|
// retval: true: data available
|
||||||
|
|
||||||
|
uint32_t getWriteCount() { return writeCount; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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();
|
||||||
|
@ -121,13 +121,8 @@ public:
|
|||||||
explicit hwapi(QObject *parent = nullptr);
|
explicit hwapi(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef THIS_IS_CA_MASTER
|
#ifdef THIS_IS_CA_MASTER
|
||||||
T_datif *myDatif;
|
T_datif *myDatif;
|
||||||
#else // THIS_IS_CA_SLAVE
|
|
||||||
QString getVersions();
|
|
||||||
void resetVersions();
|
|
||||||
bool m_resetVersions = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
T_runProc *runProcess;
|
T_runProc *runProcess;
|
||||||
@ -1406,8 +1401,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hwapi_restoredVersions();
|
|
||||||
|
|
||||||
void hwapi_reportDCDownloadStatus(QString const&) const override;
|
void hwapi_reportDCDownloadStatus(QString const&) const override;
|
||||||
void hwapi_reportDCDownloadSuccess(QString const&) const override;
|
void hwapi_reportDCDownloadSuccess(QString const&) const override;
|
||||||
void hwapi_reportDCDownloadFailure(QString const&) const override;
|
void hwapi_reportDCDownloadFailure(QString const&) const override;
|
||||||
|
@ -122,6 +122,9 @@ 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
|
||||||
|
|
||||||
|
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);
|
||||||
|
49
src/com.cpp
49
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
188
src/datIf.cpp
188
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>
|
||||||
|
|
||||||
@ -124,6 +126,7 @@ T_datif::T_datif(QObject *parent) : QObject(parent)
|
|||||||
datif_pNextCmd=0;
|
datif_pNextCmd=0;
|
||||||
datif_sendSlowCmd=0;
|
datif_sendSlowCmd=0;
|
||||||
|
|
||||||
|
readCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_datif::resetChain(void)
|
void T_datif::resetChain(void)
|
||||||
@ -480,6 +483,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 +586,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 +620,117 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
|
|
||||||
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
|
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
|
||||||
|
|
||||||
|
if (myDCIF && myDCIF->getSerialPort()) {
|
||||||
|
uint32_t writeCount = myDCIF->getSerialPort()->getWriteCount();
|
||||||
|
if ((readCount + 1) == writeCount) { // there can be only one command sent to the DC
|
||||||
|
readCount = writeCount;
|
||||||
|
if (readSource != myDCIF->getReadSource()) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << ", ignore data"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource();
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
// only for debugging
|
||||||
|
// qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << readSource << myDCIF->getReadSource();
|
||||||
|
if (readSource == 30) {
|
||||||
|
T_moduleCondition const *modCond = reinterpret_cast<T_moduleCondition const *>(receivedData);
|
||||||
|
|
||||||
|
if(modCond->rtc >= 200) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E002 (modCond->rtc >= 200)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->printer == 200 || modCond->printer == 201) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E020 (modCond->printer == 200 || modCond->printer == 201)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->printer == 202) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E018 (modCond->printer == 202)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->coinBlocker >= 200) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E025 (modCond->coinBlocker >= 200)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->mdbBus >= 200) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E034 (modCond->mdbBus >= 200)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->intEe >= 200) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (modCond->intEe >= 200)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->voltage >= 200) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E003 (modCond->voltage >= 200)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->changer >= 200) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E026 (modCond->changer >= 200)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->coinSafe == 201) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E007 (modCond->coinSafe == 201)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (modCond->coinSafe == 200) {
|
||||||
|
dump(modCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E009 (modCond->coinSafe == 200)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readSource == 31) {
|
||||||
|
T_dynamicCondition const *dynCond = reinterpret_cast<T_dynamicCondition const *>(receivedData);
|
||||||
|
|
||||||
|
if (dynCond->modeAbrech > 0) {
|
||||||
|
dump(dynCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (dynCond->modeAbrech > 0)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (dynCond->nowCardTest > 0) {
|
||||||
|
dump(dynCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E072 (dynCond->nowCardTest > 0)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
if (dynCond->startupTestIsRunning > 0) {
|
||||||
|
dump(dynCond);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E073 (dynCond->startupTestIsRunning > 0)"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << QString(": ERROR readCount + 1 != writeCount: %1 != %2").arg(readCount + 1).arg(writeCount);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << ", ignore data"
|
||||||
|
<< QByteArray((char const *)receivedData, RdDleng).toHex(':');
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource();
|
||||||
|
|
||||||
|
if (readSource == 30) {
|
||||||
|
T_moduleCondition const *modCond = reinterpret_cast<T_moduleCondition const *>(receivedData);
|
||||||
|
dump(modCond);
|
||||||
|
}
|
||||||
|
if (readSource == 31) {
|
||||||
|
T_dynamicCondition const *dynCond = reinterpret_cast<T_dynamicCondition const *>(receivedData);
|
||||||
|
dump(dynCond);
|
||||||
|
if (dynCond->coinAttached > 0) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": dynCond->coinAttached"
|
||||||
|
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readCount = writeCount;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
@ -1019,7 +1205,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
uit2=0;
|
uit2=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uit2==3 || uit2==5 || uit2==10 || uit2==20 || uit2==50 || uit2==100 || uit2==200 || uit2==500)
|
if (uit2==3 || uit2==5 || uit2==10 || uit2==20 || uit2==40 || uit2==50 || uit2==100 || uit2==200 || uit2==500)
|
||||||
{
|
{
|
||||||
// valid coin
|
// valid coin
|
||||||
if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )
|
if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "hwapi.h"
|
#include "hwapi.h"
|
||||||
#include "download_thread.h"
|
#include "download_thread.h"
|
||||||
#include "reporting_thread.h"
|
#include "reporting_thread.h"
|
||||||
#include "storeINdata.h" // epi_loadSWVer, epi_loadHWVer
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -26,37 +25,6 @@ static uint8_t hwapi_lastDoorState;
|
|||||||
static uint8_t bl_startupStep;
|
static uint8_t bl_startupStep;
|
||||||
|
|
||||||
|
|
||||||
#ifdef THIS_IS_CA_MASTER
|
|
||||||
#else // THIS_IS_CA_SLAVE
|
|
||||||
QString hwapi::getVersions() {
|
|
||||||
if (m_sharedMem != nullptr) {
|
|
||||||
// check if sw/hw-versions have been restored (see resetVersions()).
|
|
||||||
// emit a signal in such a case.
|
|
||||||
QString const &sw = epi_loadSWver(); // command 11
|
|
||||||
QString const &hw = epi_loadHWver(); // command 12
|
|
||||||
if (!sw.isEmpty() && !hw.isEmpty() && m_resetVersions) {
|
|
||||||
emit hwapi_restoredVersions();
|
|
||||||
return sw + " " + hw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::resetVersions() {
|
|
||||||
if (m_sharedMem != nullptr) {
|
|
||||||
// command 11 and 12 are included in the requests sent automatically,
|
|
||||||
// first 11, then 12. The results are used to refresh corresponding
|
|
||||||
// shared memory locations.
|
|
||||||
// set these locations to the empty string in the opposite order as
|
|
||||||
// the commands are sent.
|
|
||||||
// purpose: only when both locations are not empty again, we can be
|
|
||||||
// sure that data are not obsolete.
|
|
||||||
gpi_storeHWver(""); // command 12
|
|
||||||
gpi_storeSWver(""); // command 11
|
|
||||||
m_resetVersions = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hwapi::hwapi(QObject *parent) : QObject(parent)
|
hwapi::hwapi(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
@ -88,7 +56,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
|
||||||
|
|
||||||
|
@ -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++)
|
||||||
|
@ -6,11 +6,6 @@
|
|||||||
#include "shared_mem_buffer.h"
|
#include "shared_mem_buffer.h"
|
||||||
#include "datei.h"
|
#include "datei.h"
|
||||||
|
|
||||||
#include <QMutex>
|
|
||||||
#include <QMutexLocker>
|
|
||||||
|
|
||||||
static QMutex SWHD_mutex;
|
|
||||||
|
|
||||||
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
||||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||||
|
|
||||||
@ -69,7 +64,6 @@ bool indat_isMdbOn()
|
|||||||
|
|
||||||
void gpi_storeHWver(QString text)
|
void gpi_storeHWver(QString text)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&SWHD_mutex);
|
|
||||||
// change Qstring to array of chars, because shared mem allowes no QString!
|
// change Qstring to array of chars, because shared mem allowes no QString!
|
||||||
int nn, LL = text.length();
|
int nn, LL = text.length();
|
||||||
if (LL >= versionBufferLen)
|
if (LL >= versionBufferLen)
|
||||||
@ -85,7 +79,6 @@ void gpi_storeHWver(QString text)
|
|||||||
|
|
||||||
QString epi_loadHWver(void)
|
QString epi_loadHWver(void)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&SWHD_mutex);
|
|
||||||
// load array of chars from SM and change to QString
|
// load array of chars from SM and change to QString
|
||||||
int nn, LL = versionBufferLen;
|
int nn, LL = versionBufferLen;
|
||||||
char cc;
|
char cc;
|
||||||
@ -103,7 +96,6 @@ QString epi_loadHWver(void)
|
|||||||
|
|
||||||
void gpi_storeSWver(QString text)
|
void gpi_storeSWver(QString text)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&SWHD_mutex);
|
|
||||||
int nn, LL = text.length();
|
int nn, LL = text.length();
|
||||||
if (LL >= versionBufferLen)
|
if (LL >= versionBufferLen)
|
||||||
LL=versionBufferLen-1; // leave place for termination
|
LL=versionBufferLen-1; // leave place for termination
|
||||||
@ -119,7 +111,6 @@ void gpi_storeSWver(QString text)
|
|||||||
|
|
||||||
QString epi_loadSWver(void)
|
QString epi_loadSWver(void)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&SWHD_mutex);
|
|
||||||
int nn, LL = versionBufferLen;
|
int nn, LL = versionBufferLen;
|
||||||
char cc;
|
char cc;
|
||||||
QString myStr;
|
QString myStr;
|
||||||
|
Loading…
Reference in New Issue
Block a user