Compare commits
16 Commits
f741fb96f9
...
1.4.8
Author | SHA1 | Date | |
---|---|---|---|
0a33d078be | |||
1d64769094 | |||
2e3af64c02 | |||
f8472a3b87 | |||
24addad11e | |||
5a8298a078 | |||
52af7894db | |||
a6592ffd3e | |||
696db7de39 | |||
b31588bfab | |||
6651920f4a | |||
ef800366e1
|
|||
1acec4d876 | |||
46c481b862 | |||
8945ead5d6 | |||
bc064c38c6 |
@@ -70,12 +70,14 @@ SOURCES += \
|
|||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
sender_thread.cpp \
|
sender_thread.cpp \
|
||||||
receiver_thread.cpp \
|
receiver_thread.cpp \
|
||||||
|
worker_thread.cpp \
|
||||||
../common/src/message_handler.cpp
|
../common/src/message_handler.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
sender_thread.h \
|
sender_thread.h \
|
||||||
receiver_thread.h \
|
receiver_thread.h \
|
||||||
|
worker_thread.h \
|
||||||
../common/include/message_handler.h
|
../common/include/message_handler.h
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
|
@@ -24,6 +24,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
openSerialPort();
|
||||||
|
|
||||||
//ui->updateProgress->setRange(0, 100);
|
//ui->updateProgress->setRange(0, 100);
|
||||||
//ui->updateProgress->reset();
|
//ui->updateProgress->reset();
|
||||||
|
|
||||||
@@ -71,23 +73,18 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
//delete m_startTimer;
|
//delete m_startTimer;
|
||||||
//delete m_exitTimer;
|
//delete m_exitTimer;
|
||||||
|
closeSerialPort();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::openSerialPort() {
|
bool MainWindow::openSerialPort() {
|
||||||
// const SettingsDialog::Settings p = m_settings->settings();
|
// const SettingsDialog::Settings p = m_settings->settings();
|
||||||
//m_serial->setPortName(p.name);
|
|
||||||
//m_serial->setBaudRate(p.baudRate);
|
|
||||||
//m_serial->setDataBits(p.dataBits);
|
|
||||||
//m_serial->setParity(p.parity);
|
|
||||||
//m_serial->setStopBits(p.stopBits);
|
|
||||||
///m_serial->setFlowControl(p.flowControl);
|
|
||||||
m_serial->setPortName("");
|
m_serial->setPortName("");
|
||||||
m_serial->setBaudRate(QSerialPort::Baud115200);
|
m_serial->setBaudRate(QSerialPort::Baud115200);
|
||||||
m_serial->setDataBits(QSerialPort::DataBits::Data8);
|
m_serial->setDataBits(QSerialPort::DataBits::Data8);
|
||||||
m_serial->setParity(QSerialPort::Parity::NoParity);
|
m_serial->setParity(QSerialPort::Parity::NoParity);
|
||||||
m_serial->setStopBits(QSerialPort::StopBits::OneStop);
|
m_serial->setStopBits(QSerialPort::StopBits::OneStop);
|
||||||
m_serial->setFlowControl(QSerialPort::FlowControl::HardwareControl);
|
m_serial->setFlowControl(QSerialPort::FlowControl::NoFlowControl);
|
||||||
if (m_serial->open(QIODevice::ReadWrite)) {
|
if (m_serial->open(QIODevice::ReadWrite)) {
|
||||||
//m_console->setEnabled(true);
|
//m_console->setEnabled(true);
|
||||||
//m_console->setLocalEchoEnabled(p.localEchoEnabled);
|
//m_console->setLocalEchoEnabled(p.localEchoEnabled);
|
||||||
|
13
DownloadDCFirmware/worker_thread.cpp
Normal file
13
DownloadDCFirmware/worker_thread.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "worker_thread.h"
|
||||||
|
|
||||||
|
WorkerThread::WorkerThread(QObject *parent)
|
||||||
|
: QThread(parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkerThread::~WorkerThread() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkerThread::run() {
|
||||||
|
|
||||||
|
}
|
20
DownloadDCFirmware/worker_thread.h
Normal file
20
DownloadDCFirmware/worker_thread.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef WORKER_THREAD_H_INCLUDED
|
||||||
|
#define WORKER_THREAD_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
class WorkerThread : public QThread {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit WorkerThread(QObject *parent = nullptr);
|
||||||
|
~WorkerThread();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void run() override;
|
||||||
|
|
||||||
|
bool m_quit = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WORKER_THREAD_H_INCLUDED
|
@@ -24,7 +24,7 @@ INCLUDEPATH += \
|
|||||||
plugins \
|
plugins \
|
||||||
$${INCLUDEINTERFACES} \
|
$${INCLUDEINTERFACES} \
|
||||||
$${_PRO_FILE_PWD_}/../UpdatePTUDevCtrl \
|
$${_PRO_FILE_PWD_}/../UpdatePTUDevCtrl \
|
||||||
$${_PRO_FILE_PWD_}/../../ATBUpdateTool/common/include
|
$${_PRO_FILE_PWD_}/../common/include
|
||||||
|
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
@@ -81,13 +81,13 @@ SOURCES += \
|
|||||||
../UpdatePTUDevCtrl/message_handler.cpp \
|
../UpdatePTUDevCtrl/message_handler.cpp \
|
||||||
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
||||||
update.cpp \
|
update.cpp \
|
||||||
../../ATBUpdateTool/common/src/System.cpp
|
../common/src/System.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../UpdatePTUDevCtrl/message_handler.h \
|
../UpdatePTUDevCtrl/message_handler.h \
|
||||||
../UpdatePTUDevCtrl/commandline_parser.h \
|
../UpdatePTUDevCtrl/commandline_parser.h \
|
||||||
update.h \
|
update.h \
|
||||||
../../ATBUpdateTool/common/include/System.h
|
../common/include/System.h
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
ATBDownloadDCJsonFiles.ini
|
ATBDownloadDCJsonFiles.ini
|
||||||
|
@@ -138,7 +138,9 @@ int main(int argc, char **argv) {
|
|||||||
plugInName,
|
plugInName,
|
||||||
workingDir);
|
workingDir);
|
||||||
|
|
||||||
|
//update.checkJsonVersions();
|
||||||
update.doUpdate(filesToUpdate);
|
update.doUpdate(filesToUpdate);
|
||||||
|
update.checkJsonVersions(filesToUpdate);
|
||||||
|
|
||||||
//return a.exec();
|
//return a.exec();
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -46,7 +46,7 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
|||||||
qCritical() << "in directory" << plugInDir.absolutePath();
|
qCritical() << "in directory" << plugInDir.absolutePath();
|
||||||
qCritical() << "cannot load plugin" << pluginLoader.fileName();
|
qCritical() << "cannot load plugin" << pluginLoader.fileName();
|
||||||
qCritical() << pluginLoader.errorString();
|
qCritical() << pluginLoader.errorString();
|
||||||
exit(-1);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
|
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
|
||||||
@@ -54,25 +54,25 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
|||||||
|
|
||||||
if (!pluginLoader.isLoaded()) {
|
if (!pluginLoader.isLoaded()) {
|
||||||
qCritical() << pluginLoader.errorString();
|
qCritical() << pluginLoader.errorString();
|
||||||
exit(-2);
|
return nullptr;
|
||||||
}
|
}
|
||||||
QObject *plugin = pluginLoader.instance();
|
QObject *plugin = pluginLoader.instance();
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
qCritical() << "cannot start instance";
|
qCritical() << "cannot start instance";
|
||||||
exit(-3);
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (! (hw = qobject_cast<hwinf *>(plugin))) {
|
if (! (hw = qobject_cast<hwinf *>(plugin))) {
|
||||||
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
|
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
|
||||||
exit(-4);
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << pluginLibName << "does not exist";
|
qCritical() << pluginLibName << "does not exist";
|
||||||
exit(-5);
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "plugins directory" << plugInDir.absolutePath()
|
qCritical() << "plugins directory" << plugInDir.absolutePath()
|
||||||
<< "does not exist";
|
<< "does not exist";
|
||||||
exit(-6);
|
return nullptr;
|
||||||
}
|
}
|
||||||
return hw;
|
return hw;
|
||||||
}
|
}
|
||||||
@@ -131,45 +131,20 @@ Update::Update(QString customerRepository,
|
|||||||
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||||
<< m_sys_areDCdataValid;
|
<< m_sys_areDCdataValid;
|
||||||
|
|
||||||
#if 0
|
|
||||||
QObject const *obj = m_hw->getAPI();
|
|
||||||
Q_ASSERT(obj != nullptr);
|
|
||||||
|
|
||||||
QDebug critical = qCritical();
|
|
||||||
critical << "connect() to onReportDCDownloadStatus() ...";
|
|
||||||
if (!connect(obj,
|
|
||||||
SIGNAL(hwapi_reportDCDownloadStatus(QString const&)),
|
|
||||||
this,
|
|
||||||
SLOT(onReportDCDownloadStatus(QString const &)))) {
|
|
||||||
critical << "FAILED";
|
|
||||||
} else critical << "DONE";
|
|
||||||
|
|
||||||
critical = qCritical();
|
|
||||||
critical << "connect() to onReportDCDownloadSuccess() ...";
|
|
||||||
if (!connect(obj,
|
|
||||||
SIGNAL(hwapi_reportDCDownloadSuccess(QString const&)), this,
|
|
||||||
SLOT(onReportDCDownloadSuccess(QString const &)))) {
|
|
||||||
critical << "FAILED";
|
|
||||||
} else critical << "DONE";
|
|
||||||
|
|
||||||
critical = qCritical();
|
|
||||||
critical << "connect() to onReportDCDownloadFailure() ...";
|
|
||||||
if (!connect(obj,
|
|
||||||
SIGNAL(hwapi_reportDCDownloadFailure(QString const &)), this,
|
|
||||||
SLOT(onReportDCDownloadFailure(QString const &)))) {
|
|
||||||
critical << "FAILED";
|
|
||||||
} else critical << "DONE";
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Update::~Update() {
|
Update::~Update() {
|
||||||
// unloadDCPlugin();
|
unloadDCPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
|
if (!m_hw) {
|
||||||
|
qCritical() << "ERROR!!! m_hw == nullptr";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int tries = 20;
|
int tries = 20;
|
||||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||||
// must deliver 'true', only then are all data from hwapi valid
|
// must deliver 'true', only then are all data from hwapi valid
|
||||||
@@ -205,19 +180,16 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
|||||||
}
|
}
|
||||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
|
||||||
if ((res = updateCashConf(fToWorkOn))) {
|
if ((res = updateCashConf(fToWorkOn))) {
|
||||||
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
|
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
|
||||||
}
|
}
|
||||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
if ((res = updateConfig(fToWorkOn))) {
|
||||||
if ((res= updateConfig(fToWorkOn))) {
|
|
||||||
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
|
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
|
||||||
}
|
}
|
||||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
|
||||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||||
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
|
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
|
||||||
}
|
}
|
||||||
@@ -230,13 +202,18 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
||||||
|
|
||||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||||
|
|
||||||
uint8_t jsonNr = 0;
|
uint8_t jsonNr = 0;
|
||||||
|
|
||||||
QString const &fName = jsonFileNames[i];
|
QString const &fName = jsonFileNames[i];
|
||||||
|
|
||||||
|
// send one request for every single version
|
||||||
|
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
|
||||||
|
// 6=printer template 1 ..... 36= template 32
|
||||||
|
|
||||||
if (fName.endsWith("conf.json")) {
|
if (fName.endsWith("conf.json")) {
|
||||||
jsonNr = 1;
|
jsonNr = 1;
|
||||||
} else
|
} else
|
||||||
@@ -254,31 +231,45 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
int n = captured.toInt(&ok);
|
int n = captured.toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
jsonNr = n + 4;
|
jsonNr = n + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonNr != 0) {
|
if (jsonNr != 0) {
|
||||||
#if 0
|
// send one request for every single version
|
||||||
|
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
|
||||||
|
// 5=printer template 1 ..... 36= template 32
|
||||||
|
|
||||||
m_hw->sys_requestJsonVersions(jsonNr);
|
m_hw->sys_requestJsonVersions(jsonNr);
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
|
|
||||||
char buf[64];
|
char buf[64];
|
||||||
memset(buf, 0x00, sizeof(buf));
|
memset(buf, 0x00, sizeof(buf));
|
||||||
m_hw->sys_getJsonVersions(jsonNr, buf);
|
m_hw->sys_getJsonVersions(jsonNr, buf);
|
||||||
buf[sizeof(buf)-1] = '\0';
|
buf[16] = '\0'; // the DC only handles 16 bytes
|
||||||
|
|
||||||
QString const installedVersion(buf);
|
static const QByteArray cb(16, (char)0xff);
|
||||||
|
|
||||||
|
QString const installedVersion(QString::fromStdString(buf));
|
||||||
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
||||||
|
|
||||||
qCritical() << "installed version:" << installedVersion;
|
QFileInfo fi(jsonFileNames[i]);
|
||||||
qCritical() << " file version:" << fileVersion;
|
|
||||||
|
qCritical() << endl;
|
||||||
|
qCritical() << " json request nr:" << jsonNr;
|
||||||
|
|
||||||
if (installedVersion == fileVersion) {
|
if (installedVersion == fileVersion) {
|
||||||
|
qCritical() << " json file:" << fi.fileName();
|
||||||
|
qCritical() << " installed version in DC:" << installedVersion;
|
||||||
|
} else
|
||||||
|
if (cb == QByteArray(buf) && fileVersion == "") {
|
||||||
|
qCritical() << "unknown json file (repo and DC):" << fi.fileName();
|
||||||
|
} else {
|
||||||
|
qCritical() << " json file:" << fi.fileName();
|
||||||
|
qCritical() << " installed version in DC:" << installedVersion;
|
||||||
|
qCritical() << " file version in repository:" << fileVersion;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
||||||
@@ -288,6 +279,39 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Update::getFileVersion(QString const& jsonFileName) {
|
||||||
|
// "version":"15.10.2023 14:55 02.00.06",
|
||||||
|
static const QRegularExpression re("^.*(\\\"[Vv]ersion\\\":)([\\s\\\"]{0,})([^,\\\"]{0,}).*$");
|
||||||
|
|
||||||
|
QString fileVersion("");
|
||||||
|
QFile inputFile(QDir::cleanPath(m_customerRepository + QDir::separator() + jsonFileName));
|
||||||
|
|
||||||
|
if (inputFile.exists()) {
|
||||||
|
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) {
|
||||||
|
int const lastCaptured = match.lastCapturedIndex();
|
||||||
|
// the dc only sends 16 Byte
|
||||||
|
fileVersion = match.captured(lastCaptured);
|
||||||
|
fileVersion.truncate(16);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inputFile.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// qCritical() << "ERROR" << inputFile.fileName() << "does not exist";
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileVersion;
|
||||||
|
}
|
||||||
|
|
||||||
bool Update::downloadJson(enum FileTypeJson type,
|
bool Update::downloadJson(enum FileTypeJson type,
|
||||||
int templateIdx,
|
int templateIdx,
|
||||||
QString jsFileToSendToDC) const {
|
QString jsFileToSendToDC) const {
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include <DeviceController/interfaces.h>
|
#include <DeviceController/interfaces.h>
|
||||||
|
|
||||||
#ifdef PTU5
|
#ifdef PTU5
|
||||||
@@ -67,7 +69,46 @@ public:
|
|||||||
QString jsFileToSendToDC) const;
|
QString jsFileToSendToDC) const;
|
||||||
|
|
||||||
|
|
||||||
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
QString getFileVersion(QString const& jsonFileName);
|
||||||
|
bool checkJsonVersions(QStringList const& jsonFileNames =
|
||||||
|
QStringList(
|
||||||
|
QList(
|
||||||
|
std::initializer_list<QString>{
|
||||||
|
QString("etc/psa_config/DC2C_conf.json"),
|
||||||
|
QString("etc/psa_config/DC2C_cash.json"),
|
||||||
|
QString("etc/psa_config/DC2C_device.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print01.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print02.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print03.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print04.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print05.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print06.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print07.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print08.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print09.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print10.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print11.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print12.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print13.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print14.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print15.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print16.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print17.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print18.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print19.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print20.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print21.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print22.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print23.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print24.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print25.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print26.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print27.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print28.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print29.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print30.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print31.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print32.json")})));
|
||||||
/*
|
/*
|
||||||
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
||||||
|
|
||||||
|
@@ -123,7 +123,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
# Check m_hw (pointer to CA-(Slave)Plugin) before its use.
|
# Check m_hw (pointer to CA-(Slave)Plugin) before its use.
|
||||||
# Only exit() if firmware is configured to be possibly updated, but
|
# Only exit() if firmware is configured to be possibly updated, but
|
||||||
# loading the CA-plugin failed.
|
# loading the CA-plugin failed.
|
||||||
VERSION="1.4.7"
|
# 1.4.7 : Read Json-file versions of Json-files actually loaded into DC.
|
||||||
|
VERSION="1.4.8"
|
||||||
# PLANNED TODOS:
|
# PLANNED TODOS:
|
||||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||||
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
||||||
|
@@ -12,8 +12,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Terminus</family>
|
<family>Source Code Pro</family>
|
||||||
<pointsize>11</pointsize>
|
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -30,7 +29,21 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" rowspan="3" colspan="2">
|
<item row="3" column="2">
|
||||||
|
<widget class="QPushButton" name="exit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Exit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QProgressBar" name="updateProgress">
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" rowspan="3" colspan="3">
|
||||||
<widget class="QTextEdit" name="updateStatus">
|
<widget class="QTextEdit" name="updateStatus">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@@ -39,7 +52,6 @@
|
|||||||
<font>
|
<font>
|
||||||
<family>Misc Fixed</family>
|
<family>Misc Fixed</family>
|
||||||
<pointsize>11</pointsize>
|
<pointsize>11</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -592,23 +592,31 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
|||||||
|
|
||||||
QString Update::getFileVersion(QString const& jsonFileName) {
|
QString Update::getFileVersion(QString const& jsonFileName) {
|
||||||
// "version":"15.10.2023 14:55 02.00.06",
|
// "version":"15.10.2023 14:55 02.00.06",
|
||||||
static const QRegularExpression re("^.*(\\\"version\\\":)(.*)$");
|
static const QRegularExpression re("^.*(\\\"[Vv]ersion\\\":)([\\s\\\"]{0,})([^,\\\"]{0,}).*$");
|
||||||
|
|
||||||
QString fileVersion;
|
QString fileVersion("");
|
||||||
QFile inputFile(jsonFileName);
|
QFile inputFile(QDir::cleanPath(m_customerRepository + QDir::separator() + jsonFileName));
|
||||||
if (inputFile.open(QIODevice::ReadOnly)) {
|
|
||||||
QTextStream in(&inputFile);
|
|
||||||
while (!in.atEnd()) {
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
QRegularExpressionMatch match;
|
if (inputFile.exists()) {
|
||||||
int idx = line.indexOf(re, 0, &match);
|
if (inputFile.open(QIODevice::ReadOnly)) {
|
||||||
if (idx != -1) {
|
QTextStream in(&inputFile);
|
||||||
fileVersion = match.captured(match.lastCapturedIndex());
|
while (!in.atEnd()) {
|
||||||
break;
|
QString line = in.readLine();
|
||||||
}
|
|
||||||
}
|
QRegularExpressionMatch match;
|
||||||
inputFile.close();
|
int idx = line.indexOf(re, 0, &match);
|
||||||
|
if (idx != -1) {
|
||||||
|
int const lastCaptured = match.lastCapturedIndex();
|
||||||
|
// the dc only sends 16 Byte
|
||||||
|
fileVersion = match.captured(lastCaptured);
|
||||||
|
fileVersion.truncate(16);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inputFile.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// qCritical() << "ERROR" << inputFile.fileName() << "does not exist";
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileVersion;
|
return fileVersion;
|
||||||
@@ -619,58 +627,78 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||||
|
|
||||||
uint8_t jsonNr = 0;
|
uint8_t jsonNr = 0;
|
||||||
QFileInfo fInfo(jsonFileNames[i]);
|
|
||||||
|
|
||||||
if (fInfo.fileName().endsWith("conf.json")) {
|
QString const &fName = jsonFileNames[i];
|
||||||
|
|
||||||
|
// send one request for every single version
|
||||||
|
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
|
||||||
|
// 6=printer template 1 ..... 36= template 32
|
||||||
|
|
||||||
|
if (fName.endsWith("conf.json")) {
|
||||||
jsonNr = 1;
|
jsonNr = 1;
|
||||||
} else
|
} else
|
||||||
if (fInfo.fileName().endsWith("device.json")) {
|
if (fName.endsWith("device.json")) {
|
||||||
jsonNr = 2;
|
jsonNr = 2;
|
||||||
} else
|
} else
|
||||||
if (fInfo.fileName().endsWith("cash.json")) {
|
if (fName.endsWith("cash.json")) {
|
||||||
jsonNr = 3;
|
jsonNr = 3;
|
||||||
} else {
|
} else {
|
||||||
QRegularExpressionMatch match;
|
QRegularExpressionMatch match;
|
||||||
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
|
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
|
||||||
int idx = fInfo.fileName().indexOf(re, 0, &match);
|
int idx = fName.indexOf(re, 0, &match);
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
QString captured = match.captured(match.lastCapturedIndex());
|
QString captured = match.captured(match.lastCapturedIndex());
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int n = captured.toInt(&ok);
|
int n = captured.toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
jsonNr = n + 4;
|
jsonNr = n + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonNr != 0) {
|
if (jsonNr != 0) {
|
||||||
#if 0
|
// send one request for every single version
|
||||||
|
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
|
||||||
|
// 5=printer template 1 ..... 36= template 32
|
||||||
|
|
||||||
m_hw->sys_requestJsonVersions(jsonNr);
|
m_hw->sys_requestJsonVersions(jsonNr);
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
|
|
||||||
char buf[64];
|
char buf[64];
|
||||||
memset(buf, 0x00, sizeof(buf));
|
memset(buf, 0x00, sizeof(buf));
|
||||||
m_hw->sys_getJsonVersions(jsonNr, buf);
|
m_hw->sys_getJsonVersions(jsonNr, buf);
|
||||||
buf[sizeof(buf)-1] = '\0';
|
buf[16] = '\0'; // the DC only handles 16 bytes
|
||||||
|
|
||||||
QString const installedVersion(buf);
|
static const QByteArray cb(16, (char)0xff);
|
||||||
|
|
||||||
|
QString const installedVersion(QString::fromStdString(buf));
|
||||||
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
||||||
|
|
||||||
qCritical() << "installed version:" << installedVersion;
|
QFileInfo fi(jsonFileNames[i]);
|
||||||
qCritical() << " file version:" << fileVersion;
|
|
||||||
|
qCritical() << endl;
|
||||||
|
qCritical() << " json request nr:" << jsonNr;
|
||||||
|
|
||||||
if (installedVersion == fileVersion) {
|
if (installedVersion == fileVersion) {
|
||||||
|
qCritical() << " json file:" << fi.fileName();
|
||||||
|
qCritical() << " installed version in DC:" << installedVersion;
|
||||||
|
} else
|
||||||
|
if (cb == QByteArray(buf) && fileVersion == "") {
|
||||||
|
qCritical() << "unknown json file (repo and DC):" << fi.fileName();
|
||||||
|
} else {
|
||||||
|
qCritical() << " json file:" << fi.fileName();
|
||||||
|
qCritical() << " installed version in DC:" << installedVersion;
|
||||||
|
qCritical() << " file version in repository:" << fileVersion;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "CANNOT FIND JSON-NR FOR" << jsonFileNames[i];
|
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
|
Reference in New Issue
Block a user