Compare commits
11 Commits
2e7d33c4c8
...
edeff35d7e
Author | SHA1 | Date | |
---|---|---|---|
edeff35d7e | |||
09d5de1b0b | |||
145fdab26e | |||
89d1ec5b21 | |||
f38c975dc6 | |||
fba007aa35 | |||
8b6adb3ea7 | |||
30603317c6 | |||
7083f3b4f8 | |||
7ff866525e | |||
2164037123 |
@ -23,6 +23,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# changes).
|
||||
# 1.3.7 : Wait forever for git-commands to finish in QProcess executing such
|
||||
# a command.
|
||||
# 1.3.8 : Remove accessing opkg_commands under file-system-path /etc/psa_update.
|
||||
# Activate download of json-configuration files.
|
||||
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
@ -32,7 +34,7 @@ win32 {
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
}
|
||||
|
||||
VERSION="1.3.7"
|
||||
VERSION="1.3.8"
|
||||
|
||||
INCLUDEPATH += plugins
|
||||
|
||||
|
@ -321,6 +321,7 @@ void MainWindow::onRestartExitTimer() {
|
||||
m_exitTimer->stop();
|
||||
m_exitTimer->start(60 * 1000);
|
||||
|
||||
scrollDownTextEdit();
|
||||
ui->updateStatus->setEnabled(false);
|
||||
}
|
||||
|
||||
|
138
update.cpp
138
update.cpp
@ -29,11 +29,7 @@
|
||||
#include <QMap>
|
||||
|
||||
#define UPDATE_OPKG (1)
|
||||
#define UPDATE_DC (1)
|
||||
#define UPDATE_PRINTER_TEMPLATES (1)
|
||||
#define UPDATE_CASH_TEMPLATE (1)
|
||||
#define UPDATE_CONF_TEMPLATE (1)
|
||||
#define UPDATE_DEVICE_TEMPLATE (1)
|
||||
#define UPDATE_DC (0)
|
||||
|
||||
static const QMap<QString, int> baudrateMap = {
|
||||
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
|
||||
@ -610,9 +606,12 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
int templateIdx,
|
||||
QString jsFileToSendToDC) const {
|
||||
|
||||
qDebug() << "updating json-file:" << jsFileToSendToDC << "...";
|
||||
qDebug() << " template-index:" << templateIdx;
|
||||
qDebug() << " json-type:" << jsonType(type);
|
||||
|
||||
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";
|
||||
@ -623,7 +622,7 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
while ((ready = m_hw->sys_ready4sending()) == false) {
|
||||
QThread::msleep(200);
|
||||
if (--nTry <= 0) {
|
||||
qCritical() << "SYS NOT READY FOR SENDING AFTER 5 SECONDS";
|
||||
Utils::printCriticalErrorMsg("SYS NOT READY FOR SENDING AFTER 5 SECONDS");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -636,22 +635,27 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
if (fi.size() <= 800) {
|
||||
QByteArray ba = file.readAll();
|
||||
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
|
||||
// nrOfTemplate=1...32 if kindOfFile==6
|
||||
// content = content of the Json file, max 800byte ascii signs
|
||||
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
|
||||
templateIdx,
|
||||
(uint8_t *)ba.data())) {
|
||||
QThread::sleep(1);
|
||||
qDebug() << "SENT" << jsFileToSendToDC;
|
||||
ret = true;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "SIZE OF" << jsFileToSendToDC
|
||||
<< "TOO BIG (" << fi.size() << "BYTES)";
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("SIZE OF %1 TOO BIG (%2 BYTES)")
|
||||
.arg(jsFileToSendToDC).arg(fi.size()));
|
||||
}
|
||||
} else {
|
||||
qCritical() << "CANNOT OPEN" << jsFileToSendToDC << "FOR READING";
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING");
|
||||
}
|
||||
} else {
|
||||
qCritical() << jsFileToSendToDC << "DOES NOT EXIST";
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString(jsFileToSendToDC) + " DOES NOT EXIST");
|
||||
}
|
||||
}
|
||||
|
||||
@ -738,71 +742,13 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
||||
}
|
||||
|
||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
// 04.10.2023: deactivated -> first testing of opkg_commands
|
||||
//
|
||||
// wird auch nie wieder gebraucht, da alles von der dc-lib erledigt wird.
|
||||
// die dc-lib braucht dazu nur datei-namen.
|
||||
return true;
|
||||
|
||||
|
||||
bool serialOpened = false;
|
||||
|
||||
QString const &parentName = Utils::getParentName();
|
||||
|
||||
Utils::printInfoMsg(
|
||||
QString("PARENT OF ATB-UPDATE-TOOL (ppid=%1) ").arg(getppid()) + parentName);
|
||||
|
||||
if (parentName == "ATBQT" || parentName == "systemd") {
|
||||
// the tool was not called during 'service' ot during an automatic
|
||||
// update procedure. and it was called explicitly with libCAmaster.so
|
||||
if (m_pluginName.contains("master", Qt::CaseInsensitive)) {
|
||||
Utils::printCriticalErrorMsg(parentName
|
||||
+ " IS MASTER, BUT ATB-UPDATE-TOOL CALLED WITH libCAmaster.so");
|
||||
return false;
|
||||
}
|
||||
Utils::printInfoMsg(
|
||||
QString("ATB-UPDATE-TOOL STARTED AS SLAVE OF ") + parentName);
|
||||
} else
|
||||
if (Utils::isATBQTRunning()) { // manual testing
|
||||
if (m_pluginName.contains("master", Qt::CaseInsensitive)) {
|
||||
Utils::printCriticalErrorMsg(
|
||||
"ATBQT IS MASTER, BUT ATB-UPDATE-TOOL CALLED WITH libCAmaster.so");
|
||||
return false;
|
||||
}
|
||||
Utils::printInfoMsg(
|
||||
"ATB-UPDATE-TOOL STARTED AS SLAVE-SIBLING OF ATBQT-MASTER");
|
||||
} else {
|
||||
if (m_pluginName.contains("slave", Qt::CaseInsensitive)) {
|
||||
Utils::printCriticalErrorMsg(
|
||||
"ATB-UPDATE-TOOL CALLED WITH libCAslave.so ALTHOUGH MASTER");
|
||||
return false;
|
||||
}
|
||||
Utils::printInfoMsg("ATB-UPDATE-TOOL STARTED AS MASTER");
|
||||
|
||||
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate),
|
||||
m_baudrate,
|
||||
m_serialInterface)) == false) {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("CANNOT OPEN ")
|
||||
+ m_serialInterface
|
||||
+ "( BAUDRATE=" + m_baudrate + ")");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
|
||||
Utils::printInfoMsg(
|
||||
QString("SERIAL OPEN ") + m_serialInterface
|
||||
+ " (BAUDRATE=" + m_baudrate + ")");
|
||||
}
|
||||
|
||||
// always assume that serial line is open
|
||||
bool res = false;
|
||||
QList<QString>::const_iterator it;
|
||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||
m_worker->startProgressLoop();
|
||||
QString fToWorkOn = (*it).trimmed();
|
||||
fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + fToWorkOn);
|
||||
|
||||
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);
|
||||
@ -817,7 +763,6 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
bool updateBinaryRes = true;
|
||||
|
||||
qInfo() << "DOWNLOADING" << finfo.completeBaseName() << "TO DC";
|
||||
#if UPDATE_DC == 1
|
||||
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
|
||||
@ -844,13 +789,12 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
res = updateBinaryRes;
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
#endif
|
||||
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
#if UPDATE_PRINTER_TEMPLATES == 1
|
||||
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
||||
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
||||
if ((templateIdx < 1) || (templateIdx > 32)) {
|
||||
@ -858,50 +802,46 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
res = false;
|
||||
} else {
|
||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||
qInfo() << "downloaded printer template"<< fToWorkOn;
|
||||
Utils::printInfoMsg(
|
||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||
.arg(fToWorkOn)
|
||||
.arg(templateIdx));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
#if UPDATE_CASH_TEMPLATE == 1
|
||||
if ((res = updateCashConf(fToWorkOn))) {
|
||||
qInfo() << "downloaded cash template"<< fToWorkOn;
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
#endif
|
||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
#if UPDATE_CONF_TEMPLATE == 1
|
||||
if ((res= updateConfig(fToWorkOn))) {
|
||||
qInfo() << "downloaded config template"<< fToWorkOn;
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
#endif
|
||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
#if UPDATE_DEVICE_TEMPLATE == 1
|
||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||
qInfo() << "downloaded device template"<< fToWorkOn;
|
||||
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||
res = false;
|
||||
@ -914,12 +854,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
}
|
||||
} // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
|
||||
|
||||
//m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON
|
||||
//qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
|
||||
if (serialOpened) {
|
||||
m_hw->dc_closeSerial();
|
||||
}
|
||||
m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
33
worker.cpp
33
worker.cpp
@ -820,20 +820,23 @@ bool Worker::updateFiles(quint8 percent) {
|
||||
f.close();
|
||||
if (cmdCount > 0) {
|
||||
m_displayIndex = 1;
|
||||
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update opkg pakets ... ");
|
||||
opkgCommands.prepend(prepend);
|
||||
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
|
||||
} else {
|
||||
m_displayIndex = 1;
|
||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (fName.contains("print", Qt::CaseInsensitive)) {
|
||||
if (fName.contains("DC2C_print", Qt::CaseInsensitive) ||
|
||||
fName.contains("DC2C_device", Qt::CaseInsensitive) ||
|
||||
fName.contains("DC2C_conf", Qt::CaseInsensitive) ||
|
||||
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
|
||||
filesToDownload << fName; // download printer-config-files
|
||||
} else {
|
||||
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
|
||||
@ -852,6 +855,8 @@ bool Worker::updateFiles(quint8 percent) {
|
||||
Update *update = m_mainWindow->getUpdate();
|
||||
if (update) {
|
||||
return update->doUpdate(m_displayIndex, filesToDownload);
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg("UPDATE NOT SET");
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW");
|
||||
@ -868,7 +873,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
||||
if (QDir::setCurrent(m_customerRepository)) {
|
||||
Command md("bash");
|
||||
if (!md.execute(m_customerRepository,
|
||||
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/psa_update /etc/dc /etc/psa_tariff")) {
|
||||
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
|
||||
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
|
||||
}
|
||||
int progress = 10;
|
||||
@ -882,8 +887,15 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
||||
"--include=*.json "
|
||||
"--include=*.ini");
|
||||
QStringList cmds;
|
||||
cmds << QString("rsync ") + params.simplified() + " etc/ /etc";
|
||||
cmds << QString("rsync ") + params.simplified() + " opt/ /opt";
|
||||
|
||||
if (QDir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/")).exists()) {
|
||||
cmds << QString("rsync ") + params.simplified() + " etc/ /etc";
|
||||
Utils::printInfoMsg(QString("CONFIGURED SYNCING TO /ETC"));
|
||||
}
|
||||
if (QDir(QDir::cleanPath(m_customerRepository + QDir::separator() + "opt/")).exists()) {
|
||||
cmds << QString("rsync ") + params.simplified() + " opt/ /opt";
|
||||
Utils::printInfoMsg(QString("CONFIGURED SYNCING TO /OPT"));
|
||||
}
|
||||
|
||||
QString cmd;
|
||||
bool error = false;
|
||||
@ -893,6 +905,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
||||
if (!error) {
|
||||
Command c("bash");
|
||||
qInfo() << "EXECUTING CMD..." << cmd;
|
||||
Utils::printInfoMsg(QString("EXECUTING CMD %1...").arg(cmd));
|
||||
if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) {
|
||||
QStringList result = c.getCommandResult().split('\n');
|
||||
QString const &p1 = "send_files mapped ";
|
||||
@ -1067,9 +1080,7 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
QString printSysDir("/etc/psa_config");
|
||||
QString tariffSysDir("/etc/psa_tariff");
|
||||
QString tariffRepoDir("etc/psa_tariff");
|
||||
QString opkgSysDir("/etc/psa_update");
|
||||
QString opkgRepoDir("etc/psa_update");
|
||||
QString const &absPathNameOpkg = QDir::cleanPath(opkgSysDir + QDir::separator() + "opkg_commands");
|
||||
QString const &absPathNameRepositoryOpkg = QDir::cleanPath(opkgRepoDir + QDir::separator() + "opkg_commands");
|
||||
QString absPathName;
|
||||
QString absPathNameRepository;
|
||||
@ -1103,9 +1114,9 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
psaInstalled.hw.linuxVersion = m_osVersion;
|
||||
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
||||
|
||||
psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameOpkg);
|
||||
psaInstalled.opkg.size = getFileSize(absPathNameOpkg);
|
||||
psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameOpkg);
|
||||
psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameRepositoryOpkg);
|
||||
psaInstalled.opkg.size = getFileSize(absPathNameRepositoryOpkg);
|
||||
psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameRepositoryOpkg);
|
||||
psaInstalled.opkg.lastCommit = m_gc.gitLastCommit(absPathNameRepositoryOpkg);
|
||||
|
||||
psaInstalled.dc.versionHW = deviceControllerVersionHW;
|
||||
|
Loading…
x
Reference in New Issue
Block a user