read dc-verion directly from binary file

This commit is contained in:
Gerhard Hoffmann 2024-11-28 12:53:44 +01:00
parent 6663866743
commit 11524b8389
4 changed files with 31 additions and 4 deletions

View File

@ -80,6 +80,7 @@ SOURCES += \
mainwindow.cpp \ mainwindow.cpp \
../common/src/message_handler.cpp \ ../common/src/message_handler.cpp \
../UpdatePTUDevCtrl/commandline_parser.cpp \ ../UpdatePTUDevCtrl/commandline_parser.cpp \
../UpdatePTUDevCtrl/process/command.cpp \
update.cpp \ update.cpp \
dc_download.cpp \ dc_download.cpp \
../common/src/System.cpp ../common/src/System.cpp
@ -89,6 +90,7 @@ HEADERS += \
mainwindow.h \ mainwindow.h \
../common/include/message_handler.h \ ../common/include/message_handler.h \
../UpdatePTUDevCtrl/commandline_parser.h \ ../UpdatePTUDevCtrl/commandline_parser.h \
../UpdatePTUDevCtrl/process/command.h \
update.h \ update.h \
dc_download.h \ dc_download.h \
../common/include/System.h ../common/include/System.h

View File

@ -114,21 +114,28 @@ int main(int argc, char **argv) {
qInfo() << "readDCVersion ............" << readDCVersion; qInfo() << "readDCVersion ............" << readDCVersion;
qInfo() << "dcDir ...................." << dcDir; qInfo() << "dcDir ...................." << dcDir;
if (readDCVersion) {
qInfo() << "dc-version ..............." << Update::dcVersion(
QDir::cleanPath(rtPath + QDir::separator()
+ QString("customer_%1").arg(customerNr) + QDir::separator()
+ dcDir + QDir::separator() + "dc2c.bin"));
}
if (showExtendedVersion) { if (showExtendedVersion) {
printf(APP_EXTENDED_VERSION"\n"); printf(APP_EXTENDED_VERSION"\n");
return 0; return 0;
} }
QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
QStringList filesToUpdate; // QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
// QStringList filesToUpdate;
QThread::currentThread()->setObjectName("main thread"); QThread::currentThread()->setObjectName("main thread");
qInfo() << "Main thread" << QThread::currentThreadId(); qInfo() << "Main thread" << QThread::currentThreadId();
MainWindow mw; // MainWindow mw;
mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint); // mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
// mw.showFullScreen(); // mw.showFullScreen();
// qCritical() << "SHOW"; // qCritical() << "SHOW";

View File

@ -1,4 +1,5 @@
#include "update.h" #include "update.h"
#include "process/command.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QFile> #include <QFile>
@ -21,6 +22,8 @@
#include <QDateTime> #include <QDateTime>
#include <QPluginLoader> #include <QPluginLoader>
#include <QMap> #include <QMap>
#include <QStringList>
#include <QString>
#define UPDATE_OPKG (1) #define UPDATE_OPKG (1)
#define UPDATE_DC (0) #define UPDATE_DC (0)
@ -92,6 +95,20 @@ bool Update::unloadDCPlugin() {
return false; return false;
} }
QString Update::dcVersion(QString const &dcBinFile) {
Command c("bash");
QStringList param;
param << "-c" << QString(R"(strings %1 | grep DC2c.\[0-9\] | uniq)").arg(dcBinFile);
if (c.execute("/tmp", param)) {
return c.getCommandResult().trimmed().split(QRegularExpression("\\s")).first();
// qInfo() << "(" << __func__ << ":" << __LINE__ << ")" << v;
}
return "";
}
class hwapi; class hwapi;
Update::Update(QString customerRepository, Update::Update(QString customerRepository,
QString customerNrStr, QString customerNrStr,

View File

@ -59,6 +59,7 @@ public:
virtual ~Update() override; virtual ~Update() override;
bool doUpdate(); bool doUpdate();
static QString dcVersion(QString const &dcBinFile);
private: private:
DownloadResult sendStatus(int ret) const; DownloadResult sendStatus(int ret) const;