Add define for TEST_DC_DOWNLOAD and add corresponding code
to test the download without actual dc-controller on the PTU.
This commit is contained in:
parent
716543ec8c
commit
df6f33a259
@ -30,6 +30,10 @@
|
||||
#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}
|
||||
@ -130,11 +134,16 @@ Update::sendNextAddress(int bNum) const {
|
||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||
// qDebug() << "addr-block" << bNum << "...";
|
||||
while (noAnswerCount <= 250) {
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
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
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
@ -180,9 +189,15 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
||||
|
||||
while (noAnswerCount <= 250) {
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
#else
|
||||
DownloadResult const res = DownloadResult::OK;
|
||||
#endif
|
||||
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
@ -203,13 +218,9 @@ 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
|
||||
qDebug() << "starting bootloader...";
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
int nTry = 10;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_startBL();
|
||||
@ -225,21 +236,18 @@ bool Update::startBootloader() const {
|
||||
}
|
||||
}
|
||||
qCritical() << "starting bootloader...FAILED";
|
||||
return false;
|
||||
|
||||
#else
|
||||
QThread::msleep(1000);
|
||||
qInfo() << "starting bootloader...OK";
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::stopBootloader() const {
|
||||
#if 0
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "stopping bootloader";
|
||||
QThread::msleep(1000);
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "stopping bootloader ...done";
|
||||
return true;
|
||||
|
||||
#else
|
||||
|
||||
qDebug() << "stopping bootloader...";
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
@ -250,14 +258,22 @@ bool Update::stopBootloader() const {
|
||||
}
|
||||
}
|
||||
qCritical() << "stopping bootloader...FAILED";
|
||||
return false;
|
||||
|
||||
#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
|
||||
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
QThread::sleep(1);
|
||||
@ -383,7 +399,9 @@ int Update::run() {
|
||||
qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName);
|
||||
}
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->dc_autoRequest(false);
|
||||
#endif
|
||||
|
||||
qInfo() << "DC auto request OFF";
|
||||
|
||||
@ -398,7 +416,6 @@ int Update::run() {
|
||||
// fill last block of data to be sent with 0xFF
|
||||
ba = ba.leftJustified(m_totalBlocks*64, (char)(0xFF));
|
||||
|
||||
// TODO
|
||||
resetDeviceController();
|
||||
if (startBootloader()) {
|
||||
|
||||
@ -439,7 +456,10 @@ int Update::run() {
|
||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||
// if starting the bootloader failed
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "<DC-UPDATE-SUCCESS>";
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->dc_autoRequest(true); //restart dc_autoRequest after download else E255!
|
||||
#endif
|
||||
return -(int)Result::SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user