From 11524b838902833fd62fbd348412e2bdd052f5fb Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 28 Nov 2024 12:53:44 +0100 Subject: [PATCH] read dc-verion directly from binary file --- DownloadDCFirmware/DownloadDCFirmware.pro | 2 ++ DownloadDCFirmware/main.cpp | 15 +++++++++++---- DownloadDCFirmware/update.cpp | 17 +++++++++++++++++ DownloadDCFirmware/update.h | 1 + 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/DownloadDCFirmware/DownloadDCFirmware.pro b/DownloadDCFirmware/DownloadDCFirmware.pro index 088f6d1..b32522f 100644 --- a/DownloadDCFirmware/DownloadDCFirmware.pro +++ b/DownloadDCFirmware/DownloadDCFirmware.pro @@ -80,6 +80,7 @@ SOURCES += \ mainwindow.cpp \ ../common/src/message_handler.cpp \ ../UpdatePTUDevCtrl/commandline_parser.cpp \ + ../UpdatePTUDevCtrl/process/command.cpp \ update.cpp \ dc_download.cpp \ ../common/src/System.cpp @@ -89,6 +90,7 @@ HEADERS += \ mainwindow.h \ ../common/include/message_handler.h \ ../UpdatePTUDevCtrl/commandline_parser.h \ + ../UpdatePTUDevCtrl/process/command.h \ update.h \ dc_download.h \ ../common/include/System.h diff --git a/DownloadDCFirmware/main.cpp b/DownloadDCFirmware/main.cpp index 354cb86..cd4e0bf 100644 --- a/DownloadDCFirmware/main.cpp +++ b/DownloadDCFirmware/main.cpp @@ -114,21 +114,28 @@ int main(int argc, char **argv) { qInfo() << "readDCVersion ............" << readDCVersion; 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) { printf(APP_EXTENDED_VERSION"\n"); 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"); qInfo() << "Main thread" << QThread::currentThreadId(); - MainWindow mw; + // MainWindow mw; - mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint); + // mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint); // mw.showFullScreen(); // qCritical() << "SHOW"; diff --git a/DownloadDCFirmware/update.cpp b/DownloadDCFirmware/update.cpp index c8fd39d..e6ba2df 100644 --- a/DownloadDCFirmware/update.cpp +++ b/DownloadDCFirmware/update.cpp @@ -1,4 +1,5 @@ #include "update.h" +#include "process/command.h" #include #include @@ -21,6 +22,8 @@ #include #include #include +#include +#include #define UPDATE_OPKG (1) #define UPDATE_DC (0) @@ -92,6 +95,20 @@ bool Update::unloadDCPlugin() { 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; Update::Update(QString customerRepository, QString customerNrStr, diff --git a/DownloadDCFirmware/update.h b/DownloadDCFirmware/update.h index d8fb96b..e253b59 100644 --- a/DownloadDCFirmware/update.h +++ b/DownloadDCFirmware/update.h @@ -59,6 +59,7 @@ public: virtual ~Update() override; bool doUpdate(); + static QString dcVersion(QString const &dcBinFile); private: DownloadResult sendStatus(int ret) const;