Compare commits
No commits in common. "9ed8603dfb9419047ecb6be55ba84803fe699dd7" and "f5611cf826c435ae10a8c37f4f01464466173bbe" have entirely different histories.
9ed8603dfb
...
f5611cf826
@ -189,7 +189,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
Update u(fi.absoluteFilePath(), libca, debug, noaction);
|
||||
u.run();
|
||||
// u.run();
|
||||
|
||||
qInfo() << "<DC-UPDATE-FINISH>";
|
||||
|
||||
|
@ -30,10 +30,6 @@
|
||||
#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}
|
||||
@ -134,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) {
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
|
||||
QThread::msleep(10); //from 100ms to 20ms
|
||||
//###################################################################################
|
||||
QThread::msleep(100);
|
||||
|
||||
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) {
|
||||
@ -182,22 +173,15 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
|
||||
qInfo() << s.toUtf8().constData();
|
||||
|
||||
QThread::msleep(20); //reduce from 200 to 50 ms
|
||||
//############################################################################
|
||||
QThread::msleep(200);
|
||||
|
||||
QByteArray b((const char *)(&local[0]), 64);
|
||||
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) {
|
||||
@ -218,13 +202,17 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
}
|
||||
|
||||
bool Update::startBootloader() const {
|
||||
qDebug() << "starting bootloader...";
|
||||
#if 0
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "start boot loader";
|
||||
QThread::msleep(1000);
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "start boot loader ...done";
|
||||
return true;
|
||||
#else
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
int nTry = 10;
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_startBL();
|
||||
QThread::msleep(1000);
|
||||
QThread::msleep(5000);
|
||||
m_hw->bl_checkBL();
|
||||
if (m_hw->bl_isUp()) {
|
||||
qInfo() << "starting bootloader...OK";
|
||||
@ -232,48 +220,42 @@ bool Update::startBootloader() const {
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << "bootloader not up (" << nTry << ")";
|
||||
qCritical() << "IS BOOTLOADER INSTALLED ???";
|
||||
}
|
||||
}
|
||||
qCritical() << "starting bootloader...FAILED";
|
||||
#else
|
||||
QThread::msleep(1000);
|
||||
qInfo() << "starting bootloader...OK";
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Update::stopBootloader() const {
|
||||
qDebug() << "stopping bootloader...";
|
||||
#if 0
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "stopping bootloader";
|
||||
QThread::msleep(1000);
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "stopping bootloader ...done";
|
||||
return true;
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
#else
|
||||
|
||||
qDebug() << "stopping bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
QThread::msleep(1000);
|
||||
QThread::msleep(500);
|
||||
if (!m_hw->bl_isUp()) {
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
qCritical() << "stopping bootloader...FAILED";
|
||||
|
||||
#else // Test code
|
||||
QThread::msleep(1000);
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
@ -399,9 +381,7 @@ 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";
|
||||
|
||||
@ -416,14 +396,14 @@ 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()) {
|
||||
|
||||
int currentBlock = 0;
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "64-byte block" << currentBlock;
|
||||
|
||||
while (res != DownloadResult::ERROR && currentBlock <= m_totalBlocks) {
|
||||
while (res != DownloadResult::ERROR && currentBlock < m_totalBlocks) {
|
||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||
currentBlock += 1;
|
||||
@ -456,14 +436,9 @@ 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;
|
||||
}
|
||||
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "<DC-UPDATE-FAILURE>";
|
||||
//To Do Error handling if Dc doesnt start after download
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
QT += core
|
||||
QT += serialport network
|
||||
|
||||
TARGET = ATBUpdateJsonFiles
|
||||
TARGET = ATBDownloadDCJsonFiles
|
||||
|
||||
VERSION="0.1.0"
|
||||
win32 {
|
||||
|
@ -22,9 +22,9 @@
|
||||
#define UPDATE_CUSTOMER_REPOSITORY 2
|
||||
#define INSTALL_SW_PACKETS_DRY_RUN 3
|
||||
#define INSTALL_SW_PACKETS 4
|
||||
#define UPDATE_DC 5
|
||||
#define INSTALL_DC_CONFIGURATION 5
|
||||
#define SYNCHRONIZE_REPOSITORY 6
|
||||
#define INSTALL_DC_CONFIGURATION 7
|
||||
#define UPDATE_DC 7
|
||||
|
||||
#define CHECK_ISMAS_CONNECT_PERCENT_START ( 1)
|
||||
#define CHECK_ISMAS_CONNECT_PERCENT_END (10)
|
||||
@ -41,14 +41,14 @@
|
||||
#define UPDATE_OPKG_PERCENT_START (25)
|
||||
#define UPDATE_OPKG_PERCENT_END (40)
|
||||
|
||||
#define UPDATE_DOWNLOAD_DC_START (41)
|
||||
#define UPDATE_DOWNLOAD_DC_END (80)
|
||||
#define UPDATE_DOWNLOAD_JSON_START (40)
|
||||
#define UPDATE_DOWNLOAD_JSON_END (49)
|
||||
|
||||
#define UPDATE_SYNC_START (81)
|
||||
#define UPDATE_SYNC_END (90)
|
||||
#define UPDATE_SYNC_START (49)
|
||||
#define UPDATE_SYNC_END (50)
|
||||
|
||||
#define UPDATE_DOWNLOAD_JSON_START (91)
|
||||
#define UPDATE_DOWNLOAD_JSON_END (100)
|
||||
#define UPDATE_DOWNLOAD_DC_START (50)
|
||||
#define UPDATE_DOWNLOAD_DC_END (100)
|
||||
|
||||
void MainWindow::onFileChanged(QString const& /*f*/) {
|
||||
static int i = 30;
|
||||
@ -84,9 +84,9 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
m_updateSteps[UPDATE_CUSTOMER_REPOSITORY] = "Update customer repository ";
|
||||
m_updateSteps[INSTALL_SW_PACKETS_DRY_RUN] = "Install SW packets (dry run) ";
|
||||
m_updateSteps[INSTALL_SW_PACKETS] = "Install SW packets ";
|
||||
m_updateSteps[UPDATE_DC] = "Update DC ";
|
||||
m_updateSteps[SYNCHRONIZE_REPOSITORY] = "Synchronize repository/filesystem ";
|
||||
m_updateSteps[INSTALL_DC_CONFIGURATION] = "Install DC configuration ";
|
||||
m_updateSteps[SYNCHRONIZE_REPOSITORY] = "Synchronize repository/filesystem ";
|
||||
m_updateSteps[UPDATE_DC] = "Update DC ";
|
||||
|
||||
QString text{};
|
||||
for (int i = 0; i < m_updateSteps.size(); ++i) {
|
||||
|
@ -244,8 +244,8 @@ Worker::Worker(int customerNr,
|
||||
// the corresponding branch, and check the integrity of the repository.
|
||||
m_workList.push_back(
|
||||
std::make_unique<CheckAndFetchCustomerRepositoryCommand>(
|
||||
// QString("echo ATBUpdateGit")
|
||||
QString("/opt/app/tools/atbupdate/ATBUpdateGit")
|
||||
QString("echo ATBUpdateGit")
|
||||
// QString("/opt/app/tools/atbupdate/ATBUpdateGit")
|
||||
, this, ++next));
|
||||
|
||||
// *** exec opkg-commands (noaction) ***
|
||||
@ -264,19 +264,11 @@ Worker::Worker(int customerNr,
|
||||
// QString("/opt/app/tools/atbupdate/ATBUpdateOpkg")
|
||||
, this, ++next, false));
|
||||
|
||||
// send device-controller firmware down to device-controller-hardware
|
||||
m_workList.push_back(
|
||||
std::make_unique<UpdateDCCommand>(
|
||||
// QString("echo ATBUpdateDC")
|
||||
QString("/opt/app/tools/atbupdate/ATBUpdateDC")
|
||||
, this, ++next));
|
||||
|
||||
|
||||
// *** send json files down to device controller ***
|
||||
m_workList.push_back(
|
||||
std::make_unique<UpdateJsonCommand>(
|
||||
QString("echo ATBUpdateJsonFiles")
|
||||
//QString("/opt/app/tools/atbupdate/ATBUpdateJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())
|
||||
QString("echo ATBDownloadDCJsonFiles")
|
||||
//QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())
|
||||
, this, ++next, false));
|
||||
|
||||
// sync json files in repo etc-directory with /etc fs-directory
|
||||
@ -285,6 +277,12 @@ Worker::Worker(int customerNr,
|
||||
QString("echo ATBUpdateSync")
|
||||
, this, ++next));
|
||||
|
||||
// send device-controller firmware down to device-controller-hardware
|
||||
m_workList.push_back(
|
||||
std::make_unique<UpdateDCCommand>(
|
||||
// QString("echo ATBUpdateDC")
|
||||
QString("/opt/app/tools/atbupdate/ATBUpdateDC")
|
||||
, this, ++next));
|
||||
|
||||
// show/send software-status
|
||||
m_workList.push_back(
|
||||
|
Loading…
x
Reference in New Issue
Block a user