Compare commits

...

7 Commits

5 changed files with 173 additions and 63 deletions

View File

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

View File

@ -77,7 +77,11 @@ DEFINES += QT_DEPRECATED_WARNINGS
# an activated ISMAS trigger (button). The tariff-files are rsynced to
# the local filesystem for such clone.
# Set new filename for device controller: dc2c.bin.
VERSION="1.3.22"
# 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.
@ -111,6 +115,7 @@ VERSION="1.3.22"
# 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 {

View File

@ -376,6 +376,13 @@ bool Update::downloadJson(enum FileTypeJson type,
templateIdx,
(uint8_t *)ba.data())) {
/*
* 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);
@ -394,6 +401,7 @@ bool Update::downloadJson(enum FileTypeJson type,
QByteArray ba((const char*)data, length);
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
*/
ret = true;
}
@ -494,6 +502,86 @@ QStringList Update::getDcSoftAndHardWareVersion() {
<< "DC SW-version not available";
}
QString Update::getFileVersion(QString const& jsonFileName) {
// "version":"15.10.2023 14:55 02.00.06",
static const QRegularExpression re("^.*(\\\"version\\\":)(.*)$");
QString fileVersion;
QFile inputFile(jsonFileName);
if (inputFile.open(QIODevice::ReadOnly)) {
QTextStream in(&inputFile);
while (!in.atEnd()) {
QString line = in.readLine();
QRegularExpressionMatch match;
int idx = line.indexOf(re, 0, &match);
if (idx != -1) {
fileVersion = match.captured(match.lastCapturedIndex());
break;
}
}
inputFile.close();
}
return fileVersion;
}
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
uint8_t jsonNr = 0;
QFileInfo fInfo(jsonFileNames[i]);
if (fInfo.fileName().endsWith("conf.json")) {
jsonNr = 1;
} else
if (fInfo.fileName().endsWith("device.json")) {
jsonNr = 2;
} else
if (fInfo.fileName().endsWith("cash.json")) {
jsonNr = 3;
} else {
QRegularExpressionMatch match;
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
int idx = fInfo.fileName().indexOf(re, 0, &match);
if (idx != -1) {
QString captured = match.captured(match.lastCapturedIndex());
bool ok = false;
int n = captured.toInt(&ok);
if (ok) {
jsonNr = n + 4;
}
}
}
if (jsonNr != 0) {
m_hw->sys_requestJsonVersions(jsonNr);
QThread::msleep(500);
char buf[64];
memset(buf, 0x00, sizeof(buf));
m_hw->sys_getJsonVersions(jsonNr, buf);
buf[sizeof(buf)-1] = '\0';
QString const installedVersion(buf);
QString const fileVersion = getFileVersion(jsonFileNames[i]);
qCritical() << "installed version:" << installedVersion;
qCritical() << " file version:" << fileVersion;
if (installedVersion == fileVersion) {
}
} else {
qCritical() << "CANNOT FIND JSON-NR FOR" << jsonFileNames[i];
}
}
return false;
}
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
if (m_sys_areDCdataValid == false) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
@ -504,7 +592,9 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
QList<QString>::const_iterator it;
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
m_worker->startProgressLoop();
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
if (fToWorkOn.contains("dc2c.bin")) {
bool updateBinaryRes = true;
@ -541,7 +631,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
res = updateBinaryRes;
} else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
} else {
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
@ -595,6 +686,7 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false;
}
}
if (res == false) {
break;

View File

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

View File

@ -666,7 +666,9 @@ bool Worker::filesToUpdate() {
if (dir.exists()) {
QStringList jsons = dir.entryList(QStringList() << "DC2C*.json", QDir::Files);
if (!jsons.isEmpty()) {
m_filesToUpdate << jsons;
for (QStringList::size_type i=0; i<jsons.size(); ++i) {
m_filesToUpdate << QDir::cleanPath(QString("etc/psa_config/") + jsons.at(i));
}
}
}
}
@ -679,7 +681,7 @@ bool Worker::filesToUpdate() {
QStringList dc = dir.entryList(QStringList() << "dc2c.bin", QDir::Files,
QDir::SortFlag::Time | QDir::SortFlag::Reversed);
if (!dc.isEmpty()) {
m_filesToUpdate << dc.first();
m_filesToUpdate << QDir::cleanPath(QString("etc/dc/") + dc.first());
}
}
}
@ -836,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);