Compare commits
No commits in common. "0a33d078be3f59070648c8d33d049f4b1f80d915" and "f8472a3b8770876093a3c41ba2281eaa337a34d2" have entirely different histories.
0a33d078be
...
f8472a3b87
@ -123,8 +123,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# Check m_hw (pointer to CA-(Slave)Plugin) before its use.
|
||||
# Only exit() if firmware is configured to be possibly updated, but
|
||||
# loading the CA-plugin failed.
|
||||
# 1.4.7 : Read Json-file versions of Json-files actually loaded into DC.
|
||||
VERSION="1.4.8"
|
||||
VERSION="1.4.7"
|
||||
# PLANNED TODOS:
|
||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
||||
|
@ -592,12 +592,10 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
||||
|
||||
QString Update::getFileVersion(QString const& jsonFileName) {
|
||||
// "version":"15.10.2023 14:55 02.00.06",
|
||||
static const QRegularExpression re("^.*(\\\"[Vv]ersion\\\":)([\\s\\\"]{0,})([^,\\\"]{0,}).*$");
|
||||
static const QRegularExpression re("^.*(\\\"version\\\":)(.*)$");
|
||||
|
||||
QString fileVersion("");
|
||||
QFile inputFile(QDir::cleanPath(m_customerRepository + QDir::separator() + jsonFileName));
|
||||
|
||||
if (inputFile.exists()) {
|
||||
QString fileVersion;
|
||||
QFile inputFile(jsonFileName);
|
||||
if (inputFile.open(QIODevice::ReadOnly)) {
|
||||
QTextStream in(&inputFile);
|
||||
while (!in.atEnd()) {
|
||||
@ -606,18 +604,12 @@ QString Update::getFileVersion(QString const& jsonFileName) {
|
||||
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);
|
||||
fileVersion = match.captured(match.lastCapturedIndex());
|
||||
break;
|
||||
}
|
||||
}
|
||||
inputFile.close();
|
||||
}
|
||||
} else {
|
||||
// qCritical() << "ERROR" << inputFile.fileName() << "does not exist";
|
||||
}
|
||||
|
||||
return fileVersion;
|
||||
}
|
||||
@ -627,78 +619,58 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||
|
||||
uint8_t jsonNr = 0;
|
||||
QFileInfo fInfo(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 (fInfo.fileName().endsWith("conf.json")) {
|
||||
jsonNr = 1;
|
||||
} else
|
||||
if (fName.endsWith("device.json")) {
|
||||
if (fInfo.fileName().endsWith("device.json")) {
|
||||
jsonNr = 2;
|
||||
} else
|
||||
if (fName.endsWith("cash.json")) {
|
||||
if (fInfo.fileName().endsWith("cash.json")) {
|
||||
jsonNr = 3;
|
||||
} else {
|
||||
QRegularExpressionMatch match;
|
||||
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
|
||||
int idx = fName.indexOf(re, 0, &match);
|
||||
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 + 5;
|
||||
jsonNr = n + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonNr != 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
|
||||
|
||||
#if 0
|
||||
m_hw->sys_requestJsonVersions(jsonNr);
|
||||
QThread::msleep(500);
|
||||
|
||||
char buf[64];
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
m_hw->sys_getJsonVersions(jsonNr, buf);
|
||||
buf[16] = '\0'; // the DC only handles 16 bytes
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
|
||||
static const QByteArray cb(16, (char)0xff);
|
||||
|
||||
QString const installedVersion(QString::fromStdString(buf));
|
||||
QString const installedVersion(buf);
|
||||
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
||||
|
||||
QFileInfo fi(jsonFileNames[i]);
|
||||
|
||||
qCritical() << endl;
|
||||
qCritical() << " json request nr:" << jsonNr;
|
||||
qCritical() << "installed version:" << installedVersion;
|
||||
qCritical() << " file version:" << 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 {
|
||||
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
||||
qCritical() << "CANNOT FIND JSON-NR FOR" << jsonFileNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
|
||||
if (!m_hw) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user