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