ATBUpdateTool/commands_to_update_dc.cpp

85 lines
1.5 KiB
C++
Raw Normal View History

2023-04-05 14:43:27 +02:00
#include "commands_to_update_dc.h"
#include "plugins/interfaces.h"
#include <QDebug>
#include <QThread>
#include <QCoreApplication>
Command::Command(hwinf const *hw)
: m_hw(hw)
, m_serial(hw, 115200, "115200", "ttyUSB0") {
qDebug() << "opening serial...";
m_serial.openSerial();
}
Command::~Command() {
qDebug() << "close serial...";
m_serial.closeSerial();
QCoreApplication::quit();
}
bool Command::startCmdSequence() {
QThread::sleep(3);
qDebug() << "updating dc-fw...";
if (!resetDeviceController()) {
qCritical() << "resetDeviceController failed";
return false;
}
QThread::sleep(10);
return true;
if (!enterBootloader()) {
// after max. 3 seconds start boot loader
qCritical() << "enterBootloader failed";
return false;
}
if (!isBootloaderRunning()) {
qCritical() << "isBootloaderRunning failed";
return false;
}
//if (!loadBinary()) {
//
// }
// if (!sendBinary()) {
//
// }
if (!exitBootloader()) {
qCritical() << "exitBootloader failed";
return false;
}
qDebug() << "updating dc-fw...done";
return true;
}
bool Command::resetDeviceController() {
qDebug() << __func__;
m_hw->dc_OrderToReset();
return true;
}
bool Command::enterBootloader() {
return false;
}
bool Command::isBootloaderRunning() {
return false;
}
bool Command::loadBinary() {
return false;
}
bool Command::sendBinary() {
return false;
}
bool Command::exitBootloader() {
return false;
}