From 5577cc5d6dfddf388c98c64f6804b01df0b42ef1 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 24 Nov 2023 14:08:54 +0100 Subject: [PATCH] Add m_sys_areDCdataValid plus its handling --- update.cpp | 62 ++++++++++++++++++++++++++++++------------------------ update.h | 1 + 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/update.cpp b/update.cpp index 5ef2de8..551d912 100644 --- a/update.cpp +++ b/update.cpp @@ -115,15 +115,28 @@ Update::Update(Worker *worker, , m_branchName(branchName) , m_pluginName(pluginName) , m_workingDir(workingDir) - , m_dryRun(dryRun) { + , m_dryRun(dryRun) + , m_sys_areDCdataValid(false) { - qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface; - qInfo() << "UPDATE: m_baudrate ..." << m_baudrate; - qInfo() << "UPDATE: m_customerRepository ..." << m_customerRepository; - qInfo() << "UPDATE: m_customerNr ..........." << m_customerNrStr; - qInfo() << "UPDATE: m_branchName ..........." << m_branchName; - qInfo() << "UPDATE: m_pluginName ..........." << m_pluginName; - qInfo() << "UPDATE: m_workingDirectory ....." << m_workingDir; + int tries = 20; + while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) { + // must deliver 'true', only then are all data from hwapi valid + if (--tries < 0) { + qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED"; + } + m_hw->dc_autoRequest(true); + QThread::msleep(500); + } + + qCritical() << "UPDATE: m_sys_areDCDataValid ..." << m_sys_areDCdataValid; + + //qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface; + //qInfo() << "UPDATE: m_baudrate ..." << m_baudrate; + //qInfo() << "UPDATE: m_customerRepository ..." << m_customerRepository; + //qInfo() << "UPDATE: m_customerNr ..........." << m_customerNrStr; + //qInfo() << "UPDATE: m_branchName ..........." << m_branchName; + //qInfo() << "UPDATE: m_pluginName ..........." << m_pluginName; + //qInfo() << "UPDATE: m_workingDirectory ....." << m_workingDir; } Update::~Update() { @@ -363,23 +376,24 @@ bool Update::downloadJson(enum FileTypeJson type, templateIdx, (uint8_t *)ba.data())) { - QThread::msleep(1000); + m_hw->dc_autoRequest(true); + QThread::msleep(500); // testing - //m_hw->request_ReadbackMachineID(); - //QThread::msleep(500); + m_hw->request_ReadbackMachineID(); + QThread::msleep(500); - //uint8_t data[64]; - //memset(data, 0x00, sizeof(data)); - //uint8_t length = 0; + uint8_t data[64]; + memset(data, 0x00, sizeof(data)); + uint8_t length = 0; - //m_hw->readback_machineIDdata(&length, data); + m_hw->readback_machineIDdata(&length, data); - //QThread::msleep(500); + QThread::msleep(500); - //QByteArray ba((const char*)data, length); + QByteArray ba((const char*)data, length); - //qCritical() << length << "MACHINE ID =" << ba.toHex(':'); + qCritical() << length << "MACHINE ID =" << ba.toHex(':'); ret = true; } @@ -481,15 +495,9 @@ QStringList Update::getDcSoftAndHardWareVersion() { } bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { - int tries = 20; - while (!m_hw->sys_areDCdataValid()) { // must deliver 'true', only then are all - // data from hwapi valid - if (--tries < 0) { - qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED"; - return false; - } - m_hw->dc_autoRequest(true); - QThread::msleep(500); + if (m_sys_areDCdataValid == false) { + qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED"; + return false; } bool res = false; diff --git a/update.h b/update.h index 0413618..cb1d01a 100644 --- a/update.h +++ b/update.h @@ -32,6 +32,7 @@ class Update : public QObject { QString m_workingDir; bool m_maintenanceMode; bool m_dryRun; + bool m_sys_areDCdataValid; static QPluginLoader pluginLoader;