Replace TEST_DC_DOWNLOAD with m_debug.
This commit is contained in:
		@@ -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
 | 
			
		||||
            m_hw->bl_sendAddress(bNum);
 | 
			
		||||
            DownloadResult res = DownloadResult::OK;
 | 
			
		||||
            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());
 | 
			
		||||
#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,60 +217,61 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
 | 
			
		||||
bool Update::startBootloader() const {
 | 
			
		||||
    qDebug() << "starting bootloader...";
 | 
			
		||||
 | 
			
		||||
#if TEST_DC_DOWNLOAD==0
 | 
			
		||||
    int nTry = 10;
 | 
			
		||||
    while (--nTry >= 0) {
 | 
			
		||||
        m_hw->bl_startBL();
 | 
			
		||||
        QThread::msleep(1000);
 | 
			
		||||
        m_hw->bl_checkBL();
 | 
			
		||||
        if (m_hw->bl_isUp()) {
 | 
			
		||||
            qInfo() << "starting bootloader...OK";
 | 
			
		||||
            QThread::msleep(5000);
 | 
			
		||||
            return true;
 | 
			
		||||
        } else {
 | 
			
		||||
            qCritical() << "bootloader not up (" << nTry << ")";
 | 
			
		||||
            qCritical() << "IS BOOTLOADER INSTALLED ???";
 | 
			
		||||
    if (!m_debug) {
 | 
			
		||||
        int nTry = 10;
 | 
			
		||||
        while (--nTry >= 0) {
 | 
			
		||||
            m_hw->bl_startBL();
 | 
			
		||||
            QThread::msleep(1000);
 | 
			
		||||
            m_hw->bl_checkBL();
 | 
			
		||||
            if (m_hw->bl_isUp()) {
 | 
			
		||||
                qInfo() << "starting bootloader...OK";
 | 
			
		||||
                QThread::msleep(5000);
 | 
			
		||||
                return true;
 | 
			
		||||
            } else {
 | 
			
		||||
                qCritical() << "bootloader not up (" << nTry << ")";
 | 
			
		||||
                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;
 | 
			
		||||
#endif
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Update::stopBootloader() const {
 | 
			
		||||
    qDebug() << "stopping bootloader...";
 | 
			
		||||
 | 
			
		||||
#if TEST_DC_DOWNLOAD==0
 | 
			
		||||
    int nTry = 5;
 | 
			
		||||
    while (--nTry >= 0) {
 | 
			
		||||
        m_hw->bl_stopBL();
 | 
			
		||||
        QThread::msleep(1000);
 | 
			
		||||
        if (!m_hw->bl_isUp()) {
 | 
			
		||||
            qInfo() << "stopping bootloader...OK";
 | 
			
		||||
            return true;
 | 
			
		||||
    if (!m_debug) {
 | 
			
		||||
        int nTry = 5;
 | 
			
		||||
        while (--nTry >= 0) {
 | 
			
		||||
            m_hw->bl_stopBL();
 | 
			
		||||
            QThread::msleep(1000);
 | 
			
		||||
            if (!m_hw->bl_isUp()) {
 | 
			
		||||
                qInfo() << "stopping bootloader...OK";
 | 
			
		||||
                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;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Update::resetDeviceController() const {
 | 
			
		||||
    qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller";
 | 
			
		||||
 | 
			
		||||
#if TEST_DC_DOWNLOAD==0
 | 
			
		||||
    m_hw->bl_rebootDC();
 | 
			
		||||
#endif
 | 
			
		||||
    if (!m_debug) {
 | 
			
		||||
        m_hw->bl_rebootDC();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // wait maximally 3 seconds, before starting bootloader
 | 
			
		||||
    QThread::sleep(1);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user