Add the steps to prepare the bootloader for device-controller-firmware download
using cutom-events of type update-dc-event.
This commit is contained in:
parent
60cc752819
commit
df0951d671
@ -211,6 +211,86 @@ void MainWindow::customEvent(QEvent *event) {
|
|||||||
} else {
|
} else {
|
||||||
qCritical() << "!!! UNKNOWN SENDER !!!";
|
qCritical() << "!!! UNKNOWN SENDER !!!";
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
if (event->type() == UpdateDcEvent::type()) {
|
||||||
|
UpdateDcEvent *pevent = (UpdateDcEvent *)event;
|
||||||
|
UpdateDcEvent::UpdateStep const updateStep = pevent->updateStep();
|
||||||
|
QObject const *sender = pevent->sender();
|
||||||
|
if (sender == m_worker) {
|
||||||
|
QDateTime const &recv = QDateTime::currentDateTime();
|
||||||
|
QDateTime const &send = pevent->sendDateTime();
|
||||||
|
qint64 const delay = recv.toMSecsSinceEpoch() - send.toMSecsSinceEpoch();
|
||||||
|
switch(updateStep) {
|
||||||
|
case UpdateDcEvent::UpdateStep::NONE:
|
||||||
|
break;
|
||||||
|
case UpdateDcEvent::UpdateStep::DC_REBOOT: {
|
||||||
|
m_hw->bl_rebootDC();
|
||||||
|
QString msg = QDateTime::currentDateTime().toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": reset device controller (delay=%1ms").arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
m_updateStep = UpdateDcEvent::UpdateStep::DC_REBOOT;
|
||||||
|
} break;
|
||||||
|
case UpdateDcEvent::UpdateStep::BL_START: {
|
||||||
|
QString const &msg = recv.toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": start bootloader (%1, delay=%2ms)").arg(pevent->count()).arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
m_hw->bl_startBL();
|
||||||
|
if (pevent->count() == BL_START_COUNT) {
|
||||||
|
m_updateStep = UpdateDcEvent::UpdateStep::BL_START;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case UpdateDcEvent::UpdateStep::BL_CHECK: {
|
||||||
|
if (m_updateStep != UpdateDcEvent::UpdateStep::BL_IS_UP) {
|
||||||
|
QString const &msg = recv.toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": request bootloader version (%1, delay=%2ms)").arg(pevent->count()).arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
m_hw->bl_checkBL();
|
||||||
|
//m_updateStep = UpdateDcEvent::UpdateStep::BL_CHECK;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case UpdateDcEvent::UpdateStep::BL_IS_UP: {
|
||||||
|
QString msg = recv.toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": check running bootloader (%1, delay=%2ms)").arg(pevent->count()).arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
if (m_updateStep != UpdateDcEvent::UpdateStep::BL_IS_UP) {
|
||||||
|
if (m_hw->bl_isUp()) {
|
||||||
|
msg = recv.toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": bootloader running (%1, delay=%2ms)").arg(pevent->count()).arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
m_updateStep = UpdateDcEvent::UpdateStep::BL_IS_UP;
|
||||||
|
} else {
|
||||||
|
msg = recv.toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": bootloader stop requested (%1, delay=%2ms)").arg(pevent->count()).arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
if (m_updateStep == UpdateDcEvent::UpdateStep::BL_STOP) {
|
||||||
|
msg = QDateTime::currentDateTime().toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": bootloader down (%1, delay=%2ms)").arg(pevent->count()).arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
m_updateStep = UpdateDcEvent::UpdateStep::BL_IS_DOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case UpdateDcEvent::UpdateStep::BL_STOP: {
|
||||||
|
QString const &msg = QDateTime::currentDateTime().toString(Qt::ISODateWithMs)
|
||||||
|
+ QString(": stop bootloader (%1, delay=%2ms)").arg(pevent->count()).arg(delay);
|
||||||
|
emit m_worker->showStatusMessage("dc update", msg);
|
||||||
|
Utils::printInfoMsg(msg.toUpper());
|
||||||
|
//if (m_bootLoaderIsUp) {
|
||||||
|
m_hw->bl_stopBL();
|
||||||
|
m_updateStep = UpdateDcEvent::UpdateStep::BL_STOP;
|
||||||
|
//}
|
||||||
|
} break;
|
||||||
|
default: ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QThread::yieldCurrentThread();
|
QThread::yieldCurrentThread();
|
||||||
|
Loading…
Reference in New Issue
Block a user