diff --git a/DownloadDCFirmware/main.cpp b/DownloadDCFirmware/main.cpp index 0c1267a..ad64256 100644 --- a/DownloadDCFirmware/main.cpp +++ b/DownloadDCFirmware/main.cpp @@ -189,7 +189,7 @@ int main(int argc, char **argv) { } Update u(fi.absoluteFilePath(), libca, debug, noaction); - u.run(); + // u.run(); qInfo() << ""; diff --git a/DownloadDCFirmware/update.cpp b/DownloadDCFirmware/update.cpp index 52ac204..166c785 100644 --- a/DownloadDCFirmware/update.cpp +++ b/DownloadDCFirmware/update.cpp @@ -130,16 +130,11 @@ Update::sendNextAddress(int bNum) const { if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) { // qDebug() << "addr-block" << bNum << "..."; while (noAnswerCount <= 250) { - // TODO - // m_hw->bl_sendAddress(bNum); + m_hw->bl_sendAddress(bNum); QThread::msleep(100); - // TODO - // DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK()); - - DownloadResult const res = DownloadResult::OK; - + DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK()); if (res != DownloadResult::NOP) { if (res == DownloadResult::ERROR) { if (++errorCount >= 10) { @@ -179,20 +174,14 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const { qInfo() << s.toUtf8().constData(); QThread::msleep(200); - return DownloadResult::OK; - // QByteArray b((const char *)(&local[0]), 64); - // qCritical() << "SNDB" << bNum << b.size() << b.toHex(); + QByteArray b((const char *)(&local[0]), 64); + qCritical() << "SNDB" << bNum << b.size() << b.toHex(); while (noAnswerCount <= 250) { - // TODO - // m_hw->bl_sendDataBlock(64, local); - - // TODO - // DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK()); - - DownloadResult const res = DownloadResult::OK; + m_hw->bl_sendDataBlock(64, local); + DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK()); if (res != DownloadResult::NOP) { if (res == DownloadResult::ERROR) { if (++errorCount >= 10) { @@ -213,12 +202,13 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const { } bool Update::startBootloader() const { +#if 0 qInfo() << nextTimePoint().toUtf8().constData() << "start boot loader"; QThread::msleep(1000); qInfo() << nextTimePoint().toUtf8().constData() << "start boot loader ...done"; return true; +#else -#if 0 int nTry = 5; while (--nTry >= 0) { m_hw->bl_startBL(); @@ -234,16 +224,19 @@ bool Update::startBootloader() const { } qCritical() << "starting bootloader...FAILED"; return false; + #endif } bool Update::stopBootloader() const { +#if 0 qInfo() << nextTimePoint().toUtf8().constData() << "stopping bootloader"; QThread::msleep(1000); qInfo() << nextTimePoint().toUtf8().constData() << "stopping bootloader ...done"; return true; -#if 0 +#else + qDebug() << "stopping bootloader..."; int nTry = 5; while (--nTry >= 0) { @@ -256,13 +249,13 @@ bool Update::stopBootloader() const { } qCritical() << "stopping bootloader...FAILED"; return false; + #endif } bool Update::resetDeviceController() const { qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller"; - // TODO - // m_hw->bl_rebootDC(); + m_hw->bl_rebootDC(); // wait maximally 3 seconds, before starting bootloader QThread::sleep(1); @@ -280,12 +273,12 @@ QByteArray Update::loadBinaryDCFile(QString const &filename) const { if (!file.exists()) { qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << file.fileName() << "does not exist"; - return QByteArray(); + return QByteArray{}; } if (!file.open(QIODevice::ReadOnly)) { qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "cannot open file" << file.fileName(); - return QByteArray(); + return QByteArray{}; } qInfo() << nextTimePoint().toUtf8().constData() @@ -392,10 +385,8 @@ int Update::run() { qInfo() << "DC auto request OFF"; - // dennis einzelne linie qCritical() << "start dc-update for" << m_dcFileName << "at" << m_start.toString(Qt::ISODate); - QByteArray ba = loadBinaryDCFile(m_dcFileName); if (ba.size() > 0) { m_totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1; @@ -415,8 +406,6 @@ int Update::run() { while (res != DownloadResult::ERROR && currentBlock < m_totalBlocks) { if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) { if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) { - // TODO - // m_hw->dcDownloadSetCurrentBlockNumber(currentBlock); currentBlock += 1; } else break; }