Replace TEST_DC_DOWNLOAD with m_debug.
This commit is contained in:
parent
575a740692
commit
a47dd60e9e
@ -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;
|
||||||
m_hw->bl_sendAddress(bNum);
|
if (!m_debug) {
|
||||||
|
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,60 +217,61 @@ 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();
|
||||||
QThread::msleep(1000);
|
QThread::msleep(1000);
|
||||||
m_hw->bl_checkBL();
|
m_hw->bl_checkBL();
|
||||||
if (m_hw->bl_isUp()) {
|
if (m_hw->bl_isUp()) {
|
||||||
qInfo() << "starting bootloader...OK";
|
qInfo() << "starting bootloader...OK";
|
||||||
QThread::msleep(5000);
|
QThread::msleep(5000);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "bootloader not up (" << nTry << ")";
|
qCritical() << "bootloader not up (" << nTry << ")";
|
||||||
qCritical() << "IS BOOTLOADER INSTALLED ???";
|
qCritical() << "IS BOOTLOADER INSTALLED ???";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
qCritical() << "starting bootloader...FAILED";
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
QThread::msleep(1000);
|
||||||
|
qInfo() << "starting bootloader...OK";
|
||||||
}
|
}
|
||||||
qCritical() << "starting bootloader...FAILED";
|
|
||||||
#else
|
|
||||||
QThread::msleep(1000);
|
|
||||||
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();
|
||||||
QThread::msleep(1000);
|
QThread::msleep(1000);
|
||||||
if (!m_hw->bl_isUp()) {
|
if (!m_hw->bl_isUp()) {
|
||||||
qInfo() << "stopping bootloader...OK";
|
qInfo() << "stopping bootloader...OK";
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
qCritical() << "stopping bootloader...FAILED";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
QThread::msleep(1000);
|
||||||
|
qInfo() << "stopping bootloader...OK";
|
||||||
}
|
}
|
||||||
qCritical() << "stopping bootloader...FAILED";
|
|
||||||
|
|
||||||
#else // Test code
|
|
||||||
QThread::msleep(1000);
|
|
||||||
qInfo() << "stopping bootloader...OK";
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user