Revert "Remove any reference to device controller as downloading jsons/dc-firmware"
This reverts commit 6b0a784fc8.
This commit is contained in:
@@ -105,6 +105,7 @@ Update::Update(Worker *worker,
|
|||||||
char const *serialInterface,
|
char const *serialInterface,
|
||||||
char const *baudrate)
|
char const *baudrate)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
, m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
|
||||||
, m_worker(worker)
|
, m_worker(worker)
|
||||||
, m_serialInterface(serialInterface)
|
, m_serialInterface(serialInterface)
|
||||||
, m_baudrate(baudrate)
|
, m_baudrate(baudrate)
|
||||||
@@ -115,6 +116,24 @@ Update::Update(Worker *worker,
|
|||||||
, m_workingDir(workingDir)
|
, m_workingDir(workingDir)
|
||||||
, m_dryRun(dryRun)
|
, m_dryRun(dryRun)
|
||||||
, m_sys_areDCdataValid(false) {
|
, m_sys_areDCdataValid(false) {
|
||||||
|
|
||||||
|
if (!m_hw) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin not loaded";
|
||||||
|
} else {
|
||||||
|
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";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_hw->dc_autoRequest(true);
|
||||||
|
QThread::msleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||||
|
<< m_sys_areDCdataValid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Update::~Update() {
|
Update::~Update() {
|
||||||
@@ -132,6 +151,43 @@ void Update::onReportDCDownloadFailure(QString const &errorMsg) {
|
|||||||
qCritical() << "msg" << errorMsg;
|
qCritical() << "msg" << errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// br is a index into a table, used for historical reasons.
|
||||||
|
bool Update::openSerial(int br, QString baudrate, QString comPort) const {
|
||||||
|
if (m_hw) {
|
||||||
|
qDebug() << "opening serial" << br << baudrate << comPort << "...";
|
||||||
|
if (m_hw->dc_openSerial(br, baudrate, comPort, 1) == true) { // 1 for connect
|
||||||
|
Utils::printInfoMsg(
|
||||||
|
QString("OPENING SERIAL %1").arg(br)
|
||||||
|
+ " " + baudrate + " " + comPort + "...OK");
|
||||||
|
|
||||||
|
// m_hw->dc_autoRequest(true);
|
||||||
|
// m_hw->dc_autoRequest(false);
|
||||||
|
// QThread::sleep(1);
|
||||||
|
|
||||||
|
Utils::printInfoMsg(QString("IS PORT OPEN %1").arg(m_hw->dc_isPortOpen()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::printCriticalErrorMsg(
|
||||||
|
QString("OPENING SERIAL %1").arg(br)
|
||||||
|
+ " " + baudrate + " " + comPort + "...FAILED");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update::closeSerial() const {
|
||||||
|
qInfo() << "CLOSED SERIAL" << m_baudrate << m_serialInterface;
|
||||||
|
if (m_hw) {
|
||||||
|
m_hw->dc_closeSerial();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Update::isSerialOpen() const {
|
||||||
|
return m_hw ? m_hw->dc_isPortOpen() : false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -226,13 +282,95 @@ bool Update::updateBinary(QString const &fileToSendToDC) {
|
|||||||
qInfo() << "updating dc-binary" << fileToSendToDC << "...";
|
qInfo() << "updating dc-binary" << fileToSendToDC << "...";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
QFile fn(fileToSendToDC);
|
||||||
|
if (!fn.exists()) {
|
||||||
|
// output via CONSOLE() etc
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bl_isUp = false;
|
||||||
|
if (m_hw->bl_completeStart()) {
|
||||||
|
int cnt = 5;
|
||||||
|
while (--cnt > 0) {
|
||||||
|
if (m_hw->bl_isUp()) {
|
||||||
|
bl_isUp = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bl_isUp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_hw->bl_storeFirmware(fileToSendToDC)) {
|
||||||
|
m_hw->bl_stopBL();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t const nrOfFirmwareBlocks = m_hw->bl_getNrOfFirmwareBlocks();
|
||||||
|
|
||||||
|
for (uint16_t blockNr = 0; blockNr <= nrOfFirmwareBlocks; ++blockNr) {
|
||||||
|
m_hw->bl_blockAutoLoad(blockNr);
|
||||||
|
|
||||||
|
int sleepTime = 0;
|
||||||
|
while (1) {
|
||||||
|
if (sleepTime > 1500) {
|
||||||
|
m_hw->bl_stopBL();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t const r = m_hw->bl_blockAutoResponse();
|
||||||
|
|
||||||
|
// after every "bl_blockAutoLoad()" call this until response
|
||||||
|
// retval 0: wait 1: OK, blk was sent 2: OK, transfer complete
|
||||||
|
// 3: error despite repeating, cancel. probably bin file corrupted
|
||||||
|
// Max duration: 3x no response from BL = 900ms
|
||||||
|
|
||||||
|
switch(r) {
|
||||||
|
case 1:
|
||||||
|
/* fall through */
|
||||||
|
case 2:
|
||||||
|
sleepTime = 0;
|
||||||
|
break;
|
||||||
|
case 0: {
|
||||||
|
QThread::msleep(100);
|
||||||
|
sleepTime += 100;
|
||||||
|
} break;
|
||||||
|
case 3:
|
||||||
|
m_hw->bl_stopBL();
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
m_hw->bl_stopBL();
|
||||||
|
return false; // unknown error code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hw->bl_stopBL();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Update::jsonType(enum FileTypeJson type) {
|
||||||
|
switch (type) {
|
||||||
|
case FileTypeJson::CASH: return "CASH";
|
||||||
|
case FileTypeJson::CONFIG: return "CONFIG";
|
||||||
|
case FileTypeJson::PRINTER: return "PRINTER";
|
||||||
|
case FileTypeJson::SERIAL: return "SERIAL";
|
||||||
|
case FileTypeJson::DEVICE: return "DEVICE";
|
||||||
|
case FileTypeJson::TIME: return "TIME";
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::downloadJson(enum FileTypeJson type,
|
bool Update::downloadJson(enum FileTypeJson type,
|
||||||
int templateIdx,
|
int templateIdx,
|
||||||
QString jsFileToSendToDC) const {
|
QString jsFileToSendToDC) const {
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (m_hw) {
|
if (m_hw) {
|
||||||
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
|
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
|
||||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||||
@@ -351,7 +489,6 @@ bool Update::downloadJson(enum FileTypeJson type,
|
|||||||
// QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
// QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +547,6 @@ void Update::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList Update::getDcSoftAndHardWareVersion() {
|
QStringList Update::getDcSoftAndHardWareVersion() {
|
||||||
#if 0
|
|
||||||
if (m_hw) {
|
if (m_hw) {
|
||||||
m_hw->dc_autoRequest(true);
|
m_hw->dc_autoRequest(true);
|
||||||
QThread::sleep(1); // make sure the timer-slots are active
|
QThread::sleep(1); // make sure the timer-slots are active
|
||||||
@@ -433,17 +569,15 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return QStringList() << "DC HW-version not available"
|
return QStringList() << "DC HW-version not available"
|
||||||
<< "DC SW-version not available";
|
<< "DC SW-version not available";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Update::getFileVersion(QString const& jsonFileName) {
|
QString Update::getFileVersion(QString const& jsonFileName) {
|
||||||
QString fileVersion("");
|
|
||||||
#if 0
|
|
||||||
// "version":"15.10.2023 14:55 02.00.06",
|
// "version":"15.10.2023 14:55 02.00.06",
|
||||||
static const QRegularExpression re("^.*(\\\"[Vv]ersion\\\":)([\\s\\\"]{0,})([^,\\\"]{0,}).*$");
|
static const QRegularExpression re("^.*(\\\"[Vv]ersion\\\":)([\\s\\\"]{0,})([^,\\\"]{0,}).*$");
|
||||||
|
|
||||||
|
QString fileVersion("");
|
||||||
QFile inputFile(QDir::cleanPath(m_customerRepository + QDir::separator() + jsonFileName));
|
QFile inputFile(QDir::cleanPath(m_customerRepository + QDir::separator() + jsonFileName));
|
||||||
|
|
||||||
if (inputFile.exists()) {
|
if (inputFile.exists()) {
|
||||||
@@ -468,12 +602,10 @@ QString Update::getFileVersion(QString const& jsonFileName) {
|
|||||||
// qCritical() << "ERROR" << inputFile.fileName() << "does not exist";
|
// qCritical() << "ERROR" << inputFile.fileName() << "does not exist";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return fileVersion;
|
return fileVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
||||||
#if 0
|
|
||||||
|
|
||||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||||
|
|
||||||
@@ -548,7 +680,6 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +687,6 @@ QMap<QString, QString>
|
|||||||
Update::getInstalledJsonVersions(QStringList const& jsonFileNames) {
|
Update::getInstalledJsonVersions(QStringList const& jsonFileNames) {
|
||||||
QMap<QString, QString> map;
|
QMap<QString, QString> map;
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||||
<< "ERROR!!! m_hw == nullptr";
|
<< "ERROR!!! m_hw == nullptr";
|
||||||
@@ -656,13 +786,11 @@ Update::getInstalledJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
Utils::printInfoMsg("CA-PLUGIN NOT LOADED");
|
Utils::printInfoMsg("CA-PLUGIN NOT LOADED");
|
||||||
return false;
|
return false;
|
||||||
@@ -869,7 +997,4 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class Worker;
|
|||||||
class Update : public QObject {
|
class Update : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
hwinf *m_hw = nullptr;
|
||||||
Worker *m_worker = nullptr;
|
Worker *m_worker = nullptr;
|
||||||
char const *m_serialInterface;
|
char const *m_serialInterface;
|
||||||
char const *m_baudrate;
|
char const *m_baudrate;
|
||||||
@@ -101,6 +102,12 @@ public:
|
|||||||
QString("etc/psa_config/DC2C_print31.json"),
|
QString("etc/psa_config/DC2C_print31.json"),
|
||||||
QString("etc/psa_config/DC2C_print32.json")})));
|
QString("etc/psa_config/DC2C_print32.json")})));
|
||||||
|
|
||||||
|
hwinf *hw() { return m_hw; }
|
||||||
|
hwinf const *hw() const { return m_hw; }
|
||||||
|
|
||||||
|
//QString customerId() { return m_customerId; }
|
||||||
|
//QString const customerId() const { return m_customerId; }
|
||||||
|
|
||||||
QString branchName() { return m_branchName; }
|
QString branchName() { return m_branchName; }
|
||||||
QString const branchName() const { return m_branchName; }
|
QString const branchName() const { return m_branchName; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user