49 Commits

Author SHA1 Message Date
226553a8ab Set version to 1.3.9 after fix of gitShowReason(). 2023-10-09 15:57:11 +02:00
d4ee56559b Use getShowReason() with branchName. Use getOsVersion(0 and
getApismVersion().
2023-10-09 15:54:58 +02:00
355b28ba40 Use current branch name in gitShowReason(), not just master 2023-10-09 15:53:35 +02:00
edeff35d7e Activate download of json-configuration files. 2023-10-06 13:02:23 +02:00
09d5de1b0b rsync: check if source directories in customer repositories exist. 2023-10-06 13:00:25 +02:00
145fdab26e Minor: fixed output format (in text edit) 2023-10-06 13:00:00 +02:00
89d1ec5b21 Deactivate download of device controller. Will be added in coming
version.
2023-10-06 12:58:38 +02:00
f38c975dc6 Remove check for which parent has started atbupdatetool: it is always
systemd now.
2023-10-06 12:57:38 +02:00
fba007aa35 Activate download of json-configuration files. 2023-10-06 12:56:03 +02:00
8b6adb3ea7 Scrolldown text edit at end of whole update process to show
UPDATE_SUCCESS message.
2023-10-06 12:51:30 +02:00
30603317c6 Minor: Add debug messages or change debug message format. 2023-10-06 10:47:08 +02:00
7083f3b4f8 Minor: add debug message. 2023-10-06 10:44:55 +02:00
7ff866525e Fix: allow for json-files EC2C_conf/cash/device.json as well. 2023-10-06 10:43:55 +02:00
2164037123 Do not use opkg_commnands-file as located in the filesystem under
/etc/psa_update anymore.
2023-10-06 10:42:35 +02:00
2e7d33c4c8 Set version to 1.3.7: wait forever for git-commands to finish in QProcess. 2023-10-05 10:54:19 +02:00
2a2751f6f3 Add creation of BUILD_DATE and BUILD_TIME 2023-10-04 14:34:54 +02:00
2764ef4371 Output of current tool version at program startup 2023-10-04 14:33:52 +02:00
9783f343e1 Set version to 1.3.6: exec opkg-commands even for unchanged opkg-commnds-file 2023-10-04 13:23:06 +02:00
8c6f0dfcc7 Minor: use Q_UNUSED() for unused parameters 2023-10-04 13:21:49 +02:00
d688ad3d5c Minor: comments 2023-10-04 10:34:56 +02:00
7b3f652b0e Deactivated doUpdate 2023-10-04 10:20:52 +02:00
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
15 changed files with 332 additions and 276 deletions

View File

@@ -15,39 +15,49 @@ DEFINES += QT_DEPRECATED_WARNINGS
# In order to do so, uncomment the following line. # 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. # 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 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
VERSION=1.3.2
# 1.3.6 : Do not update device-controller/json files, but have the library
# (in a later step) do that.
# Fixed sending messages to ISMAS.
# Always execute contents of opkg_commands-file (even if there are no
# changes).
# 1.3.7 : Wait forever for git-commands to finish in QProcess executing such
# a command.
# 1.3.8 : Remove accessing opkg_commands under file-system-path /etc/psa_update.
# Activate download of json-configuration files.
# 1.3.9 : Fix sendLastVersion: use configured branch and not master branch in
# git show origin/master -s --format="c=%h m=%s d=%cI" ==>
# git show origin/zg1/zone1 -s --format="c=%h m=%s d=%cI"
# Use dynamic values for os-release and apism-version when sending
# last version info.
win32 {
BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t")
} else {
BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S")
}
VERSION="1.3.8"
INCLUDEPATH += plugins INCLUDEPATH += plugins
CONFIG += c++17 console CONFIG += c++17
# CONFIG -= app_bundle # CONFIG -= app_bundle
DEFINES+=APP_VERSION=\\\"$$VERSION\\\" DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
QMAKE_CXXFLAGS += -g QMAKE_CXXFLAGS += -g
QMAKE_CXXFLAGS += -Wno-deprecated-copy 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 ) { contains( CONFIG, PTU5 ) {
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport 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 QMAKE_CXXFLAGS += -Wno-deprecated-copy
ARCH = PTU5 ARCH = PTU5
DEFINES+=PTU5 DEFINES+=PTU5
@@ -107,18 +117,6 @@ HEADERS += \
FORMS += \ FORMS += \
mainwindow.ui 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 # for running program on target through QtCreator

View File

@@ -114,16 +114,14 @@ bool GitClient::gitCloneAndCheckoutBranch() {
return false; return false;
} }
QStringList GitClient::gitShowReason() { QStringList GitClient::gitShowReason(QString branchName) {
QStringList lst; QStringList lst;
if (QDir(m_customerRepository).exists()) { if (QDir(m_customerRepository).exists()) {
// %h: commit (short form) // %h: commit (short form)
// %s: commit message // %s: commit message
// %cI: commit date, strict ISO 8601 format // %cI: commit date, strict ISO 8601 format
// Note: use master branch. By convention, there is a ChangeLog file // Note: branch with branchName has to exist: format zg1/zone1
// in the root of the repository, which has to be always the last file Command c(QString("git show origin/%1 -s --format=\"c=%h m=%s d=%cI\"").arg(branchName));
// to be checked in when the customer repository somehow changed.
Command c("git show origin/master -s --format=\"c=%h m=%s d=%cI\"");
if (c.execute(m_customerRepository)) { if (c.execute(m_customerRepository)) {
QString const s = c.getCommandResult().trimmed(); QString const s = c.getCommandResult().trimmed();
int const c = s.indexOf("c="); int const c = s.indexOf("c=");
@@ -271,8 +269,8 @@ std::optional<QString> GitClient::gitFetch() {
Utils::printCriticalErrorMsg(QString("WRONG FORMAT FOR RESULT OF 'GIT FETCH' ") + s); Utils::printCriticalErrorMsg(QString("WRONG FORMAT FOR RESULT OF 'GIT FETCH' ") + s);
} }
} else { } else {
emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'"); // emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'");
Utils::printCriticalErrorMsg("EMPTY RESULT FOR 'GIT FETCH'"); Utils::printInfoMsg("EMPTY RESULT FOR 'GIT FETCH'");
} }
} }
} else { } else {

View File

@@ -50,7 +50,7 @@ class GitClient : public QObject {
std::optional<QStringList> gitMerge(); std::optional<QStringList> gitMerge();
QString gitLastCommit(QString fileName); QString gitLastCommit(QString fileName);
QStringList gitShowReason(); QStringList gitShowReason(QString branchName);
static QString gitBlob(QString fileName); static QString gitBlob(QString fileName);
QString gitCommitForBlob(QString blob); QString gitCommitForBlob(QString blob);
bool gitIsFileTracked(QString file2name); bool gitIsFileTracked(QString file2name);

View File

@@ -23,6 +23,15 @@
#include <QJsonObject> #include <QJsonObject>
#if 0 #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% # $1: EVENT: U0001 update finished: 100%
# U0002 reset TRG # U0002 reset TRG
# U0003 error # U0003 error
@@ -857,7 +866,14 @@ QString IsmasClient::jsonParseFailed(int resultCode, QString reason, QString con
version.toStdString().c_str()); version.toStdString().c_str());
} }
std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason, QString const &version) { std::optional<QString> IsmasClient::finalResult(int resultCode,
QString reason,
QString const &version) {
Q_UNUSED(resultCode);
Q_UNUSED(reason);
Q_UNUSED(version);
/*
m_progressInPercent = 100; m_progressInPercent = 100;
if (resultCode == RESULT_CODE::SUCCESS) { if (resultCode == RESULT_CODE::SUCCESS) {
return updateNewsToIsmas("U0002", return updateNewsToIsmas("U0002",
@@ -875,6 +891,7 @@ std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason,
reason.toStdString().c_str(), reason.toStdString().c_str(),
version.toStdString().c_str()); version.toStdString().c_str());
} }
*/
return std::nullopt; return std::nullopt;
} }

View File

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

View File

@@ -10,6 +10,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>
#include <QScrollBar> #include <QScrollBar>
#include <QEvent>
@@ -125,15 +126,16 @@ MainWindow::MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *paren
QString start = QDateTime::currentDateTime().toString(Qt::ISODate); QString start = QDateTime::currentDateTime().toString(Qt::ISODate);
lst << QString("Start: ") + start.leftJustified(m_width-10); lst << QString("Start: ") + start.leftJustified(m_width-10);
lst << QString("").leftJustified(m_width-3, '='); lst << QString("").leftJustified(m_width-3, '=');
lst << QString("Machine number : %1 ").arg(m_worker->machineNr()).leftJustified(m_width-3); lst << QString("Update tool version: %1 - %2 %3").arg(APP_VERSION).arg(APP_BUILD_DATE).arg(APP_BUILD_TIME).leftJustified(m_width-3);
lst << QString("Customer number : %1 ").arg(m_worker->customerNr()).leftJustified(m_width-3); lst << QString("Machine number : %1 ").arg(m_worker->machineNr()).leftJustified(m_width-3);
lst << QString("Zone number : %1 (%2)").arg(m_worker->zoneNr()).arg(Utils::zoneName(m_worker->zoneNr())).leftJustified(m_width-3); lst << QString("Customer number : %1 ").arg(m_worker->customerNr()).leftJustified(m_width-3);
lst << QString("APISM version : %1").arg(m_worker->apismVersion()).leftJustified(m_width-3); lst << QString("Zone number : %1 (%2)").arg(m_worker->zoneNr()).arg(Utils::zoneName(m_worker->zoneNr())).leftJustified(m_width-3);
lst << QString("APISM version : %1").arg(m_worker->apismVersion()).leftJustified(m_width-3);
lst << QString("").leftJustified(m_width-3, '='); lst << QString("").leftJustified(m_width-3, '=');
ui->updateStatus->setText(lst.join('\n')); ui->updateStatus->setText(lst.join('\n'));
ui->updateStatus->setEnabled(true); ui->updateStatus->setEnabled(true);
// ui->updateStatus->installEventFilter(this);
m_startTimer = new QTimer(this); m_startTimer = new QTimer(this);
connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(update())); connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(update()));
@@ -308,9 +310,19 @@ void MainWindow::onEnableExit() {
ui->exit->setEnabled(true); 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() { void MainWindow::onRestartExitTimer() {
m_exitTimer->stop(); m_exitTimer->stop();
m_exitTimer->start(60 * 1000); m_exitTimer->start(60 * 1000);
scrollDownTextEdit();
ui->updateStatus->setEnabled(false);
} }
void MainWindow::onQuit() { void MainWindow::onQuit() {
@@ -320,7 +332,8 @@ void MainWindow::onQuit() {
} }
void MainWindow::scrollDownTextEdit() { 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); ui->updateStatus->setEnabled(true);
@@ -331,30 +344,39 @@ void MainWindow::scrollDownTextEdit() {
} }
void MainWindow::onAppendText(QString text, QString suffix) { 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(); QString editText = ui->updateStatus->toPlainText();
scrollDownTextEdit();
if (!suffix.isNull() && suffix.size() > 0) { if (!suffix.isNull() && suffix.size() > 0) {
//qInfo() << "TEXT" << text << "SUFFIX" << suffix; //qInfo() << "TEXT" << text << "SUFFIX" << suffix;
if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) { if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) {
editText += QString("\n").leftJustified(m_width-3, '='); ui->updateStatus->insertPlainText(QString("\n").leftJustified(m_width-3, '=') + " ");
editText += " "; // editText += QString("\n").leftJustified(m_width-3, '=');
// editText += " ";
} }
QString const &add = (QString("\n") + text).leftJustified(m_width - (2 + suffix.size())) + suffix; QString const &add = (QString("\n") + text).leftJustified(m_width - (2 + suffix.size())) + suffix;
editText += add; ui->updateStatus->insertPlainText(add);
// editText += add;
} else { } else {
QString const &add = text.leftJustified(m_width-9); QString const &add = text.leftJustified(m_width-9);
editText += add; ui->updateStatus->insertPlainText(add);
//editText += add;
} }
Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts)); // debug
ui->updateStatus->setText(editText.trimmed()); // 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) { 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(); int const s = newTextLines.size();
if (s > 0) { if (s > 0) {
@@ -388,7 +410,8 @@ void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
} }
void MainWindow::onReplaceLast(QString text, 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(); QString editText = ui->updateStatus->toPlainText();
QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts); QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);

View File

@@ -21,6 +21,7 @@ class MainWindow : public QMainWindow {
protected: protected:
void customEvent(QEvent *event) override; void customEvent(QEvent *event) override;
// bool eventFilter(QObject *obj, QEvent *ev) override;
public: public:
MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *parent = nullptr); 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 coinChecker; // EMP, OMP or mei-cashflow
uint8_t coinEscrow; 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 creditTerm;
uint8_t coinReject; uint8_t coinReject;
@@ -818,7 +818,7 @@ public:
// --------------------------------------------- MIFARE ----------------------------------------------------- // --------------------------------------------- MIFARE -----------------------------------------------------
// ---------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------
// obsolete
virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const =0; virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const =0;
// retval 0=OK 1=error host buffer too small // retval 0=OK 1=error host buffer too small
/* data description, new fast version: /* data description, new fast version:
@@ -840,13 +840,16 @@ public:
virtual bool mif_readerIsOK(void) const =0; virtual bool mif_readerIsOK(void) const =0;
virtual bool mif_cardAttached(void) const =0; virtual bool mif_cardAttached(void) const =0;
// not working! use mif_cardIsAttached() instead
virtual uint8_t mif_readResult(void) const =0; virtual uint8_t mif_readResult(void) const =0;
// result: 0: unknown or still in progress // result: 0: unknown or still in progress
// 1: card read successful // 1: card read successful
// 2: reading error // 2: reading error
// not working!
virtual QString mif_cardUID(void) const =0; 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; 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 // 1= wrong length 2=wrong start sign 5= wrong crc
// 6= slave: master cmd was wrong 7: slave: could not write/read data // 6= slave: master cmd was wrong 7: slave: could not write/read data
// 8=timeout, got no response from slave // 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...) // use for important and extended commands (print several templates, print ticket...)
virtual void log_startSupervision(void) const =0; virtual void log_startSupervision(void) const =0;
@@ -1299,6 +1302,7 @@ public:
// 0: started, in progress // 0: started, in progress
// 1: done and OK // 1: done and OK
// 2: done and error // 2: done and error
// not working properly, always 0
virtual bool log_getVaultData(uint8_t *data) const =0; virtual bool log_getVaultData(uint8_t *data) const =0;
// get vault record in linear 8bit buffer with 384 byte // 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: signals:
virtual void hwapi_templatePrintFinished_OK(void) const=0; virtual void hwapi_templatePrintFinished_OK(void) const=0;
virtual void hwapi_templatePrintFinished_Err(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.1"
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.2" //#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.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) Q_DECLARE_INTERFACE(hwinf, HWINF_iid)

BIN
plugins/libCAmaster.so Normal file → Executable file

Binary file not shown.

View File

@@ -69,7 +69,10 @@ bool Command::execute(QString workingDirectory, QStringList args) {
qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory(); qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory();
if (p->state() == QProcess::ProcessState::Running) { if (p->state() == QProcess::ProcessState::Running) {
qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory(); qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory();
if (p->waitForFinished(m_waitForFinishTimeout)) { // wait forever fot git-commands to finish
int const wait = m_command.trimmed().startsWith("git", Qt::CaseInsensitive) ? -1 : m_waitForFinishTimeout;
bool const no_timeout = p->waitForFinished(wait);
if (no_timeout) {
qDebug() << "PROCESS" << m_command << "FINISHED IN" << p->workingDirectory(); qDebug() << "PROCESS" << m_command << "FINISHED IN" << p->workingDirectory();
if (p->exitStatus() == QProcess::NormalExit) { if (p->exitStatus() == QProcess::NormalExit) {
if ((m_exitCode = p->exitCode()) == 0) { if ((m_exitCode = p->exitCode()) == 0) {
@@ -89,8 +92,8 @@ bool Command::execute(QString workingDirectory, QStringList args) {
} }
} else { } else {
qCritical() << "PROCESS" << m_command qCritical() << "PROCESS" << m_command
<< "DID NOT FINISH" << "DID NOT FINISH WITH" << wait
<< "IN" << p->workingDirectory(); << "MS IN" << p->workingDirectory();
} }
} else { } else {
qCritical() << "WRONG PROCESS STATE" << p->state() qCritical() << "WRONG PROCESS STATE" << p->state()

View File

@@ -14,9 +14,9 @@
#include <QRegExp> #include <QRegExp>
#include <QApplication> #include <QApplication>
//#include <iostream> #if defined (Q_OS_UNIX) || defined (Q_OS_LINUX)
//#include <fstream> #include "unistd.h"
//#include <ctime> #endif
#include "plugins/interfaces.h" #include "plugins/interfaces.h"
@@ -29,17 +29,15 @@
#include <QMap> #include <QMap>
#define UPDATE_OPKG (1) #define UPDATE_OPKG (1)
#define UPDATE_DC (1) #define UPDATE_DC (0)
#define UPDATE_PRINTER_TEMPLATES (1)
#define UPDATE_CASH_TEMPLATE (1)
#define UPDATE_CONF_TEMPLATE (1)
#define UPDATE_DEVICE_TEMPLATE (1)
static const QMap<QString, int> baudrateMap = { static const QMap<QString, int> baudrateMap = {
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
{"57600" , 4}, {"115200" , 5} {"57600" , 4}, {"115200" , 5}
}; };
QPluginLoader Update::pluginLoader;
hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) { hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
hwinf *hw = nullptr; hwinf *hw = nullptr;
if (plugInDir.exists()) { if (plugInDir.exists()) {
@@ -48,7 +46,8 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
QFileInfo info(pluginLibName); QFileInfo info(pluginLibName);
if (info.exists()) { if (info.exists()) {
pluginLibName = plugInDir.absoluteFilePath(pluginLibName); pluginLibName = plugInDir.absoluteFilePath(pluginLibName);
static QPluginLoader pluginLoader(pluginLibName); pluginLoader.setFileName(pluginLibName);
// static QPluginLoader pluginLoader(pluginLibName);
if (!pluginLoader.load()) { if (!pluginLoader.load()) {
qCritical() << "in directory" << plugInDir.absolutePath(); qCritical() << "in directory" << plugInDir.absolutePath();
qCritical() << "cannot load plugin" << pluginLoader.fileName(); qCritical() << "cannot load plugin" << pluginLoader.fileName();
@@ -80,6 +79,21 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
return hw; 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, Update::Update(hwinf *hw,
Worker *worker, Worker *worker,
QString customerRepository, QString customerRepository,
@@ -592,9 +606,12 @@ bool Update::downloadJson(enum FileTypeJson type,
int templateIdx, int templateIdx,
QString jsFileToSendToDC) const { QString jsFileToSendToDC) const {
qDebug() << "updating json-file:" << jsFileToSendToDC << "...";
qDebug() << " template-index:" << templateIdx; Utils::printInfoMsg(
qDebug() << " json-type:" << jsonType(type); QString("UPDATING JSON-FILE=%1, TEMPLATE-INDEX=%2, JSON-TYPE=%3")
.arg(jsFileToSendToDC)
.arg(templateIdx)
.arg(jsonType(type)));
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
qDebug() << "SET AUTO-REQUEST=TRUE"; qDebug() << "SET AUTO-REQUEST=TRUE";
@@ -605,7 +622,7 @@ bool Update::downloadJson(enum FileTypeJson type,
while ((ready = m_hw->sys_ready4sending()) == false) { while ((ready = m_hw->sys_ready4sending()) == false) {
QThread::msleep(200); QThread::msleep(200);
if (--nTry <= 0) { if (--nTry <= 0) {
qCritical() << "SYS NOT READY FOR SENDING AFTER 5 SECONDS"; Utils::printCriticalErrorMsg("SYS NOT READY FOR SENDING AFTER 5 SECONDS");
break; break;
} }
} }
@@ -618,22 +635,27 @@ bool Update::downloadJson(enum FileTypeJson type,
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
if (fi.size() <= 800) { if (fi.size() <= 800) {
QByteArray ba = file.readAll(); QByteArray ba = file.readAll();
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
// nrOfTemplate=1...32 if kindOfFile==6
// content = content of the Json file, max 800byte ascii signs
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type), if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
templateIdx, templateIdx,
(uint8_t *)ba.data())) { (uint8_t *)ba.data())) {
QThread::sleep(1); QThread::sleep(1);
qDebug() << "SENT" << jsFileToSendToDC;
ret = true; ret = true;
} }
} else { } else {
qCritical() << "SIZE OF" << jsFileToSendToDC Utils::printCriticalErrorMsg(
<< "TOO BIG (" << fi.size() << "BYTES)"; QString("SIZE OF %1 TOO BIG (%2 BYTES)")
.arg(jsFileToSendToDC).arg(fi.size()));
} }
} else { } else {
qCritical() << "CANNOT OPEN" << jsFileToSendToDC << "FOR READING"; Utils::printCriticalErrorMsg(
QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING");
} }
} else { } else {
qCritical() << jsFileToSendToDC << "DOES NOT EXIST"; Utils::printCriticalErrorMsg(
QString(jsFileToSendToDC) + " DOES NOT EXIST");
} }
} }
@@ -720,56 +742,13 @@ QStringList Update::getDcSoftAndHardWareVersion() {
} }
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
bool serialOpened = false; // always assume that serial line is open
QString const &parentName = Utils::getParentName();
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
if (m_pluginName.contains("master", Qt::CaseInsensitive)) {
Utils::printCriticalErrorMsg(parentName
+ " IS MASTER, BUT ATB-UPDATE-TOOL CALLED WITH libCAmaster.so");
return false;
}
} else
if (Utils::isATBQTRunning()) { // manual testing
if (m_pluginName.contains("master", Qt::CaseInsensitive)) {
Utils::printCriticalErrorMsg(
"ATBQT IS MASTER, BUT ATB-UPDATE-TOOL CALLED WITH libCAmaster.so");
return false;
}
} else {
if (m_pluginName.contains("slave", Qt::CaseInsensitive)) {
Utils::printCriticalErrorMsg(
"ATB-UPDATE-TOOL CALLED WITH libCAslave.so ALTHOUGH MASTER");
return false;
}
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate),
m_baudrate,
m_serialInterface)) == false) {
Utils::printCriticalErrorMsg(
QString("CANNOT OPEN ")
+ m_serialInterface
+ "( BAUDRATE=" + m_baudrate + ")");
return false;
}
m_hw->dc_autoRequest(false);
Utils::printInfoMsg(
QString("SERIAL OPEN ") + m_serialInterface
+ " (BAUDRATE=" + m_baudrate + ")");
}
bool res = false; bool res = false;
QList<QString>::const_iterator it; QList<QString>::const_iterator it;
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) { for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
m_worker->startProgressLoop(); m_worker->startProgressLoop();
QString fToWorkOn = (*it).trimmed(); QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + fToWorkOn); #if UPDATE_DC == 1
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$"); static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
if (fToWorkOn.contains(version)) { if (fToWorkOn.contains(version)) {
Utils::printInfoMsg("DO-UPDATE FILE-TO-WORK-ON " + fToWorkOn); Utils::printInfoMsg("DO-UPDATE FILE-TO-WORK-ON " + fToWorkOn);
@@ -784,7 +763,6 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
bool updateBinaryRes = true; bool updateBinaryRes = true;
qInfo() << "DOWNLOADING" << finfo.completeBaseName() << "TO DC"; qInfo() << "DOWNLOADING" << finfo.completeBaseName() << "TO DC";
#if UPDATE_DC == 1
m_hw->dc_autoRequest(false);// default: turn auto-request setting off m_hw->dc_autoRequest(false);// default: turn auto-request setting off
QThread::sleep(1); // wait to be sure that there are no more QThread::sleep(1); // wait to be sure that there are no more
// commands sent to dc-hardware // commands sent to dc-hardware
@@ -811,13 +789,12 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1]; qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
} }
} }
#endif
res = updateBinaryRes; res = updateBinaryRes;
} }
} else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive) #endif
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true; res = true;
#if UPDATE_PRINTER_TEMPLATES == 1
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive); int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt(); int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
if ((templateIdx < 1) || (templateIdx > 32)) { if ((templateIdx < 1) || (templateIdx > 32)) {
@@ -825,50 +802,46 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
res = false; res = false;
} else { } else {
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) { if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
qInfo() << "downloaded printer template"<< fToWorkOn; Utils::printInfoMsg(
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
.arg(fToWorkOn)
.arg(templateIdx));
++displayIndex; ++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")") emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(), + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE); Worker::UPDATE_STEP_DONE);
} }
} }
#endif
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive) } else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true; res = true;
#if UPDATE_CASH_TEMPLATE == 1
if ((res = updateCashConf(fToWorkOn))) { if ((res = updateCashConf(fToWorkOn))) {
qInfo() << "downloaded cash template"<< fToWorkOn; Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
++displayIndex; ++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")") emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(), + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE); Worker::UPDATE_STEP_DONE);
} }
#endif
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive) } else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true; res = true;
#if UPDATE_CONF_TEMPLATE == 1
if ((res= updateConfig(fToWorkOn))) { if ((res= updateConfig(fToWorkOn))) {
qInfo() << "downloaded config template"<< fToWorkOn; Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
++displayIndex; ++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")") emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(), + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE); Worker::UPDATE_STEP_DONE);
} }
#endif
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive) } else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true; res = true;
#if UPDATE_DEVICE_TEMPLATE == 1
if ((res = updateDeviceConf(fToWorkOn))) { if ((res = updateDeviceConf(fToWorkOn))) {
qInfo() << "downloaded device template"<< fToWorkOn; Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
++displayIndex; ++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")") emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(), + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE); Worker::UPDATE_STEP_DONE);
} }
#endif
} else { } else {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn; qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false; res = false;
@@ -881,12 +854,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
} }
} // for (it = openLines.cbegin(); it != openLines.end(); ++it) { } // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
//m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON
//qDebug() << "SET AUTO-REQUEST=TRUE"; qDebug() << "SET AUTO-REQUEST=TRUE";
if (serialOpened) {
m_hw->dc_closeSerial();
}
return res; return res;
} }

View File

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

View File

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

View File

@@ -88,6 +88,7 @@ Worker::Worker(int customerNr,
m_apismVersion = v.value(); m_apismVersion = v.value();
} }
Utils::printInfoMsg("STARTING PTU-UPDATE");
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate); qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
qInfo() << "OS VERSION ................." << m_osVersion; qInfo() << "OS VERSION ................." << m_osVersion;
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion; qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
@@ -170,8 +171,7 @@ void Worker::privateUpdate() {
stopProgressLoop(); stopProgressLoop();
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE); emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
int progress = (m_mainWindow->progressValue()/10) + 10; setProgress(5);
setProgress(progress);
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS, m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
QString("CLONED AND CHECKED OUT: ") + m_customerRepository); QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
@@ -181,7 +181,7 @@ void Worker::privateUpdate() {
m_ismasClient.cloneAndCheckoutCustomerRepository( m_ismasClient.cloneAndCheckoutCustomerRepository(
m_updateStatus.m_statusDescription)); m_updateStatus.m_statusDescription));
setProgress(progress + 10); setProgress(10);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
@@ -195,9 +195,7 @@ void Worker::privateUpdate() {
m_returnCode = 0; m_returnCode = 0;
} else { } else {
stopProgressLoop(); stopProgressLoop();
setProgress(0);
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress);
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL); emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
@@ -210,11 +208,9 @@ void Worker::privateUpdate() {
m_returnCode = -3; m_returnCode = -3;
} }
} else { } else {
m_ismasClient.setProgressInPercent(10); if (updateTriggerSet(5)) {
if (updateTriggerSet()) { if (customerEnvironment(30)) {
m_ismasClient.setProgressInPercent(20); m_ismasClient.setProgressInPercent(50);
if (customerEnvironment()) {
m_ismasClient.setProgressInPercent(30);
if (filesToUpdate()) { if (filesToUpdate()) {
// send message to ISMAS about files which have been // send message to ISMAS about files which have been
// checked in into git repository // checked in into git repository
@@ -224,23 +220,19 @@ void Worker::privateUpdate() {
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE", m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
m_updateStatus.m_statusDescription)); m_updateStatus.m_statusDescription));
m_ismasClient.setProgressInPercent(40); if (updateFiles(60)) {
if (updateFiles(50)) { m_ismasClient.setProgressInPercent(70);
m_ismasClient.setProgressInPercent(50);
if (syncCustomerRepositoryAndFS()) { if (syncCustomerRepositoryAndFS()) {
m_ismasClient.setProgressInPercent(60); m_ismasClient.setProgressInPercent(80);
if (sendIsmasLastVersionNotification()) { if (sendIsmasLastVersionNotification()) {
m_ismasClient.setProgressInPercent(70); m_ismasClient.setProgressInPercent(90);
sentIsmasLastVersionNotification = true; sentIsmasLastVersionNotification = true;
if (saveLogFile()) { if (saveLogFile()) {
m_ismasClient.setProgressInPercent(80);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSASucceeded("")); m_ismasClient.updateOfPSASucceeded(""));
// mark update as activated -> this resets the WAIT button // mark update as activated -> this resets the WAIT button
m_ismasClient.setProgressInPercent(95);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAActivated()); m_ismasClient.updateOfPSAActivated());
@@ -325,13 +317,14 @@ void Worker::privateUpdate() {
stopProgressLoop(); stopProgressLoop();
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL); emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE, // m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
QString("Update process failed")); // QString("Update process failed"));
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR, // if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
m_updateStatus.m_statusDescription)) { // m_updateStatus.m_statusDescription)) {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, // IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + s.value()); // QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
} // }
} else { } else {
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS); emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
@@ -414,7 +407,7 @@ std::optional<QString> Worker::getApismVersion() {
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..." #define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
bool Worker::updateTriggerSet() { bool Worker::updateTriggerSet(int progress) {
if (m_withoutIsmasDirectPort) { // useful for testing if (m_withoutIsmasDirectPort) { // useful for testing
return true; return true;
} }
@@ -450,8 +443,7 @@ bool Worker::updateTriggerSet() {
= IsmasClient::sendRequestReceiveResponse( = IsmasClient::sendRequestReceiveResponse(
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) { IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; setProgress(m_mainWindow->progressValue()/10 + 11);
setProgress(progress);
QString msg = result.value(); QString msg = result.value();
@@ -490,15 +482,13 @@ bool Worker::updateTriggerSet() {
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL); emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
return false; return false;
} }
progress += 1; setProgress(m_mainWindow->progressValue()/10 + 11);
setProgress(progress);
QJsonObject obj = document.object(); QJsonObject obj = document.object();
// always look for an 'error' first // always look for an 'error' first
if (obj.contains("error")) { if (obj.contains("error")) {
progress += 1; setProgress(m_mainWindow->progressValue()/10 + 11);
setProgress(progress);
QString value = obj.value("error").toString(); QString value = obj.value("error").toString();
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">"); emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<" qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
@@ -583,8 +573,7 @@ bool Worker::updateTriggerSet() {
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL); emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
return false; return false;
} }
progress += 1; setProgress(m_mainWindow->progressValue()/10 + 11);
setProgress(progress);
if (obj.contains("Fileupload")) { if (obj.contains("Fileupload")) {
QJsonValue v = obj.value("Fileupload"); QJsonValue v = obj.value("Fileupload");
@@ -602,11 +591,17 @@ bool Worker::updateTriggerSet() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK, m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK,
QString("MACHINE-NR (%1) AND CUST-NR (%2) OK") QString("MACHINE-NR (%1) AND CUST-NR (%2) OK")
.arg(m_machineNr).arg(m_customerNr)); .arg(m_machineNr).arg(m_customerNr));
m_ismasClient.setProgressInPercent(progress);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK", m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK",
m_updateStatus.m_statusDescription)); m_updateStatus.m_statusDescription));
progress += 5;
m_ismasClient.setProgressInPercent(progress);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET, m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET,
QString("UPDATE TRIGGER SET. CONTINUE. ")); QString("UPDATE TRIGGER SET. CONTINUE. "));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@@ -618,9 +613,7 @@ bool Worker::updateTriggerSet() {
} else } else
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; setProgress(m_mainWindow->progressValue()/10 + 11);
progress += 1;
setProgress(progress);
emit showErrorMessage("check update trigger", "empty update-trigger"); emit showErrorMessage("check update trigger", "empty update-trigger");
QThread::sleep(6); QThread::sleep(6);
continue; continue;
@@ -675,9 +668,7 @@ bool Worker::updateTriggerSet() {
} }
} else { } else {
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; setProgress(m_mainWindow->progressValue()/10 + 11);
progress += 1;
setProgress(progress);
emit showErrorMessage("check update trigger", "no ISMAS response"); emit showErrorMessage("check update trigger", "no ISMAS response");
QThread::sleep(6); QThread::sleep(6);
} }
@@ -695,14 +686,14 @@ bool Worker::updateTriggerSet() {
return false; return false;
} }
bool Worker::customerEnvironment() { bool Worker::customerEnvironment(int progress) {
emit appendText("\nPrepare customer environment ..."); emit appendText("\nPrepare customer environment ...");
if (QDir(m_customerRepository).exists()) { if (QDir(m_customerRepository).exists()) {
startProgressLoop(); startProgressLoop();
setProgress(m_mainWindow->progressValue()/10 + 11);
if (m_gc.gitCheckoutBranch()) { if (m_gc.gitCheckoutBranch()) {
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; m_ismasClient.setProgressInPercent(progress);
setProgress(progress);
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH, m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
QString("CHECKED-OUT BRANCH ") + m_gc.branchName()); QString("CHECKED-OUT BRANCH ") + m_gc.branchName());
@@ -717,8 +708,8 @@ bool Worker::customerEnvironment() {
return true; return true;
} else { } else {
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; m_ismasClient.setProgressInPercent(0);
setProgress(progress);
emit showErrorMessage("cust-env", emit showErrorMessage("cust-env",
QString("Checkout ") + m_customerRepository + " failed"); QString("Checkout ") + m_customerRepository + " failed");
Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED")); Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
@@ -736,6 +727,10 @@ bool Worker::customerEnvironment() {
bool Worker::filesToUpdate() { bool Worker::filesToUpdate() {
emit appendText("\nFetch changes files ..."); emit appendText("\nFetch changes files ...");
startProgressLoop(); startProgressLoop();
// always execute contents of opkg_commands-file
m_filesToUpdate << "etc/psa_update/opkg_commands";
if (std::optional<QString> changes = m_gc.gitFetch()) { if (std::optional<QString> changes = m_gc.gitFetch()) {
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; int progress = (m_mainWindow->progressValue()/10) + 10;
@@ -750,47 +745,38 @@ bool Worker::filesToUpdate() {
setProgress(progress + 20); setProgress(progress + 20);
if (m_gc.gitPull()) { if (m_gc.gitPull()) {
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE); 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(); stopProgressLoop();
if (size > 1) { setProgress(100);
emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE);
for (int i = 0; i < size; ++i) { return false;
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;
} }
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", Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(','));
QString("no changes in ") + m_customerRepository +
" (checked-in any files?)");
Utils::printCriticalErrorMsg("NO CHANGES IN " m_filesToUpdate.removeDuplicates();
+ m_customerRepository int const size = m_filesToUpdate.size();
+ " (CHECKED IN ANY FILES?)"); 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); return true;
setProgress(100);
return false;
} }
bool Worker::updateFiles(quint8 percent) { bool Worker::updateFiles(quint8 percent) {
@@ -834,20 +820,23 @@ bool Worker::updateFiles(quint8 percent) {
f.close(); f.close();
if (cmdCount > 0) { if (cmdCount > 0) {
m_displayIndex = 1; m_displayIndex = 1;
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")") QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update opkg pakets ... "); + QString(" Update opkg pakets ... ");
opkgCommands.prepend(prepend); opkgCommands.prepend(prepend);
emit replaceLast(opkgCommands, UPDATE_STEP_DONE); emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
} else { } else {
m_displayIndex = 1; m_displayIndex = 1;
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")") emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL); + QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
} }
} }
} }
} }
} else } else
if (fName.contains("print", Qt::CaseInsensitive)) { if (fName.contains("DC2C_print", Qt::CaseInsensitive) ||
fName.contains("DC2C_device", Qt::CaseInsensitive) ||
fName.contains("DC2C_conf", Qt::CaseInsensitive) ||
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
filesToDownload << fName; // download printer-config-files filesToDownload << fName; // download printer-config-files
} else { } else {
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$"); static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
@@ -866,6 +855,8 @@ bool Worker::updateFiles(quint8 percent) {
Update *update = m_mainWindow->getUpdate(); Update *update = m_mainWindow->getUpdate();
if (update) { if (update) {
return update->doUpdate(m_displayIndex, filesToDownload); return update->doUpdate(m_displayIndex, filesToDownload);
} else {
Utils::printCriticalErrorMsg("UPDATE NOT SET");
} }
} else { } else {
Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW"); Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW");
@@ -882,7 +873,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
if (QDir::setCurrent(m_customerRepository)) { if (QDir::setCurrent(m_customerRepository)) {
Command md("bash"); Command md("bash");
if (!md.execute(m_customerRepository, if (!md.execute(m_customerRepository,
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/psa_update /etc/dc /etc/psa_tariff")) { QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")"; qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
} }
int progress = 10; int progress = 10;
@@ -894,11 +885,17 @@ bool Worker::syncCustomerRepositoryAndFS() {
"--exclude=.* " "--exclude=.* "
"--include=*.bin " "--include=*.bin "
"--include=*.json " "--include=*.json "
"--include=opkg_commands "
"--include=*.ini"); "--include=*.ini");
QStringList cmds; QStringList cmds;
cmds << QString("rsync ") + params.simplified() + " etc/ /etc";
cmds << QString("rsync ") + params.simplified() + " opt/ /opt"; if (QDir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/")).exists()) {
cmds << QString("rsync ") + params.simplified() + " etc/ /etc";
Utils::printInfoMsg(QString("CONFIGURED SYNCING TO /ETC"));
}
if (QDir(QDir::cleanPath(m_customerRepository + QDir::separator() + "opt/")).exists()) {
cmds << QString("rsync ") + params.simplified() + " opt/ /opt";
Utils::printInfoMsg(QString("CONFIGURED SYNCING TO /OPT"));
}
QString cmd; QString cmd;
bool error = false; bool error = false;
@@ -908,6 +905,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
if (!error) { if (!error) {
Command c("bash"); Command c("bash");
qInfo() << "EXECUTING CMD..." << cmd; qInfo() << "EXECUTING CMD..." << cmd;
Utils::printInfoMsg(QString("EXECUTING CMD %1...").arg(cmd));
if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) { if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) {
QStringList result = c.getCommandResult().split('\n'); QStringList result = c.getCommandResult().split('\n');
QString const &p1 = "send_files mapped "; QString const &p1 = "send_files mapped ";
@@ -1082,9 +1080,7 @@ PSAInstalled Worker::getPSAInstalled() {
QString printSysDir("/etc/psa_config"); QString printSysDir("/etc/psa_config");
QString tariffSysDir("/etc/psa_tariff"); QString tariffSysDir("/etc/psa_tariff");
QString tariffRepoDir("etc/psa_tariff"); QString tariffRepoDir("etc/psa_tariff");
QString opkgSysDir("/etc/psa_update");
QString opkgRepoDir("etc/psa_update"); QString opkgRepoDir("etc/psa_update");
QString const &absPathNameOpkg = QDir::cleanPath(opkgSysDir + QDir::separator() + "opkg_commands");
QString const &absPathNameRepositoryOpkg = QDir::cleanPath(opkgRepoDir + QDir::separator() + "opkg_commands"); QString const &absPathNameRepositoryOpkg = QDir::cleanPath(opkgRepoDir + QDir::separator() + "opkg_commands");
QString absPathName; QString absPathName;
QString absPathNameRepository; QString absPathNameRepository;
@@ -1093,7 +1089,7 @@ PSAInstalled Worker::getPSAInstalled() {
psaInstalled.versionInfo.reason = ""; psaInstalled.versionInfo.reason = "";
psaInstalled.versionInfo.created = ""; psaInstalled.versionInfo.created = "";
QStringList versionInfo = m_gc.gitShowReason(); QStringList versionInfo = m_gc.gitShowReason(m_branchName);
if (versionInfo.size() == 3) { if (versionInfo.size() == 3) {
psaInstalled.versionInfo.lastCommit = versionInfo.at(0); psaInstalled.versionInfo.lastCommit = versionInfo.at(0);
psaInstalled.versionInfo.reason = versionInfo.at(1); psaInstalled.versionInfo.reason = versionInfo.at(1);
@@ -1115,12 +1111,12 @@ PSAInstalled Worker::getPSAInstalled() {
psaInstalled.tariff.info = "N/A"; psaInstalled.tariff.info = "N/A";
psaInstalled.tariff.version = "N/A"; psaInstalled.tariff.version = "N/A";
psaInstalled.hw.linuxVersion = m_osVersion; psaInstalled.hw.linuxVersion = getOsVersion();
psaInstalled.hw.cpuSerial = m_cpuSerial; psaInstalled.hw.cpuSerial = m_cpuSerial;
psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameOpkg); psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameRepositoryOpkg);
psaInstalled.opkg.size = getFileSize(absPathNameOpkg); psaInstalled.opkg.size = getFileSize(absPathNameRepositoryOpkg);
psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameOpkg); psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameRepositoryOpkg);
psaInstalled.opkg.lastCommit = m_gc.gitLastCommit(absPathNameRepositoryOpkg); psaInstalled.opkg.lastCommit = m_gc.gitLastCommit(absPathNameRepositoryOpkg);
psaInstalled.dc.versionHW = deviceControllerVersionHW; psaInstalled.dc.versionHW = deviceControllerVersionHW;
@@ -1129,7 +1125,9 @@ PSAInstalled Worker::getPSAInstalled() {
psaInstalled.dc.gitLastCommit = "N/A"; psaInstalled.dc.gitLastCommit = "N/A";
psaInstalled.dc.size = -1; psaInstalled.dc.size = -1;
psaInstalled.sw.apismVersion = m_apismVersion; if (std::optional<QString> v = getApismVersion()) {
psaInstalled.sw.apismVersion = v.value();
}
psaInstalled.sw.atbQTVersion = m_atbqtVersion; psaInstalled.sw.atbQTVersion = m_atbqtVersion;
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController; psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;

View File

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