29 Commits

Author SHA1 Message Date
bfa39eb3df Set version to 1.3.22.
After git clone: execute full update process (modulo settings in ATBUpdateTool.ini).
2023-12-13 14:00:21 +01:00
d7fcfa3d0f Click the Exit button after 5 seconds timeout (old timeout: 60s). 2023-12-13 13:59:00 +01:00
f1e449c108 Change known filename of device controller: dc2c.bin. 2023-12-13 13:57:46 +01:00
32346c2665 If the repository is cloned (or repaired and cloned) and the settings
always-download-config and always-download-dc are set in the ini-file,
then download the json-files and dc-file, even without an activated
WAIT-button. The tariff-files are always synced for a clone.
2023-12-13 13:49:22 +01:00
38e7bf4985 Minor: call rsync with -v instead of -vvv. 2023-12-13 13:48:23 +01:00
6df73e1082 Minor: change some debug output. 2023-12-13 13:47:02 +01:00
19250a0a2f If the update process is activated without a valid ISMAS trigger, then
wait for a valid trigger value 15x (=90s) instaed of 100x.
2023-12-13 13:44:55 +01:00
6f5c8103e4 When checking the sanity of the customer repository, check also for existence
of etc-directory inside repository.
2023-12-13 13:42:12 +01:00
07dcf0ba30 Minor: add some GUI debug output when checking ISMAS trigger. 2023-12-13 13:41:06 +01:00
1e379cf086 Fix: set directory of application for directory of the ini-file. 2023-12-13 13:38:34 +01:00
e87456f26b set version to 1.3.21 2023-12-13 10:06:04 +01:00
0c9a7bc7b5 let ISMAS know if some opkg commands fail 2023-12-13 10:04:38 +01:00
a35c6afcb8 Minor: add debug output if some opkg commands fail 2023-12-13 10:03:37 +01:00
b06f4f46bb Update interfaces.h (DeviceController) 2023-12-08 13:02:23 +01:00
33d45eab2e Merge branch 'master' of git.mimbach49.de:GerhardHoffmann/UpdatePTUDevCtrl 2023-12-08 13:01:03 +01:00
d2e11d8f07 Replace the last line of the text edit when the new line is
the last line followed by a suffix.
2023-11-29 14:18:01 +01:00
fbffdc923f Minor: When appendig text, scroll down the text edit. 2023-11-29 14:17:28 +01:00
8faf5af2bf Typo: replace m_files_to_update with m_files_to_download. 2023-11-29 12:07:25 +01:00
1d532c13a4 Minor: show files to update with a direct qCritical() 2023-11-29 12:06:17 +01:00
d2d3afc28e Show debug output in text-edit only when at least one file to update. 2023-11-29 12:05:09 +01:00
f4bb201633 Minor: Add debug message to console 2023-11-29 11:37:08 +01:00
b68cf1fd1d Set version to 1.3.20. 2023-11-29 11:30:50 +01:00
0888c1b525 Read machine-nr, customer-nr and zone-nr from /mnt/system_data/
rather then the deprecated /etc-directory.
2023-11-29 11:29:52 +01:00
a6faf9ce21 Init triggerValue with "NOT CHECKED YET" otherwise one might be confused. 2023-11-29 11:28:35 +01:00
5577cc5d6d Add m_sys_areDCdataValid plus its handling 2023-11-24 14:08:54 +01:00
9967d5cc45 Add comment 2023-11-24 14:08:19 +01:00
e20ed57bd5 Set version to 1.3.19 2023-11-21 16:18:17 +01:00
6986007b16 Set all parameters to default values other than "" 2023-11-21 16:17:15 +01:00
9ecdf73bc0 Minor: output all command parameters 2023-11-21 16:16:28 +01:00
9 changed files with 184 additions and 96 deletions

View File

@@ -62,8 +62,22 @@ DEFINES += QT_DEPRECATED_WARNINGS
# 1.3.16: Bug fixes found during testing. # 1.3.16: Bug fixes found during testing.
# 1.3.17: Add ATBUpdateTool.ini and custom command line parser. Settings # 1.3.17: Add ATBUpdateTool.ini and custom command line parser. Settings
# given in ATBUpdateTool.ini can be overwritten on the command-line. # given in ATBUpdateTool.ini can be overwritten on the command-line.
VERSION="1.3.18"
# 1.3.18: Bug fixes found during testing. # 1.3.18: Bug fixes found during testing.
# 1.3.19: Bug fixes found during testing.
# 1.3.20: Bug fixes found during testing.
# 1.3.21: Bug fixes found during testing:
# Fix directory of ATBUpdateTool.ini to be the working directory of
# the application rather than just ".".
# Check existance of etc-directory inside customer repository.
# Check for valid ISMAS trigger (button) 15x (=90s).
# NOTE: if the customer repository is cloned (or repaired and cloned
# again), and if the settings always-download-config=true and
# always-download-dc=true in the ATBUpdateTool.ini file, the download
# the printer-json files and the device controller file, even without
# an activated ISMAS trigger (button). The tariff-files are rsynced to
# the local filesystem for such clone.
# Set new filename for device controller: dc2c.bin.
VERSION="1.3.22"
# PLANNED TODOS: # PLANNED TODOS:
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT. # 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
@@ -90,7 +104,13 @@ VERSION="1.3.18"
# es so arrangieren, dass der DC plus die Json-files im Repository immer # es so arrangieren, dass der DC plus die Json-files im Repository immer
# runtergeladen werden, obwohl sich im Repository gar nicts veraendert # runtergeladen werden, obwohl sich im Repository gar nicts veraendert
# hat. Eeventuell nuetzlich beim initialen Setuo eines PSA. # hat. Eeventuell nuetzlich beim initialen Setuo eines PSA.
# 9: Das Kunden-Repository sollte immer gezogen werden, unabhaengig von der
# Stellung des WAIT-Button. Grund: es koennte sein, dass andernfalls ein
# PSA weit hiter anderen steht, und dann ploetzlich einmal alle vorher-
# gehenden Aenderungen anzieht, die gar nicht fuer ihn gemeint waren.
# 10: Bei einer Neuinstallation (Neuhauser) immer JSON files runterladen,
# Tariff-Files syncen (d.h. nur wenn noch kein Repo vorhanden ist), und
# zwar auch ohne WAIT-Button.
win32 { win32 {

View File

@@ -6,16 +6,18 @@
#include <QFile> #include <QFile>
CommandLineParser::CommandLineParser() CommandLineParser::CommandLineParser()
: m_repositoryUrl("") : m_repositoryUrl("https://git.mimbach49.de/GerhardHoffmann")
, m_plugInDir("") , m_plugInDir("/usr/lib/")
, m_plugInName("") , m_plugInName("libCAslave.so")
, m_workingDir("") , m_workingDir("/opt/app/tools/atbupdate/")
, m_dryRun("") , m_dryRun("false")
, m_noUpdatePsaHardware("") , m_noUpdatePsaHardware("false")
, m_showYoctoVersion("") , m_showYoctoVersion("false")
, m_showYoctoInstallStatus("") , m_showYoctoInstallStatus("false")
, m_showExtendedVersion("") , m_showExtendedVersion("false")
, m_iniFileName("") , m_iniFileName("ATBUpdateTool.ini")
, m_alwaysDownloadConfig("false")
, m_alwaysDownloadDC("false")
, m_repositoryUrlOption( , m_repositoryUrlOption(
QCommandLineOption( QCommandLineOption(
QStringList() << "repository-url" << "repository-url", QStringList() << "repository-url" << "repository-url",
@@ -85,7 +87,7 @@ void CommandLineParser::configure() {
m_repositoryUrlOption.setDefaultValue("https://git.mimbach49.de/GerhardHoffmann"); m_repositoryUrlOption.setDefaultValue("https://git.mimbach49.de/GerhardHoffmann");
m_parser.addOption(m_repositoryUrlOption); m_parser.addOption(m_repositoryUrlOption);
m_iniFileDirectoryOption.setDefaultValue("."); m_iniFileDirectoryOption.setDefaultValue(QCoreApplication::applicationDirPath());
m_parser.addOption(m_iniFileDirectoryOption); m_parser.addOption(m_iniFileDirectoryOption);
m_iniFileNameOption.setDefaultValue("ATBUpdateTool.ini"); m_iniFileNameOption.setDefaultValue("ATBUpdateTool.ini");
@@ -115,10 +117,10 @@ void CommandLineParser::configure() {
m_extendedVersionOption.setDefaultValue("false"); m_extendedVersionOption.setDefaultValue("false");
m_parser.addOption(m_extendedVersionOption); m_parser.addOption(m_extendedVersionOption);
m_yoctoVersionOption .setDefaultValue("false"); m_yoctoVersionOption.setDefaultValue("false");
m_parser.addOption(m_yoctoVersionOption); m_parser.addOption(m_yoctoVersionOption);
m_yoctoInstallStatusOption .setDefaultValue("false"); m_yoctoInstallStatusOption.setDefaultValue("false");
m_parser.addOption(m_yoctoInstallStatusOption); m_parser.addOption(m_yoctoInstallStatusOption);
} }
@@ -126,7 +128,6 @@ void CommandLineParser::readSettings() {
QString const iniFileDir = m_parser.value(m_iniFileDirectoryOption); QString const iniFileDir = m_parser.value(m_iniFileDirectoryOption);
QString const iniFileName = m_parser.value(m_iniFileNameOption); QString const iniFileName = m_parser.value(m_iniFileNameOption);
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName); m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
if (!m_iniFileName.isEmpty()) { if (!m_iniFileName.isEmpty()) {
if (QFile(m_iniFileName).exists()) { if (QFile(m_iniFileName).exists()) {
QSettings settings(m_iniFileName, QSettings::IniFormat); QSettings settings(m_iniFileName, QSettings::IniFormat);

View File

@@ -1834,6 +1834,9 @@ public:
virtual uint8_t prn_getPrintResult() const { virtual uint8_t prn_getPrintResult() const {
return 0; return 0;
} }
// return: 0: just printing, wait
// 1: OK - last print was succesful
// 2: error - not printed
@@ -2273,7 +2276,32 @@ public:
signals: signals:
virtual void hwapi_templatePrintFinished_OK(void) const=0;
virtual void hwapi_templatePrintFinished_Err(void) const=0;
virtual void hwapi_coinCollectionJustStarted(void) const=0;
virtual void hwapi_coinCollectionAborted(void) const=0;
virtual void hwapi_gotNewCoin(void) const=0;
virtual void hwapi_payStopByMax(void) const=0;
virtual void hwapi_payStopByPushbutton(void) const=0;
virtual void hwapi_payStopByEscrow(void) const=0;
virtual void hwapi_payStopByError(void) const=0;
virtual void hwapi_payStopByTimeout(void) const=0;
virtual void hwapi_payCancelled(void) const=0;
virtual void hwapi_coinProcessJustStopped(void) const=0;
virtual void hwapi_doorServiceDoorOpened(void) const=0;
virtual void hwapi_doorVaultDoorOpened(void) const=0;
virtual void hwapi_doorCoinBoxRemoved(void) const=0;
virtual void hwapi_doorCoinBoxInserted(void) const=0;
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
virtual void hwapi_doorAllDoorsClosed(void) const=0;
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid. // NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
/* GH Version, bringt Fehler
void hwapi_templatePrintFinished_OK() const; void hwapi_templatePrintFinished_OK() const;
void hwapi_templatePrintFinished_Err() const; void hwapi_templatePrintFinished_Err() const;
@@ -2296,6 +2324,7 @@ signals:
void hwapi_doorCoinBoxInserted() const; void hwapi_doorCoinBoxInserted() const;
void hwapi_doorCBinAndAllDoorsClosed() const; void hwapi_doorCBinAndAllDoorsClosed() const;
void hwapi_doorAllDoorsClosed() const; void hwapi_doorAllDoorsClosed() const;
*/
}; };

View File

@@ -74,6 +74,7 @@ int main(int argc, char *argv[]) {
QString plugInDir = parser.plugInDir(); QString plugInDir = parser.plugInDir();
QString plugInName = parser.plugInName(); QString plugInName = parser.plugInName();
QString workingDir = parser.workingDir(); QString workingDir = parser.workingDir();
QString iniFileName = parser.iniFileName();
bool const dryRun = parser.dryRun(); bool const dryRun = parser.dryRun();
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware(); bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
bool const showYoctoVersion = parser.yoctoVersion(); bool const showYoctoVersion = parser.yoctoVersion();
@@ -84,6 +85,12 @@ int main(int argc, char *argv[]) {
QString const rtPath = QCoreApplication::applicationDirPath(); QString const rtPath = QCoreApplication::applicationDirPath();
int const machineNr = Utils::read1stLineOfFile("/mnt/system_data/machine_nr");
int const customerNr = Utils::read1stLineOfFile("/mnt/system_data/cust_nr");
int const zoneNr = Utils::read1stLineOfFile("/mnt/system_data/zone_nr");
QString const branchName = (zoneNr != 0)
? QString("zg1/zone%1").arg(zoneNr) : "master";
qInfo() << "pwd ......................" << rtPath; qInfo() << "pwd ......................" << rtPath;
qInfo() << "repositoryUrl ............" << repositoryUrl; qInfo() << "repositoryUrl ............" << repositoryUrl;
qInfo() << "plugInDir ................" << plugInDir; qInfo() << "plugInDir ................" << plugInDir;
@@ -93,7 +100,14 @@ int main(int argc, char *argv[]) {
qInfo() << "noUpdatePsaHardware ......" << noUpdatePsaHardware; qInfo() << "noUpdatePsaHardware ......" << noUpdatePsaHardware;
qInfo() << "alwaysDownloadConfig ....." << alwaysDownloadConfig; qInfo() << "alwaysDownloadConfig ....." << alwaysDownloadConfig;
qInfo() << "alwaysDownloadDC ........." << alwaysDownloadDC; qInfo() << "alwaysDownloadDC ........." << alwaysDownloadDC;
qInfo() << "showYoctoVersion ........." << showYoctoVersion;
qInfo() << "showYoctoInstallStatus ..." << showYoctoInstallStatus;
qInfo() << "showExtendedVersion ......" << showExtendedVersion;
qInfo() << "iniFileName .............." << iniFileName;
qInfo() << "extended-version ........." << APP_EXTENDED_VERSION; qInfo() << "extended-version ........." << APP_EXTENDED_VERSION;
qInfo() << "machineNr ................" << machineNr;
qInfo() << "customerNr ..............." << customerNr;
qInfo() << "zoneNr ..................." << zoneNr;
if (showExtendedVersion) { if (showExtendedVersion) {
printf(APP_EXTENDED_VERSION"\n"); printf(APP_EXTENDED_VERSION"\n");
@@ -108,11 +122,6 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
int machineNr = Utils::read1stLineOfFile("/etc/machine_nr");
int customerNr = Utils::read1stLineOfFile("/etc/cust_nr");
int zoneNr = Utils::read1stLineOfFile("/etc/zone_nr");
QString const branchName = (zoneNr != 0)
? QString("zg1/zone%1").arg(zoneNr) : "master";
QThread::currentThread()->setObjectName("main thread"); QThread::currentThread()->setObjectName("main thread");
qInfo() << "Main thread" << QThread::currentThreadId(); qInfo() << "Main thread" << QThread::currentThreadId();

View File

@@ -146,7 +146,7 @@ void MainWindow::onEnableExit() {
void MainWindow::onRestartExitTimer() { void MainWindow::onRestartExitTimer() {
m_exitTimer->stop(); m_exitTimer->stop();
m_exitTimer->start(60 * 1000); m_exitTimer->start(5 * 1000);
scrollDownTextEdit(); scrollDownTextEdit();
ui->updateStatus->setEnabled(false); ui->updateStatus->setEnabled(false);
@@ -208,13 +208,12 @@ void MainWindow::onAppendText(QString text, QString suffix) {
// Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts)); // Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts));
// ui->updateStatus->setText(editText.trimmed()); // ui->updateStatus->setText(editText.trimmed());
// scrollDownTextEdit(); scrollDownTextEdit();
} }
void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) { void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
// Utils::printInfoMsg(QString("ON REPLACE LAST (LIST) CALLED AT ") // Utils::printInfoMsg(QString("ON REPLACE LAST (LIST) CALLED AT ")
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs)); // + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
int const s = newTextLines.size(); int const s = newTextLines.size();
if (s > 0) { if (s > 0) {
QString editText = ui->updateStatus->toPlainText(); QString editText = ui->updateStatus->toPlainText();
@@ -249,11 +248,15 @@ void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
void MainWindow::onReplaceLast(QString text, QString suffix) { void MainWindow::onReplaceLast(QString text, QString suffix) {
// Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ") // Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ")
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs)); // + 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);
if (lines.size() > 0) { if (lines.size() > 0) {
// removing the last line is really meant for refreshing the last line
// with a string very similar than the original one, typically only
// followed by a suffix.
if (lines.last().contains(text)) {
lines.removeLast(); lines.removeLast();
}
if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") { if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
QString const add = text.leftJustified(m_width-10) + suffix; QString const add = text.leftJustified(m_width-10) + suffix;
if (!add.isEmpty()) { if (!add.isEmpty()) {

View File

@@ -115,15 +115,28 @@ Update::Update(Worker *worker,
, m_branchName(branchName) , m_branchName(branchName)
, m_pluginName(pluginName) , m_pluginName(pluginName)
, m_workingDir(workingDir) , m_workingDir(workingDir)
, m_dryRun(dryRun) { , m_dryRun(dryRun)
, m_sys_areDCdataValid(false) {
qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface; int tries = 20;
qInfo() << "UPDATE: m_baudrate ..." << m_baudrate; while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
qInfo() << "UPDATE: m_customerRepository ..." << m_customerRepository; // must deliver 'true', only then are all data from hwapi valid
qInfo() << "UPDATE: m_customerNr ..........." << m_customerNrStr; if (--tries < 0) {
qInfo() << "UPDATE: m_branchName ..........." << m_branchName; qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
qInfo() << "UPDATE: m_pluginName ..........." << m_pluginName; }
qInfo() << "UPDATE: m_workingDirectory ....." << m_workingDir; m_hw->dc_autoRequest(true);
QThread::msleep(500);
}
qCritical() << "UPDATE: m_sys_areDCDataValid ..." << m_sys_areDCdataValid;
//qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface;
//qInfo() << "UPDATE: m_baudrate ..." << m_baudrate;
//qInfo() << "UPDATE: m_customerRepository ..." << m_customerRepository;
//qInfo() << "UPDATE: m_customerNr ..........." << m_customerNrStr;
//qInfo() << "UPDATE: m_branchName ..........." << m_branchName;
//qInfo() << "UPDATE: m_pluginName ..........." << m_pluginName;
//qInfo() << "UPDATE: m_workingDirectory ....." << m_workingDir;
} }
Update::~Update() { Update::~Update() {
@@ -363,23 +376,24 @@ bool Update::downloadJson(enum FileTypeJson type,
templateIdx, templateIdx,
(uint8_t *)ba.data())) { (uint8_t *)ba.data())) {
QThread::msleep(1000); m_hw->dc_autoRequest(true);
QThread::msleep(500);
// testing // testing
//m_hw->request_ReadbackMachineID(); m_hw->request_ReadbackMachineID();
//QThread::msleep(500); QThread::msleep(500);
//uint8_t data[64]; uint8_t data[64];
//memset(data, 0x00, sizeof(data)); memset(data, 0x00, sizeof(data));
//uint8_t length = 0; uint8_t length = 0;
//m_hw->readback_machineIDdata(&length, data); m_hw->readback_machineIDdata(&length, data);
//QThread::msleep(500); QThread::msleep(500);
//QByteArray ba((const char*)data, length); QByteArray ba((const char*)data, length);
//qCritical() << length << "MACHINE ID =" << ba.toHex(':'); qCritical() << length << "MACHINE ID =" << ba.toHex(':');
ret = true; ret = true;
} }
@@ -481,24 +495,17 @@ QStringList Update::getDcSoftAndHardWareVersion() {
} }
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
int tries = 20; if (m_sys_areDCdataValid == false) {
while (!m_hw->sys_areDCdataValid()) { // must deliver 'true', only then are all
// data from hwapi valid
if (--tries < 0) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED"; qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
return false; return false;
} }
m_hw->dc_autoRequest(true);
QThread::msleep(500);
}
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 const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed()); QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$"); if (fToWorkOn.contains("dc2c.bin")) {
if (fToWorkOn.contains(version)) {
bool updateBinaryRes = true; bool updateBinaryRes = true;
// CONSOLE() // CONSOLE()
@@ -588,8 +595,6 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn; qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false; res = false;
} }
// m_worker->stopProgressLoop();
// m_worker->setProgress(100);
if (res == false) { if (res == false) {
break; break;

View File

@@ -32,6 +32,7 @@ class Update : public QObject {
QString m_workingDir; QString m_workingDir;
bool m_maintenanceMode; bool m_maintenanceMode;
bool m_dryRun; bool m_dryRun;
bool m_sys_areDCdataValid;
static QPluginLoader pluginLoader; static QPluginLoader pluginLoader;

View File

@@ -214,6 +214,12 @@ bool Worker::isRepositoryCorrupted() {
Utils::printCriticalErrorMsg("CORRUPTED CUSTOMER REPOSITORY .GIT DOES NOT EXIST"); Utils::printCriticalErrorMsg("CORRUPTED CUSTOMER REPOSITORY .GIT DOES NOT EXIST");
return true; return true;
} }
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
if (!customerRepositoryEtc.exists()) {
// should never happen
Utils::printCriticalErrorMsg(QString("CORRUPTED CUSTOMER REPOSITORY %1/etc DOES NOT EXIST").arg(m_customerRepository));
return true;
}
} }
return false; return false;
} }
@@ -334,21 +340,30 @@ void Worker::privateUpdate() {
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
m_ismasTriggerActive = false; m_ismasTriggerActive = false;
if (m_clone == false) {
if ((continueUpdate = updateTriggerSet()) == false) { if ((continueUpdate = updateTriggerSet()) == false) {
return;
} else {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
setProgress(_CHECK_ISMAS_TRIGGER_SUCCESS);
}
} else {
if (m_initialClone) { if (m_initialClone) {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER)); GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER));
} }
return;
} else {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER));
} }
qCritical() << "**** m_ismasTriggerActive:" << m_ismasTriggerActive;
qCritical() << "**** m_clone:" << m_clone;
if (m_ismasTriggerActive == false) {// make it explicit again: only if the if (m_ismasTriggerActive == false) {// make it explicit again: only if the
// ismas trigger is active ('WAIT'), // ismas trigger is active ('WAIT'),
// then proceed // then proceed
return;
} if (m_clone == false) { // if it is an (initial) clone, then
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS)); return; // run the whole update process:
setProgress(_CHECK_ISMAS_TRIGGER_SUCCESS); } // sync tariff-files, download jsons,
} // download device controller
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@@ -457,9 +472,9 @@ bool Worker::updateTriggerSet() {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER)); GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER));
QString triggerValue(""); QString triggerValue("NOT CHECKED YET");
static constexpr int const repeats = 15;
for (int repeat = 1; repeat <= 100; ++repeat) { for (int repeat = 1; repeat <= repeats; ++repeat) {
if (repeat > 1) { if (repeat > 1) {
int const startMs = QTime::currentTime().msecsSinceStartOfDay(); int const startMs = QTime::currentTime().msecsSinceStartOfDay();
@@ -467,10 +482,12 @@ bool Worker::updateTriggerSet() {
QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000); QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG; CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG;
} else { } else {
CONSOLE(QStringList(func) << QString("-> REPEAT=%1").arg(repeat)) << UPDATE_STEP::DEBUG; QStringList lst = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat));
// GUI(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER;
CONSOLE(lst) << UPDATE_STEP::DEBUG;
} }
if ((repeat % 10) == 0) { if ((repeat % 8) == 0) {
CONSOLE(QStringList(func) << "RESTART APISM") << UPDATE_STEP::DEBUG; CONSOLE(QStringList(func) << "RESTART APISM") << UPDATE_STEP::DEBUG;
Command c("systemctl restart apism"); Command c("systemctl restart apism");
if (c.execute("/tmp")) { if (c.execute("/tmp")) {
@@ -560,7 +577,7 @@ bool Worker::updateTriggerSet() {
return m_ismasTriggerActive; return m_ismasTriggerActive;
} else } else
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
QStringList lst("empty update trigger"); QStringList lst(QString("%1 empty update trigger (%2)").arg(repeat).arg(repeats-repeat));
if (m_clone) { if (m_clone) {
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE); GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
// if the customer repository has just been cloned // if the customer repository has just been cloned
@@ -642,10 +659,7 @@ bool Worker::filesToUpdate() {
// always execute contents of opkg_commands-file // always execute contents of opkg_commands-file
m_filesToUpdate << "etc/psa_update/opkg_commands"; m_filesToUpdate << "etc/psa_update/opkg_commands";
if (m_alwaysDownloadConfig) { if (m_clone && m_alwaysDownloadConfig) {
#if 0
QStringList lst(QString("m_alwaysDownloadConfig NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
// always download all json-config files, even if none of them have been // always download all json-config files, even if none of them have been
// changed in the git repository. useful for first installation. // changed in the git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config")); QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config"));
@@ -655,24 +669,19 @@ bool Worker::filesToUpdate() {
m_filesToUpdate << jsons; m_filesToUpdate << jsons;
} }
} }
#endif
} }
if (m_alwaysDownloadDC) { if (m_clone && m_alwaysDownloadDC) {
#if 0
QStringList lst(QString("m_alwaysDownloadDC NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
// always download the last dc-binary, even if not changed in the // always download the last dc-binary, even if not changed in the
// git repository. useful for first installation. // git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_update")); QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/dc"));
if (dir.exists()) { if (dir.exists()) {
QStringList dc = dir.entryList(QStringList() << "dc2c*.bin", QDir::Files, QStringList dc = dir.entryList(QStringList() << "dc2c.bin", QDir::Files,
QDir::SortFlag::Time | QDir::SortFlag::Reversed); QDir::SortFlag::Time | QDir::SortFlag::Reversed);
if (!dc.isEmpty()) { if (!dc.isEmpty()) {
m_filesToUpdate << dc.first(); m_filesToUpdate << dc.first();
} }
} }
#endif
} }
if (std::optional<QString> changes = m_gc.gitPull()) { if (std::optional<QString> changes = m_gc.gitPull()) {
@@ -682,6 +691,9 @@ bool Worker::filesToUpdate() {
} }
} }
m_filesToUpdate.removeDuplicates(); m_filesToUpdate.removeDuplicates();
qCritical() << __PRETTY_FUNCTION__ << "FILES-TO-UPDATE" << m_filesToUpdate;
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE); GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE);
setProgress(_FILES_TO_UPDATE); setProgress(_FILES_TO_UPDATE);
} else { } else {
@@ -702,8 +714,7 @@ bool Worker::computeFilesToDownload() {
fName.contains("DC2C_cash", Qt::CaseInsensitive)) { fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
m_filesToDownload << fName; // download printer-config-files m_filesToDownload << fName; // download printer-config-files
} else { } else {
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$"); if (fName.contains("dc2c.bin")) {
if (fName.contains(version)) {
m_filesToDownload << fName; // download device controller m_filesToDownload << fName; // download device controller
} }
} }
@@ -724,7 +735,7 @@ bool Worker::execOpkgCommands() {
if (f.open(QIODevice::ReadOnly)) { if (f.open(QIODevice::ReadOnly)) {
QTextStream in(&f); QTextStream in(&f);
m_opkgCommands.clear(); m_opkgCommands.clear();
bool executeOpkgCommandFailed = false; QStringList opkgErrorLst;
while (!in.atEnd()) { while (!in.atEnd()) {
QString line = in.readLine(); QString line = in.readLine();
static const QRegularExpression comment("^\\s*#.*$"); static const QRegularExpression comment("^\\s*#.*$");
@@ -732,7 +743,7 @@ bool Worker::execOpkgCommands() {
// found opkg command // found opkg command
QString opkgCommand = line.trimmed(); QString opkgCommand = line.trimmed();
if (!executeOpkgCommand(opkgCommand)) { if (!executeOpkgCommand(opkgCommand)) {
executeOpkgCommandFailed = true; opkgErrorLst << opkgCommand;
} else { } else {
QString cmd = "\n " + opkgCommand; QString cmd = "\n " + opkgCommand;
emit appendText(cmd); emit appendText(cmd);
@@ -786,14 +797,15 @@ bool Worker::execOpkgCommands() {
} }
} }
f.close(); f.close();
if (!executeOpkgCommandFailed) { if (opkgErrorLst.size() == 0) {
if (m_opkgCommands.size() > 0) { if (m_opkgCommands.size() > 0) {
m_displayIndex = 1; m_displayIndex = 1;
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS; ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS));
setProgress(_EXEC_OPKG_COMMAND_SUCCESS); setProgress(_EXEC_OPKG_COMMAND_SUCCESS);
} }
} else { } else {
m_displayIndex = 1; m_displayIndex = 1;
ISMAS(opkgErrorLst) << (GUI(opkgErrorLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE));
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE; GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE;
setProgress(_EXEC_OPKG_COMMAND_FAILURE); setProgress(_EXEC_OPKG_COMMAND_FAILURE);
return false; return false;
@@ -809,7 +821,7 @@ bool Worker::execOpkgCommands() {
bool Worker::downloadFilesToPSAHardware() { bool Worker::downloadFilesToPSAHardware() {
m_displayIndex = 0; m_displayIndex = 0;
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE); GUI(m_filesToDownload) << (CONSOLE(m_filesToDownload) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE);
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE); setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE);
if (m_noUpdatePsaHardware == false) { if (m_noUpdatePsaHardware == false) {
@@ -844,7 +856,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
QStringList() << "-c" << "mkdir -p /etc/psa_config /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() << ")";
} }
QString const params("-vvv " QString const params("-v "
"--recursive " "--recursive "
"--progress " "--progress "
"--checksum " "--checksum "

View File

@@ -520,8 +520,10 @@ private:
break; break;
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE: case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE:
break; break;
case UPDATE_STEP::FILES_TO_UPDATE: case UPDATE_STEP::FILES_TO_UPDATE: {
break; lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst);
} break;
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE: { case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE: {
lst << instance->m_debugMsg; lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst); Utils::printUpdateStatusMsg(debug, lst);
@@ -555,8 +557,10 @@ private:
break; break;
case UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS: case UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS:
break; break;
case UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE: case UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE: {
break; lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst);
} break;
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE: case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
break; break;
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS: case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
@@ -1123,6 +1127,9 @@ private:
break; break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER: case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
emit worker->appendText("\n" CHECK_UPDATE_TRIGGER_SET); emit worker->appendText("\n" CHECK_UPDATE_TRIGGER_SET);
if (worker->m_guiMsg.size() > 0) {
emit worker->showStatusMessage(worker->m_guiMsg);
}
break; break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS: case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
break; break;
@@ -1173,7 +1180,8 @@ private:
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
emit worker->appendText(QString("\n ") + worker->m_filesToUpdate.at(i)); emit worker->appendText(QString("\n ") + worker->m_filesToUpdate.at(i));
} }
} else { }
if (size == 1) {
emit worker->appendText("Found 1 file to update :", UPDATE_STEP_DONE); emit worker->appendText("Found 1 file to update :", UPDATE_STEP_DONE);
emit worker->appendText(QString("\n ") + worker->m_filesToUpdate.at(0)); emit worker->appendText(QString("\n ") + worker->m_filesToUpdate.at(0));
} }