28 Commits

Author SHA1 Message Date
4cc42b2a65 Set version to 1.3.6. Removed DCPlugin related stuff. 2023-09-28 12:11:47 +02:00
d783fd7fb6 Minor: print info instead of critical message when git fetch is empty 2023-09-28 12:09:57 +02:00
e0a0ff54e1 Added comment for U00-ISMAS values. Deactivated finalResult() 2023-09-28 12:08:42 +02:00
863d052a21 Removed debug info in appendText()/replcaeLst(). 2023-09-28 12:06:28 +02:00
61b3d29e31 Disable text-edit (showing update-status) ehen update procedure
finished.
2023-09-28 12:05:07 +02:00
cac4f7249e Minor: Add progress parameters. 2023-09-28 12:01:55 +02:00
3223c430be Do not rsync opkg_commnds to local file systems: this sync is not needed. 2023-09-28 12:00:24 +02:00
c09682ea33 Always execute commands contained in opkg_commands, even if no
change in opkg_commands. WAIT button in ISMAS must still be activated.
2023-09-28 11:57:17 +02:00
fef1d43d5f Adapated information of update-progress-status. 2023-09-28 11:56:20 +02:00
705424727b Removed call to final-result: ISMAS will not show U0002 twice. 2023-09-28 11:53:59 +02:00
b96f0896e3 Add explicit message when update-process is starting. 2023-09-28 11:53:10 +02:00
a3967c76ac Use showFullScreen() instead of using a flag 2023-09-28 11:47:09 +02:00
1197598a3d Set version to 1.3.5 2023-09-21 16:52:42 +02:00
ec13e97226 Update interfaces.h to HWapi/4.6 2023-09-21 15:55:31 +02:00
a8dd9d7e24 Merge branch 'master' of git.mimbach49.de:GerhardHoffmann/UpdatePTUDevCtrl 2023-09-21 15:50:19 +02:00
82751eb1d4 Set version to 1.3.4. 2023-09-11 10:14:41 +02:00
17a4a69df2 Added some debug output for parent-process-name 2023-09-11 10:14:04 +02:00
a03261d04a Fixed getParentName() to work analogously to isATBQTRunning(). 2023-09-11 10:12:20 +02:00
7832ef5d8c Set version to 1.3.3. 2023-09-10 17:22:49 +02:00
9c213d0a97 Added some better debug output in the slots concerned with the text edit
of the main window ("update status").
Use insertPlainText() when adding to the text edit to simplify code.
2023-09-10 16:55:32 +02:00
18378afdc5 Did some testing with event filters on the main window. not used. 2023-09-10 16:54:54 +02:00
6dd8a8c6b3 did some testing with event filter. not used. 2023-09-10 16:54:29 +02:00
adfb358e12 Add some output to see if start of the update tool is configured correctly. 2023-09-10 16:51:36 +02:00
ff418b11a1 Use plauginLoader as a dedicated static object. 2023-09-10 16:51:07 +02:00
38e79f0354 Use pluginLoader as a dedicated static object. 2023-09-10 16:50:19 +02:00
103b3f3f9c isATBQTRunning():
Use std::fstream to read /proc/<pid>/status, as the lines
end on '\r', not on '\n'.
2023-09-10 16:46:59 +02:00
ff6a6e0e45 Use libCAslave.so as default library to use for downloading the device-controller-firmware. 2023-09-10 16:45:40 +02:00
afbce3b4ea Add new dc-lib 2023-09-09 15:10:53 +02:00
13 changed files with 226 additions and 161 deletions

View File

@@ -15,7 +15,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
VERSION=1.3.2
VERSION=1.3.6
INCLUDEPATH += plugins
@@ -27,27 +27,11 @@ DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
QMAKE_CXXFLAGS += -g
QMAKE_CXXFLAGS += -Wno-deprecated-copy
# custom target for 'git subtree'
# subtree.target = subtree
# subtree.commands = git subtree add --prefix DCPlugin https://git.mimbach49.de/GerhardHoffmann/DCPlugin.git master --squash
# subtree.depends =
# QMAKE_EXTRA_UNIX_TARGETS += subtree
# ! exists(DCPlugin) {
# $$system("git subtree add --prefix DCPlugin https://git.mimbach49.de/GerhardHoffmann/DCPlugin.git master --squash")
# } else {
# $$system("git subtree pull --prefix DCPlugin https://git.mimbach49.de/GerhardHoffmann/DCPlugin.git master --squash")
# }
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
contains( CONFIG, PTU5 ) {
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
CONFIG += link_pkgconfig
lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7
QMAKE_CXXFLAGS += -Wno-deprecated-copy
ARCH = PTU5
DEFINES+=PTU5
@@ -107,18 +91,6 @@ HEADERS += \
FORMS += \
mainwindow.ui
OTHER_FILES += \
/opt/app/tools/atbupdate/update_log.csv \
main.cpp.bck \
main.cpp.bck2 \
main.cpp.bck3
# https://blog.developer.atlassian.com/the-power-of-git-subtree/?_ga=2-71978451-1385799339-1568044055-1068396449-1567112770
# git subtree add --prefix DCPlugin https://git.mimbach49.de/GerhardHoffmann/DCPlugin.git master --squash
# git subtree pull --prefix DCPlugin https://git.mimbach49.de/GerhardHoffmann/DCPlugin.git master --squash
# include(./DCPlugin/DCPlugin.pri)
##########################################################################################
# for running program on target through QtCreator

View File

@@ -271,8 +271,8 @@ std::optional<QString> GitClient::gitFetch() {
Utils::printCriticalErrorMsg(QString("WRONG FORMAT FOR RESULT OF 'GIT FETCH' ") + s);
}
} else {
emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'");
Utils::printCriticalErrorMsg("EMPTY RESULT FOR 'GIT FETCH'");
// emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'");
Utils::printInfoMsg("EMPTY RESULT FOR 'GIT FETCH'");
}
}
} else {

View File

@@ -23,6 +23,15 @@
#include <QJsonObject>
#if 0
########################
# Spec vom 27.10.2023:
# U0010 -> %-Werte
# U0001 -> 100%
# U0003 -> "FAIL"
# U0002 -> "" (OK -> WAIT state reset)
# ISMAS -> "WAIT"
########################
#
# $1: EVENT: U0001 update finished: 100%
# U0002 reset TRG
# U0003 error
@@ -858,6 +867,7 @@ QString IsmasClient::jsonParseFailed(int resultCode, QString reason, QString con
}
std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason, QString const &version) {
/*
m_progressInPercent = 100;
if (resultCode == RESULT_CODE::SUCCESS) {
return updateNewsToIsmas("U0002",
@@ -875,6 +885,7 @@ std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason,
reason.toStdString().c_str(),
version.toStdString().c_str());
}
*/
return std::nullopt;
}

View File

@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
QCommandLineOption pluginNameOption(QStringList() << "plugin-name" << "plugin-name",
QCoreApplication::translate("main", "Name of dc-plugin."),
QCoreApplication::translate("main", "directory"));
QString const pluginNameDefault = "libCAmaster.so";
QString const pluginNameDefault = "libCAslave.so";
pluginNameOption.setDefaultValue(pluginNameDefault);
parser.addOption(pluginNameOption);
@@ -180,8 +180,7 @@ int main(int argc, char *argv[]) {
worker.setMainWindow(&mw);
mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
mw.setWindowState(Qt::WindowFullScreen);
mw.show();
mw.showFullScreen();
return a.exec();
}

View File

@@ -10,6 +10,7 @@
#include <QMessageBox>
#include <QDebug>
#include <QScrollBar>
#include <QEvent>
@@ -131,9 +132,9 @@ MainWindow::MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *paren
lst << QString("APISM version : %1").arg(m_worker->apismVersion()).leftJustified(m_width-3);
lst << QString("").leftJustified(m_width-3, '=');
ui->updateStatus->setText(lst.join('\n'));
ui->updateStatus->setEnabled(true);
// ui->updateStatus->installEventFilter(this);
m_startTimer = new QTimer(this);
connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(update()));
@@ -308,9 +309,18 @@ void MainWindow::onEnableExit() {
ui->exit->setEnabled(true);
}
//bool MainWindow::eventFilter(QObject *obj, QEvent *ev) {
// if (obj == ui->updateStatus) {
// qCritical() << "REc. event for text edit" << ev->type();
// }
// return QMainWindow::eventFilter(obj, ev);
//}
void MainWindow::onRestartExitTimer() {
m_exitTimer->stop();
m_exitTimer->start(60 * 1000);
ui->updateStatus->setEnabled(false);
}
void MainWindow::onQuit() {
@@ -320,7 +330,8 @@ void MainWindow::onQuit() {
}
void MainWindow::scrollDownTextEdit() {
qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
// Utils::printInfoMsg(QString("SCROLL-DOWN-TEXT_EDIT CALLED AT ")
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
ui->updateStatus->setEnabled(true);
@@ -331,30 +342,39 @@ void MainWindow::scrollDownTextEdit() {
}
void MainWindow::onAppendText(QString text, QString suffix) {
qCritical() << "ON APPEND CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
// Utils::printInfoMsg(QString("ON APPEND CALLED AT ")
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
QString editText = ui->updateStatus->toPlainText();
scrollDownTextEdit();
if (!suffix.isNull() && suffix.size() > 0) {
//qInfo() << "TEXT" << text << "SUFFIX" << suffix;
if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) {
editText += QString("\n").leftJustified(m_width-3, '=');
editText += " ";
ui->updateStatus->insertPlainText(QString("\n").leftJustified(m_width-3, '=') + " ");
// editText += QString("\n").leftJustified(m_width-3, '=');
// editText += " ";
}
QString const &add = (QString("\n") + text).leftJustified(m_width - (2 + suffix.size())) + suffix;
editText += add;
ui->updateStatus->insertPlainText(add);
// editText += add;
} else {
QString const &add = text.leftJustified(m_width-9);
editText += add;
ui->updateStatus->insertPlainText(add);
//editText += add;
}
Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts));
ui->updateStatus->setText(editText.trimmed());
// debug
// QString editText = ui->updateStatus->toPlainText();
// Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts));
// ui->updateStatus->setText(editText.trimmed());
scrollDownTextEdit();
// scrollDownTextEdit();
}
void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
// Utils::printInfoMsg(QString("ON REPLACE LAST (LIST) CALLED AT ")
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
int const s = newTextLines.size();
if (s > 0) {
@@ -388,7 +408,8 @@ void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
}
void MainWindow::onReplaceLast(QString text, QString suffix) {
qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
// Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ")
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
QString editText = ui->updateStatus->toPlainText();
QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);

View File

@@ -21,6 +21,7 @@ class MainWindow : public QMainWindow {
protected:
void customEvent(QEvent *event) override;
// bool eventFilter(QObject *obj, QEvent *ev) override;
public:
MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *parent = nullptr);

51
plugins/interfaces.h Normal file → Executable file
View File

@@ -193,7 +193,7 @@ struct T_moduleCondition
uint8_t coinChecker; // EMP, OMP or mei-cashflow
uint8_t coinEscrow;
uint8_t mifareReader;
uint8_t mifareReader; // 0: unknown 1=OK 200=no response 201=wrong response 202: Reader reports HW-error
uint8_t creditTerm;
uint8_t coinReject;
@@ -818,7 +818,7 @@ public:
// --------------------------------------------- MIFARE -----------------------------------------------------
// ----------------------------------------------------------------------------------------------------------
// obsolete
virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const =0;
// retval 0=OK 1=error host buffer too small
/* data description, new fast version:
@@ -840,13 +840,16 @@ public:
virtual bool mif_readerIsOK(void) const =0;
virtual bool mif_cardAttached(void) const =0;
// not working! use mif_cardIsAttached() instead
virtual uint8_t mif_readResult(void) const =0;
// result: 0: unknown or still in progress
// 1: card read successful
// 2: reading error
// not working!
virtual QString mif_cardUID(void) const =0;
// not working
virtual uint8_t mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const =0;
@@ -1289,7 +1292,7 @@ public:
// 1= wrong length 2=wrong start sign 5= wrong crc
// 6= slave: master cmd was wrong 7: slave: could not write/read data
// 8=timeout, got no response from slave
// 0,8 work, 1..6 not yet tested. 8 comes immed. and stays 8 until reconnect
// use for important and extended commands (print several templates, print ticket...)
virtual void log_startSupervision(void) const =0;
@@ -1299,6 +1302,7 @@ public:
// 0: started, in progress
// 1: done and OK
// 2: done and error
// not working properly, always 0
virtual bool log_getVaultData(uint8_t *data) const =0;
// get vault record in linear 8bit buffer with 384 byte
@@ -1343,6 +1347,37 @@ public:
// new functions from 8.9.23
virtual QString mif_getReaderType(void) const =0;
// return "SL025" if correct reader is connected
virtual void mif_getCardSize(uint8_t *cardSize, uint8_t *idLeng) const =0;
// cardSize=1k or 4kByte
// idLeng =4Byte or 7 byte
virtual char mif_getAtbCardData(uint8_t *buf, uint8_t maxBuffSiz) const =0;
// return complete buffer binary, just for test purpose
virtual bool mif_isValidAtbCard(void) const =0;
virtual uint32_t mif_getAtbCardCuNu(void) const =0;
virtual uint8_t mif_getAtbCardTyp(void) const =0;
// return 1=upper door card 1=lower door 3=printer-test 4=coin-test
// 0: not a valid atb2020 card
virtual QString mif_getAtbCardPerso(void) const =0;
// e.g. "PNsax001" used for personal number, name shortcode, card number
// free to use, can be set in AtbMcw23.exe tool
virtual void mif_getAtbCardExpire(uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *minute) const =0;
signals:
virtual void hwapi_templatePrintFinished_OK(void) const=0;
virtual void hwapi_templatePrintFinished_Err(void) const=0;
@@ -1413,9 +1448,15 @@ signals:
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.1"
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.2"
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.3"
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.4"
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.4"
// 8.9.2023 two new functions (end of file) for mifare test
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.5"
// 18.9.2023 major improvements for DC data exchange
// verification of door and cash box signals
// intensive verification of Json-Programming Master-Slave (PTU to DC), 100% ok
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.6"
// 20.9.2023: speeding up door and cash box signals
Q_DECLARE_INTERFACE(hwinf, HWINF_iid)

BIN
plugins/libCAmaster.so Normal file → Executable file

Binary file not shown.

View File

@@ -14,9 +14,9 @@
#include <QRegExp>
#include <QApplication>
//#include <iostream>
//#include <fstream>
//#include <ctime>
#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX)
#include "unistd.h"
#endif
#include "plugins/interfaces.h"
@@ -40,6 +40,8 @@ static const QMap<QString, int> baudrateMap = {
{"57600" , 4}, {"115200" , 5}
};
QPluginLoader Update::pluginLoader;
hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
hwinf *hw = nullptr;
if (plugInDir.exists()) {
@@ -48,7 +50,8 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
QFileInfo info(pluginLibName);
if (info.exists()) {
pluginLibName = plugInDir.absoluteFilePath(pluginLibName);
static QPluginLoader pluginLoader(pluginLibName);
pluginLoader.setFileName(pluginLibName);
// static QPluginLoader pluginLoader(pluginLibName);
if (!pluginLoader.load()) {
qCritical() << "in directory" << plugInDir.absolutePath();
qCritical() << "cannot load plugin" << pluginLoader.fileName();
@@ -80,6 +83,21 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
return hw;
}
bool Update::unloadDCPlugin() {
if (pluginLoader.unload()) {
qCritical() << "unloaded plugin" << pluginLoader.fileName();
// Note: will re-instantiate the library !
// QObject *rootObject = pluginLoader.instance();
// if (rootObject) {
// qCritical() << "reloaded plugin: root object again available";
// return false;
// }
// qCritical()unloaded plugin: root object gone";
return true;
}
return false;
}
Update::Update(hwinf *hw,
Worker *worker,
QString customerRepository,
@@ -724,6 +742,9 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
QString const &parentName = Utils::getParentName();
Utils::printInfoMsg(
QString("PARENT OF ATB-UPDATE-TOOL (ppid=%1) ").arg(getppid()) + parentName);
if (parentName == "ATBQT" || parentName == "systemd") {
// the tool was not called during 'service' ot during an automatic
// update procedure. and it was called explicitly with libCAmaster.so
@@ -732,6 +753,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
+ " IS MASTER, BUT ATB-UPDATE-TOOL CALLED WITH libCAmaster.so");
return false;
}
Utils::printInfoMsg(
QString("ATB-UPDATE-TOOL STARTED AS SLAVE OF ") + parentName);
} else
if (Utils::isATBQTRunning()) { // manual testing
if (m_pluginName.contains("master", Qt::CaseInsensitive)) {
@@ -739,12 +762,15 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
"ATBQT IS MASTER, BUT ATB-UPDATE-TOOL CALLED WITH libCAmaster.so");
return false;
}
Utils::printInfoMsg(
"ATB-UPDATE-TOOL STARTED AS SLAVE-SIBLING OF ATBQT-MASTER");
} else {
if (m_pluginName.contains("slave", Qt::CaseInsensitive)) {
Utils::printCriticalErrorMsg(
"ATB-UPDATE-TOOL CALLED WITH libCAslave.so ALTHOUGH MASTER");
return false;
}
Utils::printInfoMsg("ATB-UPDATE-TOOL STARTED AS MASTER");
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate),
m_baudrate,

View File

@@ -7,6 +7,7 @@
#include <QDir>
#include <QByteArray>
#include <QProcess>
#include <QPluginLoader>
#include "plugins/interfaces.h"
@@ -32,11 +33,14 @@ class Update : public QObject {
bool m_maintenanceMode;
bool m_dryRun;
static QPluginLoader pluginLoader;
public:
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
enum class FileTypeJson {CONFIG=1, DEVICE=2, CASH=3, SERIAL=4, TIME=5, PRINTER=6};
static hwinf *loadDCPlugin(QDir const &plugInDir, QString const &fn);
static bool unloadDCPlugin();
static QStringList split(QString line, QChar sep = ',');

View File

@@ -2,13 +2,19 @@
#include "message_handler.h"
#include "git/git_client.h"
#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX)
#include "unistd.h"
#endif
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <QDir>
#include <QDirIterator>
#include <QRegularExpression>
#include <fstream>
int Utils::read1stLineOfFile(QString fileName) {
QFile f(fileName);
@@ -177,18 +183,15 @@ bool Utils::sameFilesInDirs(QDir const &dir1, QDir const &dir2,
QString Utils::getParentName() { // get name of parent process
QString ppid = QString("/proc/%1/status").arg(getppid());
QFile f(ppid);
if (f.exists()) {
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&f);
in.setCodec("UTF-8");
while(!in.atEnd()) {
// Name: ATBQT
QStringList line = in.readLine().split(':');
if (line.size() == 2) {
if (line[0].trimmed() == "Name") {
return line[1].trimmed();
}
std::ifstream f(ppid.toStdString().c_str());
if (f.is_open()) {
std::string next;
while (std::getline(f, next)) {
QString line = QString(next.c_str()).simplified();
if (line.startsWith("Name")) {
int const idx = line.indexOf(QChar(':'));
if (idx != -1) {
return line.mid(idx+1).trimmed();
}
}
}
@@ -203,17 +206,19 @@ bool Utils::isATBQTRunning() {
QDirIterator::Subdirectories);
while (it.hasNext()) {
QString const &nextStatusFile = it.next();
QFile f(nextStatusFile);
if (f.exists()) {
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&f);
in.setCodec("UTF-8");
while(!in.atEnd()) {
// Name: ATBQT
QStringList line = in.readLine().split(':');
if (line.size() == 2) {
if (line[0].trimmed() == "Name") {
if (line[1].trimmed() == "ATBQT") {
static const QRegularExpression re("^/proc/[0-9]{1,}/status");
QRegularExpressionMatch match = re.match(nextStatusFile);
if (match.hasMatch()) {
std::ifstream f(nextStatusFile.toStdString().c_str());
if (f.is_open()) {
std::string next;
while (std::getline(f, next)) {
QString line = QString(next.c_str()).simplified();
if (line.startsWith("Name")) {
int const idx = line.indexOf(QChar(':'));
if (idx != -1) {
QString const binary = line.mid(idx+1).trimmed();
if (binary == "ATBQT") {
return true;
}
}

View File

@@ -88,6 +88,7 @@ Worker::Worker(int customerNr,
m_apismVersion = v.value();
}
Utils::printInfoMsg("STARTING PTU-UPDATE");
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
qInfo() << "OS VERSION ................." << m_osVersion;
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
@@ -170,8 +171,7 @@ void Worker::privateUpdate() {
stopProgressLoop();
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress);
setProgress(5);
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
@@ -181,7 +181,7 @@ void Worker::privateUpdate() {
m_ismasClient.cloneAndCheckoutCustomerRepository(
m_updateStatus.m_statusDescription));
setProgress(progress + 10);
setProgress(10);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
@@ -195,9 +195,7 @@ void Worker::privateUpdate() {
m_returnCode = 0;
} else {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress);
setProgress(0);
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
@@ -210,11 +208,9 @@ void Worker::privateUpdate() {
m_returnCode = -3;
}
} else {
m_ismasClient.setProgressInPercent(10);
if (updateTriggerSet()) {
m_ismasClient.setProgressInPercent(20);
if (customerEnvironment()) {
m_ismasClient.setProgressInPercent(30);
if (updateTriggerSet(5)) {
if (customerEnvironment(30)) {
m_ismasClient.setProgressInPercent(50);
if (filesToUpdate()) {
// send message to ISMAS about files which have been
// checked in into git repository
@@ -224,23 +220,19 @@ void Worker::privateUpdate() {
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
m_updateStatus.m_statusDescription));
m_ismasClient.setProgressInPercent(40);
if (updateFiles(50)) {
m_ismasClient.setProgressInPercent(50);
if (updateFiles(60)) {
m_ismasClient.setProgressInPercent(70);
if (syncCustomerRepositoryAndFS()) {
m_ismasClient.setProgressInPercent(60);
m_ismasClient.setProgressInPercent(80);
if (sendIsmasLastVersionNotification()) {
m_ismasClient.setProgressInPercent(70);
m_ismasClient.setProgressInPercent(90);
sentIsmasLastVersionNotification = true;
if (saveLogFile()) {
m_ismasClient.setProgressInPercent(80);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSASucceeded(""));
// mark update as activated -> this resets the WAIT button
m_ismasClient.setProgressInPercent(95);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAActivated());
@@ -325,13 +317,14 @@ void Worker::privateUpdate() {
stopProgressLoop();
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
QString("Update process failed"));
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
m_updateStatus.m_statusDescription)) {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
}
// m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
// QString("Update process failed"));
// if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
// m_updateStatus.m_statusDescription)) {
// IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
// QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
// }
} else {
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
@@ -414,7 +407,7 @@ std::optional<QString> Worker::getApismVersion() {
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
bool Worker::updateTriggerSet() {
bool Worker::updateTriggerSet(int progress) {
if (m_withoutIsmasDirectPort) { // useful for testing
return true;
}
@@ -450,8 +443,7 @@ bool Worker::updateTriggerSet() {
= IsmasClient::sendRequestReceiveResponse(
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress);
setProgress(m_mainWindow->progressValue()/10 + 11);
QString msg = result.value();
@@ -490,15 +482,13 @@ bool Worker::updateTriggerSet() {
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
return false;
}
progress += 1;
setProgress(progress);
setProgress(m_mainWindow->progressValue()/10 + 11);
QJsonObject obj = document.object();
// always look for an 'error' first
if (obj.contains("error")) {
progress += 1;
setProgress(progress);
setProgress(m_mainWindow->progressValue()/10 + 11);
QString value = obj.value("error").toString();
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
@@ -583,8 +573,7 @@ bool Worker::updateTriggerSet() {
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
return false;
}
progress += 1;
setProgress(progress);
setProgress(m_mainWindow->progressValue()/10 + 11);
if (obj.contains("Fileupload")) {
QJsonValue v = obj.value("Fileupload");
@@ -602,11 +591,17 @@ bool Worker::updateTriggerSet() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK,
QString("MACHINE-NR (%1) AND CUST-NR (%2) OK")
.arg(m_machineNr).arg(m_customerNr));
m_ismasClient.setProgressInPercent(progress);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK",
m_updateStatus.m_statusDescription));
progress += 5;
m_ismasClient.setProgressInPercent(progress);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET,
QString("UPDATE TRIGGER SET. CONTINUE. "));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@@ -618,9 +613,7 @@ bool Worker::updateTriggerSet() {
} else
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
progress += 1;
setProgress(progress);
setProgress(m_mainWindow->progressValue()/10 + 11);
emit showErrorMessage("check update trigger", "empty update-trigger");
QThread::sleep(6);
continue;
@@ -675,9 +668,7 @@ bool Worker::updateTriggerSet() {
}
} else {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
progress += 1;
setProgress(progress);
setProgress(m_mainWindow->progressValue()/10 + 11);
emit showErrorMessage("check update trigger", "no ISMAS response");
QThread::sleep(6);
}
@@ -695,14 +686,14 @@ bool Worker::updateTriggerSet() {
return false;
}
bool Worker::customerEnvironment() {
bool Worker::customerEnvironment(int progress) {
emit appendText("\nPrepare customer environment ...");
if (QDir(m_customerRepository).exists()) {
startProgressLoop();
setProgress(m_mainWindow->progressValue()/10 + 11);
if (m_gc.gitCheckoutBranch()) {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress);
m_ismasClient.setProgressInPercent(progress);
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
QString("CHECKED-OUT BRANCH ") + m_gc.branchName());
@@ -717,8 +708,8 @@ bool Worker::customerEnvironment() {
return true;
} else {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress);
m_ismasClient.setProgressInPercent(0);
emit showErrorMessage("cust-env",
QString("Checkout ") + m_customerRepository + " failed");
Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
@@ -736,6 +727,10 @@ bool Worker::customerEnvironment() {
bool Worker::filesToUpdate() {
emit appendText("\nFetch changes files ...");
startProgressLoop();
// always execute contents of opkg_commands-file
m_filesToUpdate << "etc/psa_update/opkg_commands";
if (std::optional<QString> changes = m_gc.gitFetch()) {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
@@ -750,47 +745,38 @@ bool Worker::filesToUpdate() {
setProgress(progress + 20);
if (m_gc.gitPull()) {
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
m_filesToUpdate = changedFileNames.value();
m_filesToUpdate << changedFileNames.value();
} else {
emit showErrorMessage("files to update", "pulling files failed");
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(','));
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
int const size = m_filesToUpdate.size();
if (size > 1) {
emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE);
for (int i = 0; i < size; ++i) {
emit appendText(QString("\n ") + m_filesToUpdate.at(i));
}
} else {
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
}
return true;
stopProgressLoop();
setProgress(100);
return false;
}
emit showErrorMessage("files to update", "pulling files failed");
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
} else {
emit showErrorMessage("files to update", "no files to update (checked-in any files?)");
Utils::printCriticalErrorMsg("NO FILES TO UPDATE (CHECKED IN ANY FILES?)");
}
setProgress(progress + 30);
} else {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress + 30);
emit showErrorMessage("files to update",
QString("no changes in ") + m_customerRepository +
" (checked-in any files?)");
Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(','));
Utils::printCriticalErrorMsg("NO CHANGES IN "
+ m_customerRepository
+ " (CHECKED IN ANY FILES?)");
m_filesToUpdate.removeDuplicates();
int const size = m_filesToUpdate.size();
if (size > 1) {
emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE);
for (int i = 0; i < size; ++i) {
emit appendText(QString("\n ") + m_filesToUpdate.at(i));
}
} else {
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
}
setProgress(progress + 30);
}
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
setProgress(100);
return false;
return true;
}
bool Worker::updateFiles(quint8 percent) {
@@ -894,7 +880,6 @@ bool Worker::syncCustomerRepositoryAndFS() {
"--exclude=.* "
"--include=*.bin "
"--include=*.json "
"--include=opkg_commands "
"--include=*.ini");
QStringList cmds;
cmds << QString("rsync ") + params.simplified() + " etc/ /etc";

View File

@@ -190,8 +190,8 @@ public slots:
void update();
private slots:
bool updateTriggerSet();
bool customerEnvironment();
bool updateTriggerSet(int progress);
bool customerEnvironment(int progress);
bool filesToUpdate();
bool updateFiles(quint8 percent);
bool syncCustomerRepositoryAndFS();