Replace TEST_DC_DOWNLOAD with m_debug.

This commit is contained in:
Gerhard Hoffmann 2025-08-20 11:15:09 +02:00
parent 575a740692
commit a47dd60e9e

View File

@ -26,14 +26,12 @@
#include <QString> #include <QString>
#include <QSerialPort> #include <QSerialPort>
#include <QSerialPortInfo> #include <QSerialPortInfo>
#include <QSettings>
#define UPDATE_OPKG (1) #define UPDATE_OPKG (1)
#define UPDATE_DC (0) #define UPDATE_DC (0)
// TODO: dynamisch setzen
#define TEST_DC_DOWNLOAD (0) // 0/1
static const QMap<QString, int> baudrateMap = { static const QMap<QString, int> baudrateMap = {
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
{"57600" , 4}, {"115200" , 5} {"57600" , 4}, {"115200" , 5}
@ -135,15 +133,15 @@ Update::sendNextAddress(int bNum) const {
// qDebug() << "addr-block" << bNum << "..."; // qDebug() << "addr-block" << bNum << "...";
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
#if TEST_DC_DOWNLOAD==0 DownloadResult res = DownloadResult::OK;
if (!m_debug) {
m_hw->bl_sendAddress(bNum); m_hw->bl_sendAddress(bNum);
QThread::msleep(10); //from 100ms to 20ms QThread::msleep(10); //from 100ms to 20ms
//################################################################################### //###################################################################################
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK()); res = sendStatus(m_hw->bl_wasSendingAddOK());
#else }
DownloadResult const res = DownloadResult::OK;
#endif
if (res != DownloadResult::NOP) { if (res != DownloadResult::NOP) {
if (res == DownloadResult::ERROR) { if (res == DownloadResult::ERROR) {
if (++errorCount >= 10) { if (++errorCount >= 10) {
@ -157,7 +155,7 @@ Update::sendNextAddress(int bNum) const {
} else { } else {
noAnswerCount += 1; // no answer by now noAnswerCount += 1; // no answer by now
} }
} } // while
// wait max. about 3 seconds // wait max. about 3 seconds
return DownloadResult::TIMEOUT; return DownloadResult::TIMEOUT;
} }
@ -190,13 +188,12 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
#if TEST_DC_DOWNLOAD==0 DownloadResult res = DownloadResult::OK;
m_hw->bl_sendDataBlock(64, local);
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK()); if (!m_debug) {
#else m_hw->bl_sendDataBlock(64, local);
DownloadResult const res = DownloadResult::OK; res = sendStatus(m_hw->bl_wasSendingDataOK());
#endif }
if (res != DownloadResult::NOP) { if (res != DownloadResult::NOP) {
if (res == DownloadResult::ERROR) { if (res == DownloadResult::ERROR) {
@ -220,7 +217,7 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
bool Update::startBootloader() const { bool Update::startBootloader() const {
qDebug() << "starting bootloader..."; qDebug() << "starting bootloader...";
#if TEST_DC_DOWNLOAD==0 if (!m_debug) {
int nTry = 10; int nTry = 10;
while (--nTry >= 0) { while (--nTry >= 0) {
m_hw->bl_startBL(); m_hw->bl_startBL();
@ -236,18 +233,19 @@ bool Update::startBootloader() const {
} }
} }
qCritical() << "starting bootloader...FAILED"; qCritical() << "starting bootloader...FAILED";
#else return false;
} else {
QThread::msleep(1000); QThread::msleep(1000);
qInfo() << "starting bootloader...OK"; qInfo() << "starting bootloader...OK";
}
return true; return true;
#endif
return false;
} }
bool Update::stopBootloader() const { bool Update::stopBootloader() const {
qDebug() << "stopping bootloader..."; qDebug() << "stopping bootloader...";
#if TEST_DC_DOWNLOAD==0 if (!m_debug) {
int nTry = 5; int nTry = 5;
while (--nTry >= 0) { while (--nTry >= 0) {
m_hw->bl_stopBL(); m_hw->bl_stopBL();
@ -258,22 +256,22 @@ bool Update::stopBootloader() const {
} }
} }
qCritical() << "stopping bootloader...FAILED"; qCritical() << "stopping bootloader...FAILED";
return false;
#else // Test code } else {
QThread::msleep(1000); QThread::msleep(1000);
qInfo() << "stopping bootloader...OK"; qInfo() << "stopping bootloader...OK";
return true; }
#endif
return false; return true;
} }
bool Update::resetDeviceController() const { bool Update::resetDeviceController() const {
qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller"; qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller";
#if TEST_DC_DOWNLOAD==0 if (!m_debug) {
m_hw->bl_rebootDC(); m_hw->bl_rebootDC();
#endif }
// wait maximally 3 seconds, before starting bootloader // wait maximally 3 seconds, before starting bootloader
QThread::sleep(1); QThread::sleep(1);