Compare commits
55 Commits
Author | SHA1 | Date | |
---|---|---|---|
5e9b05e887 | |||
37aae73f21 | |||
0b4eed9dc0 | |||
12f48ad1bb | |||
5d7d1a2870 | |||
5d7f13a254 | |||
d332a990d5 | |||
bfa39eb3df | |||
d7fcfa3d0f | |||
f1e449c108 | |||
32346c2665 | |||
38e7bf4985 | |||
6df73e1082 | |||
19250a0a2f | |||
6f5c8103e4 | |||
07dcf0ba30 | |||
1e379cf086 | |||
e87456f26b | |||
0c9a7bc7b5 | |||
a35c6afcb8 | |||
b06f4f46bb
|
|||
33d45eab2e
|
|||
d2e11d8f07 | |||
fbffdc923f | |||
8faf5af2bf | |||
1d532c13a4 | |||
d2d3afc28e | |||
f4bb201633 | |||
b68cf1fd1d | |||
0888c1b525 | |||
a6faf9ce21 | |||
5577cc5d6d | |||
9967d5cc45 | |||
e20ed57bd5 | |||
6986007b16 | |||
9ecdf73bc0 | |||
59d6c49cb2 | |||
f6a8059e2d | |||
4372cb578b | |||
d683a8fc32 | |||
4e92522578 | |||
b45f3a04b4 | |||
0db39746db | |||
f2844aa4d9 | |||
d4043bd7d2 | |||
89b639c0ed | |||
1ad13d9a8a | |||
6f2cbb0a26 | |||
c15cebf503 | |||
5ee1308c9d | |||
746d96ca7c | |||
f387eaedea | |||
0fd977c399 | |||
d53d72c536 | |||
f4be1f3f51 |
@@ -14,3 +14,5 @@ dry-run=false
|
||||
extended-version=false
|
||||
yocto-version=false
|
||||
yocto-install=false
|
||||
always-download-config=true
|
||||
always-download-dc=false
|
||||
|
@@ -60,8 +60,28 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# Turned previous worker-object into its own thread, but without any
|
||||
# own event-loop (so it cannot block anything inside the CA-plugin).
|
||||
# 1.3.16: Bug fixes found during testing.
|
||||
VERSION="1.3.17"
|
||||
# Add ATBUpdateTool.ini and custom command line parser.
|
||||
# 1.3.17: Add ATBUpdateTool.ini and custom command line parser. Settings
|
||||
# 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.
|
||||
# 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.
|
||||
VERSION="1.3.23"
|
||||
|
||||
# PLANNED TODOS:
|
||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||
@@ -81,6 +101,22 @@ VERSION="1.3.17"
|
||||
# installieren, sodass zumnidest SEND-LAST-VERSION mit rausgeht.
|
||||
# 6: rsync: explizites Binary, nicht das in busybox enthaltene.
|
||||
# 7: Versionen der Json-Files lassen sich auslesen.
|
||||
# Problem: Einstellungen in den Json-Files lassen sich auch mittels
|
||||
# Funktionen in der CD-Library ueberschreiben. Damit ist dann wieder nicht
|
||||
# mehr so klar, was jetzt eigentlich aktiv ist.
|
||||
# 8: m_alwaysDownloadConfig und m_alwaysDownloadDC: vorbereitet: man koennte
|
||||
# es so arrangieren, dass der DC plus die Json-files im Repository immer
|
||||
# runtergeladen werden, obwohl sich im Repository gar nicts veraendert
|
||||
# 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.
|
||||
# 11: Das Edit-Fenster teilen um die Anzeige zu verbessern.
|
||||
|
||||
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
|
@@ -6,16 +6,18 @@
|
||||
#include <QFile>
|
||||
|
||||
CommandLineParser::CommandLineParser()
|
||||
: m_repositoryUrl("")
|
||||
, m_plugInDir("")
|
||||
, m_plugInName("")
|
||||
, m_workingDir("")
|
||||
, m_dryRun("")
|
||||
, m_noUpdatePsaHardware("")
|
||||
, m_showYoctoVersion("")
|
||||
, m_showYoctoInstallStatus("")
|
||||
, m_showExtendedVersion("")
|
||||
, m_iniFileName("")
|
||||
: m_repositoryUrl("https://git.mimbach49.de/GerhardHoffmann")
|
||||
, m_plugInDir("/usr/lib/")
|
||||
, m_plugInName("libCAslave.so")
|
||||
, m_workingDir("/opt/app/tools/atbupdate/")
|
||||
, m_dryRun("false")
|
||||
, m_noUpdatePsaHardware("false")
|
||||
, m_showYoctoVersion("false")
|
||||
, m_showYoctoInstallStatus("false")
|
||||
, m_showExtendedVersion("false")
|
||||
, m_iniFileName("ATBUpdateTool.ini")
|
||||
, m_alwaysDownloadConfig("false")
|
||||
, m_alwaysDownloadDC("false")
|
||||
, m_repositoryUrlOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "repository-url" << "repository-url",
|
||||
@@ -45,6 +47,14 @@ CommandLineParser::CommandLineParser()
|
||||
QCommandLineOption(
|
||||
"no-psa-hardware-update",
|
||||
QCoreApplication::translate("main", "Do not update the PSA firmware (json, device-controller).")))
|
||||
, m_alwaysDownloadConfigOption(
|
||||
QCommandLineOption(
|
||||
"always-download-config",
|
||||
QCoreApplication::translate("main", "Always download the (json-)configs to DC).")))
|
||||
, m_alwaysDownloadDCOption(
|
||||
QCommandLineOption(
|
||||
"always-download-dc",
|
||||
QCoreApplication::translate("main", "Always download the dc-bin-file to DC).")))
|
||||
, m_workingDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "working-directory" << "working-directory",
|
||||
@@ -77,26 +87,40 @@ 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");
|
||||
m_parser.addOption(m_iniFileNameOption);
|
||||
|
||||
m_pluginDirectoryOption.setDefaultValue("/usr/lib");
|
||||
m_pluginDirectoryOption.setDefaultValue("/usr/lib/");
|
||||
m_parser.addOption(m_pluginDirectoryOption);
|
||||
|
||||
m_pluginNameOption.setDefaultValue("libCAslave.so");
|
||||
m_parser.addOption(m_pluginNameOption);
|
||||
|
||||
m_alwaysDownloadConfigOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_alwaysDownloadConfigOption);
|
||||
|
||||
m_alwaysDownloadDCOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_alwaysDownloadDCOption);
|
||||
|
||||
m_noDownloadOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_noDownloadOption);
|
||||
|
||||
m_workingDirectoryOption.setDefaultValue("/opt/app/tools/atbupdate");
|
||||
m_workingDirectoryOption.setDefaultValue("/opt/app/tools/atbupdate/");
|
||||
m_parser.addOption(m_workingDirectoryOption);
|
||||
|
||||
m_dryRunOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_dryRunOption);
|
||||
|
||||
m_extendedVersionOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_extendedVersionOption);
|
||||
|
||||
m_yoctoVersionOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_yoctoVersionOption);
|
||||
|
||||
m_yoctoInstallStatusOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_yoctoInstallStatusOption);
|
||||
}
|
||||
|
||||
@@ -104,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);
|
||||
@@ -118,7 +141,7 @@ void CommandLineParser::readSettings() {
|
||||
m_plugInDir = v.toString();
|
||||
} else
|
||||
if (key.contains("working-directory")) {
|
||||
m_plugInName = v.toString();
|
||||
m_workingDir = v.toString();
|
||||
} else
|
||||
if (key.contains("dry-run")) {
|
||||
m_dryRun = (v.toBool() ? "true" : "false");
|
||||
@@ -129,6 +152,12 @@ void CommandLineParser::readSettings() {
|
||||
if (key.contains("no-psa-hardware-update")) {
|
||||
m_noUpdatePsaHardware = (v.toBool() ? "true" : "false");
|
||||
} else
|
||||
if (key.contains("always-download-config")) {
|
||||
m_alwaysDownloadConfig = (v.toBool() ? "true" : "false");
|
||||
} else
|
||||
if (key.contains("always-download-dc")) {
|
||||
m_alwaysDownloadDC = (v.toBool() ? "true" : "false");
|
||||
} else
|
||||
if (key.contains("yocto-install")) {
|
||||
m_showYoctoInstallStatus = (v.toBool() ? "true" : "false");
|
||||
} else
|
||||
@@ -144,65 +173,78 @@ void CommandLineParser::readSettings() {
|
||||
}
|
||||
|
||||
QString CommandLineParser::repositoryUrl() {
|
||||
return m_repositoryUrl;
|
||||
if (m_repositoryUrl.isEmpty()) {
|
||||
if (m_parser.isSet(m_repositoryUrlOption)) {
|
||||
m_repositoryUrl = m_parser.value(m_repositoryUrlOption);
|
||||
}
|
||||
return m_repositoryUrl;
|
||||
}
|
||||
|
||||
QString CommandLineParser::plugInDir() {
|
||||
if (m_plugInDir.isEmpty()) {
|
||||
if (m_parser.isSet(m_pluginDirectoryOption)) {
|
||||
m_plugInDir = m_parser.value(m_pluginDirectoryOption);
|
||||
}
|
||||
return m_plugInDir;
|
||||
}
|
||||
|
||||
QString CommandLineParser::plugInName() {
|
||||
if (m_plugInName.isEmpty()) {
|
||||
if (m_parser.isSet(m_pluginNameOption)) {
|
||||
m_plugInName = m_parser.value(m_pluginNameOption);
|
||||
}
|
||||
return m_plugInName;
|
||||
}
|
||||
|
||||
QString CommandLineParser::workingDir() {
|
||||
if (m_workingDir.isEmpty()) {
|
||||
if (m_parser.isSet(m_workingDirectoryOption)) {
|
||||
m_workingDir = m_parser.value(m_workingDirectoryOption);
|
||||
}
|
||||
return m_workingDir;
|
||||
}
|
||||
|
||||
bool CommandLineParser::dryRun() {
|
||||
if (m_dryRun.isEmpty()) {
|
||||
if (m_parser.isSet(m_dryRunOption)) {
|
||||
m_dryRun = m_parser.value(m_dryRunOption);
|
||||
}
|
||||
return m_dryRun == "false" ? false : true;
|
||||
}
|
||||
|
||||
bool CommandLineParser::noUpdatePsaHardware() {
|
||||
if (m_noUpdatePsaHardware.isEmpty()) {
|
||||
if (m_parser.isSet(m_noDownloadOption)) {
|
||||
m_noUpdatePsaHardware = m_parser.value(m_noDownloadOption);
|
||||
}
|
||||
return m_noUpdatePsaHardware == "false" ? false : true;
|
||||
}
|
||||
|
||||
bool CommandLineParser::yoctoVersion() {
|
||||
if (m_showYoctoVersion.isEmpty()) {
|
||||
if (m_parser.isSet(m_yoctoVersionOption)) {
|
||||
m_showYoctoVersion = m_parser.value(m_yoctoVersionOption);
|
||||
}
|
||||
return m_showYoctoVersion == "false" ? false : true;
|
||||
}
|
||||
|
||||
bool CommandLineParser::yoctoInstallStatus() {
|
||||
if (m_showYoctoInstallStatus.isEmpty()) {
|
||||
if (m_parser.isSet(m_yoctoInstallStatusOption)) {
|
||||
m_showYoctoInstallStatus = m_parser.value(m_yoctoInstallStatusOption);
|
||||
}
|
||||
return m_showYoctoInstallStatus == "false" ? false : true;
|
||||
}
|
||||
|
||||
bool CommandLineParser::extendedVersion() {
|
||||
if (m_showExtendedVersion.isEmpty()) {
|
||||
if (m_parser.isSet(m_extendedVersionOption)) {
|
||||
m_showExtendedVersion = m_parser.value(m_extendedVersionOption);
|
||||
}
|
||||
return m_showExtendedVersion == "false" ? false : true;
|
||||
}
|
||||
|
||||
bool CommandLineParser::alwaysDownloadConfig() {
|
||||
if (m_parser.isSet(m_alwaysDownloadConfigOption)) {
|
||||
m_alwaysDownloadConfig = m_parser.value(m_alwaysDownloadConfigOption);
|
||||
}
|
||||
return m_alwaysDownloadConfig == "false" ? false : true;
|
||||
}
|
||||
|
||||
bool CommandLineParser::alwaysDownloadDC() {
|
||||
if (m_parser.isSet(m_alwaysDownloadDCOption)) {
|
||||
m_alwaysDownloadDC = m_parser.value(m_alwaysDownloadDCOption);
|
||||
}
|
||||
return m_alwaysDownloadDC == "false" ? false : true;
|
||||
}
|
||||
|
@@ -17,6 +17,8 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QString m_showYoctoInstallStatus;
|
||||
QString m_showExtendedVersion;
|
||||
QString m_iniFileName;
|
||||
QString m_alwaysDownloadConfig;
|
||||
QString m_alwaysDownloadDC;
|
||||
|
||||
QCommandLineOption m_repositoryUrlOption;
|
||||
QCommandLineOption m_iniFileDirectoryOption;
|
||||
@@ -24,6 +26,8 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QCommandLineOption m_pluginDirectoryOption;
|
||||
QCommandLineOption m_pluginNameOption;
|
||||
QCommandLineOption m_noDownloadOption;
|
||||
QCommandLineOption m_alwaysDownloadConfigOption;
|
||||
QCommandLineOption m_alwaysDownloadDCOption;
|
||||
QCommandLineOption m_workingDirectoryOption;
|
||||
QCommandLineOption m_dryRunOption;
|
||||
QCommandLineOption m_extendedVersionOption;
|
||||
@@ -53,5 +57,7 @@ public:
|
||||
bool yoctoVersion();
|
||||
bool yoctoInstallStatus();
|
||||
bool extendedVersion();
|
||||
bool alwaysDownloadConfig();
|
||||
bool alwaysDownloadDC();
|
||||
};
|
||||
#endif // COMMAND_LINE_PARSER_H_INCLUDED
|
||||
|
29
interfaces.h
29
interfaces.h
@@ -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;
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
25
main.cpp
25
main.cpp
@@ -74,14 +74,23 @@ int main(int argc, char *argv[]) {
|
||||
QString plugInDir = parser.plugInDir();
|
||||
QString plugInName = parser.plugInName();
|
||||
QString workingDir = parser.workingDir();
|
||||
QString iniFileName = parser.iniFileName();
|
||||
bool const dryRun = parser.dryRun();
|
||||
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
||||
bool const showYoctoVersion = parser.yoctoVersion();
|
||||
bool const showYoctoInstallStatus = parser.yoctoInstallStatus();
|
||||
bool const showExtendedVersion = parser.extendedVersion();
|
||||
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
|
||||
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
|
||||
|
||||
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() << "repositoryUrl ............" << repositoryUrl;
|
||||
qInfo() << "plugInDir ................" << plugInDir;
|
||||
@@ -89,7 +98,16 @@ int main(int argc, char *argv[]) {
|
||||
qInfo() << "workingDir ..............." << workingDir;
|
||||
qInfo() << "dryRun ..................." << dryRun;
|
||||
qInfo() << "noUpdatePsaHardware ......" << noUpdatePsaHardware;
|
||||
qInfo() << "alwaysDownloadConfig ....." << alwaysDownloadConfig;
|
||||
qInfo() << "alwaysDownloadDC ........." << alwaysDownloadDC;
|
||||
qInfo() << "showYoctoVersion ........." << showYoctoVersion;
|
||||
qInfo() << "showYoctoInstallStatus ..." << showYoctoInstallStatus;
|
||||
qInfo() << "showExtendedVersion ......" << showExtendedVersion;
|
||||
qInfo() << "iniFileName .............." << iniFileName;
|
||||
qInfo() << "extended-version ........." << APP_EXTENDED_VERSION;
|
||||
qInfo() << "machineNr ................" << machineNr;
|
||||
qInfo() << "customerNr ..............." << customerNr;
|
||||
qInfo() << "zoneNr ..................." << zoneNr;
|
||||
|
||||
if (showExtendedVersion) {
|
||||
printf(APP_EXTENDED_VERSION"\n");
|
||||
@@ -104,11 +122,6 @@ int main(int argc, char *argv[]) {
|
||||
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");
|
||||
qInfo() << "Main thread" << QThread::currentThreadId();
|
||||
@@ -136,6 +149,8 @@ int main(int argc, char *argv[]) {
|
||||
plugInName,
|
||||
workingDir,
|
||||
noUpdatePsaHardware,
|
||||
alwaysDownloadConfig,
|
||||
alwaysDownloadDC,
|
||||
dryRun);
|
||||
|
||||
MainWindow mw(&worker);
|
||||
|
@@ -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);
|
||||
@@ -208,13 +208,12 @@ void MainWindow::onAppendText(QString text, QString suffix) {
|
||||
// Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts));
|
||||
// ui->updateStatus->setText(editText.trimmed());
|
||||
|
||||
// scrollDownTextEdit();
|
||||
scrollDownTextEdit();
|
||||
}
|
||||
|
||||
void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
|
||||
// Utils::printInfoMsg(QString("ON REPLACE LAST (LIST) CALLED AT ")
|
||||
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
|
||||
int const s = newTextLines.size();
|
||||
if (s > 0) {
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
@@ -249,11 +248,15 @@ void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
|
||||
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
||||
// Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ")
|
||||
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);
|
||||
if (lines.size() > 0) {
|
||||
lines.removeLast();
|
||||
// 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();
|
||||
}
|
||||
if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
|
||||
QString const add = text.leftJustified(m_width-10) + suffix;
|
||||
if (!add.isEmpty()) {
|
||||
|
713
update.cpp
713
update.cpp
@@ -115,214 +115,33 @@ Update::Update(Worker *worker,
|
||||
, m_branchName(branchName)
|
||||
, m_pluginName(pluginName)
|
||||
, m_workingDir(workingDir)
|
||||
, m_dryRun(dryRun) {
|
||||
, m_dryRun(dryRun)
|
||||
, m_sys_areDCdataValid(false) {
|
||||
|
||||
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;
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
if (--tries < 0) {
|
||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
}
|
||||
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::DownloadResult Update::sendStatus(int ret) const {
|
||||
switch (ret) { // return values of dc are:
|
||||
case 0: // 0: no answer by now
|
||||
return DownloadResult::NOP; // 1: error
|
||||
case 10: // 10: success
|
||||
return DownloadResult::OK;
|
||||
default:;
|
||||
}
|
||||
return DownloadResult::ERROR;
|
||||
}
|
||||
|
||||
Update::DownloadResult Update::sendNextAddress(int bNum) const {
|
||||
// sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||
// qDebug() << "addr-block" << bNum << "...";
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
QThread::msleep(100);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "addr-block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else { // res == DownloadResult::OK
|
||||
// qInfo() << "addr-block" << bNum << "...OK";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
// blockNumber is not one of 0, 1024, 2048, 3072, 4096 -> do nothing
|
||||
return DownloadResult::NOP;
|
||||
}
|
||||
|
||||
Update::DownloadResult Update::sendNextDataBlock(QByteArray const &binary,
|
||||
int bNum) const {
|
||||
uint8_t local[66];
|
||||
int const bAddr = bNum * 64;
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
memcpy(local, binary.constData() + bAddr, 64);
|
||||
local[64] = local[65] = 0x00;
|
||||
|
||||
// QByteArray b((const char *)(&local[0]), 64);
|
||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
||||
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
QThread::msleep(10);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "data for block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
// qInfo() << "data for block" << bNum << "OK";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
|
||||
Update::DownloadResult Update::dc_downloadBinary(QByteArray const &b) const {
|
||||
int const nBlocks = (((b.size())%64)==0) ? (b.size()/64) : (b.size()/64)+1;
|
||||
|
||||
// fill lst block of data to be sent with 0xFF
|
||||
QByteArray ba = b.leftJustified(nBlocks*64, (char)(0xFF));
|
||||
|
||||
qInfo() << "total number of bytes to send to dc" << ba.size();
|
||||
qInfo() << "total number of blocks to send to dc" << nBlocks;
|
||||
|
||||
int bNum = 0;
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
fprintf(stderr, "\n64-byte block %04d ", bNum);
|
||||
while (res != DownloadResult::ERROR && bNum < nBlocks) {
|
||||
if ((res = sendNextAddress(bNum)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, bNum)) != DownloadResult::ERROR) {
|
||||
bNum += 1;
|
||||
fprintf(stderr, ".");
|
||||
if ((bNum % 80) == 0) {
|
||||
fprintf(stderr, "\n64-byte block %04d ", bNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\nlast 64-byte block %04d\n", bNum);
|
||||
|
||||
int const rest = ba.size() % 64;
|
||||
int const offset = ba.size() - rest;
|
||||
char const *startAddress = ba.constData() + offset;
|
||||
|
||||
if (rest > 0) {
|
||||
// SHOULD NEVER HAPPEN !!!
|
||||
uint8_t local[66];
|
||||
memset(local, 0xFF, sizeof(local));
|
||||
memcpy(local, startAddress, rest);
|
||||
qCritical() << "ERROR SEND REMAINING" << rest << "BYTES";
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
}
|
||||
|
||||
m_hw->bl_sendLastBlock();
|
||||
qInfo() << "last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Update::startBootloader() const { // deprecated
|
||||
return false;
|
||||
#if 0
|
||||
int nStartTry = 5;
|
||||
while (--nStartTry >= 0) {
|
||||
m_hw->bl_startBL();
|
||||
QThread::msleep(500);
|
||||
int nCheckTry = 10;
|
||||
while (--nCheckTry >= 0) {
|
||||
m_hw->bl_checkBL();
|
||||
QThread::msleep(500);
|
||||
if (m_hw->bl_isUp()) {
|
||||
qInfo() << "starting bootloader...OK";
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << "bootloader not up ("
|
||||
<< nStartTry << "," << nCheckTry << ")" << QThread::currentThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << "starting bootloader...FAILED" << QThread::currentThread();
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Update::stopBootloader() const {
|
||||
// stop bootloader: this MUST work -> otherwise the PSA has to be restarted
|
||||
// manually
|
||||
emit m_worker->showErrorMessage("dc update", "stopping bootloader...");
|
||||
|
||||
int nTryFinalize = 1; // could do this in an endless loop
|
||||
|
||||
do {
|
||||
// in principle, any value except BL_STOP will do, as we want to detect
|
||||
// change to BL_STOP
|
||||
m_worker->mainWindow()->setUpdateStep(UpdateDcEvent::UpdateStep::BL_CHECK);
|
||||
|
||||
QApplication::postEvent(
|
||||
m_worker->mainWindow(),
|
||||
new UpdateDcEvent(m_worker, UpdateDcEvent::UpdateStep::BL_STOP, nTryFinalize));
|
||||
|
||||
QThread::sleep(1);
|
||||
|
||||
int const cntLimit = 20;
|
||||
int cnt = 0;
|
||||
while (++cnt < cntLimit &&
|
||||
m_worker->mainWindow()->updateStep() != UpdateDcEvent::UpdateStep::BL_STOP) {
|
||||
// wait until bl_stopBL() has been sent
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
QApplication::postEvent(
|
||||
m_worker->mainWindow(),
|
||||
new UpdateDcEvent(m_worker, UpdateDcEvent::UpdateStep::BL_CHECK, nTryFinalize));
|
||||
QThread::sleep(1);
|
||||
|
||||
QApplication::postEvent(
|
||||
m_worker->mainWindow(),
|
||||
new UpdateDcEvent(m_worker, UpdateDcEvent::UpdateStep::BL_IS_UP, nTryFinalize));
|
||||
QThread::sleep(1);
|
||||
|
||||
cnt = 0;
|
||||
while (++cnt < cntLimit &&
|
||||
m_worker->mainWindow()->updateStep() != UpdateDcEvent::UpdateStep::BL_IS_DOWN) {
|
||||
// wait until done
|
||||
QThread::msleep(200);
|
||||
}
|
||||
|
||||
} while (++nTryFinalize <= MainWindow::BL_STOP_COUNT &&
|
||||
m_worker->mainWindow()->updateStep() != UpdateDcEvent::UpdateStep::BL_IS_DOWN);
|
||||
|
||||
return (m_worker->mainWindow()->updateStep() == UpdateDcEvent::UpdateStep::BL_IS_DOWN);
|
||||
}
|
||||
|
||||
// br is a index into a table, used for historical reasons.
|
||||
bool Update::openSerial(int br, QString baudrate, QString comPort) const {
|
||||
qDebug() << "opening serial" << br << baudrate << comPort << "...";
|
||||
@@ -354,51 +173,6 @@ bool Update::isSerialOpen() const {
|
||||
return m_hw->dc_isPortOpen();
|
||||
}
|
||||
|
||||
bool Update::resetDeviceController() const { // deprecated
|
||||
return false;
|
||||
#if 0
|
||||
qDebug() << "resetting device controller...";
|
||||
m_hw->bl_rebootDC();
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
qInfo() << "resetting device controller...OK";
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Update::loadBinaryDCFile(QString filename) const {
|
||||
qDebug() << "loading dc binary" << filename << "...";
|
||||
|
||||
QFile file(filename); // closed in destructor call
|
||||
if (!file.exists()) {
|
||||
qCritical() << file.fileName() << "does not exist";
|
||||
return QByteArray();
|
||||
}
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "cannot open file" << file.fileName();
|
||||
return QByteArray();
|
||||
}
|
||||
qInfo() << "loading dc binary" << filename << "...OK";
|
||||
return file.readAll();
|
||||
}
|
||||
|
||||
bool Update::downloadBinaryToDC(QString const &bFile) const {
|
||||
qDebug() << "sending" << bFile << "to dc...";
|
||||
QByteArray const dcBinary = loadBinaryDCFile(bFile);
|
||||
if (dcBinary.size() > 0) {
|
||||
if (dc_downloadBinary(dcBinary) != DownloadResult::OK) {
|
||||
qCritical() << "sending" << bFile << "to dc...FAILED";
|
||||
return false;
|
||||
} else {
|
||||
qInfo() << "sending" << bFile << "to dc...OK";
|
||||
}
|
||||
} else {
|
||||
qCritical() << "sending" << bFile << "to dc...FAILED";
|
||||
qCritical() << "loading binary" << bFile << "FAILED";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -482,111 +256,78 @@ bool Update::downloadBinaryToDC(QString const &bFile) const {
|
||||
// There is no problem to repeat this command until the
|
||||
// bootloader is really not running anymore.
|
||||
*/
|
||||
bool Update::updateBinary(char const *fileToSendToDC) {
|
||||
bool Update::updateBinary(QString const &fileToSendToDC) {
|
||||
qInfo() << "UPDATING DEVICE CONTROLLER FIRMWARE BINARY" << fileToSendToDC;
|
||||
|
||||
return false;
|
||||
|
||||
QFile fn(fileToSendToDC);
|
||||
bool r;
|
||||
if ((r = fn.exists()) == true) {
|
||||
QFileInfo fi(fn);
|
||||
if ((r = updateDC(fileToSendToDC)) == true) {
|
||||
Utils::printInfoMsg(
|
||||
QString(" UPDATING BINARY ") + fi.fileName()
|
||||
+ QString(" (size=%1").arg(fi.size()) + ") DONE");
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString(" UPDATING BINARY ") + fi.fileName()
|
||||
+ QString(" (size=%1").arg(fi.size()) + ") FAILED");
|
||||
if (!fn.exists()) {
|
||||
// output via CONSOLE() etc
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bl_isUp = false;
|
||||
if (m_hw->bl_completeStart()) {
|
||||
int cnt = 5;
|
||||
while (--cnt > 0) {
|
||||
if (m_hw->bl_isUp()) {
|
||||
bl_isUp = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString(fileToSendToDC) + " DOES NOT EXIST -> NO UPDATE OF DC FIRMWARE");
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
bool Update::updateDC(QString bFile) const {
|
||||
qDebug() << "IN UPDATEDC: UPDATING DC: FILE TO SEND" << bFile;
|
||||
|
||||
m_worker->mainWindow()->setUpdateStep(UpdateDcEvent::UpdateStep::NONE);
|
||||
|
||||
QApplication::postEvent( // step 1: reset device controller
|
||||
m_worker->mainWindow(),
|
||||
new UpdateDcEvent(m_worker, UpdateDcEvent::UpdateStep::DC_REBOOT, 1));
|
||||
QThread::sleep(1);
|
||||
|
||||
for (int i=1; i <= MainWindow::BL_START_COUNT; ++i) {
|
||||
QApplication::postEvent( // step 2: start bootloader (5x)
|
||||
m_worker->mainWindow(),
|
||||
new UpdateDcEvent(m_worker, UpdateDcEvent::UpdateStep::BL_START, i));
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
int const cntLimit = 100; // wait until its for sure that bl_startBL()
|
||||
int cnt = 0; // has been excuted
|
||||
while (++cnt < cntLimit &&
|
||||
m_worker->mainWindow()->updateStep() != UpdateDcEvent::UpdateStep::BL_START) {
|
||||
// wait until all bl_startBL() are done
|
||||
QThread::msleep(200);
|
||||
}
|
||||
|
||||
if (cnt == cntLimit) {
|
||||
// start events not received ???
|
||||
Utils::printCriticalErrorMsg("BL_START EVENT NOT RECEIVED AFTER 20 SECS");
|
||||
if (!bl_isUp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_worker->mainWindow()->setUpdateStep(UpdateDcEvent::UpdateStep::BL_CHECK);
|
||||
if (!m_hw->bl_storeFirmware(fileToSendToDC)) {
|
||||
m_hw->bl_stopBL();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i=1; i <= MainWindow::BL_IS_UP_COUNT; ++i) {
|
||||
QApplication::postEvent(m_worker->mainWindow(), new UpdateDcEvent(m_worker, UpdateDcEvent::UpdateStep::BL_CHECK, i));
|
||||
QThread::sleep(1);
|
||||
QApplication::postEvent(m_worker->mainWindow(), new UpdateDcEvent(m_worker, UpdateDcEvent::UpdateStep::BL_IS_UP, i));
|
||||
if (m_worker->mainWindow()->updateStep() == UpdateDcEvent::UpdateStep::BL_IS_UP) {
|
||||
break;
|
||||
uint16_t const nrOfFirmwareBlocks = m_hw->bl_getNrOfFirmwareBlocks();
|
||||
|
||||
for (uint16_t blockNr = 0; blockNr <= nrOfFirmwareBlocks; ++blockNr) {
|
||||
m_hw->bl_blockAutoLoad(blockNr);
|
||||
|
||||
int sleepTime = 0;
|
||||
while (1) {
|
||||
if (sleepTime > 1500) {
|
||||
m_hw->bl_stopBL();
|
||||
return false;
|
||||
}
|
||||
|
||||
int8_t const r = m_hw->bl_blockAutoResponse();
|
||||
|
||||
// after every "bl_blockAutoLoad()" call this until response
|
||||
// retval 0: wait 1: OK, blk was sent 2: OK, transfer complete
|
||||
// 3: error despite repeating, cancel. probably bin file corrupted
|
||||
// Max duration: 3x no response from BL = 900ms
|
||||
|
||||
switch(r) {
|
||||
case 1:
|
||||
/* fall through */
|
||||
case 2:
|
||||
sleepTime = 0;
|
||||
break;
|
||||
case 0: {
|
||||
QThread::msleep(100);
|
||||
sleepTime += 100;
|
||||
} break;
|
||||
case 3:
|
||||
m_hw->bl_stopBL();
|
||||
return false;
|
||||
default:
|
||||
m_hw->bl_stopBL();
|
||||
return false; // unknown error code
|
||||
}
|
||||
}
|
||||
QThread::sleep(1);
|
||||
|
||||
m_hw->bl_stopBL();
|
||||
}
|
||||
|
||||
cnt = 0;
|
||||
while (++cnt < cntLimit &&
|
||||
m_worker->mainWindow()->updateStep() != UpdateDcEvent::UpdateStep::BL_IS_UP) {
|
||||
// wait until all bl_startBL() are done
|
||||
QThread::msleep(200);
|
||||
}
|
||||
|
||||
if (cnt == cntLimit) {
|
||||
// really not up
|
||||
Utils::printCriticalErrorMsg("BL_IS_UP EVENT NOT RECEIVED AFTER 20 SECS");
|
||||
stopBootloader(); // try to stop bootloader whichhas been already started
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_worker->mainWindow()->updateStep() == UpdateDcEvent::UpdateStep::BL_IS_UP) {
|
||||
// bootloader MUST be running to download device-controller
|
||||
#if 0
|
||||
if (!downloadBinaryToDC(bFile)) {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("UPDATING DC: ") + bFile + " ...DOWNLOAD FAILED");
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("UPDATING DC: ") + bFile + " BOOT LOADER NOT RUNNING -> NO DOWNLOAD ("
|
||||
+ QThread::currentThread()->objectName() + ")");
|
||||
return false;
|
||||
}
|
||||
|
||||
// do this unconditionally, even if bootloader is not running at all ->
|
||||
// the controller possibly tells us nonsense.
|
||||
if (!stopBootloader()) {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("UPDATING DC: ") + bFile + " BOOT LOADER STILL RUNNING ("
|
||||
+ QThread::currentThread()->objectName() + ")");
|
||||
return false;
|
||||
}
|
||||
|
||||
Utils::printInfoMsg(QString("UPDATING DC: ") + bFile + " ...OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -606,13 +347,6 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
int templateIdx,
|
||||
QString jsFileToSendToDC) const {
|
||||
|
||||
|
||||
Utils::printInfoMsg(
|
||||
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
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
@@ -641,7 +375,34 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
|
||||
templateIdx,
|
||||
(uint8_t *)ba.data())) {
|
||||
QThread::sleep(1);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
uint8_t data[64];
|
||||
memset(data, 0x00, sizeof(data));
|
||||
uint8_t length = 0;
|
||||
|
||||
m_hw->readback_machineIDdata(&length, data);
|
||||
|
||||
QThread::msleep(500);
|
||||
|
||||
QByteArray ba((const char*)data, length);
|
||||
|
||||
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
|
||||
*/
|
||||
|
||||
ret = true;
|
||||
}
|
||||
} else {
|
||||
@@ -741,123 +502,191 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
||||
<< "DC SW-version not available";
|
||||
}
|
||||
|
||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
int tries = 20;
|
||||
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";
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
|
||||
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";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool res = false;
|
||||
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());
|
||||
#if UPDATE_DC == 1
|
||||
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
|
||||
if (fToWorkOn.contains(version)) {
|
||||
Utils::printInfoMsg("DO-UPDATE FILE-TO-WORK-ON " + fToWorkOn);
|
||||
|
||||
QFile fn(fToWorkOn);
|
||||
QFileInfo finfo(fn);
|
||||
if (!fn.exists()) { // check for broken link
|
||||
Utils::printCriticalErrorMsg("DO-UPDATE FILE-TO-WORK-ON "
|
||||
+ fToWorkOn + " DOES NOT EXIST");
|
||||
res = false;
|
||||
} else {
|
||||
bool updateBinaryRes = true;
|
||||
if (fToWorkOn.contains("dc2c.bin")) {
|
||||
bool updateBinaryRes = true;
|
||||
|
||||
qInfo() << "DOWNLOADING" << finfo.completeBaseName() << "TO DC";
|
||||
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||
QThread::sleep(1); // wait to be sure that there are no more
|
||||
// commands sent to dc-hardware
|
||||
qInfo() << "SET AUTO-REQUEST=FALSE";
|
||||
// CONSOLE()
|
||||
|
||||
if ((updateBinaryRes = updateBinary(fToWorkOn.toStdString().c_str())) == true) {
|
||||
qCritical() << "downloaded binary" << fToWorkOn;
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||
QThread::sleep(1); // wait to be sure that there are no more
|
||||
// commands sent to dc-hardware
|
||||
|
||||
if ((updateBinaryRes = updateBinary(fToWorkOn)) == true) {
|
||||
|
||||
// qCritical() << "downloaded binary" << fToWorkOn;
|
||||
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||
|
||||
// qInfo() << "SET AUTO-REQUEST=TRUE";
|
||||
|
||||
QStringList const &versions = Update::getDcSoftAndHardWareVersion();
|
||||
if (versions.size() >= 2) {
|
||||
if (updateBinaryRes == true) {
|
||||
qInfo() << "dc-hardware-version (UPDATED)" << versions[0];
|
||||
qInfo() << "dc-firmware-version (UPDATED)" << versions[1];
|
||||
} else {
|
||||
qInfo() << "dc-hardware-version (NOT UPDATED)" << versions[0];
|
||||
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
|
||||
}
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||
qInfo() << "SET AUTO-REQUEST=TRUE";
|
||||
res = updateBinaryRes;
|
||||
|
||||
QStringList const &versions = Update::getDcSoftAndHardWareVersion();
|
||||
if (versions.size() >= 2) {
|
||||
if (updateBinaryRes == true) {
|
||||
qInfo() << "dc-hardware-version (UPDATED)" << versions[0];
|
||||
qInfo() << "dc-firmware-version (UPDATED)" << versions[1];
|
||||
} else {
|
||||
qInfo() << "dc-hardware-version (NOT UPDATED)" << versions[0];
|
||||
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
|
||||
} 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));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
res = updateBinaryRes;
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
} 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;
|
||||
|
14
update.h
14
update.h
@@ -32,6 +32,7 @@ class Update : public QObject {
|
||||
QString m_workingDir;
|
||||
bool m_maintenanceMode;
|
||||
bool m_dryRun;
|
||||
bool m_sys_areDCdataValid;
|
||||
|
||||
static QPluginLoader pluginLoader;
|
||||
|
||||
@@ -57,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; }
|
||||
@@ -72,29 +74,21 @@ public:
|
||||
|
||||
private:
|
||||
static QString jsonType(enum FileTypeJson type);
|
||||
|
||||
DownloadResult sendStatus(int ret) const;
|
||||
DownloadResult sendNextAddress(int bNum) const;
|
||||
DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const;
|
||||
DownloadResult dc_downloadBinary(QByteArray const &binary) const;
|
||||
|
||||
bool startBootloader() const;
|
||||
bool stopBootloader() const;
|
||||
bool openSerial(int br, QString baudrate, QString comPort) const;
|
||||
void closeSerial() const;
|
||||
bool isSerialOpen() const;
|
||||
bool resetDeviceController() const;
|
||||
QByteArray loadBinaryDCFile(QString filename) const;
|
||||
bool downloadBinaryToDC(QString const &bFile) const;
|
||||
bool updateDC(QString bFile) const;
|
||||
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
||||
bool updateBinary(char const *fileToSendToDC);
|
||||
bool updateBinary(QString const &fileToSendToDC);
|
||||
bool updateConfig(QString jsFileToSendToDC);
|
||||
bool updateCashConf(QString jsFileToSendToDC);
|
||||
bool updateDeviceConf(QString jsFileToSendToDC);
|
||||
bool downloadJson(enum FileTypeJson type, int templateIdx,
|
||||
QString jsFileToSendToDC) const;
|
||||
QStringList getDcSoftAndHardWareVersion();
|
||||
QString getFileVersion(QString const& jsonFile);
|
||||
|
||||
private slots:
|
||||
void readyReadStandardOutput();
|
||||
|
107
worker.cpp
107
worker.cpp
@@ -116,6 +116,8 @@ Worker::Worker(int customerNr,
|
||||
QString pluginName,
|
||||
QString workingDirectory,
|
||||
bool noUpdatePsaHardware,
|
||||
bool alwaysDownloadConfig,
|
||||
bool alwaysDownloadDC,
|
||||
bool dryRun,
|
||||
QObject *parent,
|
||||
char const *serialInterface,
|
||||
@@ -131,6 +133,8 @@ Worker::Worker(int customerNr,
|
||||
, m_customerRepositoryPath(QString("%1/%2.git").arg(repositoryUrl).arg(m_customerNrStr))
|
||||
, m_customerRepository(QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr))
|
||||
, m_noUpdatePsaHardware(noUpdatePsaHardware)
|
||||
, m_alwaysDownloadConfig(alwaysDownloadConfig)
|
||||
, m_alwaysDownloadDC(alwaysDownloadDC)
|
||||
, m_dryRun(dryRun)
|
||||
, m_parent(parent)
|
||||
, m_serialInterface(serialInterface)
|
||||
@@ -210,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;
|
||||
}
|
||||
@@ -330,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
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -453,9 +472,9 @@ bool Worker::updateTriggerSet() {
|
||||
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER));
|
||||
|
||||
QString triggerValue("");
|
||||
|
||||
for (int repeat = 1; repeat <= 100; ++repeat) {
|
||||
QString triggerValue("NOT CHECKED YET");
|
||||
static constexpr int const repeats = 15;
|
||||
for (int repeat = 1; repeat <= repeats; ++repeat) {
|
||||
|
||||
if (repeat > 1) {
|
||||
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
||||
@@ -463,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")) {
|
||||
@@ -556,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
|
||||
@@ -638,6 +659,33 @@ bool Worker::filesToUpdate() {
|
||||
// always execute contents of opkg_commands-file
|
||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||
|
||||
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()) {
|
||||
for (QStringList::size_type i=0; i<jsons.size(); ++i) {
|
||||
m_filesToUpdate << QDir::cleanPath(QString("etc/psa_config/") + jsons.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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/dc"));
|
||||
if (dir.exists()) {
|
||||
QStringList dc = dir.entryList(QStringList() << "dc2c.bin", QDir::Files,
|
||||
QDir::SortFlag::Time | QDir::SortFlag::Reversed);
|
||||
if (!dc.isEmpty()) {
|
||||
m_filesToUpdate << QDir::cleanPath(QString("etc/dc/") + dc.first());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (std::optional<QString> changes = m_gc.gitPull()) {
|
||||
if (!changes.value().contains("Already up to date")) {
|
||||
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
||||
@@ -645,6 +693,9 @@ bool Worker::filesToUpdate() {
|
||||
}
|
||||
}
|
||||
m_filesToUpdate.removeDuplicates();
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << "FILES-TO-UPDATE" << m_filesToUpdate;
|
||||
|
||||
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE);
|
||||
setProgress(_FILES_TO_UPDATE);
|
||||
} else {
|
||||
@@ -652,7 +703,6 @@ bool Worker::filesToUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -666,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
|
||||
}
|
||||
}
|
||||
@@ -688,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*#.*$");
|
||||
@@ -696,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);
|
||||
@@ -750,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;
|
||||
@@ -773,7 +823,7 @@ bool Worker::execOpkgCommands() {
|
||||
bool Worker::downloadFilesToPSAHardware() {
|
||||
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);
|
||||
|
||||
if (m_noUpdatePsaHardware == false) {
|
||||
@@ -788,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);
|
||||
@@ -808,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 "
|
||||
|
94
worker.h
94
worker.h
@@ -124,6 +124,8 @@ class Worker : public QThread{
|
||||
QString const m_customerRepositoryPath;
|
||||
QString const m_customerRepository;
|
||||
bool const m_noUpdatePsaHardware;
|
||||
bool const m_alwaysDownloadConfig;
|
||||
bool const m_alwaysDownloadDC;
|
||||
bool const m_dryRun;
|
||||
QObject *m_parent;
|
||||
QString const m_serialInterface;
|
||||
@@ -331,6 +333,8 @@ public:
|
||||
QString pluginName,
|
||||
QString workingDir = ".",
|
||||
bool noUpdatePsaHardware = false,
|
||||
bool alwaysDownloadConfig = false,
|
||||
bool alwaysDownloadDC = false,
|
||||
bool dryRun = false,
|
||||
QObject *parent = nullptr,
|
||||
char const *serialInterface = SERIAL_PORT,
|
||||
@@ -516,8 +520,10 @@ private:
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::FILES_TO_UPDATE:
|
||||
break;
|
||||
case UPDATE_STEP::FILES_TO_UPDATE: {
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE: {
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
@@ -551,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:
|
||||
@@ -572,18 +580,24 @@ private:
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
||||
break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::SAVE_LOGS:
|
||||
break;
|
||||
case UPDATE_STEP::SAVE_LOGS_SUCCESS:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::SAVE_LOGS_FAILURE:
|
||||
break;
|
||||
@@ -591,12 +605,18 @@ private:
|
||||
// SEND_LAST_VERSION_CORRECTION
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_SUCCEEDED:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_ACTIVATED:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_FAILED:
|
||||
break;
|
||||
case UPDATE_STEP::FINISHED:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::DEBUG: {
|
||||
lst << instance->m_debugMsg;
|
||||
@@ -924,33 +944,77 @@ private:
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER);
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS:
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER_SUCCESS);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER_FAILURE);
|
||||
break;
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS:
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE:
|
||||
ismasClient.setProgressInPercent(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
|
||||
break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
||||
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY);
|
||||
break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS:
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE:
|
||||
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY_FAILURE);
|
||||
break;
|
||||
case UPDATE_STEP::SAVE_LOGS:
|
||||
ismasClient.setProgressInPercent(_SAVE_LOGS);
|
||||
break;
|
||||
case UPDATE_STEP::SAVE_LOGS_SUCCESS:
|
||||
case UPDATE_STEP::SAVE_LOGS_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_SAVE_LOGS_SUCCESS);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::SAVE_LOGS_FAILURE:
|
||||
ismasClient.setProgressInPercent(_SAVE_LOGS_FAILURE);
|
||||
break;
|
||||
@@ -1063,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;
|
||||
@@ -1113,7 +1180,8 @@ private:
|
||||
for (int i = 0; i < size; ++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(QString("\n ") + worker->m_filesToUpdate.at(0));
|
||||
}
|
||||
|
Reference in New Issue
Block a user