Compare commits
2 Commits
dc-downloa
...
bugfix_mas
Author | SHA1 | Date | |
---|---|---|---|
8ee6fa24d9
|
|||
786c4332ee
|
@@ -21,15 +21,14 @@ INCLUDEPATH += ../include
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
BUILD_TIME=$$system("time /t")
|
||||
GIT_COMMIT=""
|
||||
EXTENDED_VERSION=""
|
||||
} else {
|
||||
BUILD_DATE=$$system("date +%d-%m-%y")
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
|
||||
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
|
||||
}
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
|
||||
|
||||
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
|
@@ -33,8 +33,6 @@ QMAKE_CXXFLAGS += -C
|
||||
QMAKE_CXXFLAGS += -O2 -O
|
||||
QMAKE_CXXFLAGS += -g
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
# QMAKE_CXXFLAGS += -fsanitize=address
|
||||
# QMAKE_CXXFLAGS += -fno-omit-frame-pointer
|
||||
|
||||
QMAKE_LFLAGS += -Wl,-e,main
|
||||
|
||||
|
BIN
build/CArunGui
BIN
build/CArunGui
Binary file not shown.
1147
build/carun_out.txt
1147
build/carun_out.txt
File diff suppressed because it is too large
Load Diff
BIN
build/dCArun
BIN
build/dCArun
Binary file not shown.
2492
build/interfaces.h
2492
build/interfaces.h
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -25,16 +25,15 @@ INCLUDEPATH += ../include
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
BUILD_TIME=$$system("time /t")
|
||||
GIT_COMMIT=""
|
||||
EXTENDED_VERSION=""
|
||||
} else {
|
||||
BUILD_DATE=$$system("date +%d-%m-%y")
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
|
||||
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
|
||||
}
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
|
||||
|
||||
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
|
@@ -134,8 +134,7 @@
|
||||
|
||||
|
||||
|
||||
class DownloadThread;
|
||||
class hwinf;
|
||||
|
||||
class T_datif : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -166,14 +165,13 @@ class T_datif : public QObject
|
||||
T_prot *myDCIF;
|
||||
QTimer *datif_trigger;
|
||||
uint8_t selectedSlaveAddr;
|
||||
hwinf *m_hw = nullptr;
|
||||
|
||||
private slots:
|
||||
char datif_cycleSend();
|
||||
void StoredRecData();
|
||||
|
||||
public:
|
||||
T_datif(hwinf *hw, QObject *parent = nullptr);
|
||||
T_datif(QObject *parent = nullptr);
|
||||
|
||||
void resetChain(void);
|
||||
char isPortOpen(void);
|
||||
|
@@ -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
|
@@ -80,8 +80,7 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
||||
|
||||
|
||||
class QSharedMemory;
|
||||
class DownloadThread;
|
||||
class ReportingThread;
|
||||
|
||||
class hwapi : public QObject,
|
||||
public hwinf
|
||||
{
|
||||
@@ -93,13 +92,12 @@ private:
|
||||
void sub_storeSendingText(QByteArray *buf) const;
|
||||
QTimer *hwapi_TimerPayment;
|
||||
QSharedMemory *m_sharedMem;
|
||||
ReportingThread *m_reportingThread = nullptr;
|
||||
DownloadThread *m_downloadThread = nullptr;
|
||||
//QTimer *hwapi_triggerBL;
|
||||
|
||||
public:
|
||||
explicit hwapi(QWidget *parent = nullptr);
|
||||
|
||||
|
||||
#ifdef THIS_IS_CA_MASTER
|
||||
T_datif *myDatif;
|
||||
#endif
|
||||
@@ -1318,47 +1316,10 @@ public:
|
||||
// countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker
|
||||
// countOfBills[1] for 10€ and so on
|
||||
|
||||
// download device controller
|
||||
bool dcDownloadRequest(QString const &fileToDownload) const override;
|
||||
bool dcDownloadRequested() const override;
|
||||
bool dcDownloadResetRequest() const override;
|
||||
bool dcDownloadRequestAck() const override;
|
||||
bool dcDownloadRunning() const override;
|
||||
bool dcDownloadFinished() override;
|
||||
|
||||
bool dcDownloadReportStart() const override;
|
||||
bool dcDownloadReportRunning() const 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;
|
||||
bool dcDownloadSetRequested(bool) override;
|
||||
bool dcDownloadSetRunning(bool) override;
|
||||
bool dcDownloadSetFinished(bool) override;
|
||||
void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) override;
|
||||
void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) override;
|
||||
bool dcDownloadGetRequested() const override;
|
||||
bool dcDownloadGetRunning() const override;
|
||||
bool dcDownloadGetFinished() const override;
|
||||
uint16_t dcDownloadGetTotalBlockNumber() const override;
|
||||
uint16_t dcDownloadGetCurrentBlockNumber() const override;
|
||||
|
||||
virtual QObject const *getAPI() override;
|
||||
|
||||
signals:
|
||||
void hwapi_reportDCDownloadStatus(QString const&) const;
|
||||
void hwapi_reportDCDownloadSuccess(QString const&) const;
|
||||
void hwapi_reportDCDownloadFailure(QString const&) const;
|
||||
|
||||
void hwapi_templatePrintFinished_OK(void) const override;
|
||||
void hwapi_templatePrintFinished_Err(void) const override;
|
||||
|
||||
|
@@ -414,7 +414,6 @@ struct T_bna
|
||||
|
||||
};
|
||||
|
||||
class DownloadThread;
|
||||
class hwinf
|
||||
{
|
||||
|
||||
@@ -2300,73 +2299,9 @@ public:
|
||||
// countOfBills[1] for 10€ and so on
|
||||
|
||||
|
||||
// download device controller
|
||||
virtual bool dcDownloadRequest(QString const &fileToDownload) const {
|
||||
Q_UNUSED(fileToDownload);
|
||||
return false;
|
||||
}
|
||||
virtual bool dcDownloadRequested() const { return false; }
|
||||
virtual bool dcDownloadResetRequest() const { return false; }
|
||||
virtual bool dcDownloadRequestAck() const { return false; }
|
||||
virtual bool dcDownloadRunning() const { return false; }
|
||||
virtual bool dcDownloadFinished() { return false; }
|
||||
|
||||
virtual bool dcDownloadReportStart() const { return false; }
|
||||
virtual bool dcDownloadReportRunning() const { return true; }
|
||||
virtual bool dcDownloadReportFinished() { return true; }
|
||||
|
||||
virtual bool dcDownloadThreadStart() { return false; }
|
||||
virtual bool dcDownloadThreadRunning() const { return true; }
|
||||
virtual void dcDownloadThreadFinalize(DownloadThread *) {}
|
||||
virtual bool dcDownloadThreadFinished() const { return true; }
|
||||
virtual bool dcDownloadReportThreadStart() { return false; }
|
||||
virtual bool dcDownloadReportThreadRunning() const { return true; }
|
||||
virtual void dcDownloadReportThreadFinalize() {}
|
||||
virtual void dcDownloadReportThreadQuit() {}
|
||||
virtual bool dcDownloadReportThreadFinished() const { return true; }
|
||||
|
||||
|
||||
virtual QString dcDownloadFileName() const { return ""; }
|
||||
virtual bool dcDownloadSetRequested(bool requested) {
|
||||
Q_UNUSED(requested); return false;
|
||||
}
|
||||
virtual bool dcDownloadSetRunning(bool running) {
|
||||
Q_UNUSED(running); return false;
|
||||
}
|
||||
virtual bool dcDownloadSetFinished(bool finished) {
|
||||
Q_UNUSED(finished); return false;
|
||||
}
|
||||
virtual void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
|
||||
Q_UNUSED(totalBlockNumber);
|
||||
}
|
||||
virtual void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
|
||||
Q_UNUSED(currentBlockNumber);
|
||||
}
|
||||
virtual bool dcDownloadGetRequested() const { return false; }
|
||||
virtual bool dcDownloadGetRunning() const { return false; }
|
||||
virtual bool dcDownloadGetFinished() const { return false; }
|
||||
virtual uint16_t dcDownloadGetTotalBlockNumber() const { return 0; }
|
||||
virtual uint16_t dcDownloadGetCurrentBlockNumber() const { return 0; }
|
||||
|
||||
virtual QObject const *getAPI() { return nullptr; }
|
||||
|
||||
|
||||
signals:
|
||||
/*
|
||||
NOTE: the difference between a virtual Qt signal and a normal Qt signal:
|
||||
A Qt virtual signal is a connection that is established using a pointer
|
||||
or reference and is not connected to an object or data. It is therefore
|
||||
not bound to a particular object, but to a specific class (object type).
|
||||
Qt virtual signals are useful because they allow you to create
|
||||
connections without worrying about whether an object or a specific data
|
||||
element has been destroyed.
|
||||
https://www.youtube.com/watch?v=HTH3VFfqsXw
|
||||
|
||||
*/
|
||||
virtual void hwapi_reportDCDownloadStatus(QString const&) const {}
|
||||
virtual void hwapi_reportDCDownloadSuccess(QString const&) const {}
|
||||
virtual void hwapi_reportDCDownloadFailure(QString const&) const {}
|
||||
|
||||
virtual void hwapi_templatePrintFinished_OK(void) const=0;
|
||||
virtual void hwapi_templatePrintFinished_Err(void) const=0;
|
||||
|
||||
|
@@ -1,35 +0,0 @@
|
||||
#ifndef REPORTING_THREAD_H_INCLUDED
|
||||
#define REPORTING_THREAD_H_INCLUDED
|
||||
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
// #include <functional>
|
||||
|
||||
class hwapi;
|
||||
class ReportingThread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReportingThread(hwapi *hw);
|
||||
~ReportingThread();
|
||||
|
||||
//void setFunction(std::function<void(QString const&)> f) {
|
||||
// m_f = f;
|
||||
//}
|
||||
|
||||
//std::function<void(QString const&)> function() {
|
||||
// return m_f;
|
||||
//}
|
||||
|
||||
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;
|
||||
//std::function<void(QString const&)> m_f;
|
||||
};
|
||||
|
||||
#endif // REPORTING_THREAD_H_INCLUDED
|
@@ -300,31 +300,10 @@ struct SharedMem
|
||||
|
||||
uint8_t p_nextFDcmdsInQueue;
|
||||
|
||||
// download of device controller and json files
|
||||
struct DCDownload {
|
||||
enum class FILE_INDEX {
|
||||
DC_BINARY = 0, DC2C_CASH = 1, DC2C_CONF = 2, DC2C_SERIAL=3,
|
||||
DC2C_PRINT_01, DC2C_PRINT_02, DC2C_PRINT_03, DC2C_PRINT_04,
|
||||
DC2C_PRINT_05, DC2C_PRINT_06, DC2C_PRINT_07, DC2C_PRINT_08,
|
||||
DC2C_PRINT_09, DC2C_PRINT_10, DC2C_PRINT_11, DC2C_PRINT_12,
|
||||
DC2C_PRINT_13, DC2C_PRINT_14, DC2C_PRINT_15, DC2C_PRINT_16,
|
||||
DC2C_PRINT_17, DC2C_PRINT_18, DC2C_PRINT_19, DC2C_PRINT_20,
|
||||
DC2C_PRINT_21, DC2C_PRINT_22, DC2C_PRINT_23, DC2C_PRINT_24,
|
||||
DC2C_PRINT_25, DC2C_PRINT_26, DC2C_PRINT_27, DC2C_PRINT_28,
|
||||
DC2C_PRINT_29, DC2C_PRINT_30, DC2C_PRINT_31, DC2C_PRINT_32
|
||||
};
|
||||
char m_filename[(int)FILE_INDEX::DC2C_PRINT_32][512];
|
||||
std::atomic_ushort m_totalBlocks;
|
||||
std::atomic_ushort m_currentblockNumber;
|
||||
std::atomic_bool m_requested{false};
|
||||
std::atomic_bool m_running{false};
|
||||
std::atomic_bool m_finished{false};
|
||||
} m_downLoadDC;
|
||||
|
||||
// meta-data
|
||||
char os_release[64];
|
||||
char date_of_creation[32];
|
||||
char creator[128]; // name of application plus pid
|
||||
|
||||
|
||||
|
||||
|
||||
static QSharedMemory *getShm(std::size_t s = 0);
|
||||
|
||||
|
@@ -1,601 +0,0 @@
|
||||
#ifndef SHARED_MEM_BUFFER_INCLUDED_H
|
||||
#define SHARED_MEM_BUFFER_INCLUDED_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <atomic>
|
||||
|
||||
#include <QSharedMemory>
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
bool shdMem_firstUse(void);
|
||||
|
||||
// Vorsicht: im shared memory ist kein QString erlaubt!!!!!!!!!!!!!!!!!!!!!!
|
||||
// nur standard C Typen!!!!!!
|
||||
// also auch kein QByteArray o.ä.
|
||||
|
||||
// Vorsicht: Zugriffe auf Comport NICHT ins shared mem --> Absturz!!!!
|
||||
|
||||
struct SharedMem
|
||||
{
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_1;
|
||||
#endif
|
||||
|
||||
// ------------------ Comport Control --------------------------------
|
||||
bool rs_portIsOpen;
|
||||
bool AutoEmissionOn;
|
||||
bool Sdata_serialTestResult;
|
||||
uint8_t Sdata_pProtResultOk;
|
||||
uint16_t Sdata_receivedDataLength;
|
||||
uint8_t Sdata_receivedDataBlock[64];
|
||||
uint8_t ndbs, pari, nsb, br;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_2;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_lastResult;
|
||||
uint8_t Sdata_OverallResult;
|
||||
bool Sdata_startSV;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_3;
|
||||
#endif
|
||||
|
||||
// ------------------ Data INPUT --------------------------------
|
||||
|
||||
bool indat_savePrnPwr;
|
||||
bool indat_saveMifPwr;
|
||||
bool indat_MdbIsOn;
|
||||
//QString indat_HWversion;
|
||||
//QString indat_SWversion;
|
||||
//QString indat_DCstate;
|
||||
|
||||
#define versionBufferLen 32
|
||||
char indat_HWversion[versionBufferLen];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_4;
|
||||
#endif
|
||||
|
||||
char indat_SWversion[versionBufferLen];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_5;
|
||||
#endif
|
||||
|
||||
char indat_DCstate[versionBufferLen];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_6;
|
||||
#endif
|
||||
|
||||
struct Sdata
|
||||
{
|
||||
uint64_t slaveUID;
|
||||
uint8_t UIDstr[8];
|
||||
} Sdata;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_7;
|
||||
#endif
|
||||
|
||||
struct T_globTime
|
||||
{
|
||||
// Reihenfolge nicht vertauschen!!!!!
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
uint8_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t DayOfMonth;
|
||||
uint8_t DayOfWeek; // 1=monday...7
|
||||
uint8_t reserve1;
|
||||
|
||||
uint16_t MinutesOfToday;
|
||||
uint16_t reserve2;
|
||||
|
||||
uint32_t SecondsOfToday;
|
||||
|
||||
uint8_t IsLeapyear;
|
||||
uint8_t nextLeap;
|
||||
uint8_t lastLeap;
|
||||
uint8_t hoursOfWeek;
|
||||
|
||||
uint16_t minOfWeek;
|
||||
uint16_t hoursOfMonth;
|
||||
uint16_t minOfMonth;
|
||||
uint16_t dayOfYear;
|
||||
uint16_t hoursOfYear;
|
||||
uint16_t reserve3;
|
||||
|
||||
uint32_t minOfYear;
|
||||
|
||||
uint8_t squareOutMode;
|
||||
uint8_t free1;
|
||||
uint16_t reserve4;
|
||||
uint32_t minOfMillenium;
|
||||
// bis hierher 44byts
|
||||
uint32_t free2;
|
||||
uint32_t free3;
|
||||
uint32_t free4;
|
||||
|
||||
} getGlobalTime;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_8;
|
||||
#endif
|
||||
|
||||
#define MAXNROF_AI 4
|
||||
uint16_t AI_val[MAXNROF_AI];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_9;
|
||||
#endif
|
||||
|
||||
#define MAXNROF_MEASURE 4
|
||||
uint32_t Sdata_measurement[MAXNROF_MEASURE];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_10;
|
||||
#endif
|
||||
|
||||
uint8_t di_doorSwitch;
|
||||
uint8_t di_vaultSwitch;
|
||||
uint8_t di_lockSwitch;
|
||||
uint8_t di_opto;
|
||||
uint8_t di_aux;
|
||||
bool di_wakeFromPtu;
|
||||
bool di_wakeFromMdb;
|
||||
bool di_PrnReady;
|
||||
bool di_CoinAttach;
|
||||
bool di_CoinEscrowOpen;
|
||||
bool di_mifCardTap;
|
||||
bool di_wakeFromModem;
|
||||
bool di_contactPwrOn;
|
||||
bool di_mifarePwrOn;
|
||||
bool di_rdbk_mdbTxd;
|
||||
bool di_AuxPwrOn;
|
||||
bool di_gsmPwrOn;
|
||||
bool di_creditPwrOn;
|
||||
bool di_printerPwrOn;
|
||||
bool di_mdbPwrOn;
|
||||
bool di_rejMot_home;
|
||||
uint8_t di_npe_sensor;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_11;
|
||||
#endif
|
||||
|
||||
uint8_t do_mbdRxTst;
|
||||
uint8_t do_motorBits;
|
||||
uint8_t do_serialSwitch;
|
||||
uint8_t do_ledsAndFan;
|
||||
uint8_t do_laermUndRelay;
|
||||
uint8_t do_ptuWake;
|
||||
uint8_t do_auxPower;
|
||||
uint8_t do_coinShutter;
|
||||
uint8_t do_coinEscrow;
|
||||
uint8_t do_printerPower;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_12;
|
||||
#endif
|
||||
|
||||
//#define NROFMIFSTATEBYTES 40
|
||||
//uint8_t Sdata_MIF_STATE[NROFMIFSTATEBYTES];
|
||||
uint8_t Sdata_MIF_DATA[64];
|
||||
//uint8_t mif_cardType;
|
||||
//uint8_t mif_cardHolder[8];
|
||||
uint8_t Sdata_MIF_ATB[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_13;
|
||||
#endif
|
||||
|
||||
#define pi_prnStateArraySize 20
|
||||
uint8_t Sdata_PRN_STATE[pi_prnStateArraySize];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_14;
|
||||
#endif
|
||||
|
||||
#define pi_prnFontArraySize 20
|
||||
uint8_t Sdata_PRN_FONTS[pi_prnFontArraySize];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_15;
|
||||
#endif
|
||||
|
||||
bool Sdata_mdb_busRdy;
|
||||
bool Sdata_mdb_V12on;
|
||||
bool Sdata_mdb_V5on;
|
||||
|
||||
uint8_t Sdata_mdbNrOfRecData;
|
||||
uint8_t Sdata_RecBuff[40];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_16;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_empNrOfsettings;
|
||||
uint8_t Sdata_emp_settingsBuff[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_17;
|
||||
#endif
|
||||
|
||||
struct T_coin
|
||||
{
|
||||
uint8_t valid;
|
||||
uint8_t signal;
|
||||
uint8_t error;
|
||||
uint8_t pad;
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
#define MEMDEPTH_GOTCOINS 16
|
||||
struct T_coin gotCoin[MEMDEPTH_GOTCOINS];
|
||||
uint8_t ctr_gotCoin;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_18;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_NrOfDeviceSetting;
|
||||
uint8_t Sdata_DeviceSettingBuff[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_19;
|
||||
#endif
|
||||
|
||||
uint8_t SizeMachineIDBuff;
|
||||
uint8_t MachineIDBuff[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_20;
|
||||
#endif
|
||||
|
||||
uint32_t store_insertedAmount;
|
||||
uint16_t store_lastCoinType[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_21;
|
||||
#endif
|
||||
|
||||
uint16_t store_lastCoinValue[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_22;
|
||||
#endif
|
||||
|
||||
uint8_t p_lastCoin;
|
||||
char store_curPayNewCoin;
|
||||
|
||||
uint64_t stor_wakSrc;
|
||||
uint8_t stor_reason;
|
||||
|
||||
uint8_t store_rbDevParamLen;
|
||||
uint8_t store_rbDevParams[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_23;
|
||||
#endif
|
||||
|
||||
uint8_t store_deviceCondLen;
|
||||
uint8_t store_deviceCond[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_24;
|
||||
#endif
|
||||
|
||||
uint8_t store_machCondLen;
|
||||
uint8_t store_machCond[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_25;
|
||||
#endif
|
||||
|
||||
uint8_t store_DcBackupNrOfAccNr;
|
||||
uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_26;
|
||||
#endif
|
||||
|
||||
#define PI_SIZOFVAULTRECORD 400
|
||||
uint8_t store_gotNrBlocksOfVaultRec;
|
||||
uint8_t store_vaultrecord[PI_SIZOFVAULTRECORD];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_27;
|
||||
#endif
|
||||
|
||||
uint32_t store_amount;
|
||||
uint16_t store_nrOfCoins;
|
||||
|
||||
bool store_DcDataAreValid;
|
||||
|
||||
uint8_t storeDCdynPrinterData[64];
|
||||
uint8_t DCdynPrinterDataActual;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_28;
|
||||
#endif
|
||||
|
||||
uint16_t store_DCNextAccountNumber;
|
||||
|
||||
uint16_t storeMifCardTypDataLen;
|
||||
uint8_t storeMcardTypData[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_29;
|
||||
#endif
|
||||
|
||||
// new from 6.9.23:
|
||||
#define RAW_BL_DATALEN 150
|
||||
uint8_t Sdata_rawData[RAW_BL_DATALEN];
|
||||
uint8_t Sdata_LengthRawData;
|
||||
|
||||
#define numberOfJsons 36
|
||||
#define versionStringLength 16
|
||||
char store_jsonVersion[versionStringLength][numberOfJsons];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_30;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_changeResult;
|
||||
uint32_t Sdata_changedAmount;
|
||||
uint8_t store_tubeLev[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_31;
|
||||
#endif
|
||||
|
||||
uint8_t store_bnaParameter[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_32;
|
||||
#endif
|
||||
|
||||
uint8_t store_bnaCollect[8];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_33;
|
||||
#endif
|
||||
|
||||
uint8_t store_bnaContent[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_34;
|
||||
#endif
|
||||
|
||||
|
||||
// Mitteilung von Hwapi zu Datif:
|
||||
bool Sdata_coinPaymentNow;
|
||||
bool Sdata_bootloadingNow;
|
||||
|
||||
|
||||
// ------------------ Data OUTPUT --------------------------------
|
||||
|
||||
// sendWRcmd.cpp
|
||||
#define CMDSTACKDEPTH 16
|
||||
uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH];
|
||||
uint8_t nrOfCmdsInQueue;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_35;
|
||||
#endif
|
||||
|
||||
#define CMD4STACKDEPTH 8
|
||||
uint16_t nextAsynchsendCmd4[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para1[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para2[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para3[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para4[CMD4STACKDEPTH];
|
||||
uint8_t nrOfCmds4InQueue;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_36;
|
||||
#endif
|
||||
|
||||
#define CMD8STACKDEPTH 4
|
||||
uint16_t nextAsynchsendCmd8[CMD8STACKDEPTH];
|
||||
uint8_t nextCmd8para1[CMD8STACKDEPTH];
|
||||
uint8_t nextCmd8para2[CMD8STACKDEPTH];
|
||||
uint16_t nextCmd8para3[CMD8STACKDEPTH];
|
||||
uint32_t nextCmd8para4[CMD8STACKDEPTH];
|
||||
uint8_t nrOfCmds8InQueue;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_37;
|
||||
#endif
|
||||
|
||||
#define SENDASYDAT_BUFFSIZE 200
|
||||
uint8_t sendAsynchDataBuf[SENDASYDAT_BUFFSIZE]; // no stack, only ONE buffer
|
||||
uint8_t sendAsyDatLen;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_38;
|
||||
#endif
|
||||
|
||||
#define MDBSEND_BUFFSIZE 64
|
||||
uint8_t Sdata_mdbSendBuffer[MDBSEND_BUFFSIZE];
|
||||
uint8_t Sdata_mdbSendLen;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_39;
|
||||
#endif
|
||||
|
||||
uint8_t prnDataParameters[4];
|
||||
uint8_t prnDataBufferUser;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_40;
|
||||
#endif
|
||||
|
||||
|
||||
// ONE printer doc consists of 20 x 64 byte
|
||||
#define MAXNROF_PRNBYTES 64
|
||||
#define MAXNROF_PRNBLOCKS 20
|
||||
char Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
|
||||
uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_41;
|
||||
#endif
|
||||
|
||||
//#define FDCMD_STACKDEPTH 16 // up to 1024 byte
|
||||
#define FDCMD_STACKDEPTH 32 // up to 2048 byte
|
||||
// header
|
||||
uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDshort[FDCMD_STACKDEPTH];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_42;
|
||||
#endif
|
||||
|
||||
// short data
|
||||
uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
||||
// long data:
|
||||
uint8_t longFDlength[FDCMD_STACKDEPTH];
|
||||
uint8_t longFDpara[FDCMD_STACKDEPTH][64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_43;
|
||||
#endif
|
||||
|
||||
uint8_t p_nextFDcmdsInQueue;
|
||||
|
||||
// download of device controller and json files
|
||||
struct DCDownload {
|
||||
enum class FILE_INDEX {
|
||||
DC_BINARY = 0, DC2C_CASH = 1, DC2C_CONF = 2, DC2C_SERIAL=3,
|
||||
DC2C_PRINT_01, DC2C_PRINT_02, DC2C_PRINT_03, DC2C_PRINT_04,
|
||||
DC2C_PRINT_05, DC2C_PRINT_06, DC2C_PRINT_07, DC2C_PRINT_08,
|
||||
DC2C_PRINT_09, DC2C_PRINT_10, DC2C_PRINT_11, DC2C_PRINT_12,
|
||||
DC2C_PRINT_13, DC2C_PRINT_14, DC2C_PRINT_15, DC2C_PRINT_16,
|
||||
DC2C_PRINT_17, DC2C_PRINT_18, DC2C_PRINT_19, DC2C_PRINT_20,
|
||||
DC2C_PRINT_21, DC2C_PRINT_22, DC2C_PRINT_23, DC2C_PRINT_24,
|
||||
DC2C_PRINT_25, DC2C_PRINT_26, DC2C_PRINT_27, DC2C_PRINT_28,
|
||||
DC2C_PRINT_29, DC2C_PRINT_30, DC2C_PRINT_31, DC2C_PRINT_32
|
||||
};
|
||||
char m_filename[(int)FILE_INDEX::DC2C_PRINT_32][512];
|
||||
std::atomic_ushort m_totalBlocks;
|
||||
std::atomic_ushort m_currentblockNumber;
|
||||
std::atomic_bool m_requested{false};
|
||||
std::atomic_bool m_running{false};
|
||||
std::atomic_bool m_finished{false};
|
||||
} m_downLoadDC;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_44;
|
||||
#endif
|
||||
|
||||
// meta-data
|
||||
char os_release[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_45;
|
||||
#endif
|
||||
|
||||
char date_of_creation[32];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_46;
|
||||
#endif
|
||||
|
||||
char creator[128]; // name of application plus pid
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_47;
|
||||
#endif
|
||||
|
||||
static QSharedMemory *getShm(std::size_t s = 0);
|
||||
|
||||
static SharedMem *getData()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem *)getShm()->data();
|
||||
}
|
||||
|
||||
static SharedMem const *getDataConst()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem const *)getShm()->data();
|
||||
}
|
||||
|
||||
// static SharedMemBuffer *write()
|
||||
static SharedMem *write()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem *)getShm()->data();
|
||||
}
|
||||
|
||||
// static SharedMemBuffer const *read()
|
||||
static SharedMem const *read()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem const *)getShm()->data();
|
||||
}
|
||||
|
||||
bool thisIsTheFirstUse(void);
|
||||
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_0;
|
||||
#endif
|
||||
|
||||
static void check_mem_guards() {
|
||||
#ifndef QT_NO_DEBUG
|
||||
static const char memcmp_array[48] = {0,};
|
||||
char mem[48];
|
||||
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
SharedMem const *d = (SharedMem const *)getShm()->data();
|
||||
|
||||
mem[0] = d->mem_guard_0;
|
||||
mem[1] = d->mem_guard_1; mem[2] = d->mem_guard_2; mem[3] = d->mem_guard_3;
|
||||
mem[4] = d->mem_guard_4; mem[5] = d->mem_guard_5; mem[6] = d->mem_guard_6;
|
||||
mem[7] = d->mem_guard_7; mem[8] = d->mem_guard_8; mem[9] = d->mem_guard_9;
|
||||
|
||||
mem[10] = d->mem_guard_10;
|
||||
mem[11] = d->mem_guard_11; mem[12] = d->mem_guard_12; mem[13] = d->mem_guard_13;
|
||||
mem[14] = d->mem_guard_14; mem[15] = d->mem_guard_15; mem[16] = d->mem_guard_16;
|
||||
mem[17] = d->mem_guard_17; mem[18] = d->mem_guard_18; mem[19] = d->mem_guard_19;
|
||||
|
||||
mem[20] = d->mem_guard_20;
|
||||
mem[21] = d->mem_guard_21; mem[22] = d->mem_guard_22; mem[23] = d->mem_guard_23;
|
||||
mem[24] = d->mem_guard_24; mem[25] = d->mem_guard_25; mem[26] = d->mem_guard_26;
|
||||
mem[27] = d->mem_guard_27; mem[28] = d->mem_guard_28; mem[29] = d->mem_guard_29;
|
||||
|
||||
mem[30] = d->mem_guard_30;
|
||||
mem[31] = d->mem_guard_31; mem[32] = d->mem_guard_32; mem[33] = d->mem_guard_33;
|
||||
mem[34] = d->mem_guard_34; mem[35] = d->mem_guard_35; mem[36] = d->mem_guard_36;
|
||||
mem[37] = d->mem_guard_37; mem[38] = d->mem_guard_38; mem[39] = d->mem_guard_39;
|
||||
|
||||
mem[40] = d->mem_guard_40;
|
||||
mem[41] = d->mem_guard_41; mem[42] = d->mem_guard_42; mem[43] = d->mem_guard_43;
|
||||
mem[44] = d->mem_guard_44; mem[45] = d->mem_guard_45; mem[46] = d->mem_guard_46;
|
||||
mem[47] = d->mem_guard_47;
|
||||
|
||||
if (memcmp(mem, memcmp_array, sizeof(memcmp_array))) {
|
||||
qCritical() << QByteArray(mem, sizeof(memcmp_array)).toHex(':');
|
||||
for (uint i = 0; i < sizeof(memcmp_array); ++i) {
|
||||
fprintf(stderr, "%02d -> %02x", i, (unsigned char)mem[i]);
|
||||
} fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SHARED_MEM_BUFFER_INCLUDED_H
|
@@ -1,40 +1,19 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = CAmaster
|
||||
VERSION="1.0.2"
|
||||
VERSION="1.0.0"
|
||||
|
||||
HEADERS += \
|
||||
../include/com.h \
|
||||
../include/datIf.h \
|
||||
../include/prot.h \
|
||||
../include/download_thread.h
|
||||
../include/prot.h
|
||||
|
||||
SOURCES += \
|
||||
../src/com.cpp \
|
||||
../src/datIf.cpp \
|
||||
../src/prot.cpp \
|
||||
../src/download_thread.cpp
|
||||
../src/prot.cpp
|
||||
|
||||
include(../DCLibraries.pri)
|
||||
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
BUILD_TIME=$$system("time /t")
|
||||
GIT_COMMIT=""
|
||||
EXTENDED_VERSION=""
|
||||
EXTENDED_VERSION_LIB=""
|
||||
} else {
|
||||
BUILD_DATE=$$system("date +%d-%m-%y")
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline . | cut -d' ' -f1")
|
||||
EXTENDED_VERSION_LIB="libCAmaster-$${VERSION}-$${GIT_COMMIT}"
|
||||
}
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION_LIB=\\\"$$EXTENDED_VERSION_LIB\\\"
|
||||
|
||||
DEFINES+=THIS_IS_CA_MASTER
|
||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||
|
@@ -1,35 +1,9 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = CAslave
|
||||
VERSION="1.0.2"
|
||||
|
||||
HEADERS += \
|
||||
../include/reporting_thread.h
|
||||
|
||||
SOURCES += \
|
||||
../src/reporting_thread.cpp
|
||||
VERSION="1.0.0"
|
||||
|
||||
include(../DCLibraries.pri)
|
||||
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
BUILD_TIME=$$system("time /t")
|
||||
GIT_COMMIT=""
|
||||
EXTENDED_VERSION=""
|
||||
EXTENDED_VERSION_LIB=""
|
||||
} else {
|
||||
BUILD_DATE=$$system("date +%d-%m-%y")
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline . | cut -d' ' -f1")
|
||||
EXTENDED_VERSION_LIB_="libCAslave-$${VERSION}-$${GIT_COMMIT}"
|
||||
}
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION_LIB=\\\"$$EXTENDED_VERSION_LIB\\\"
|
||||
|
||||
DEFINES+=THIS_IS_CA_SLAVE
|
||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||
|
||||
|
@@ -9,14 +9,10 @@ History:
|
||||
#include "sendWRcmd.h"
|
||||
#include "controlBus.h"
|
||||
#include "storeINdata.h"
|
||||
#include "download_thread.h"
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <datei.h>
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -58,10 +54,8 @@ static uint8_t datif_pNextCmd, datif_sendSlowCmd;
|
||||
//#define DATIF_CTR_GOTRESPVAL 100
|
||||
|
||||
|
||||
T_datif::T_datif(hwinf *hw, QObject *parent) : QObject(parent)
|
||||
T_datif::T_datif(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_hw = hw;
|
||||
|
||||
QByteArray myBA;
|
||||
QDir myDir("../dmd");
|
||||
|
||||
@@ -176,22 +170,10 @@ char T_datif::datif_cycleSend()
|
||||
// b) Antwort meldet Fehler -> 2x wiederholen (nach einer Luecke von 10ms )
|
||||
// c) gar keine Antwort, Timeout nach 100ms -> 2x wiederholen (nach einer Luecke von 10ms )
|
||||
// cycl_running=0: nichts zu tun 1: Mitteilung: Kommando wurde soeben abgesendet, 2,3,4 = Wiederholung
|
||||
if (cycl_running == 0) {
|
||||
if (m_hw) {
|
||||
if (m_hw->dcDownloadRequested()) { // only happens in ca-master
|
||||
qCritical() << "DOWNLOAD REQUESTED";
|
||||
if (!m_hw->dcDownloadThreadStart()) {
|
||||
qCritical() << "DOWNLOAD-THREAD NOT RUNNING WITHIN 1000ms";
|
||||
} else {
|
||||
qCritical() << "DOWNLOAD-THREAD RUNNING";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL)
|
||||
// if (cycl_running && doRepeat)
|
||||
|
||||
if (cycl_running) // 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL)
|
||||
// if (cycl_running && doRepeat)
|
||||
{
|
||||
// request is still running, wait for response before next sending
|
||||
//qDebug()<< "datif wait for response";
|
||||
datif_trigger->stop();
|
||||
|
@@ -1,440 +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() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): DOWNLOAD THREAD STARTED:";
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName();
|
||||
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
|
||||
#if 1
|
||||
QFile fn(m_hw->dcDownloadFileName());
|
||||
|
||||
if (!fn.exists()) {
|
||||
// output via CONSOLE() etc
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName() << "DOES NOT EXIST";;
|
||||
} else {
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): DC-CONTROLLER SW-VERSION BEFORE"
|
||||
<< m_hw->dc_getSWversion();
|
||||
|
||||
// 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));
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||
|
||||
m_hw->request_DC2_HWversion();
|
||||
m_hw->request_DC2_SWversion();
|
||||
QThread::sleep(1);
|
||||
|
||||
// m_hw->dc_autoRequest(false); // turn auto-request setting on
|
||||
|
||||
resetDeviceController();
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
|
||||
|
||||
if (startBootloader()) {
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STARTED BOOT-LOADER";
|
||||
|
||||
m_hw->dc_autoRequest(false);// turn auto-request setting off for
|
||||
// download of binary dc
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF FIRMWARE BLOCKS" << totalBlocks;
|
||||
|
||||
int currentBlock = 0; // download of binary dc
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
|
||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): currentBlockNumber ..." << currentBlock;
|
||||
|
||||
currentBlock += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< QString("DownloadThread::run(): last 64-byte block %1").arg(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(): currentBlockNumber" << currentBlock;
|
||||
// QThread::msleep(250);
|
||||
}
|
||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
|
||||
stopBootloader(); // stop bootloader several times: if it
|
||||
QThread::sleep(1); // is not stopped, then the PSA has to be
|
||||
}
|
||||
// restarted manually (!!!)
|
||||
stopBootloader();
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
|
||||
|
||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||
// if it was not started at all
|
||||
|
||||
m_hw->dc_autoRequest(true);
|
||||
}
|
||||
|
||||
#else // test
|
||||
// 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));
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||
|
||||
m_hw->request_DC2_HWversion();
|
||||
m_hw->request_DC2_SWversion();
|
||||
QThread::sleep(1);
|
||||
|
||||
resetDeviceController();
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
|
||||
QThread::sleep(1);
|
||||
|
||||
if (startBootloader()) {
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STARTED BOOT-LOADER";
|
||||
|
||||
m_hw->dc_autoRequest(false);// turn auto-request setting off for
|
||||
// download of binary dc
|
||||
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
|
||||
QThread::msleep(250);
|
||||
}
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on again
|
||||
}
|
||||
|
||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||
// if it was not started at all
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
|
||||
}
|
||||
#endif
|
||||
|
||||
m_hw->dcDownloadSetRunning(false);
|
||||
m_hw->dcDownloadSetFinished(true);
|
||||
|
||||
QDateTime const end = QDateTime::currentDateTime();
|
||||
quint64 secs = start.secsTo(end);
|
||||
QString runtime;
|
||||
if (secs % 60) {
|
||||
runtime = QString("%1min %2s").arg(secs / 60).arg(secs % 60);
|
||||
} else {
|
||||
runtime = QString("%1min").arg((secs / 60) + 1);
|
||||
}
|
||||
|
||||
qCritical() << end.time().toString(Qt::ISODateWithMs)
|
||||
<< QString("DOWNLOAD THREAD FINISHED (RUNTIME %1)")
|
||||
.arg(runtime);
|
||||
|
||||
// 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 ) {
|
||||
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;
|
||||
|
||||
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() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "starting bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_startBL();
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_startBL() ..." << nTry;
|
||||
QThread::msleep(500);
|
||||
m_hw->bl_checkBL();
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
|
||||
QThread::msleep(500);
|
||||
if (m_hw->bl_isUp()) {
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bootloader... isUP" << nTry;
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "bootloader not up (" << nTry << ")";
|
||||
}
|
||||
}
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "starting bootloader FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DownloadThread::stopBootloader() const {
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "stopping bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "bl_stopBL() ...";
|
||||
QThread::msleep(500);
|
||||
m_hw->bl_checkBL();
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
|
||||
if (!m_hw->bl_isUp()) {
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "stopping bootloader OK";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "stopping bootloader FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DownloadThread::resetDeviceController() const {
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "resetting device controller...";
|
||||
m_hw->bl_rebootDC();
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
QThread::sleep(1);
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "resetting device controller...OK";
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "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();
|
||||
}
|
306
src/hwapi.cpp
306
src/hwapi.cpp
@@ -20,14 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "hwapi.h"
|
||||
#include "download_thread.h"
|
||||
#include "reporting_thread.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
static uint32_t hwapi_lastStartAmount;
|
||||
static uint32_t hwapi_lastTotalAmount;
|
||||
@@ -41,12 +33,6 @@ static uint8_t bl_startupStep;
|
||||
hwapi::hwapi(QWidget *parent) : QObject(parent)
|
||||
{
|
||||
// constructor
|
||||
qCritical() << " hwapi::hwapi() APP_VERSION:" << APP_VERSION;
|
||||
qCritical() << " hwapi::hwapi() APP_BUILD_DATE:" << APP_BUILD_DATE;
|
||||
qCritical() << " hwapi::hwapi() APP_BUILD_TIME:" << APP_BUILD_TIME;
|
||||
qCritical() << " hwapi::hwapi() APP_EXTENDED_VERSION:" << APP_EXTENDED_VERSION;
|
||||
qCritical() << "hwapi::hwapi() APP_EXTENDED_VERSION_LIB:" << APP_EXTENDED_VERSION_LIB;
|
||||
|
||||
|
||||
// create or attach shared memory segment
|
||||
m_sharedMem = SharedMem::getShm(sizeof(SharedMem));
|
||||
@@ -59,11 +45,6 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
|
||||
qCritical() << "Creating/attaching shared memory failed";
|
||||
}
|
||||
|
||||
Q_ASSERT_X(sizeof(SharedMem) == m_sharedMem->size(), "check shm-sizes",
|
||||
QString("sizes different %1 != %2")
|
||||
.arg(sizeof(SharedMem))
|
||||
.arg(m_sharedMem->size()).toStdString().c_str());
|
||||
|
||||
//if (shdMem_firstUse()) // für Master raus
|
||||
// {
|
||||
|
||||
@@ -73,7 +54,7 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
|
||||
#error "SLAVE LIB COMPILED INTO MASTER"
|
||||
#endif
|
||||
|
||||
myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
|
||||
myDatif = new T_datif(); // für die CAslave-Lib auskommentieren!
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2640,23 +2621,12 @@ void hwapi::bl_openBinary(void) const
|
||||
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
|
||||
{
|
||||
// send 64 byte from bin file
|
||||
// gh, 09/02/2024: extend sendBuf. Buffer sometimes too small, sendLen=81
|
||||
uint8_t LL=length, sendBuf[80+32], sendLen;
|
||||
uint8_t LL=length, sendBuf[80], sendLen;
|
||||
if (LL>64) LL=64;
|
||||
|
||||
memset(sendBuf, 0, sizeof(sendBuf));
|
||||
tslib_strclr(sendBuf,0,80);
|
||||
sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame
|
||||
|
||||
// qCritical() << "(" __func__ << ":" << __LINE__ << ") sendLen=" << sendLen
|
||||
// << ":" << QByteArray((const char *)sendBuf, sendLen);
|
||||
|
||||
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
|
||||
|
||||
// if (sendLen > 80) {
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << QByteArray((const char *)&sendBuf[80], 32).toHex(':');
|
||||
// }
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
@@ -4417,274 +4387,4 @@ uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOf
|
||||
return anzahl;
|
||||
}
|
||||
|
||||
QObject const *hwapi::getAPI() {
|
||||
return this;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
|
||||
// called by worker-thread (see atbupdatetool)
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char *fNameBuffer = data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY];
|
||||
size_t const size = sizeof(data->m_downLoadDC.m_filename);
|
||||
|
||||
std::memset(fNameBuffer, 0x00, size);
|
||||
std::memcpy(fNameBuffer, dcFileToDownload.toStdString().c_str(),
|
||||
std::min(size, strlen(fNameBuffer)-1));
|
||||
|
||||
data->m_downLoadDC.m_totalBlocks = 0;
|
||||
data->m_downLoadDC.m_currentblockNumber = 0;
|
||||
|
||||
data->m_downLoadDC.m_requested = true;
|
||||
data->m_downLoadDC.m_running = false; // download thread is not running
|
||||
data->m_downLoadDC.m_finished = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRequested() const {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
Q_ASSERT_X(data != nullptr, "check", "pointer invalid");
|
||||
Q_ASSERT_X((void *)data == m_sharedMem->data(), "compare pointers", "pointers different");
|
||||
Q_ASSERT_X(sizeof(*data) == m_sharedMem->size(), "compare sizes", "sizes different");
|
||||
|
||||
// called by download-thread
|
||||
// 1: true at entry: reset atomically to false
|
||||
// 2: false at entry: no change
|
||||
return data ? data->m_downLoadDC.m_requested.exchange(false) : false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadResetRequest() const {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_requested = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRequestAck() const {
|
||||
// called by download-thread
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_running = true;
|
||||
data->m_downLoadDC.m_finished = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRunning() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
if (data) {
|
||||
int cnt = 10;
|
||||
while (--cnt > 0) {
|
||||
bool running = data->m_downLoadDC.m_running;
|
||||
bool finished = data->m_downLoadDC.m_finished;
|
||||
if ((running == true) && (finished == false)) {
|
||||
// see dcDownloadRequestAck()
|
||||
break;
|
||||
}
|
||||
if (cnt < 3) {
|
||||
qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished;
|
||||
}
|
||||
QThread::msleep(500);
|
||||
}
|
||||
// qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0);
|
||||
return (cnt > 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
|
||||
Q_UNUSED(dthread);
|
||||
// delete dthread;
|
||||
m_downloadThread = nullptr;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadFinished() {
|
||||
int cnt = 10;
|
||||
while (dcDownloadRunning()) {
|
||||
if (--cnt == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//if (cnt > 0) {
|
||||
// delete m_downloadThread;
|
||||
// m_downloadThread = nullptr;
|
||||
// return true;
|
||||
//}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// download thread
|
||||
|
||||
bool hwapi::dcDownloadThreadStart() {
|
||||
// called by timer in datIf.cpp: T_datif::datif_cycleSend()
|
||||
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->moveToThread(QApplication::instance()->thread());
|
||||
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 {
|
||||
// if the pointer to the underlying c++-object is not valid, the thread
|
||||
// counts as finished
|
||||
return m_reportingThread ? m_reportingThread->isFinished() : true;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportStart() const {
|
||||
int cnt = 10;
|
||||
while (--cnt > 0 && !dcDownloadRunning()) {
|
||||
QThread::msleep(200);
|
||||
}
|
||||
return (cnt == 0);
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportRunning() const {
|
||||
return dcDownloadReportThreadRunning();
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadReportFinished() {
|
||||
int cnt = 10;
|
||||
while (--cnt > 0 && !dcDownloadReportThreadFinished()) {
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
if (cnt == 0 && !dcDownloadReportThreadFinished()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dcDownloadReportThreadFinished()) {
|
||||
if (m_reportingThread) {
|
||||
delete m_reportingThread;
|
||||
m_reportingThread = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString hwapi::dcDownloadFileName() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY] : "";
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadSetRequested(bool requested) {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_requested = requested;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadSetRunning(bool running) {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_running = running;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadSetFinished(bool finished) {
|
||||
SharedMem *data = SharedMem::getData();
|
||||
if (data) {
|
||||
data->m_downLoadDC.m_finished = finished;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
|
||||
SharedMem::getData()->m_downLoadDC.m_totalBlocks = totalBlockNumber;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
|
||||
SharedMem::getData()->m_downLoadDC.m_currentblockNumber = currentBlockNumber;
|
||||
}
|
||||
|
||||
uint16_t hwapi::dcDownloadGetTotalBlockNumber() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_totalBlocks.load() : 0;
|
||||
}
|
||||
|
||||
uint16_t hwapi::dcDownloadGetCurrentBlockNumber() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_currentblockNumber.load() : 0;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadGetRequested() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_requested.load() : 0;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadGetRunning() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_running.load() : 0;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadGetFinished() const {
|
||||
SharedMem const *data = SharedMem::getDataConst();
|
||||
return data ? data->m_downLoadDC.m_running.load() : 0;
|
||||
}
|
||||
|
10
src/main.cpp
10
src/main.cpp
@@ -18,11 +18,11 @@ int main(int argc, char *argv[])
|
||||
#include <stdio.h>
|
||||
|
||||
// Must define the interpreter to be the dynamic linker
|
||||
//#ifdef __LP64__
|
||||
//#error "__LP64__ not defined for PTU5"
|
||||
//#else
|
||||
//const char service_interp[] __attribute__((section(".interp"))) = "/lib/ld-linux-armhf.so.3";
|
||||
//#endif
|
||||
#ifdef __LP64__
|
||||
#error "__LP64__ not defined for PTU5"
|
||||
#else
|
||||
const char service_interp[] __attribute__((section(".interp"))) = "/lib/ld-linux-armhf.so.3";
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@@ -1,210 +0,0 @@
|
||||
#include "reporting_thread.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "hwapi.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
ReportingThread::ReportingThread(hwapi *hw)
|
||||
: m_hw(hw)
|
||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
||||
// , m_f([](QString const&){}) {
|
||||
}
|
||||
|
||||
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().time().toString(Qt::ISODate)
|
||||
<< "START REPORT THREAD"
|
||||
<< "(PART OF APPLICATION" << QCoreApplication::applicationName() << ")";
|
||||
|
||||
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().time().toString(Qt::ISODate))
|
||||
.arg(cnt);
|
||||
qCritical() << "(" << __func__ << ":" << __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 totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
cnt = 10;
|
||||
while(--cnt > 0 && totalBlocks == 0) {
|
||||
totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 TOTAL BLOCKS=%2 (%3)")
|
||||
.arg(__LINE__).arg(totalBlocks).arg(cnt);
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 TOTAL BLOCKS=%2").arg(__LINE__).arg(totalBlocks);
|
||||
|
||||
if (totalBlocks) {
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
uint16_t currentBlockNumber = 0;
|
||||
uint16_t prevBlockNumber = ~0;
|
||||
uint64_t estimatedMinutesLeftMax = ~0ULL;
|
||||
uint64_t estimatedSecondsLeftMax = ~0ULL;
|
||||
uint64_t estimatedMinutesLeftPrev = 0;
|
||||
uint64_t estimatedSecondsLeftPrev = 0;
|
||||
|
||||
while (m_hw->dcDownloadGetRunning()) {
|
||||
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
||||
if (prevBlockNumber != currentBlockNumber) {
|
||||
double durationSecs = start.secsTo(QDateTime::currentDateTime());
|
||||
|
||||
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationSecs / currentBlockNumber) : durationSecs;
|
||||
uint64_t estimatedSecondsLeft = lround((timeAveragePerBlock * (totalBlocks - currentBlockNumber)));
|
||||
uint64_t estimatedMinutesLeft =
|
||||
((estimatedSecondsLeft % 60) == 0) ?
|
||||
(estimatedSecondsLeft / 60) :
|
||||
((estimatedSecondsLeft + 60) / 60);
|
||||
|
||||
estimatedSecondsLeft = (estimatedSecondsLeft % 60);
|
||||
|
||||
if ((estimatedMinutesLeft <= estimatedMinutesLeftMax)
|
||||
|| (estimatedSecondsLeft <= estimatedSecondsLeftMax)) {
|
||||
estimatedMinutesLeftMax = estimatedMinutesLeft;
|
||||
estimatedSecondsLeftMax = estimatedSecondsLeft;
|
||||
estimatedMinutesLeftPrev = estimatedMinutesLeft;
|
||||
estimatedSecondsLeftPrev = estimatedSecondsLeft;
|
||||
|
||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
|
||||
.arg(totalBlocks)
|
||||
.arg(currentBlockNumber)
|
||||
.arg(percent, 0, 'f', 2)
|
||||
.arg(estimatedMinutesLeft)
|
||||
.arg(estimatedSecondsLeft, 2);
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
<< QString("line=%1: RT report").arg(__LINE__) << report;
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
|
||||
} else {
|
||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
|
||||
.arg(totalBlocks)
|
||||
.arg(currentBlockNumber)
|
||||
.arg(percent, 0, 'f', 2)
|
||||
.arg(estimatedMinutesLeftPrev)
|
||||
.arg(estimatedSecondsLeftPrev, 2);
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
<< QString("line=%1: RT report").arg(__LINE__) << report;
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
}
|
||||
|
||||
prevBlockNumber = currentBlockNumber;
|
||||
}
|
||||
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().time().toString(Qt::ISODate) << __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__);
|
||||
}
|
@@ -641,11 +641,8 @@ void T_runProc::bl_rebootDC(void)
|
||||
// BL is working for 5s after power-on-reset.
|
||||
|
||||
uint8_t len, buf[20];
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
len=dcBL_restartDC(buf);
|
||||
|
||||
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
|
||||
sendWRcmd_setSendBlock160(len, buf);
|
||||
}
|
||||
|
||||
@@ -655,13 +652,8 @@ void T_runProc::bl_startBL(void)
|
||||
// otherwise the BL jumps to normal DC application
|
||||
uint8_t len, buf[20];
|
||||
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
len=dcBL_activatBootloader(buf);
|
||||
|
||||
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
|
||||
sendWRcmd_setSendBlock160(len, buf);
|
||||
|
||||
epi_setNowIsBootload(true);
|
||||
}
|
||||
|
||||
@@ -669,11 +661,8 @@ void T_runProc::bl_checkBL(void)
|
||||
{
|
||||
// call this function in order to get information, afterwards use "bl_isUp()"
|
||||
uint8_t len, buf[20];
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
len=dcBL_readFWversion(buf);
|
||||
|
||||
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
|
||||
sendWRcmd_setSendBlock160(len, buf);
|
||||
}
|
||||
|
||||
@@ -684,7 +673,6 @@ bool T_runProc::bl_isUp(void)
|
||||
|
||||
for (nn=0; nn<160; nn++) receivedData[nn]=0;
|
||||
LL=epi_getRawRecLength();
|
||||
|
||||
if (LL>0)
|
||||
{
|
||||
epi_getRawReceivedData(receivedData);
|
||||
@@ -697,24 +685,13 @@ bool T_runProc::bl_isUp(void)
|
||||
//epi_clrRawReceivedString();
|
||||
return true;
|
||||
}
|
||||
|
||||
// response to "start BL" { 2, 101, 48, 223, 131, 3}
|
||||
static uint8_t const cmp[6] = {0x02, 0x65, 0x30, 0xdf, 0x83, 0x03};
|
||||
|
||||
if (LL >= 6 && LL <= 13) {
|
||||
// (1) "02:63:34:35:62:33:03:02:65:30:df:83:03"
|
||||
// (2) "02:65:30:df:83:03"
|
||||
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__
|
||||
// << ") CHECK" << QByteArray((char const*)receivedData, LL).toHex(':');
|
||||
|
||||
for (int i=0; i <= LL-6; ++i) {
|
||||
if (memcmp(cmp, &receivedData[i], 6) == 0) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__
|
||||
<< ") BL RESPONSE to bl_start(): BOOTLOADER IS UP";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// response to "start BL"
|
||||
if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 &&
|
||||
receivedData[3]==223 && receivedData[4] ==131 )
|
||||
{
|
||||
qDebug() << "hwapi_bl_isUp: got BL response to start";
|
||||
//epi_clrRawReceivedString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@@ -1,13 +1,7 @@
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
#include <QCoreApplication>
|
||||
#include <atomic>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef QT_POSIX_IPC
|
||||
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
||||
@@ -15,124 +9,33 @@
|
||||
// macro will be defined. -> we use SystemV shared memory
|
||||
#error "QT_POSIX_IPC defined"
|
||||
#else
|
||||
#ifdef linux
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef __linux__
|
||||
#include <sys/ipc.h> // ftok
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//static bool shdMemFirstUse;
|
||||
|
||||
static QString read1stLineOfFile(QString fileName) { // read for instance /etc/os-release
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
return in.readLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
|
||||
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||
static QSharedMemory shMem;
|
||||
if (size > 0) {
|
||||
#ifdef linux
|
||||
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||
//static const QString fkey = "0123456?000=7";
|
||||
#ifdef __linux__
|
||||
//static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||
//static const QString fkey = std::to_string(nativeKey).c_str();
|
||||
static const QString fkey = "0123456?000=7";
|
||||
#else
|
||||
static const QString fkey = "0123456?000=9";
|
||||
#endif
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": size" << size;
|
||||
|
||||
shMem.setKey(fkey);
|
||||
if (!shMem.isAttached()) {
|
||||
if (shMem.create(size)) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": created shared memory";
|
||||
|
||||
#ifdef linux
|
||||
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "size=" << size
|
||||
<< "shMem.size=" << shMem.size()
|
||||
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||
<< "ABOUT TO REBOOT SYSTEM...";
|
||||
if (system("reboot")) {
|
||||
// reboot system -> shared memory re-created
|
||||
}
|
||||
}
|
||||
|
||||
struct SharedMem *sh = (SharedMem *)(shMem.data());
|
||||
|
||||
memset(sh->indat_HWversion, 0x00, sizeof(sh->indat_HWversion));
|
||||
memset(sh->indat_SWversion, 0x00, sizeof(sh->indat_SWversion));
|
||||
|
||||
memset(sh->os_release, 0x00, sizeof(sh->os_release));
|
||||
memset(sh->date_of_creation, 0x00, sizeof(sh->date_of_creation));
|
||||
memset(sh->creator, 0x00, sizeof(sh->creator));
|
||||
|
||||
QString const &os_release = read1stLineOfFile("/etc/os-release");
|
||||
strncpy(sh->os_release, os_release.toStdString().c_str(),
|
||||
std::min((int)os_release.size(), (int)sizeof(sh->os_release)-1));
|
||||
|
||||
QString const ¤tDateTime = QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||
char const *current = currentDateTime.toUtf8().constData();
|
||||
strncpy(sh->date_of_creation, current,
|
||||
std::min((int)strlen(current), (int)sizeof(sh->date_of_creation)-1));
|
||||
|
||||
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
strncpy(sh->creator, appPid.toStdString().c_str(),
|
||||
std::min((int)strlen(appPid.toStdString().c_str()),
|
||||
(int)sizeof(sh->creator)-1));
|
||||
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
|
||||
#else
|
||||
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||
#endif
|
||||
return &shMem;
|
||||
} else {
|
||||
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||
if (shMem.attach()) {
|
||||
#ifdef linux
|
||||
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "size=" << size
|
||||
<< "shMem.size=" << shMem.size()
|
||||
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||
<< "ABOUT TO REBOOT SYSTEM...";
|
||||
if (system("reboot")) {
|
||||
// reboot system -> shared memory re-created
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||
#endif
|
||||
|
||||
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << appPid << "attached shared memory";
|
||||
|
||||
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
|
||||
return &shMem;
|
||||
}
|
||||
}
|
||||
@@ -140,13 +43,6 @@ QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||
<< shMem.error() << shMem.errorString();
|
||||
return nullptr;
|
||||
} else {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "shared memory already attached";
|
||||
|
||||
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
}
|
||||
}
|
||||
return &shMem;
|
||||
|
@@ -1,232 +0,0 @@
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
#include <QCoreApplication>
|
||||
#include <atomic>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef QT_POSIX_IPC
|
||||
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
||||
// option to the Qt configure script. If it is enabled, the QT_POSIX_IPC
|
||||
// macro will be defined. -> we use SystemV shared memory
|
||||
#error "QT_POSIX_IPC defined"
|
||||
#else
|
||||
#ifdef linux
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ipc.h> // ftok
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//static bool shdMemFirstUse;
|
||||
|
||||
static QString read1stLineOfFile(QString fileName) { // read for instance /etc/os-release
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
return in.readLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
|
||||
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||
static QSharedMemory shMem;
|
||||
if (size > 0) {
|
||||
#ifdef linux
|
||||
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||
//static const QString fkey = "0123456?000=7";
|
||||
#else
|
||||
static const QString fkey = "0123456?000=9";
|
||||
#endif
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": size" << size;
|
||||
|
||||
shMem.setKey(fkey);
|
||||
if (!shMem.isAttached()) {
|
||||
if (shMem.create(size)) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": created shared memory";
|
||||
|
||||
#ifdef linux
|
||||
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "size=" << size
|
||||
<< "shMem.size=" << shMem.size()
|
||||
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||
<< "ABOUT TO REBOOT SYSTEM...";
|
||||
if (system("reboot")) {
|
||||
// reboot system -> shared memory re-created
|
||||
}
|
||||
}
|
||||
|
||||
struct SharedMem *sh = (SharedMem *)(shMem.data());
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
sh->mem_guard_0 = 0;
|
||||
sh->mem_guard_1 = 0; sh->mem_guard_2 = 0; sh->mem_guard_3 = 0;
|
||||
sh->mem_guard_4 = 0; sh->mem_guard_5 = 0; sh->mem_guard_6 = 0;
|
||||
sh->mem_guard_7 = 0; sh->mem_guard_8 = 0; sh->mem_guard_9 = 0;
|
||||
|
||||
sh->mem_guard_10 = 0;
|
||||
sh->mem_guard_11 = 0; sh->mem_guard_12 = 0; sh->mem_guard_13 = 0;
|
||||
sh->mem_guard_14 = 0; sh->mem_guard_15 = 0; sh->mem_guard_16 = 0;
|
||||
sh->mem_guard_17 = 0; sh->mem_guard_18 = 0; sh->mem_guard_19 = 0;
|
||||
|
||||
sh->mem_guard_20 = 0;
|
||||
sh->mem_guard_21 = 0; sh->mem_guard_22 = 0; sh->mem_guard_23 = 0;
|
||||
sh->mem_guard_24 = 0; sh->mem_guard_25 = 0; sh->mem_guard_26 = 0;
|
||||
sh->mem_guard_27 = 0; sh->mem_guard_28 = 0; sh->mem_guard_29 = 0;
|
||||
|
||||
sh->mem_guard_30 = 0;
|
||||
sh->mem_guard_31 = 0; sh->mem_guard_32 = 0; sh->mem_guard_33 = 0;
|
||||
sh->mem_guard_34 = 0; sh->mem_guard_35 = 0; sh->mem_guard_36 = 0;
|
||||
sh->mem_guard_37 = 0; sh->mem_guard_38 = 0; sh->mem_guard_39 = 0;
|
||||
|
||||
sh->mem_guard_40 = 0;
|
||||
sh->mem_guard_41 = 0; sh->mem_guard_42 = 0; sh->mem_guard_43 = 0;
|
||||
sh->mem_guard_44 = 0; sh->mem_guard_45 = 0; sh->mem_guard_46 = 0;
|
||||
sh->mem_guard_47 = 0;
|
||||
#endif
|
||||
|
||||
memset(sh->indat_HWversion, 0x00, sizeof(sh->indat_HWversion));
|
||||
memset(sh->indat_SWversion, 0x00, sizeof(sh->indat_SWversion));
|
||||
|
||||
memset(sh->os_release, 0x00, sizeof(sh->os_release));
|
||||
memset(sh->date_of_creation, 0x00, sizeof(sh->date_of_creation));
|
||||
memset(sh->creator, 0x00, sizeof(sh->creator));
|
||||
|
||||
QString const &os_release = read1stLineOfFile("/etc/os-release");
|
||||
strncpy(sh->os_release, os_release.toStdString().c_str(),
|
||||
std::min((int)os_release.size(), (int)sizeof(sh->os_release)-1));
|
||||
|
||||
QString const ¤tDateTime = QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||
char const *current = currentDateTime.toUtf8().constData();
|
||||
strncpy(sh->date_of_creation, current,
|
||||
std::min((int)strlen(current), (int)sizeof(sh->date_of_creation)-1));
|
||||
|
||||
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
strncpy(sh->creator, appPid.toStdString().c_str(),
|
||||
std::min((int)strlen(appPid.toStdString().c_str()),
|
||||
(int)sizeof(sh->creator)-1));
|
||||
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
|
||||
#else
|
||||
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||
#endif
|
||||
return &shMem;
|
||||
} else {
|
||||
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||
if (shMem.attach()) {
|
||||
#ifdef linux
|
||||
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "size=" << size
|
||||
<< "shMem.size=" << shMem.size()
|
||||
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||
<< "ABOUT TO REBOOT SYSTEM...";
|
||||
if (system("reboot")) {
|
||||
// reboot system -> shared memory re-created
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||
#endif
|
||||
|
||||
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << appPid << "attached shared memory";
|
||||
|
||||
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
|
||||
return &shMem;
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||
<< shMem.error() << shMem.errorString();
|
||||
return nullptr;
|
||||
} else {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "shared memory already attached";
|
||||
|
||||
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
}
|
||||
}
|
||||
return &shMem;
|
||||
}
|
||||
|
||||
|
||||
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
||||
/*
|
||||
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||
|
||||
static QSharedMemory shMem;
|
||||
if (size > 0) {
|
||||
#ifdef __linux__
|
||||
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||
#else
|
||||
static const QString fkey = "0123456?000=9";
|
||||
#endif
|
||||
shdMemFirstUse=false;
|
||||
shMem.setKey(fkey);
|
||||
if (!shMem.isAttached())
|
||||
{
|
||||
if (shMem.create(size))
|
||||
{
|
||||
// sm was created successful, did not exist before
|
||||
shdMemFirstUse=true;
|
||||
return &shMem;
|
||||
} else
|
||||
{
|
||||
// create was false because mem already existed
|
||||
if (shMem.error() == QSharedMemory::AlreadyExists)
|
||||
{
|
||||
if (shMem.attach())
|
||||
{
|
||||
return &shMem;
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||
<< shMem.error() << shMem.errorString();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return &shMem;
|
||||
}
|
||||
|
||||
|
||||
bool shdMem_firstUse(void)
|
||||
{
|
||||
return shdMemFirstUse;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -6,15 +6,12 @@
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "datei.h"
|
||||
|
||||
#include <QTextCodec>
|
||||
|
||||
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// store power on/off condition of the devices to control the data request
|
||||
|
||||
//static bool indat_savePrnPwr;
|
||||
@@ -66,64 +63,66 @@ bool indat_isMdbOn()
|
||||
|
||||
void gpi_storeHWver(QString text)
|
||||
{
|
||||
QString prev(QByteArray(SharedMem::read()->indat_HWversion, versionBufferLen-1));
|
||||
prev = prev.trimmed();
|
||||
// change Qstring to array of chars, because shared mem allowes no QString!
|
||||
int nn, LL = text.length();
|
||||
if (LL >= versionBufferLen)
|
||||
LL=versionBufferLen-1; // leave place for termination
|
||||
|
||||
QString const textTruncated = text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||
|
||||
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||
&& textTruncated != prev) {
|
||||
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||
if (!string.isEmpty()) {
|
||||
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
|
||||
char *p = (char *)SharedMem::write()->indat_HWversion;
|
||||
char *q = (char *)string.constData();
|
||||
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||
if (q[j]) {
|
||||
*p++ = q[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (nn=0; nn<LL; nn++)
|
||||
{
|
||||
SharedMem::write()->indat_HWversion[nn] = text.at(nn).toLatin1();
|
||||
}
|
||||
for (nn=LL; nn<versionBufferLen; nn++)
|
||||
SharedMem::write()->indat_HWversion[nn] =0;
|
||||
}
|
||||
|
||||
QString epi_loadHWver(void)
|
||||
{
|
||||
QString text(SharedMem::read()->indat_HWversion);
|
||||
return text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||
// load array of chars from SM and change to QString
|
||||
int nn, LL = versionBufferLen;
|
||||
char cc;
|
||||
QString myStr;
|
||||
|
||||
myStr.clear();
|
||||
|
||||
for (nn=0; nn<LL; nn++)
|
||||
{
|
||||
cc = SharedMem::read()->indat_HWversion[nn];
|
||||
myStr.append(cc);
|
||||
}
|
||||
return myStr;
|
||||
}
|
||||
|
||||
void gpi_storeSWver(QString text)
|
||||
{
|
||||
QString prev(QByteArray(SharedMem::read()->indat_SWversion, 12));
|
||||
prev = prev.trimmed();
|
||||
int nn, LL = text.length();
|
||||
if (LL >= versionBufferLen)
|
||||
LL=versionBufferLen-1; // leave place for termination
|
||||
|
||||
QString const textTruncated = text.mid(0, qMin(12, text.size())).trimmed();
|
||||
|
||||
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||
&& textTruncated != prev) {
|
||||
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||
if (!string.isEmpty()) {
|
||||
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
|
||||
char *p = (char *)SharedMem::write()->indat_SWversion;
|
||||
char *q = (char *)string.constData();
|
||||
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||
if (q[j]) {
|
||||
*p++ = q[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (nn=0; nn<LL; nn++)
|
||||
{
|
||||
SharedMem::write()->indat_SWversion[nn] = text.at(nn).toLatin1();
|
||||
}
|
||||
for (nn=LL; nn<versionBufferLen; nn++)
|
||||
SharedMem::write()->indat_SWversion[nn] =0;
|
||||
|
||||
}
|
||||
|
||||
QString epi_loadSWver(void)
|
||||
{
|
||||
QString text(SharedMem::read()->indat_SWversion);
|
||||
return text.mid(0, qMin(12, text.size())).trimmed();
|
||||
int nn, LL = versionBufferLen;
|
||||
char cc;
|
||||
QString myStr;
|
||||
|
||||
myStr.clear();
|
||||
|
||||
for (nn=0; nn<LL; nn++)
|
||||
{
|
||||
cc = SharedMem::read()->indat_SWversion[nn];
|
||||
myStr.append(cc);
|
||||
}
|
||||
return myStr;
|
||||
|
||||
}
|
||||
|
||||
void gpi_storeDCstate(QString text)
|
||||
@@ -2203,8 +2202,8 @@ void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData)
|
||||
SharedMem::write()->Sdata_LengthRawData=lrd;
|
||||
for (nn=0; nn<lrd; nn++)
|
||||
SharedMem::write()->Sdata_rawData[nn]=receivedData[nn];
|
||||
|
||||
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
||||
|
||||
}
|
||||
|
||||
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
|
||||
|
Reference in New Issue
Block a user