Compare commits

..

27 Commits

Author SHA1 Message Date
686e113c3a Fix: add break when checking dc alive status. set version to 1.3.24. 2023-12-19 14:30:58 +01:00
6ddfbbfd9e add a break to prevent possible endless loop 2023-12-19 14:25:59 +01:00
7bfbdc0f07 Update flowchart for UpdateTool. 2023-12-19 13:05:10 +01:00
dd591fdd23 Amde some preparations for sendLastVersion 2023-12-17 16:25:31 +01:00
18c7b656c3 Add some new points. 2023-12-17 15:23:00 +01:00
5e9b05e887 Set version to 1.3.23. 2023-12-15 09:48:14 +01:00
37aae73f21 Fix: Make sure the path for the json-files and the decive-controller is correct. 2023-12-15 09:39:46 +01:00
0b4eed9dc0 doUpdate(): add another level in if-case when downloading json-files. 2023-12-15 09:38:01 +01:00
12f48ad1bb Remove only half-working check if download of json-conf-file worked. 2023-12-15 09:33:57 +01:00
5d7d1a2870 Implement helpers getFileVersions() and checkDownloadedJsonVersions(). 2023-12-15 09:32:54 +01:00
5d7f13a254 Future: add getFileVersion() and checkDownloadedJsonVersions() to
check if download of Json-File worked and to ask what Json-Version
is actually installed
2023-12-15 09:30:02 +01:00
d332a990d5 Turn on automatic download of json-files. 2023-12-15 09:27:49 +01:00
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
12 changed files with 509 additions and 107 deletions

View File

@@ -14,5 +14,5 @@ dry-run=false
extended-version=false
yocto-version=false
yocto-install=false
always-download-config=false
always-download-config=true
always-download-dc=false

View File

@@ -53,7 +53,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
# local filesystem, json-files will be downloaded to firmware.
# The device-controller firmware will be handled in a later version.
# 1.3.15: Bug fixes found during testing.
# Don't disable Exit-button during update-process.
# Do not disable Exit-button during update-process.
# Removed worker-thread with an own event-loop: only the GUI thread
# has an event loop. Tested JSON-downloads several times successfully
# (using the slave lib where the CA helper tool was active as master).
@@ -64,8 +64,26 @@ DEFINES += QT_DEPRECATED_WARNINGS
# given in ATBUpdateTool.ini can be overwritten on the command-line.
# 1.3.18: Bug fixes found during testing.
# 1.3.19: Bug fixes found during testing.
VERSION="1.3.20"
# 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.
# 1.3.22: Bug fixes found during testing:
# Fix the path-names of the json-files and the device-controller.
# Set automatic download of json-file in ATBUpdateTool.ini file for
# a fresh clone of the repository.
# 1.3.23 Added a 'break' to prevent a possible endless loop when checking if
# the device is alive.
VERSION="1.3.24"
# PLANNED TODOS:
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
@@ -96,6 +114,35 @@ VERSION="1.3.20"
# 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.
# 11: Das Edit-Fenster teilen um die Anzeige zu verbessern.
# 12: Bei einem Update muss immer ersichtlich sein, warum es ueberhaupt
# angestossen wurde. Steht kein "WAIT" im ISMAS-Trigger, dann kann man
# davon ausgehen, dass es sich um ein automatisches Update handelt.
# In jedem Fall wird bei einem automatischen Update, bei dem der WAIT-
# Button nicht gesetzt war, ein "OK" gesendet, falls sonst nichts weiter
# zu tun ist. Beachte aber: wir haben auch noch den Fall, dass eine SD-
# Karte gesteckt wird. In diesem Fall wird ein komplettes Update gefahren,
# und zwar explizit auch ohne WAIT-Button.
# Am Ende eines Updates steht im ISMAS entweder ein "OK" oder ein "FAIL".
# 13: SendLastVersion: fuer jedes erfolgreich installierte Paket eine
# Send-Last-Version-Nachricht an ISMAS. Dadurch entsteht im ISMAS eine
# History (Christian darueber informieren).
# 14: Installiert werden nur Dateien, die neu sind oder geaendert wurden.
# Nicht etwas Dateien, die geloescht wurden: sicherstellen, dass man hier
# immer direkt im repository arbeitet, nicht auf dem Filesystem.
# Ferner: der DeviceController heisst dc2c.bin, auch fuer die Jsons
# sind Dtandard-Namen vergeben. Alternativ: alle vorhandenen Jsons
# werden runtergeladen: Thomas ist eh fuer deren Inhalte verantworlich.
# WICHTIG: immer ueberpruefen, ob die Dateien im Customer-Repository
# wirklich die richtigen Dateien sind.
# 15: Der WAIT-Button laesst sich auf WAIT zuruecksetzen (etwa wenn git
# selber Probleme hatte).
# 16: Der Download-Thread sollte sowohl die auto-Variable auf false setzen
# als auch den cycle-Timer stoppen, damit sichergestellt ist, dass der
# Download des DC nicht gestoert wird.
win32 {

View File

@@ -87,7 +87,7 @@ void CommandLineParser::configure() {
m_repositoryUrlOption.setDefaultValue("https://git.mimbach49.de/GerhardHoffmann");
m_parser.addOption(m_repositoryUrlOption);
m_iniFileDirectoryOption.setDefaultValue(".");
m_iniFileDirectoryOption.setDefaultValue(QCoreApplication::applicationDirPath());
m_parser.addOption(m_iniFileDirectoryOption);
m_iniFileNameOption.setDefaultValue("ATBUpdateTool.ini");
@@ -117,10 +117,10 @@ void CommandLineParser::configure() {
m_extendedVersionOption.setDefaultValue("false");
m_parser.addOption(m_extendedVersionOption);
m_yoctoVersionOption .setDefaultValue("false");
m_yoctoVersionOption.setDefaultValue("false");
m_parser.addOption(m_yoctoVersionOption);
m_yoctoInstallStatusOption .setDefaultValue("false");
m_yoctoInstallStatusOption.setDefaultValue("false");
m_parser.addOption(m_yoctoInstallStatusOption);
}
@@ -128,7 +128,6 @@ void CommandLineParser::readSettings() {
QString const iniFileDir = m_parser.value(m_iniFileDirectoryOption);
QString const iniFileName = m_parser.value(m_iniFileNameOption);
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
if (!m_iniFileName.isEmpty()) {
if (QFile(m_iniFileName).exists()) {
QSettings settings(m_iniFileName, QSettings::IniFormat);

BIN
doc/ATBUpdateTool4.pdf Normal file

Binary file not shown.

View File

@@ -1834,6 +1834,9 @@ public:
virtual uint8_t prn_getPrintResult() const {
return 0;
}
// return: 0: just printing, wait
// 1: OK - last print was succesful
// 2: error - not printed
@@ -2273,7 +2276,32 @@ public:
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.
/* GH Version, bringt Fehler
void hwapi_templatePrintFinished_OK() const;
void hwapi_templatePrintFinished_Err() const;
@@ -2296,6 +2324,7 @@ signals:
void hwapi_doorCoinBoxInserted() const;
void hwapi_doorCBinAndAllDoorsClosed() const;
void hwapi_doorAllDoorsClosed() const;
*/
};

View File

@@ -793,6 +793,152 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
return buf;
}
#if 0
// prepare
QString IsmasClient::sendLastVersion(UPDATE_COMPONENT updateComponent,
PSAInstalled const &psa) {
static char buf[4096*2];
memset(buf, 0, sizeof(buf));
switch (updateComponent) {
case UPDATE_COMPONENT::TARIFF:
snprintf(buf, sizeof(buf)-1,
"{"
"\"VERSION_INFO\" : {"
"\"UPDATE_REASON\":\"%s\","
"\"CREATED\":\"%s\","
"\"GIT_COMMIT\":\"%s\""
"},"
"\"TARIFF\" : {"
"\"VERSION\" : \"%s\","
"\"PROJECT\" : \"%s\","
"\"ZONE\" : %d,"
"\"INFO\" : \"%s\","
"\"SIZE\" : %d\""
"},"
"}",
psa.tariff.versionInfo.reason.toStdString().c_str(),
psa.tariff.versionInfo.created.toStdString().c_str(),
psa.tariff.versionInfo.lastCommit.toStdString().c_str(),
psa.tariff.version.toStdString().c_str(),
psa.tariff.project.toStdString().c_str(),
psa.tariff.zone,
psa.tariff.info.toStdString().c_str(),
psa.tariff.size);
break;
case UPDATE_COMPONENT::SOFTWARE_ATBQT:
break;
case UPDATE_COMPONENT::SOFTWARE_APISM:
break;
case UPDATE_COMPONENT::SOFTWARE_ATB_UPDATE_TOOL:
break;
case UPDATE_COMPONENT::CONFIG_PTU5_CPU_SERIAL:
break;
case UPDATE_COMPONENT::CONFIG_DEVICE_CONTROLLER:
break;
case UPDATE_COMPONENT::CONFIG_PRINTER:
break;
case UPDATE_COMPONENT::CONFIG_BNA:
break;
case UPDATE_COMPONENT::PLUGIN_ATB_DEVICE_CONTROLLER:
break;
case UPDATE_COMPONENT::PLUGIN_INGENICO_CC:
break;
case UPDATE_COMPONENT::PLUGIN_MOBILISIS_CALC_PRICE:
break;
case UPDATE_COMPONENT::PLUGIN_MOBILISIS_CALC_PRICE_UI:
break;
case UPDATE_COMPONENT::PLUGIN_PRM_CALC_PRICE:
break;
case UPDATE_COMPONENT::PLUGIN_PRM_CALC_PRICE_UI:
break;
case UPDATE_COMPONENT::PLUGIN_TCP_ZVT_CC:
break;
case UPDATE_COMPONENT::OPKG_COMMANDS:
break;
case UPDATE_COMPONENT::HARDWARE_DEVICES:
break;
case UPDATE_COMPONENT::OS:
break;
case UPDATE_COMPONENT::DC2C_CASH_JSON:
break;
case UPDATE_COMPONENT::DC2C_CONF_JSON:
break;
case UPDATE_COMPONENT::DC2C_DEVICE_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT01_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT02_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT03_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT04_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT05_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT06_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT07_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT08_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT09_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT10_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT11_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT12_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT13_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT14_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT15_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT16_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT17_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT18_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT19_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT20_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT21_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT22_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT23_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT24_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT25_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT26_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT27_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT28_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT29_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT30_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT31_JSON:
break;
case UPDATE_COMPONENT::DC2C_PRINT32_JSON:
break;
}
qInfo() << buf;
return buf;
}
#endif
QString IsmasClient::updateOfPSAContinues(QString currentStage,
QString currentStageInfo,
QString const &version) {

View File

@@ -14,6 +14,7 @@ struct PSAInstalled {
} versionInfo;
struct Tariff {
// VersionInfo versionInfo;
QString name;
QString version;
QString project;
@@ -31,6 +32,7 @@ struct PSAInstalled {
} hw;
struct Opkg {
// VersionInfo versionInfo;
int size;
QString blob;
QString lastCommit;
@@ -38,6 +40,7 @@ struct PSAInstalled {
} opkg;
struct DC {
// VersionInfo versionInfo;
QString versionHW;
QString versionSW;
QString gitBlob;
@@ -62,6 +65,7 @@ struct PSAInstalled {
} pluginVersion;
struct DC2C {
// VersionInfo versionInfo;
QString name;
QString blob;
int size;
@@ -194,8 +198,68 @@ public:
QString jsonParseFailed(int resultCode, QString reason, QString const &version = QString());
std::optional<QString> finalResult(int resultCode, QString reason, QString const &version = QString());
// legacy
QString updateOfPSASendVersion(PSAInstalled const &psa);
#if 0
enum class UPDATE_COMPONENT {
TARIFF,
SOFTWARE_ATBQT,
SOFTWARE_APISM,
SOFTWARE_ATB_UPDATE_TOOL,
CONFIG_PTU5_CPU_SERIAL,
CONFIG_DEVICE_CONTROLLER,
CONFIG_PRINTER,
CONFIG_BNA,
PLUGIN_ATB_DEVICE_CONTROLLER,
PLUGIN_INGENICO_CC,
PLUGIN_MOBILISIS_CALC_PRICE,
PLUGIN_MOBILISIS_CALC_PRICE_UI,
PLUGIN_PRM_CALC_PRICE,
PLUGIN_PRM_CALC_PRICE_UI,
PLUGIN_TCP_ZVT_CC,
OPKG_COMMANDS,
HARDWARE_DEVICES,
OS,
DC2C_CASH_JSON,
DC2C_CONF_JSON,
DC2C_DEVICE_JSON,
DC2C_PRINT01_JSON,
DC2C_PRINT02_JSON,
DC2C_PRINT03_JSON,
DC2C_PRINT04_JSON,
DC2C_PRINT05_JSON,
DC2C_PRINT06_JSON,
DC2C_PRINT07_JSON,
DC2C_PRINT08_JSON,
DC2C_PRINT09_JSON,
DC2C_PRINT10_JSON,
DC2C_PRINT11_JSON,
DC2C_PRINT12_JSON,
DC2C_PRINT13_JSON,
DC2C_PRINT14_JSON,
DC2C_PRINT15_JSON,
DC2C_PRINT16_JSON,
DC2C_PRINT17_JSON,
DC2C_PRINT18_JSON,
DC2C_PRINT19_JSON,
DC2C_PRINT20_JSON,
DC2C_PRINT21_JSON,
DC2C_PRINT22_JSON,
DC2C_PRINT23_JSON,
DC2C_PRINT24_JSON,
DC2C_PRINT25_JSON,
DC2C_PRINT26_JSON,
DC2C_PRINT27_JSON,
DC2C_PRINT28_JSON,
DC2C_PRINT29_JSON,
DC2C_PRINT30_JSON,
DC2C_PRINT31_JSON,
DC2C_PRINT32_JSON,
};
QString sendLastVersion(UPDATE_COMPONENT comp, PSAInstalled const &psa);
#endif
private:
static void printDebugMessage(int port, QString const &clientIP, int clientPort,
QString const &message);

View File

@@ -146,7 +146,7 @@ void MainWindow::onEnableExit() {
void MainWindow::onRestartExitTimer() {
m_exitTimer->stop();
m_exitTimer->start(60 * 1000);
m_exitTimer->start(5 * 1000);
scrollDownTextEdit();
ui->updateStatus->setEnabled(false);

View File

@@ -123,6 +123,7 @@ Update::Update(Worker *worker,
// must deliver 'true', only then are all data from hwapi valid
if (--tries < 0) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
break;
}
m_hw->dc_autoRequest(true);
QThread::msleep(500);
@@ -376,24 +377,32 @@ bool Update::downloadJson(enum FileTypeJson type,
templateIdx,
(uint8_t *)ba.data())) {
m_hw->dc_autoRequest(true);
QThread::msleep(500);
/*
* Note: the machine id is contained in DC2C_conf.json.
* The idea was to use this to check if the download of
* the json-file was correct. It did not work, as the
* update of the PSA (to reflect a change in the
* machine id) did not happen immediately.
*
m_hw->dc_autoRequest(true);
QThread::msleep(500);
// testing
m_hw->request_ReadbackMachineID();
QThread::msleep(500);
// testing
m_hw->request_ReadbackMachineID();
QThread::msleep(500);
uint8_t data[64];
memset(data, 0x00, sizeof(data));
uint8_t length = 0;
uint8_t data[64];
memset(data, 0x00, sizeof(data));
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;
}
@@ -494,6 +503,86 @@ QStringList Update::getDcSoftAndHardWareVersion() {
<< "DC SW-version not available";
}
QString Update::getFileVersion(QString const& jsonFileName) {
// "version":"15.10.2023 14:55 02.00.06",
static const QRegularExpression re("^.*(\\\"version\\\":)(.*)$");
QString fileVersion;
QFile inputFile(jsonFileName);
if (inputFile.open(QIODevice::ReadOnly)) {
QTextStream in(&inputFile);
while (!in.atEnd()) {
QString line = in.readLine();
QRegularExpressionMatch match;
int idx = line.indexOf(re, 0, &match);
if (idx != -1) {
fileVersion = match.captured(match.lastCapturedIndex());
break;
}
}
inputFile.close();
}
return fileVersion;
}
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
uint8_t jsonNr = 0;
QFileInfo fInfo(jsonFileNames[i]);
if (fInfo.fileName().endsWith("conf.json")) {
jsonNr = 1;
} else
if (fInfo.fileName().endsWith("device.json")) {
jsonNr = 2;
} else
if (fInfo.fileName().endsWith("cash.json")) {
jsonNr = 3;
} else {
QRegularExpressionMatch match;
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
int idx = fInfo.fileName().indexOf(re, 0, &match);
if (idx != -1) {
QString captured = match.captured(match.lastCapturedIndex());
bool ok = false;
int n = captured.toInt(&ok);
if (ok) {
jsonNr = n + 4;
}
}
}
if (jsonNr != 0) {
m_hw->sys_requestJsonVersions(jsonNr);
QThread::msleep(500);
char buf[64];
memset(buf, 0x00, sizeof(buf));
m_hw->sys_getJsonVersions(jsonNr, buf);
buf[sizeof(buf)-1] = '\0';
QString const installedVersion(buf);
QString const fileVersion = getFileVersion(jsonFileNames[i]);
qCritical() << "installed version:" << installedVersion;
qCritical() << " file version:" << fileVersion;
if (installedVersion == fileVersion) {
}
} else {
qCritical() << "CANNOT FIND JSON-NR FOR" << jsonFileNames[i];
}
}
return false;
}
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
if (m_sys_areDCdataValid == false) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
@@ -504,9 +593,10 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
QList<QString>::const_iterator it;
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
m_worker->startProgressLoop();
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(version)) {
if (fToWorkOn.contains("dc2c.bin")) {
bool updateBinaryRes = true;
// CONSOLE()
@@ -542,62 +632,62 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
res = updateBinaryRes;
} else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
} else {
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
if ((templateIdx < 1) || (templateIdx > 32)) {
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
res = false;
} else {
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
Utils::printInfoMsg(
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
.arg(fToWorkOn)
.arg(templateIdx));
res = true;
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
if ((templateIdx < 1) || (templateIdx > 32)) {
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
res = false;
} else {
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
Utils::printInfoMsg(
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
.arg(fToWorkOn)
.arg(templateIdx));
++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE);
}
}
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res = updateCashConf(fToWorkOn))) {
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE);
}
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res= updateConfig(fToWorkOn))) {
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE);
}
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res = updateDeviceConf(fToWorkOn))) {
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE);
}
} else {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false;
}
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res = updateCashConf(fToWorkOn))) {
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE);
}
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res= updateConfig(fToWorkOn))) {
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE);
}
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res = updateDeviceConf(fToWorkOn))) {
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
++displayIndex;
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
Worker::UPDATE_STEP_DONE);
}
} else {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false;
}
// m_worker->stopProgressLoop();
// m_worker->setProgress(100);
if (res == false) {
break;

View File

@@ -58,6 +58,7 @@ public:
char const *baudrate = "115200");
virtual ~Update() override;
bool doUpdate(int &displayIndex, QStringList const &linesToWorkOn);
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
hwinf *hw() { return m_hw; }
hwinf const *hw() const { return m_hw; }
@@ -87,6 +88,7 @@ private:
bool downloadJson(enum FileTypeJson type, int templateIdx,
QString jsFileToSendToDC) const;
QStringList getDcSoftAndHardWareVersion();
QString getFileVersion(QString const& jsonFile);
private slots:
void readyReadStandardOutput();

View File

@@ -214,6 +214,12 @@ bool Worker::isRepositoryCorrupted() {
Utils::printCriticalErrorMsg("CORRUPTED CUSTOMER REPOSITORY .GIT DOES NOT EXIST");
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;
}
@@ -334,21 +340,30 @@ void Worker::privateUpdate() {
//
////////////////////////////////////////////////////////////////////////////
m_ismasTriggerActive = false;
if ((continueUpdate = updateTriggerSet()) == false) {
if (m_clone == 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) {
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
// ismas trigger is active ('WAIT'),
// then proceed
return;
}
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
setProgress(_CHECK_ISMAS_TRIGGER_SUCCESS);
if (m_clone == false) { // if it is an (initial) clone, then
return; // run the whole update process:
} // sync tariff-files, download jsons,
} // download device controller
////////////////////////////////////////////////////////////////////////////
@@ -458,8 +473,8 @@ bool Worker::updateTriggerSet() {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER));
QString triggerValue("NOT CHECKED YET");
for (int repeat = 1; repeat <= 100; ++repeat) {
static constexpr int const repeats = 15;
for (int repeat = 1; repeat <= repeats; ++repeat) {
if (repeat > 1) {
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);
CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG;
} 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;
Command c("systemctl restart apism");
if (c.execute("/tmp")) {
@@ -560,7 +577,7 @@ bool Worker::updateTriggerSet() {
return m_ismasTriggerActive;
} else
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) {
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
// if the customer repository has just been cloned
@@ -642,37 +659,31 @@ bool Worker::filesToUpdate() {
// always execute contents of opkg_commands-file
m_filesToUpdate << "etc/psa_update/opkg_commands";
if (m_alwaysDownloadConfig) {
#if 0
QStringList lst(QString("m_alwaysDownloadConfig NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
if (m_clone && m_alwaysDownloadConfig) {
// always download all json-config files, even if none of them have been
// changed in the git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config"));
if (dir.exists()) {
QStringList jsons = dir.entryList(QStringList() << "DC2C*.json", QDir::Files);
if (!jsons.isEmpty()) {
m_filesToUpdate << jsons;
for (QStringList::size_type i=0; i<jsons.size(); ++i) {
m_filesToUpdate << QDir::cleanPath(QString("etc/psa_config/") + jsons.at(i));
}
}
}
#endif
}
if (m_alwaysDownloadDC) {
#if 0
QStringList lst(QString("m_alwaysDownloadDC NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
if (m_clone && m_alwaysDownloadDC) {
// always download the last dc-binary, even if not changed in the
// 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()) {
QStringList dc = dir.entryList(QStringList() << "dc2c*.bin", QDir::Files,
QStringList dc = dir.entryList(QStringList() << "dc2c.bin", QDir::Files,
QDir::SortFlag::Time | QDir::SortFlag::Reversed);
if (!dc.isEmpty()) {
m_filesToUpdate << dc.first();
m_filesToUpdate << QDir::cleanPath(QString("etc/dc/") + dc.first());
}
}
#endif
}
if (std::optional<QString> changes = m_gc.gitPull()) {
@@ -705,8 +716,7 @@ bool Worker::computeFilesToDownload() {
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
m_filesToDownload << fName; // download printer-config-files
} else {
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
if (fName.contains(version)) {
if (fName.contains("dc2c.bin")) {
m_filesToDownload << fName; // download device controller
}
}
@@ -727,7 +737,7 @@ bool Worker::execOpkgCommands() {
if (f.open(QIODevice::ReadOnly)) {
QTextStream in(&f);
m_opkgCommands.clear();
bool executeOpkgCommandFailed = false;
QStringList opkgErrorLst;
while (!in.atEnd()) {
QString line = in.readLine();
static const QRegularExpression comment("^\\s*#.*$");
@@ -735,7 +745,7 @@ bool Worker::execOpkgCommands() {
// found opkg command
QString opkgCommand = line.trimmed();
if (!executeOpkgCommand(opkgCommand)) {
executeOpkgCommandFailed = true;
opkgErrorLst << opkgCommand;
} else {
QString cmd = "\n " + opkgCommand;
emit appendText(cmd);
@@ -789,14 +799,15 @@ bool Worker::execOpkgCommands() {
}
}
f.close();
if (!executeOpkgCommandFailed) {
if (opkgErrorLst.size() == 0) {
if (m_opkgCommands.size() > 0) {
m_displayIndex = 1;
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS;
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS));
setProgress(_EXEC_OPKG_COMMAND_SUCCESS);
}
} else {
m_displayIndex = 1;
ISMAS(opkgErrorLst) << (GUI(opkgErrorLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE));
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE;
setProgress(_EXEC_OPKG_COMMAND_FAILURE);
return false;
@@ -827,7 +838,16 @@ bool Worker::downloadFilesToPSAHardware() {
m_pluginName,
m_workingDirectory);
return update.doUpdate(m_displayIndex, m_filesToDownload);
if (update.doUpdate(m_displayIndex, m_filesToDownload)) {
// prepared for use: at the moment, the dc-library does not work
// as expected.
// static const QRegularExpression re("^.*\\.json$");
// return update.checkDownloadedJsonVersions(m_filesToDownload.filter(re));
return true;
}
return false;
} else {
CONSOLE(QStringList("NO FILES TO DOWNLOAD TO PSA-HW")) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE;
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
@@ -847,7 +867,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
}
QString const params("-vvv "
QString const params("-v "
"--recursive "
"--progress "
"--checksum "

View File

@@ -557,8 +557,10 @@ private:
break;
case UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS:
break;
case UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE:
break;
case UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE: {
lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst);
} break;
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
break;
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
@@ -1125,6 +1127,9 @@ private:
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
emit worker->appendText("\n" CHECK_UPDATE_TRIGGER_SET);
if (worker->m_guiMsg.size() > 0) {
emit worker->showStatusMessage(worker->m_guiMsg);
}
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
break;