Compare commits
48 Commits
1.4.9
...
11524b8389
Author | SHA1 | Date | |
---|---|---|---|
11524b8389 | |||
6663866743 | |||
12aa9a734a | |||
9b6f5db8fe | |||
061c57ef51 | |||
e82417dde7 | |||
1e271201c5 | |||
da66d75a45 | |||
7accabfa53 | |||
201a1cbab9 | |||
9a9cce126a | |||
da0fa54d28 | |||
1433c107b3 | |||
8e0732cf95 | |||
8f6e1fdae7 | |||
0d00faf493 | |||
5beb235d92 | |||
a4bb993217 | |||
50357997c2 | |||
c02f0b08ed | |||
5da1eff41a | |||
af89c9fbc1 | |||
fa7d1ba879 | |||
1dc7578645 | |||
cd30cc91f0 | |||
6683b925aa | |||
336d208906 | |||
2da3c34d84 | |||
8f0a9112d6 | |||
25bf905a79 | |||
5d141b7234
|
|||
ebb170123e | |||
96bb70cfe9
|
|||
8c1da92ff4
|
|||
3e1a4ab09c | |||
ee203e7672 | |||
55c82eb509 | |||
f60cd9e4ef | |||
a9fb7a3630 | |||
db82f2af0d | |||
8b2e2d2086 | |||
5870f61395 | |||
aaa0f1e76c | |||
0d9a224977 | |||
d191020caa | |||
2b68242d04 | |||
bd785e7df1 | |||
f2534c7763 |
@@ -1,5 +1,5 @@
|
||||
[REPOSITORY_URL]
|
||||
repository-url="https://git.mimbach49.de/GerhardHoffmann"
|
||||
repository-url="gitea@ptu-config.atb-comm.de:ATB/"
|
||||
|
||||
[DIRECTORIES]
|
||||
plugin-directory="/usr/lib/"
|
||||
|
@@ -80,6 +80,7 @@ SOURCES += \
|
||||
mainwindow.cpp \
|
||||
../common/src/message_handler.cpp \
|
||||
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
||||
../UpdatePTUDevCtrl/process/command.cpp \
|
||||
update.cpp \
|
||||
dc_download.cpp \
|
||||
../common/src/System.cpp
|
||||
@@ -89,6 +90,7 @@ HEADERS += \
|
||||
mainwindow.h \
|
||||
../common/include/message_handler.h \
|
||||
../UpdatePTUDevCtrl/commandline_parser.h \
|
||||
../UpdatePTUDevCtrl/process/command.h \
|
||||
update.h \
|
||||
dc_download.h \
|
||||
../common/include/System.h
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "dc_download.h"
|
||||
#include "hwapi.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <QThread>
|
||||
|
@@ -55,7 +55,7 @@ int main(int argc, char **argv) {
|
||||
openlog("ATB-UPDATE-DC-FIRMWARE", LOG_PERROR | LOG_PID | LOG_CONS, LOG_USER);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setApplicationName("ATBUpdateTool");
|
||||
QApplication::setApplicationName("ATBDownloadDCFirmware");
|
||||
QApplication::setApplicationVersion(APP_VERSION);
|
||||
|
||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||
@@ -73,6 +73,7 @@ int main(int argc, char **argv) {
|
||||
QString workingDir = parser.workingDir();
|
||||
QString psaConfigDir = parser.psaConfigDir();
|
||||
QString psaTariffDir = parser.psaTariffDir();
|
||||
QString dcDir = parser.dcDir();
|
||||
QString iniFileName = parser.iniFileName();
|
||||
bool const dryRun = parser.dryRun();
|
||||
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
||||
@@ -81,6 +82,7 @@ int main(int argc, char **argv) {
|
||||
bool const showExtendedVersion = parser.extendedVersion();
|
||||
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
|
||||
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
|
||||
bool const readDCVersion = parser.readDCVersion();
|
||||
|
||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||
|
||||
@@ -109,26 +111,37 @@ int main(int argc, char **argv) {
|
||||
qInfo() << "machineNr ................" << machineNr;
|
||||
qInfo() << "customerNr ..............." << customerNr;
|
||||
qInfo() << "zoneNr ..................." << zoneNr;
|
||||
qInfo() << "readDCVersion ............" << readDCVersion;
|
||||
qInfo() << "dcDir ...................." << dcDir;
|
||||
|
||||
if (readDCVersion) {
|
||||
qInfo() << "dc-version ..............." << Update::dcVersion(
|
||||
QDir::cleanPath(rtPath + QDir::separator()
|
||||
+ QString("customer_%1").arg(customerNr) + QDir::separator()
|
||||
+ dcDir + QDir::separator() + "dc2c.bin"));
|
||||
}
|
||||
|
||||
if (showExtendedVersion) {
|
||||
printf(APP_EXTENDED_VERSION"\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||
QStringList filesToUpdate;
|
||||
|
||||
// QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||
// QStringList filesToUpdate;
|
||||
|
||||
QThread::currentThread()->setObjectName("main thread");
|
||||
qInfo() << "Main thread" << QThread::currentThreadId();
|
||||
|
||||
MainWindow mw;
|
||||
// MainWindow mw;
|
||||
|
||||
mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||
//mw.showFullScreen();
|
||||
// mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||
// mw.showFullScreen();
|
||||
|
||||
qCritical() << "SHOW";
|
||||
// qCritical() << "SHOW";
|
||||
|
||||
mw.show();
|
||||
// mw.show();
|
||||
|
||||
return a.exec();
|
||||
return 0;
|
||||
// return a.exec();
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#include "update.h"
|
||||
#include "process/command.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
@@ -21,6 +22,8 @@
|
||||
#include <QDateTime>
|
||||
#include <QPluginLoader>
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
|
||||
#define UPDATE_OPKG (1)
|
||||
#define UPDATE_DC (0)
|
||||
@@ -92,6 +95,20 @@ bool Update::unloadDCPlugin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Update::dcVersion(QString const &dcBinFile) {
|
||||
Command c("bash");
|
||||
QStringList param;
|
||||
|
||||
param << "-c" << QString(R"(strings %1 | grep DC2c.\[0-9\] | uniq)").arg(dcBinFile);
|
||||
|
||||
if (c.execute("/tmp", param)) {
|
||||
return c.getCommandResult().trimmed().split(QRegularExpression("\\s")).first();
|
||||
// qInfo() << "(" << __func__ << ":" << __LINE__ << ")" << v;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
class hwapi;
|
||||
Update::Update(QString customerRepository,
|
||||
QString customerNrStr,
|
||||
@@ -118,19 +135,8 @@ Update::Update(QString customerRepository,
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin loaded ???";
|
||||
} else {
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
if (--tries < 0) {
|
||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
break;
|
||||
}
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||
<< m_sys_areDCdataValid;
|
||||
// carun stoppen
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +144,233 @@ Update::~Update() {
|
||||
unloadDCPlugin();
|
||||
}
|
||||
|
||||
bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
||||
Update::DownloadResult Update::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;
|
||||
}
|
||||
|
||||
Update::DownloadResult
|
||||
Update::sendNextAddress(int bNum) const {
|
||||
// sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||
// qDebug() << "addr-block" << bNum << "...";
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
QThread::msleep(100);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "addr-block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else { // res == DownloadResult::OK
|
||||
qCritical() << "addr-block" << bNum << "...OK";
|
||||
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;
|
||||
}
|
||||
|
||||
Update::DownloadResult
|
||||
Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
uint8_t local[66];
|
||||
int const bAddr = bNum * 64;
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
memcpy(local, binary.constData() + bAddr, 64);
|
||||
local[64] = local[65] = 0x00;
|
||||
|
||||
// QByteArray b((const char *)(&local[0]), 64);
|
||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
||||
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
QThread::msleep(10);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "data for block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "data for block" << bNum << "OK";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
|
||||
bool Update::startBootloader() const {
|
||||
qDebug() << "starting bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_startBL();
|
||||
QThread::msleep(5000);
|
||||
m_hw->bl_checkBL();
|
||||
if (m_hw->bl_isUp()) {
|
||||
qInfo() << "starting bootloader...OK";
|
||||
QThread::msleep(5000);
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << "bootloader not up (" << nTry << ")";
|
||||
}
|
||||
}
|
||||
qCritical() << "starting bootloader...FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::stopBootloader() const {
|
||||
qDebug() << "stopping bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
QThread::msleep(500);
|
||||
if (!m_hw->bl_isUp()) {
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
qCritical() << "stopping bootloader...FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::resetDeviceController() const {
|
||||
qDebug() << "resetting device controller...";
|
||||
m_hw->bl_rebootDC();
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
QThread::sleep(1);
|
||||
qInfo() << "resetting device controller...OK";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QByteArray Update::loadBinaryDCFile(QString const &filename) const {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "loading dc binary" << filename << "...";
|
||||
|
||||
QFile file(filename); // closed in destructor call
|
||||
if (!file.exists()) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< file.fileName() << "does not exist";
|
||||
return QByteArray();
|
||||
}
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "cannot open file" << file.fileName();
|
||||
return QByteArray();
|
||||
}
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "loading dc binary" << filename << "...OK";
|
||||
|
||||
return file.readAll();
|
||||
}
|
||||
/*
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
*/
|
||||
bool Update::doUpdate() {
|
||||
//QString const &fToWorkOn = usbStickDetected ? QDir::cleanPath(it->trimmed())
|
||||
//: QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
@@ -146,66 +378,58 @@ bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
if (--tries < 0) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
|
||||
return false;
|
||||
}
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
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);
|
||||
|
||||
bool res = false;
|
||||
// fill last block of data to be sent with 0xFF
|
||||
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||
|
||||
QList<QString>::const_iterator it;
|
||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||
QString const &fToWorkOn = usbStickDetected ? QDir::cleanPath(it->trimmed())
|
||||
: QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
||||
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
||||
if ((templateIdx < 1) || (templateIdx > 32)) {
|
||||
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
|
||||
res = false;
|
||||
} else {
|
||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||
qCritical() <<
|
||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||
.arg(fToWorkOn)
|
||||
.arg(templateIdx);
|
||||
resetDeviceController();
|
||||
if (startBootloader()) {
|
||||
|
||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||
|
||||
int currentBlock = 0;
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
qCritical() << "64-byte block " << currentBlock;
|
||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
currentBlock += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
if ((res = updateCashConf(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
|
||||
|
||||
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
||||
|
||||
int const rest = ba.size() % 64;
|
||||
int const offset = ba.size() - rest;
|
||||
char const *startAddress = ba.constData() + offset;
|
||||
|
||||
if (rest > 0) {
|
||||
// SHOULD NEVER HAPPEN !!!
|
||||
uint8_t local[66];
|
||||
memset(local, 0xFF, sizeof(local));
|
||||
memcpy(local, startAddress, rest);
|
||||
qCritical() << "DownloadThread::run(): ERROR SEND REMAINING" << rest << "BYTES";
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
} else {
|
||||
m_hw->bl_sendLastBlock();
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
if ((res = updateConfig(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||
res = false;
|
||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
}
|
||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||
}
|
||||
|
||||
return res;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
@@ -436,3 +660,4 @@ bool Update::updateCashConf(QString jsFile) {
|
||||
bool Update::updateDeviceConf(QString jsFile) {
|
||||
return downloadJson(FileTypeJson::DEVICE, 0, jsFile);
|
||||
}
|
||||
#endif
|
||||
|
@@ -58,72 +58,22 @@ public:
|
||||
|
||||
virtual ~Update() override;
|
||||
|
||||
bool doUpdate(QStringList const &jsonFilesToDownload, bool usbStickDetected = false);
|
||||
bool doUpdate();
|
||||
static QString dcVersion(QString const &dcBinFile);
|
||||
|
||||
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
||||
bool updateConfig(QString jsFileToSendToDC);
|
||||
bool updateCashConf(QString jsFileToSendToDC);
|
||||
bool updateDeviceConf(QString jsFileToSendToDC);
|
||||
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 const &dcFilename) const;
|
||||
bool resetDeviceController() const;
|
||||
DownloadResult dcDownloadBinary(QByteArray const &b) const;
|
||||
|
||||
bool downloadJson(enum FileTypeJson type, int templateIdx,
|
||||
QString jsFileToSendToDC) const;
|
||||
QString m_fileToDownload;
|
||||
|
||||
|
||||
QString getFileVersion(QString const& jsonFileName);
|
||||
bool checkJsonVersions(QStringList const& jsonFileNames =
|
||||
QStringList(
|
||||
QList(
|
||||
std::initializer_list<QString>{
|
||||
QString("etc/psa_config/DC2C_conf.json"),
|
||||
QString("etc/psa_config/DC2C_cash.json"),
|
||||
QString("etc/psa_config/DC2C_device.json"),
|
||||
QString("etc/psa_config/DC2C_print01.json"),
|
||||
QString("etc/psa_config/DC2C_print02.json"),
|
||||
QString("etc/psa_config/DC2C_print03.json"),
|
||||
QString("etc/psa_config/DC2C_print04.json"),
|
||||
QString("etc/psa_config/DC2C_print05.json"),
|
||||
QString("etc/psa_config/DC2C_print06.json"),
|
||||
QString("etc/psa_config/DC2C_print07.json"),
|
||||
QString("etc/psa_config/DC2C_print08.json"),
|
||||
QString("etc/psa_config/DC2C_print09.json"),
|
||||
QString("etc/psa_config/DC2C_print10.json"),
|
||||
QString("etc/psa_config/DC2C_print11.json"),
|
||||
QString("etc/psa_config/DC2C_print12.json"),
|
||||
QString("etc/psa_config/DC2C_print13.json"),
|
||||
QString("etc/psa_config/DC2C_print14.json"),
|
||||
QString("etc/psa_config/DC2C_print15.json"),
|
||||
QString("etc/psa_config/DC2C_print16.json"),
|
||||
QString("etc/psa_config/DC2C_print17.json"),
|
||||
QString("etc/psa_config/DC2C_print18.json"),
|
||||
QString("etc/psa_config/DC2C_print19.json"),
|
||||
QString("etc/psa_config/DC2C_print20.json"),
|
||||
QString("etc/psa_config/DC2C_print21.json"),
|
||||
QString("etc/psa_config/DC2C_print22.json"),
|
||||
QString("etc/psa_config/DC2C_print23.json"),
|
||||
QString("etc/psa_config/DC2C_print24.json"),
|
||||
QString("etc/psa_config/DC2C_print25.json"),
|
||||
QString("etc/psa_config/DC2C_print26.json"),
|
||||
QString("etc/psa_config/DC2C_print27.json"),
|
||||
QString("etc/psa_config/DC2C_print28.json"),
|
||||
QString("etc/psa_config/DC2C_print29.json"),
|
||||
QString("etc/psa_config/DC2C_print30.json"),
|
||||
QString("etc/psa_config/DC2C_print31.json"),
|
||||
QString("etc/psa_config/DC2C_print32.json")})));
|
||||
/*
|
||||
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
||||
|
||||
hwinf *hw() { return m_hw; }
|
||||
hwinf const *hw() const { return m_hw; }
|
||||
|
||||
//QString customerId() { return m_customerId; }
|
||||
//QString const customerId() const { return m_customerId; }
|
||||
|
||||
QString branchName() { return m_branchName; }
|
||||
QString const branchName() const { return m_branchName; }
|
||||
|
||||
//QString repositoryPath() { return m_repositoryPath; }
|
||||
//QString const repositoryPath() const { return m_repositoryPath; }
|
||||
|
||||
private:
|
||||
static QString jsonType(enum FileTypeJson type);
|
||||
bool openSerial(int br, QString baudrate, QString comPort) const;
|
||||
|
@@ -414,10 +414,6 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
}
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -127,7 +127,27 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# 1.4.8 : Improve reading Json-file versions of Json-files actually loaded
|
||||
# in DC. If available, show version info instead of blob-info of
|
||||
# Json file.
|
||||
VERSION="1.4.9"
|
||||
# 1.4.9 : Improve ISMAS output: add messages for JSON downloads.
|
||||
# Do not send CHECK_ISMAS_TRIGGER_SUCCESS to ISMAS for an automatic
|
||||
# update.
|
||||
# In case there is an automatic update (00:00-04:00) use M0100 instead
|
||||
# of U0002.
|
||||
# 1.4.10 : Fix: for the time being, never set the autoRequest-flag to false.
|
||||
# 1.4.11 : Fix: remove hard-coded path to git-repos of gitea in mimbach. Read
|
||||
# from ATBUpdateTool.ini the url for the gitrepositories.
|
||||
# 1.5.0 : Use ptu-config.atb-comm.de (given in ini-file) as new server for
|
||||
# customer repositories.
|
||||
# Fix: allow empty lines in opkg_commands.
|
||||
# 1.5.1 : Fix: do not use cleanPath() on a url-address.
|
||||
# 1.5.2 : Remove .ipk and .gz files in /var/cache/opkg.
|
||||
# 1.5.3 : Build customer_(id) name without right justification.
|
||||
# 1.5.4 : Try to run opkg-commands even under some error conditions (failure
|
||||
# of customerEnvironment(), filesToUpdate() or
|
||||
# syncCustomerRepositoryAndFS().
|
||||
# 1.5.5 : Call into binary ptuPackageVersion to get installed package
|
||||
# versions.
|
||||
# 1.5.6 : Show additional update progress info in status bar.
|
||||
VERSION="1.5.6"
|
||||
# PLANNED TODOS:
|
||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
||||
|
@@ -85,7 +85,17 @@ CommandLineParser::CommandLineParser()
|
||||
, m_yoctoInstallStatusOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "Y" << "yocto-install",
|
||||
QCoreApplication::translate("main", "Show yocto install status of ATBUpdateTool."))) {
|
||||
QCoreApplication::translate("main", "Show yocto install status of ATBUpdateTool.")))
|
||||
, m_dcDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "dc-directory" << "dc-directory",
|
||||
QCoreApplication::translate("main", "device controller directory."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_readDCVersionOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "D" << "read-dc-version",
|
||||
QCoreApplication::translate("main", "Show version of device controller."),
|
||||
QCoreApplication::translate("main", "Show version of device controller."))) {
|
||||
configure();
|
||||
}
|
||||
|
||||
@@ -138,6 +148,12 @@ void CommandLineParser::configure() {
|
||||
|
||||
m_yoctoInstallStatusOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_yoctoInstallStatusOption);
|
||||
|
||||
m_dcDirectoryOption.setDefaultValue("etc/dc/");
|
||||
m_parser.addOption(m_dcDirectoryOption);
|
||||
|
||||
m_readDCVersionOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_readDCVersionOption);
|
||||
}
|
||||
|
||||
void CommandLineParser::readSettings() {
|
||||
@@ -145,8 +161,8 @@ void CommandLineParser::readSettings() {
|
||||
QString const iniFileName = m_parser.value(m_iniFileNameOption);
|
||||
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir;
|
||||
qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName;
|
||||
//qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir;
|
||||
//qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName;
|
||||
|
||||
if (!m_iniFileName.isEmpty()) {
|
||||
if (QFile(m_iniFileName).exists()) {
|
||||
@@ -155,8 +171,8 @@ void CommandLineParser::readSettings() {
|
||||
for (QString const &key: keys) {
|
||||
QVariant v = settings.value(key);
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__
|
||||
<< key << " -> " << v.toString();
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << key << " -> " << v.toString();
|
||||
|
||||
if (key.contains("repository-url")) {
|
||||
m_repositoryUrl = v.toString();
|
||||
@@ -196,6 +212,12 @@ void CommandLineParser::readSettings() {
|
||||
} else
|
||||
if (key.contains("plugin-name")) {
|
||||
m_plugInName = v.toString();
|
||||
} else
|
||||
if (key.contains("dc-directory")) {
|
||||
m_dcDir = v.toString();
|
||||
} else
|
||||
if (key.contains("read-dc-version")) {
|
||||
m_readDCVersion = (v.toBool() ? "true" : "false");
|
||||
} else {
|
||||
qCritical() << __PRETTY_FUNCTION__
|
||||
<< key << " -> (UNKNOWN) " << v.toString();
|
||||
@@ -243,6 +265,20 @@ QString CommandLineParser::psaTariffDir() {
|
||||
return m_psaTariffDir;
|
||||
}
|
||||
|
||||
QString CommandLineParser::dcDir() {
|
||||
if (m_parser.isSet(m_dcDirectoryOption)) {
|
||||
m_dcDir = m_parser.value(m_dcDirectoryOption);
|
||||
}
|
||||
return m_dcDir;
|
||||
}
|
||||
|
||||
bool CommandLineParser::readDCVersion() {
|
||||
if (m_parser.isSet(m_readDCVersionOption)) {
|
||||
m_readDCVersion = m_parser.value(m_readDCVersionOption);
|
||||
}
|
||||
return m_readDCVersion == "false" ? false : true;
|
||||
}
|
||||
|
||||
QString CommandLineParser::workingDir() {
|
||||
if (m_parser.isSet(m_workingDirectoryOption)) {
|
||||
m_workingDir = m_parser.value(m_workingDirectoryOption);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#ifndef COMMAND_LINE_PARSER_H_INCLUDED
|
||||
#ifndef COMMAND_LINE_PARSER_H_INCLUDED
|
||||
#define COMMAND_LINE_PARSER_H_INCLUDED
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -11,8 +11,8 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QString m_plugInDir;
|
||||
QString m_plugInName;
|
||||
QString m_workingDir;
|
||||
QString m_psaConfigDir;
|
||||
QString m_psaTariffDir;
|
||||
QString m_psaConfigDir{"etc/psa_config"};
|
||||
QString m_psaTariffDir{"etc/psa_tariff"};
|
||||
QString m_dryRun;
|
||||
QString m_noUpdatePsaHardware;
|
||||
QString m_showYoctoVersion;
|
||||
@@ -21,6 +21,8 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QString m_iniFileName;
|
||||
QString m_alwaysDownloadConfig;
|
||||
QString m_alwaysDownloadDC;
|
||||
QString m_readDCVersion{"false"};
|
||||
QString m_dcDir{"etc/dc/"};
|
||||
|
||||
QCommandLineOption m_repositoryUrlOption;
|
||||
QCommandLineOption m_iniFileDirectoryOption;
|
||||
@@ -37,6 +39,8 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QCommandLineOption m_extendedVersionOption;
|
||||
QCommandLineOption m_yoctoVersionOption;
|
||||
QCommandLineOption m_yoctoInstallStatusOption;
|
||||
QCommandLineOption m_dcDirectoryOption;
|
||||
QCommandLineOption m_readDCVersionOption;
|
||||
|
||||
QCommandLineParser m_parser;
|
||||
|
||||
@@ -65,5 +69,7 @@ public:
|
||||
bool extendedVersion();
|
||||
bool alwaysDownloadConfig();
|
||||
bool alwaysDownloadDC();
|
||||
bool readDCVersion();
|
||||
QString dcDir();
|
||||
};
|
||||
#endif // COMMAND_LINE_PARSER_H_INCLUDED
|
||||
|
@@ -9,14 +9,15 @@
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
GitClient::GitClient(QString const &customerNrStr,
|
||||
GitClient::GitClient(QString const &customerRepositoryPath,
|
||||
QString const &customerNrStr,
|
||||
QString const &customerRepository,
|
||||
QString const &workingDirectory,
|
||||
QString const &branchName,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_worker(qobject_cast<Worker *>(parent))
|
||||
, m_repositoryPath(QString("https://git.mimbach49.de/GerhardHoffmann/%1.git").arg(customerNrStr))
|
||||
, m_repositoryPath(customerRepositoryPath)
|
||||
, m_customerNr(customerNrStr)
|
||||
, m_workingDirectory(workingDirectory)
|
||||
, m_branchName(branchName)
|
||||
@@ -392,6 +393,45 @@ std::optional<QString> GitClient::gitPull() {
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
qInfo() << "BRANCH NAME" << m_branchName;
|
||||
|
||||
#if 0
|
||||
IMPORTANT COMMENT:
|
||||
|
||||
If remote host keys are changed, then
|
||||
|
||||
export GIT_SSH_COMMAND="ssh -i /opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig"
|
||||
git pull
|
||||
|
||||
leads to the following warning/error message:
|
||||
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
|
||||
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
|
||||
It is also possible that a host key has just been changed.
|
||||
The fingerprint for the ECDSA key sent by the remote host is
|
||||
SHA256:vOD5jF2hglGktqLhK9ABxfEjwEgIK68/v9erdT05NDQ.
|
||||
Please contact your system administrator.
|
||||
Add correct host key in /home/root/.ssh/known_hosts to get rid of this message.
|
||||
Offending ECDSA key in /home/root/.ssh/known_hosts:1
|
||||
Password authentication is disabled to avoid man-in-the-middle attacks.
|
||||
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
|
||||
Agent forwarding is disabled to avoid man-in-the-middle attacks.
|
||||
X11 forwarding is disabled to avoid man-in-the-middle attacks.
|
||||
Already up to date.
|
||||
|
||||
This first part is from ssh itself. Only the last line is the git message.
|
||||
|
||||
Here an output of running ATBUpdateTool with a corrupted known-hosts-file:
|
||||
|
||||
...
|
||||
Oct 23 14:18:18 ATB_PTU5 ATBUpdateTool[2696]: ( branchExistsRemotely : 310 ) branch "zg1/zone1" EXISTS REMOTELY. ( "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible that a host key has just been changed.\r\nThe fingerprint for the ECDSA key sent by the remote host is\nSHA256:vOD5jF2hglGktqLhK9ABxfEjwEgIK68/v9erdT05NDQ.\r\nPlease contact your system administrator.\r\nAdd correct host key in /home/root/.ssh/known_hosts to get rid of this message.\r\nOffending ECDSA key in /home/root/.ssh/known_hosts:1\r\nPassword authentication is disabled to avoid man-in-the-middle attacks.\r\nKeyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.\r\nAgent forwarding is disabled to avoid man-in-the-middle attacks.\r\nX11 forwarding is disabled to avoid man-in-the-middle attacks.\r\nbd4e8da4780b1a7d6be3d3ce8419f43ccf7e706f\trefs/heads/zg1/zone1" )
|
||||
Oct 23 14:18:18 ATB_PTU5 ATBUpdateTool[2696]: EXECUTED "git branch -l" "(runtime 16ms)" with code 0 IN "/opt/app/tools/atbupdate/customer_336"
|
||||
Oct 23 14:18:18 ATB_PTU5 ATBUpdateTool[2696]: "UPDATE_STEP::PULL_NEW_BRANCH"
|
||||
Oct 23 14:18:18 ATB_PTU5 ATBUpdateTool[2696]: "BRANCH-NAME zg1/zone1 CONTAINED IN RESULT master\n* zg1/zone1" .....
|
||||
|
||||
The download continues.
|
||||
#endif
|
||||
Command c("git pull");
|
||||
if (c.execute(m_customerRepository)) {
|
||||
QString const s = c.getCommandResult().trimmed();
|
||||
|
@@ -22,7 +22,8 @@ class GitClient : public QObject {
|
||||
bool copyGitConfigFromMaster();
|
||||
|
||||
public:
|
||||
explicit GitClient(QString const &customerNrStr,
|
||||
explicit GitClient(QString const &customerRepositoryUrl,
|
||||
QString const &customerNrStr,
|
||||
QString const &repositoryPath,
|
||||
QString const &workingDirectory = QCoreApplication::applicationDirPath(),
|
||||
QString const &branchName = "master",
|
||||
|
@@ -363,7 +363,19 @@ QString IsmasClient::updateNewsToIsmas(char const *event,
|
||||
char buf[1024];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
QString const ts = QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
||||
QDateTime const local(QDateTime::currentDateTime());
|
||||
|
||||
QDateTime utc(local);
|
||||
utc.setTimeSpec(Qt::UTC);
|
||||
|
||||
int const diff = (int)local.secsTo(utc); // diff between UTC and local time
|
||||
|
||||
QTime t(0, 0, 0);
|
||||
t = t.addSecs((uint)diff);
|
||||
|
||||
QString const st(QString("%1%2").arg(diff < 0 ? "-" : "+").arg(t.toString("hh:mm")));
|
||||
QString const ts(local.toString(Qt::ISODateWithMs) + st);
|
||||
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"{"
|
||||
"\"REASON\":\"SW_UP\","
|
||||
@@ -678,7 +690,8 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
||||
"\"libTCP_ZVT_CCPlugin.so\" : {"
|
||||
"\"VERSION\" : \"%s\""
|
||||
"}"
|
||||
"}"
|
||||
"},"
|
||||
"\"PTU-PACKAGE-VERSIONS\" : %s"
|
||||
"}",
|
||||
psa.versionInfo.reason.toStdString().c_str(),
|
||||
psa.versionInfo.created.toStdString().c_str(),
|
||||
@@ -789,9 +802,11 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
||||
psa.pluginVersion.mobilisisCalculatePriceConfigUi.toStdString().c_str(),
|
||||
psa.pluginVersion.prmCalculatePrice.toStdString().c_str(),
|
||||
psa.pluginVersion.prmCalculatePriceConfigUi.toStdString().c_str(),
|
||||
psa.pluginVersion.tcpZVT.toStdString().c_str());
|
||||
psa.pluginVersion.tcpZVT.toStdString().c_str(),
|
||||
|
||||
qInfo() << buf;
|
||||
psa.ptuPackageVersion.toStdString().c_str());
|
||||
|
||||
qInfo() << buf;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@@ -77,6 +77,8 @@ struct PSAInstalled {
|
||||
|
||||
DC2C print[32];
|
||||
|
||||
QString ptuPackageVersion;
|
||||
|
||||
explicit PSAInstalled() {
|
||||
tariff.name = "N/A";
|
||||
tariff.version = "N/A";
|
||||
|
@@ -50,9 +50,11 @@
|
||||
// argv[1]: file to send to dc
|
||||
int main(int argc, char *argv[]) {
|
||||
QByteArray const value = qgetenv("LC_ALL");
|
||||
if (value != "C") {
|
||||
if (value.isEmpty() || value != "C") {
|
||||
qputenv("LC_ALL", "C");
|
||||
}
|
||||
|
||||
|
||||
// qputenv("XDG_RUNTIME_DIR", "/var/run/user/0");
|
||||
|
||||
openlog("ATB-UPDATE", LOG_PERROR | LOG_PID | LOG_CONS, LOG_USER);
|
||||
@@ -72,6 +74,38 @@ int main(int argc, char *argv[]) {
|
||||
parser.readSettings();
|
||||
|
||||
QString repositoryUrl = parser.repositoryUrl();
|
||||
|
||||
if (repositoryUrl.endsWith('/')) {
|
||||
repositoryUrl.chop(1);
|
||||
}
|
||||
|
||||
QString gitSSHCommand("");
|
||||
|
||||
if (repositoryUrl.contains("ptu-config.atb-comm.de")) {
|
||||
QByteArray const v = qgetenv("GIT_SSH_COMMAND");
|
||||
if (v.isEmpty()) {
|
||||
QString sshKeyFile("/opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig");
|
||||
if (QFileInfo(sshKeyFile).exists()) {
|
||||
gitSSHCommand = "ssh -i /opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig";
|
||||
if (!qputenv("GIT_SSH_COMMAND", QByteArray(gitSSHCommand.toStdString().c_str()))) {
|
||||
qCritical() << "ERROR: GIT_SSH_COMMAND not put into env. Exiting...";
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "ERROR ssh-key-file" << sshKeyFile << "does not exists. Exiting...";
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
gitSSHCommand = QString(v.toStdString().c_str());
|
||||
qCritical() << "WARNING GIT_SSH_COMMAND already set in enviroment:"
|
||||
<< gitSSHCommand;
|
||||
if (gitSSHCommand != "ssh -i /opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig") {
|
||||
qCritical() << "ERROR" << gitSSHCommand << "wrong. Exiting...";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString plugInDir = parser.plugInDir();
|
||||
QString plugInName = parser.plugInName();
|
||||
QString workingDir = parser.workingDir();
|
||||
@@ -94,6 +128,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
qInfo() << "pwd ......................" << rtPath;
|
||||
qInfo() << "repositoryUrl ............" << repositoryUrl;
|
||||
if (!gitSSHCommand.isEmpty()) {
|
||||
qInfo() << "GIT_SSH_COMMAND .........." << gitSSHCommand;
|
||||
}
|
||||
qInfo() << "plugInDir ................" << plugInDir;
|
||||
qInfo() << "plugInName ..............." << plugInName;
|
||||
qInfo() << "workingDir ..............." << workingDir;
|
||||
|
@@ -59,6 +59,24 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
m_exitTimer->setSingleShot(true);
|
||||
m_exitTimer->start(1800 * 1000);
|
||||
|
||||
m_statusTimer = new QTimer(this);
|
||||
if (m_statusTimer) {
|
||||
connect(m_statusTimer, &QTimer::timeout, [this]() {
|
||||
static QString p(".");
|
||||
QTime const &t = QDateTime::currentDateTime().time();
|
||||
QString s = t.toString(Qt::ISODate);
|
||||
s += ": Update might take several minutes " + p;
|
||||
if (p.length() >= 5) {
|
||||
p = ".";
|
||||
} else {
|
||||
p += ".";
|
||||
}
|
||||
this->statusBar()->showMessage(s);
|
||||
});
|
||||
m_statusTimer->setSingleShot(false);
|
||||
m_statusTimer->start(1000);
|
||||
}
|
||||
|
||||
connect(ui->exit, SIGNAL(clicked()),this,SLOT(onQuit()));
|
||||
connect(m_worker, SIGNAL(disableExit()),this,SLOT(onDisableExit()));
|
||||
connect(m_worker, SIGNAL(enableExit()),this,SLOT(onEnableExit()));
|
||||
@@ -76,6 +94,7 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
MainWindow::~MainWindow() {
|
||||
delete m_startTimer;
|
||||
delete m_exitTimer;
|
||||
delete m_statusTimer;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@@ -73,5 +73,6 @@ private:
|
||||
bool m_progressRunning;
|
||||
//int m_progressValue;
|
||||
UpdateDcEvent::UpdateStep m_updateStep;
|
||||
QTimer *m_statusTimer;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
@@ -193,8 +193,8 @@ bool Update::openSerial(int br, QString baudrate, QString comPort) const {
|
||||
+ " " + baudrate + " " + comPort + "...OK");
|
||||
|
||||
// m_hw->dc_autoRequest(true);
|
||||
m_hw->dc_autoRequest(false);
|
||||
QThread::sleep(1);
|
||||
// m_hw->dc_autoRequest(false);
|
||||
// QThread::sleep(1);
|
||||
|
||||
Utils::printInfoMsg(QString("IS PORT OPEN %1").arg(m_hw->dc_isPortOpen()));
|
||||
return true;
|
||||
@@ -410,7 +410,7 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
lst << msg;
|
||||
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -463,22 +463,20 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
*/
|
||||
|
||||
if (m_worker) {
|
||||
if (templateIdx >= 1 && templateIdx <= 32) {
|
||||
msg = QString("SUCCESSFULLY LOADED %1 (INDEX=%2) TO DC").arg(file.fileName()).arg(templateIdx);
|
||||
} else {
|
||||
msg = QString("SUCCESSFULLY LOADED %1 (KIND=%2) TO DC").arg(file.fileName()).arg((uint8_t)type);
|
||||
}
|
||||
lst.clear();
|
||||
lst << msg;
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
if (templateIdx >= 1 && templateIdx <= 32) {
|
||||
lst << QString("LOADED %1 (%2) TO DC").arg(fi.fileName()).arg(templateIdx);
|
||||
} else {
|
||||
lst << QString("LOADED %1 (%2) TO DC").arg(fi.fileName()).arg((uint8_t)type);
|
||||
}
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_JSON_FILE));
|
||||
}
|
||||
} else {
|
||||
msg = QString("ERROR SEND JSON-FILE %1 TO DC").arg(file.fileName());
|
||||
Utils::printCriticalErrorMsg(msg);
|
||||
lst << msg;
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -486,8 +484,7 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
Utils::printCriticalErrorMsg(msg);
|
||||
lst << msg;
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -496,8 +493,7 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
lst << msg;
|
||||
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -506,15 +502,14 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
lst << msg;
|
||||
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
// m_hw->dc_autoRequest(false);
|
||||
// qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
// QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -589,8 +584,8 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
||||
QString const &hwVersion = m_hw->dc_getHWversion().toLower().trimmed();
|
||||
QString const &swVersion = m_hw->dc_getSWversion().toLower().trimmed();
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
QThread::sleep(1); // make sure the timer-slots are inactive
|
||||
//m_hw->dc_autoRequest(false);
|
||||
//QThread::sleep(1); // make sure the timer-slots are inactive
|
||||
|
||||
if (!hwVersion.isEmpty() && !swVersion.isEmpty()) {
|
||||
return QStringList() << hwVersion << swVersion;
|
||||
@@ -956,45 +951,58 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
res = false;
|
||||
} else {
|
||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||
Utils::printInfoMsg(
|
||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||
.arg(fToWorkOn)
|
||||
.arg(templateIdx));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("DL:%1 (%2)").arg(QFileInfo(fToWorkOn).fileName()).arg(templateIdx));
|
||||
m_worker->ISMAS(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_JSON_FILE_SUCCESS);
|
||||
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateCashConf(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("DL:%1").arg(QFileInfo(fToWorkOn).fileName()));
|
||||
m_worker->ISMAS(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_CASH_FILE_SUCCESS);
|
||||
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res= updateConfig(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("DL:%1").arg(QFileInfo(fToWorkOn).fileName()));
|
||||
m_worker->ISMAS(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS);
|
||||
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("DL:%1").arg(QFileInfo(fToWorkOn).fileName()));
|
||||
m_worker->ISMAS(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_DEVICE_FILE_SUCCESS);
|
||||
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||
|
@@ -110,19 +110,19 @@ QString Utils::getTariffInfo(QString fileName) {
|
||||
}
|
||||
|
||||
QString Utils::zoneName(quint8 i) {
|
||||
static constexpr char const *zName[] = {
|
||||
"",
|
||||
"purple",
|
||||
"blue",
|
||||
"yellow",
|
||||
"green",
|
||||
"yellow (mars)",
|
||||
"green (mars)"
|
||||
};
|
||||
if (i < (sizeof(zName)/sizeof(char const *))) {
|
||||
return zName[i];
|
||||
}
|
||||
return "N/A";
|
||||
//static constexpr char const *zName[] = {
|
||||
// "",
|
||||
// "purple",
|
||||
// "blue",
|
||||
// "yellow",
|
||||
// "green",
|
||||
// "yellow (mars)",
|
||||
// "green (mars)"
|
||||
//};
|
||||
//if (i < (sizeof(zName)/sizeof(char const *))) {
|
||||
// return zName[i];
|
||||
//}
|
||||
return "---";
|
||||
}
|
||||
|
||||
void Utils::printCriticalErrorMsg(QString const &errorMsg, bool upper, bool lower) {
|
||||
@@ -293,7 +293,7 @@ bool Utils::sameFilesInDirs(QDir const &dir1, QDir const &dir2,
|
||||
}
|
||||
if (fileNameLst1 != fileNameLst2) {
|
||||
printCriticalErrorMsg(dirPath1 + " AND " + dirPath2
|
||||
+ " DIFFER: [" + fileNameLst1.join(',') + "],["
|
||||
+ " HAVE DIFFERENT FILES: [" + fileNameLst1.join(',') + "],["
|
||||
+ fileNameLst2.join(',') + "]");
|
||||
return false;
|
||||
} else {
|
||||
@@ -323,7 +323,7 @@ bool Utils::sameFilesInDirs(QDir const &dir1, QDir const &dir2,
|
||||
|
||||
if (gitBlobLst1 != gitBlobLst2) {
|
||||
printCriticalErrorMsg(dirPath1 + " AND " + dirPath2
|
||||
+ " DIFFER: [" + gitBlobLst1.join(',') + "],["
|
||||
+ " HAVE DIFFERENT BLOBS: [" + gitBlobLst1.join(',') + "],["
|
||||
+ gitBlobLst2.join(',') + "]");
|
||||
return false;
|
||||
} else {
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <Qt>
|
||||
#include <QScopedPointer>
|
||||
#include <QRegularExpression>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "message_handler.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
@@ -89,6 +90,15 @@ const QMap<UPDATE_STEP, const char*> Worker::smap (
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CASH_FILE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CASH_FILE_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CASH_FILE_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_FILE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_FILE_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_FILE_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_JSON_FILE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_JSON_FILE_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE),
|
||||
@@ -132,7 +142,7 @@ Worker::Worker(int customerNr,
|
||||
char const *serialInterface,
|
||||
char const *baudrate)
|
||||
: m_customerNr(customerNr)
|
||||
, m_customerNrStr(QString("customer_") + QString::number(m_customerNr).rightJustified(3, '0'))
|
||||
, m_customerNrStr(QString("customer_") + QString::number(m_customerNr))
|
||||
, m_machineNr(machineNr)
|
||||
, m_zoneNr(zoneNr)
|
||||
, m_pluginDir(pluginDir)
|
||||
@@ -148,7 +158,7 @@ Worker::Worker(int customerNr,
|
||||
, m_parent(parent)
|
||||
, m_serialInterface(serialInterface)
|
||||
, m_baudrate(baudrate)
|
||||
, m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this)
|
||||
, m_gc(m_customerRepositoryPath, m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this)
|
||||
, m_versionInfo(QStringList())
|
||||
, m_osVersion(getOsVersion())
|
||||
, m_atbqtVersion(getATBQTVersion())
|
||||
@@ -316,7 +326,7 @@ void Worker::privateUpdate() {
|
||||
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
// trigger message to ISMAS and CONSOLE
|
||||
ISMAS(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
|
||||
CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS);
|
||||
// overwrite m_lastFailedUpdateStep
|
||||
m_lastFailedUpdateStep = UPDATE_STEP::NONE;
|
||||
return;
|
||||
@@ -447,6 +457,14 @@ void Worker::privateUpdate() {
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if ((continueUpdate = customerEnvironment()) == false) {
|
||||
// even if something goes wrong creating the environment, try to execute
|
||||
// opkg_commands
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
// always execute contents of opkg_commands-file
|
||||
m_filesToUpdate.clear();
|
||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||
execOpkgCommands();
|
||||
}
|
||||
return;
|
||||
}
|
||||
m_versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
@@ -461,6 +479,14 @@ void Worker::privateUpdate() {
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if ((continueUpdate = filesToUpdate()) == false) {
|
||||
// even if something goes wrong in filesToUpdate, try to execute
|
||||
// opkg_commands
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
// always execute contents of opkg_commands-file
|
||||
m_filesToUpdate.clear();
|
||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||
execOpkgCommands();
|
||||
}
|
||||
return;
|
||||
}
|
||||
m_versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
@@ -474,6 +500,14 @@ void Worker::privateUpdate() {
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if ((continueUpdate = syncCustomerRepositoryAndFS()) == false) {
|
||||
// even if something goes wrong with rsync, try to execute
|
||||
// opkg_commands
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
// always execute contents of opkg_commands-file
|
||||
m_filesToUpdate.clear();
|
||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||
execOpkgCommands();
|
||||
}
|
||||
return;
|
||||
}
|
||||
lst = QStringList(QString(smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS]));
|
||||
@@ -502,9 +536,8 @@ void Worker::privateUpdate() {
|
||||
if ((continueUpdate = downloadFilesToPSAHardware()) == false) {
|
||||
return;
|
||||
}
|
||||
lst = QStringList(QString(smap[UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS]));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS);
|
||||
lst = QStringList(QString("DONE"));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -856,7 +889,24 @@ bool Worker::computeFilesToDownload() {
|
||||
return (m_filesToDownload.size() > 0);
|
||||
}
|
||||
|
||||
|
||||
bool Worker::cleanUpOpkgCache() {
|
||||
bool removedFiles = true;
|
||||
QDir dir("/var/cache/opkg");
|
||||
if (dir.exists()) {
|
||||
dir.setNameFilters(QStringList() << ".gz" << ".ipk");
|
||||
dir.setFilter(QDir::Files);
|
||||
foreach(QString dirFile, dir.entryList()) {
|
||||
removedFiles &= dir.remove(dirFile);
|
||||
}
|
||||
}
|
||||
return removedFiles;
|
||||
}
|
||||
|
||||
bool Worker::execOpkgCommands() {
|
||||
if (!cleanUpOpkgCache()) {
|
||||
CONSOLE() << "INFO: some cached opkg files not removed";
|
||||
}
|
||||
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
||||
QString const fName = m_filesToUpdate.at(i);
|
||||
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
||||
@@ -872,10 +922,12 @@ bool Worker::execOpkgCommands() {
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
// TODO: "^\\s*[#]{0,}$" : empty line or comment line starting with #
|
||||
static const QRegularExpression comment("^\\s*#.*$");
|
||||
if (line.indexOf(comment, 0) == -1) {
|
||||
// found opkg command
|
||||
static const QRegularExpression comment("^\\s*[#].*$");
|
||||
static const QRegularExpression emptyLine("^\\s*$");
|
||||
if (line.indexOf(emptyLine, 0) == -1 &&
|
||||
line.indexOf(comment, 0) == -1) {
|
||||
QString opkgCommand = line.trimmed();
|
||||
qCritical() << "Found opkg-command" << opkgCommand;
|
||||
if (!executeOpkgCommand(opkgCommand)) {
|
||||
opkgErrorLst << opkgCommand;
|
||||
} else {
|
||||
@@ -954,13 +1006,16 @@ bool Worker::execOpkgCommands() {
|
||||
|
||||
bool Worker::downloadFilesToPSAHardware() {
|
||||
m_displayIndex = 0;
|
||||
QStringList lst(QString("START"));
|
||||
|
||||
GUI(m_filesToDownload) << (CONSOLE(m_filesToDownload) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE);
|
||||
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE);
|
||||
ISMAS(lst) << (GUI(m_filesToDownload) << (CONSOLE(m_filesToDownload) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
|
||||
if (m_noUpdatePsaHardware == false) {
|
||||
if (computeFilesToDownload() > 0) {
|
||||
QStringList lst = m_filesToDownload;
|
||||
lst.clear();
|
||||
for (int i = 0; i < m_filesToDownload.size(); ++i) {
|
||||
lst << QFileInfo(m_filesToDownload.at(i)).fileName();
|
||||
}
|
||||
ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::FILES_TO_DOWNLOAD);
|
||||
|
||||
if (m_update && m_update->doUpdate(m_displayIndex, m_filesToDownload)) {
|
||||
@@ -973,7 +1028,7 @@ bool Worker::downloadFilesToPSAHardware() {
|
||||
return true;
|
||||
}
|
||||
|
||||
CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
|
||||
ISMAS(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE));
|
||||
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
|
||||
|
||||
return false;
|
||||
@@ -984,14 +1039,20 @@ bool Worker::downloadFilesToPSAHardware() {
|
||||
}
|
||||
|
||||
bool Worker::syncCustomerRepositoryAndFS() {
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY));
|
||||
QString msg("START");
|
||||
QStringList lst(msg);
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY));
|
||||
lst.clear();
|
||||
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
if (QDir::setCurrent(m_customerRepository)) {
|
||||
Command md("bash");
|
||||
if (!md.execute(m_customerRepository,
|
||||
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
|
||||
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
|
||||
msg = QString("COULD NOT EXECUTE '%1', exitCode=%2").arg(md.command()).arg(md.exitCode());
|
||||
qCritical() << msg;
|
||||
QStringList lst2(msg);
|
||||
ISMAS(lst2) << (CONSOLE(lst2) << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY);
|
||||
}
|
||||
QString const params("-v "
|
||||
"--recursive "
|
||||
@@ -1050,12 +1111,22 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
lst.clear();
|
||||
lst << QString("SUCCESS %1").arg(cmd);
|
||||
ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY);
|
||||
} else {
|
||||
msg = QString("FAILURE %1").arg(cmd);
|
||||
lst << msg;
|
||||
QStringList lst2(msg);
|
||||
ISMAS(lst2) << (CONSOLE(lst2) << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY);
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
// now check tariff-files in etc and /etc/psa_tariff
|
||||
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
|
||||
QDir dir2("/etc/psa_tariff");
|
||||
if (Utils::sameFilesInDirs(dir1, dir2)) {
|
||||
if (Utils::sameFilesInDirs(dir1, dir2) == false) {
|
||||
CONSOLE() << QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff")
|
||||
<< "AND /etc/psa_tariff ARE DIFFERENT: CHANGED CUSTOMER-NUMBER?";
|
||||
}
|
||||
@@ -1063,9 +1134,13 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
||||
setProgress(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
lst << QString("CAN NOT CD TO CUST-REPO %1").arg(m_customerRepository);
|
||||
}
|
||||
} else {
|
||||
lst << QString("CUST-REPO %1 DOES NOT EXIST").arg(m_customerRepository);
|
||||
}
|
||||
ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE)));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE)));
|
||||
setProgress(_SYNC_CUSTOMER_REPOSITORY_FAILURE);
|
||||
return false;
|
||||
}
|
||||
@@ -1387,5 +1462,41 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
}
|
||||
}
|
||||
|
||||
psaInstalled.ptuPackageVersion = "{}";
|
||||
if (QFile::exists("/usr/bin/ptuPackageVersions")) {
|
||||
Command c("/usr/bin/ptuPackageVersions -i -o json");
|
||||
if (c.execute(m_workingDirectory)) {
|
||||
QString r = c.getCommandResult();
|
||||
// ptuPackageVersions returns a json-array
|
||||
QJsonArray const &ja = QJsonDocument::fromJson(r.remove(QRegExp("\\n")).toUtf8()).array();
|
||||
if (!ja.empty()) {
|
||||
// transform the array into an object, containing the objects
|
||||
// of the array (christian needs it this way)
|
||||
QJsonObject o;
|
||||
foreach (QJsonValue const &value, ja) {
|
||||
if (value.isObject()) {
|
||||
QJsonObject obj = value.toObject();
|
||||
QStringList keys = obj.keys();
|
||||
if (!keys.isEmpty()) {
|
||||
QString const &k = obj.keys().first();
|
||||
QJsonValue const &v = obj.value(k);
|
||||
o.insert(k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
psaInstalled.ptuPackageVersion =
|
||||
QJsonDocument(o).toJson(QJsonDocument::Compact);
|
||||
|
||||
} else {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "ERROR array return by ptuPackageVersions empty";
|
||||
}
|
||||
} else {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "ERROR executing ptuPackageVersions";
|
||||
}
|
||||
}
|
||||
|
||||
return psaInstalled;
|
||||
}
|
||||
|
@@ -35,12 +35,13 @@
|
||||
! U0003: Update finished but FAILed.
|
||||
*/
|
||||
|
||||
#define _ISMAS_DONE "U0001" // 100%, Check: Resultcode: 0
|
||||
#define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button (""), ResultCode: 0
|
||||
#define _ISMAS_FAILURE "U0003" // FAIL
|
||||
#define _ISMAS_CONTINUE "U0010" // %-values: Update laeuft, Resultcodes entsprechend laufender Schritt
|
||||
#define _ISMAS_RESET_WAIT "ISMAS" // reset WAIT-button to "WAIT"
|
||||
#define _ISMAS_TEST_TRIGGER "U0099" // check the WAIT-button
|
||||
#define _ISMAS_DONE "U0001" // 100%, Check: Resultcode: 0
|
||||
#define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button (""), ResultCode: 0
|
||||
#define _ISMAS_NO_UPDATE_NECESSARY "M0100" // empty WAIT-button (""), ResultCode: 0
|
||||
#define _ISMAS_FAILURE "U0003" // FAIL
|
||||
#define _ISMAS_CONTINUE "U0010" // %-values: Update laeuft, Resultcodes entsprechend laufender Schritt
|
||||
#define _ISMAS_RESET_WAIT "ISMAS" // reset WAIT-button to "WAIT"
|
||||
#define _ISMAS_TEST_TRIGGER "U0099" // check the WAIT-button
|
||||
|
||||
#define _STARTED (1)
|
||||
#define _CHECK_ISMAS_TRIGGER (2)
|
||||
@@ -79,7 +80,6 @@
|
||||
#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (35)
|
||||
#define _FILES_TO_UPDATE (36)
|
||||
#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (37)
|
||||
#define _FILES_TO_DOWNLOAD (38)
|
||||
#define _EXEC_OPKG_COMMANDS (39)
|
||||
#define _EXEC_OPKG_COMMAND_1 (40)
|
||||
#define _EXEC_OPKG_COMMAND_2 (41)
|
||||
@@ -93,13 +93,23 @@
|
||||
#define _EXEC_OPKG_COMMAND_LAST (49)
|
||||
#define _EXEC_OPKG_COMMAND_FAILURE (50)
|
||||
#define _EXEC_OPKG_COMMAND_SUCCESS (51)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE (60)
|
||||
#define _DOWNLOAD_CONFIG_FILE (61)
|
||||
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (62)
|
||||
#define _DOWNLOAD_CONFIG_FILE_FAILURE (63)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER (64)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (85)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (86)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE (59)
|
||||
#define _FILES_TO_DOWNLOAD (60)
|
||||
#define _DOWNLOAD_CASH_FILE (61)
|
||||
#define _DOWNLOAD_CASH_FILE_FAILURE (62)
|
||||
#define _DOWNLOAD_CASH_FILE_SUCCESS (63)
|
||||
#define _DOWNLOAD_CONFIG_FILE (64)
|
||||
#define _DOWNLOAD_CONFIG_FILE_FAILURE (65)
|
||||
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (66)
|
||||
#define _DOWNLOAD_DEVICE_FILE (67)
|
||||
#define _DOWNLOAD_DEVICE_FILE_FAILURE (68)
|
||||
#define _DOWNLOAD_DEVICE_FILE_SUCCESS (69)
|
||||
#define _DOWNLOAD_JSON_FILE (70)
|
||||
#define _DOWNLOAD_JSON_FILE_FAILURE (71)
|
||||
#define _DOWNLOAD_JSON_FILE_SUCCESS (72)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER (84)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (85)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (86)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE (87)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS (88)
|
||||
#define _SAVE_LOGS (92)
|
||||
@@ -183,6 +193,7 @@ class Worker : public QThread{
|
||||
QString m_apismVersion;
|
||||
|
||||
bool executeOpkgCommand(QString opkgCommand);
|
||||
bool cleanUpOpkgCache();
|
||||
QString getOsVersion() const;
|
||||
QString getATBQTVersion() const;
|
||||
QString getATBUpdateToolVersion() const;
|
||||
@@ -326,6 +337,15 @@ public:
|
||||
DOWNLOAD_CONFIG_FILE = _DOWNLOAD_CONFIG_FILE,
|
||||
DOWNLOAD_CONFIG_FILE_SUCCESS = _DOWNLOAD_CONFIG_FILE_SUCCESS,
|
||||
DOWNLOAD_CONFIG_FILE_FAILURE = _DOWNLOAD_CONFIG_FILE_FAILURE,
|
||||
DOWNLOAD_CASH_FILE = _DOWNLOAD_CASH_FILE,
|
||||
DOWNLOAD_CASH_FILE_FAILURE = _DOWNLOAD_CASH_FILE_FAILURE,
|
||||
DOWNLOAD_CASH_FILE_SUCCESS = _DOWNLOAD_CASH_FILE_SUCCESS,
|
||||
DOWNLOAD_DEVICE_FILE = _DOWNLOAD_DEVICE_FILE,
|
||||
DOWNLOAD_DEVICE_FILE_FAILURE = _DOWNLOAD_DEVICE_FILE_FAILURE,
|
||||
DOWNLOAD_DEVICE_FILE_SUCCESS = _DOWNLOAD_DEVICE_FILE_SUCCESS,
|
||||
DOWNLOAD_JSON_FILE = _DOWNLOAD_JSON_FILE,
|
||||
DOWNLOAD_JSON_FILE_FAILURE = _DOWNLOAD_JSON_FILE_FAILURE,
|
||||
DOWNLOAD_JSON_FILE_SUCCESS = _DOWNLOAD_JSON_FILE_SUCCESS,
|
||||
DOWNLOAD_DEVICE_CONTROLLER = _DOWNLOAD_DEVICE_CONTROLLER,
|
||||
DOWNLOAD_DEVICE_CONTROLLER_SUCCESS = _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS,
|
||||
DOWNLOAD_DEVICE_CONTROLLER_FAILURE = _DOWNLOAD_DEVICE_CONTROLLER_FAILURE,
|
||||
@@ -655,6 +675,24 @@ private:
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE_FAILURE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE_SUCCESS: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE_FAILURE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE_SUCCESS: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE_SUCCESS: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
@@ -1088,12 +1126,34 @@ private:
|
||||
case UPDATE_STEP::FILES_TO_UPDATE:
|
||||
ismasClient.setProgressInPercent(_FILES_TO_UPDATE);
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE:
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_FILES_TO_PSA_HARDWARE);
|
||||
break;
|
||||
case UPDATE_STEP::FILES_TO_DOWNLOAD:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::FILES_TO_DOWNLOAD: {
|
||||
ismasClient.setProgressInPercent(_FILES_TO_DOWNLOAD);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_JSON_FILE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::EXEC_OPKG_COMMANDS:
|
||||
ismasClient.setProgressInPercent(_EXEC_OPKG_COMMANDS);
|
||||
break;
|
||||
@@ -1229,15 +1289,180 @@ private:
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE);
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE_SUCCESS);
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE: {
|
||||
//ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE);
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_CONFIG_FILE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS: {
|
||||
//ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE_SUCCESS);
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE_FAILURE);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::JSON_FILES_DOWNLOAD_ERROR,
|
||||
smap[UPDATE_STEP::DOWNLOAD_CASH_FILE_FAILURE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE: {
|
||||
//ismasClient.setProgressInPercent(_DOWNLOAD_CASH_FILE);
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_CASH_FILE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_CASH_FILE_FAILURE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::JSON_FILES_DOWNLOAD_ERROR,
|
||||
smap[UPDATE_STEP::DOWNLOAD_CASH_FILE_FAILURE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE_SUCCESS: {
|
||||
//ismasClient.setProgressInPercent(_DOWNLOAD_CASH_FILE_SUCCESS);
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_CASH_FILE_SUCCESS],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE: {
|
||||
//ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_FILE);
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_DEVICE_FILE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_FILE_FAILURE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::JSON_FILES_DOWNLOAD_ERROR,
|
||||
smap[UPDATE_STEP::DOWNLOAD_DEVICE_FILE_FAILURE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE_SUCCESS: {
|
||||
//ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_FILE_SUCCESS);
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_DEVICE_FILE_SUCCESS],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_JSON_FILE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE_FAILURE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::JSON_FILES_DOWNLOAD_ERROR,
|
||||
smap[UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_JSON_FILE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::DOWNLOAD_JSON_FILE_SUCCESS],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER);
|
||||
break;
|
||||
@@ -1275,9 +1500,20 @@ private:
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE:
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
|
||||
break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY: {
|
||||
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
||||
QString const &ismasUpdateNews =
|
||||
@@ -1286,7 +1522,7 @@ private:
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY],
|
||||
smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
@@ -1326,24 +1562,26 @@ private:
|
||||
} break;
|
||||
case UPDATE_STEP::UPDATE_SUCCEEDED: {
|
||||
ismasClient.setProgressInPercent(_UPDATE_SUCCEEDED + _UPDATE_SUCCEEDED_CORRECTION);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_DONE, // WAIT-button set to 100%
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
if (instance->m_automaticUpdate == false) {
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_DONE, // WAIT-button set to 100%
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
}
|
||||
} break;
|
||||
case UPDATE_STEP::UPDATE_ACTIVATED: {
|
||||
ismasClient.setProgressInPercent(_UPDATE_ACTIVATED + _UPDATE_ACTIVATED_CORRECTION);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_SET_WAIT_OK, // U0002
|
||||
(instance->m_automaticUpdate ? _ISMAS_NO_UPDATE_NECESSARY : _ISMAS_SET_WAIT_OK), // U0002 or M0100
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
@@ -1357,7 +1595,7 @@ private:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_SET_WAIT_OK, // U0002
|
||||
(instance->m_automaticUpdate ? _ISMAS_NO_UPDATE_NECESSARY : _ISMAS_SET_WAIT_OK), // U0002 or M0100
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::NO_UPDATE_NECESSARY,
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
@@ -1552,6 +1790,24 @@ private:
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE_FAILURE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_CASH_FILE_SUCCESS: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE_FAILURE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_FILE_SUCCESS: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE_FAILURE: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_JSON_FILE_SUCCESS: {
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS:
|
||||
|
Reference in New Issue
Block a user