Compare commits

...

8 Commits

Author SHA1 Message Date
9ed8603dfb DCUpdate runs before download jsons and before sync. with ptu-filesystem. Show this in main-window. 2025-08-19 10:57:19 +02:00
7d367f7fa9 renamed target in *.pro 2025-08-19 10:30:39 +02:00
fc306a45f7 Renamed target ATBDownloadDCJsonFiles -> ATBUpdateJsonFiles (consistency). 2025-08-19 10:29:29 +02:00
df6f33a259 Add define for TEST_DC_DOWNLOAD and add corresponding code
to test the download without actual dc-controller on the PTU.
2025-08-19 10:14:12 +02:00
716543ec8c "after dc_download restart autorequest or else E255" 2025-08-18 13:06:25 +02:00
0f355c0c50 "shortened time to sendnextblock." 2025-08-18 13:04:50 +02:00
36a4d53df6 "increased BL_start Timer (500 -> 1000) " 2025-08-18 08:55:24 +02:00
b9e9688269 startBootloader():
set wait time to 1000ms.
    set try counter to 10.
    a message to ask for general bl installation (in hardware)
2025-08-13 11:16:15 +02:00
5 changed files with 74 additions and 47 deletions

View File

@ -189,7 +189,7 @@ int main(int argc, char **argv) {
} }
Update u(fi.absoluteFilePath(), libca, debug, noaction); Update u(fi.absoluteFilePath(), libca, debug, noaction);
// u.run(); u.run();
qInfo() << "<DC-UPDATE-FINISH>"; qInfo() << "<DC-UPDATE-FINISH>";

View File

@ -30,6 +30,10 @@
#define UPDATE_OPKG (1) #define UPDATE_OPKG (1)
#define UPDATE_DC (0) #define UPDATE_DC (0)
// TODO: dynamisch setzen
#define TEST_DC_DOWNLOAD (0) // 0/1
static const QMap<QString, int> baudrateMap = { static const QMap<QString, int> baudrateMap = {
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
{"57600" , 4}, {"115200" , 5} {"57600" , 4}, {"115200" , 5}
@ -130,11 +134,16 @@ Update::sendNextAddress(int bNum) const {
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) { if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
// qDebug() << "addr-block" << bNum << "..."; // qDebug() << "addr-block" << bNum << "...";
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
#if TEST_DC_DOWNLOAD==0
m_hw->bl_sendAddress(bNum); m_hw->bl_sendAddress(bNum);
QThread::msleep(100); QThread::msleep(10); //from 100ms to 20ms
//###################################################################################
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK()); DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
#else
DownloadResult const res = DownloadResult::OK;
#endif
if (res != DownloadResult::NOP) { if (res != DownloadResult::NOP) {
if (res == DownloadResult::ERROR) { if (res == DownloadResult::ERROR) {
if (++errorCount >= 10) { if (++errorCount >= 10) {
@ -173,15 +182,22 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
qInfo() << s.toUtf8().constData(); qInfo() << s.toUtf8().constData();
QThread::msleep(200); QThread::msleep(20); //reduce from 200 to 50 ms
//############################################################################
QByteArray b((const char *)(&local[0]), 64); QByteArray b((const char *)(&local[0]), 64);
qCritical() << "SNDB" << bNum << b.size() << b.toHex(); qCritical() << "SNDB" << bNum << b.size() << b.toHex();
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
#if TEST_DC_DOWNLOAD==0
m_hw->bl_sendDataBlock(64, local); m_hw->bl_sendDataBlock(64, local);
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK()); DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
#else
DownloadResult const res = DownloadResult::OK;
#endif
if (res != DownloadResult::NOP) { if (res != DownloadResult::NOP) {
if (res == DownloadResult::ERROR) { if (res == DownloadResult::ERROR) {
if (++errorCount >= 10) { if (++errorCount >= 10) {
@ -202,17 +218,13 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
} }
bool Update::startBootloader() const { bool Update::startBootloader() const {
#if 0 qDebug() << "starting bootloader...";
qInfo() << nextTimePoint().toUtf8().constData() << "start boot loader";
QThread::msleep(1000);
qInfo() << nextTimePoint().toUtf8().constData() << "start boot loader ...done";
return true;
#else
int nTry = 5; #if TEST_DC_DOWNLOAD==0
int nTry = 10;
while (--nTry >= 0) { while (--nTry >= 0) {
m_hw->bl_startBL(); m_hw->bl_startBL();
QThread::msleep(5000); QThread::msleep(1000);
m_hw->bl_checkBL(); m_hw->bl_checkBL();
if (m_hw->bl_isUp()) { if (m_hw->bl_isUp()) {
qInfo() << "starting bootloader...OK"; qInfo() << "starting bootloader...OK";
@ -220,42 +232,48 @@ bool Update::startBootloader() const {
return true; return true;
} else { } else {
qCritical() << "bootloader not up (" << nTry << ")"; qCritical() << "bootloader not up (" << nTry << ")";
qCritical() << "IS BOOTLOADER INSTALLED ???";
} }
} }
qCritical() << "starting bootloader...FAILED"; qCritical() << "starting bootloader...FAILED";
return false; #else
QThread::msleep(1000);
qInfo() << "starting bootloader...OK";
return true;
#endif #endif
return false;
} }
bool Update::stopBootloader() const { 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..."; qDebug() << "stopping bootloader...";
#if TEST_DC_DOWNLOAD==0
int nTry = 5; int nTry = 5;
while (--nTry >= 0) { while (--nTry >= 0) {
m_hw->bl_stopBL(); m_hw->bl_stopBL();
QThread::msleep(500); QThread::msleep(1000);
if (!m_hw->bl_isUp()) { if (!m_hw->bl_isUp()) {
qInfo() << "stopping bootloader...OK"; qInfo() << "stopping bootloader...OK";
return true; return true;
} }
} }
qCritical() << "stopping bootloader...FAILED"; qCritical() << "stopping bootloader...FAILED";
return false;
#else // Test code
QThread::msleep(1000);
qInfo() << "stopping bootloader...OK";
return true;
#endif #endif
return false;
} }
bool Update::resetDeviceController() const { bool Update::resetDeviceController() const {
qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller"; qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller";
#if TEST_DC_DOWNLOAD==0
m_hw->bl_rebootDC(); m_hw->bl_rebootDC();
#endif
// wait maximally 3 seconds, before starting bootloader // wait maximally 3 seconds, before starting bootloader
QThread::sleep(1); QThread::sleep(1);
@ -381,7 +399,9 @@ int Update::run() {
qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName); qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName);
} }
#if TEST_DC_DOWNLOAD==0
m_hw->dc_autoRequest(false); m_hw->dc_autoRequest(false);
#endif
qInfo() << "DC auto request OFF"; qInfo() << "DC auto request OFF";
@ -396,14 +416,14 @@ int Update::run() {
// fill last block of data to be sent with 0xFF // fill last block of data to be sent with 0xFF
ba = ba.leftJustified(m_totalBlocks*64, (char)(0xFF)); ba = ba.leftJustified(m_totalBlocks*64, (char)(0xFF));
// TODO
resetDeviceController(); resetDeviceController();
if (startBootloader()) { if (startBootloader()) {
int currentBlock = 0; int currentBlock = 0;
DownloadResult res = DownloadResult::OK; DownloadResult res = DownloadResult::OK;
qInfo() << nextTimePoint().toUtf8().constData() << "64-byte block" << currentBlock; 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 = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) { if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
currentBlock += 1; currentBlock += 1;
@ -436,9 +456,14 @@ int Update::run() {
stopBootloader(); // there is no harm in stopping the bootloader even stopBootloader(); // there is no harm in stopping the bootloader even
// if starting the bootloader failed // if starting the bootloader failed
qInfo() << nextTimePoint().toUtf8().constData() << "<DC-UPDATE-SUCCESS>"; 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; return -(int)Result::SUCCESS;
} }
qInfo() << nextTimePoint().toUtf8().constData() << "<DC-UPDATE-FAILURE>"; qInfo() << nextTimePoint().toUtf8().constData() << "<DC-UPDATE-FAILURE>";
//To Do Error handling if Dc doesnt start after download
return false; return false;
} }

View File

@ -1,7 +1,7 @@
QT += core QT += core
QT += serialport network QT += serialport network
TARGET = ATBDownloadDCJsonFiles TARGET = ATBUpdateJsonFiles
VERSION="0.1.0" VERSION="0.1.0"
win32 { win32 {

View File

@ -22,9 +22,9 @@
#define UPDATE_CUSTOMER_REPOSITORY 2 #define UPDATE_CUSTOMER_REPOSITORY 2
#define INSTALL_SW_PACKETS_DRY_RUN 3 #define INSTALL_SW_PACKETS_DRY_RUN 3
#define INSTALL_SW_PACKETS 4 #define INSTALL_SW_PACKETS 4
#define INSTALL_DC_CONFIGURATION 5 #define UPDATE_DC 5
#define SYNCHRONIZE_REPOSITORY 6 #define SYNCHRONIZE_REPOSITORY 6
#define UPDATE_DC 7 #define INSTALL_DC_CONFIGURATION 7
#define CHECK_ISMAS_CONNECT_PERCENT_START ( 1) #define CHECK_ISMAS_CONNECT_PERCENT_START ( 1)
#define CHECK_ISMAS_CONNECT_PERCENT_END (10) #define CHECK_ISMAS_CONNECT_PERCENT_END (10)
@ -41,14 +41,14 @@
#define UPDATE_OPKG_PERCENT_START (25) #define UPDATE_OPKG_PERCENT_START (25)
#define UPDATE_OPKG_PERCENT_END (40) #define UPDATE_OPKG_PERCENT_END (40)
#define UPDATE_DOWNLOAD_JSON_START (40) #define UPDATE_DOWNLOAD_DC_START (41)
#define UPDATE_DOWNLOAD_JSON_END (49) #define UPDATE_DOWNLOAD_DC_END (80)
#define UPDATE_SYNC_START (49) #define UPDATE_SYNC_START (81)
#define UPDATE_SYNC_END (50) #define UPDATE_SYNC_END (90)
#define UPDATE_DOWNLOAD_DC_START (50) #define UPDATE_DOWNLOAD_JSON_START (91)
#define UPDATE_DOWNLOAD_DC_END (100) #define UPDATE_DOWNLOAD_JSON_END (100)
void MainWindow::onFileChanged(QString const& /*f*/) { void MainWindow::onFileChanged(QString const& /*f*/) {
static int i = 30; static int i = 30;
@ -84,9 +84,9 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
m_updateSteps[UPDATE_CUSTOMER_REPOSITORY] = "Update customer repository "; 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_DRY_RUN] = "Install SW packets (dry run) ";
m_updateSteps[INSTALL_SW_PACKETS] = "Install SW packets "; m_updateSteps[INSTALL_SW_PACKETS] = "Install SW packets ";
m_updateSteps[INSTALL_DC_CONFIGURATION] = "Install DC configuration ";
m_updateSteps[SYNCHRONIZE_REPOSITORY] = "Synchronize repository/filesystem ";
m_updateSteps[UPDATE_DC] = "Update DC "; m_updateSteps[UPDATE_DC] = "Update DC ";
m_updateSteps[SYNCHRONIZE_REPOSITORY] = "Synchronize repository/filesystem ";
m_updateSteps[INSTALL_DC_CONFIGURATION] = "Install DC configuration ";
QString text{}; QString text{};
for (int i = 0; i < m_updateSteps.size(); ++i) { for (int i = 0; i < m_updateSteps.size(); ++i) {

View File

@ -244,8 +244,8 @@ Worker::Worker(int customerNr,
// the corresponding branch, and check the integrity of the repository. // the corresponding branch, and check the integrity of the repository.
m_workList.push_back( m_workList.push_back(
std::make_unique<CheckAndFetchCustomerRepositoryCommand>( std::make_unique<CheckAndFetchCustomerRepositoryCommand>(
QString("echo ATBUpdateGit") // QString("echo ATBUpdateGit")
// QString("/opt/app/tools/atbupdate/ATBUpdateGit") QString("/opt/app/tools/atbupdate/ATBUpdateGit")
, this, ++next)); , this, ++next));
// *** exec opkg-commands (noaction) *** // *** exec opkg-commands (noaction) ***
@ -264,11 +264,19 @@ Worker::Worker(int customerNr,
// QString("/opt/app/tools/atbupdate/ATBUpdateOpkg") // QString("/opt/app/tools/atbupdate/ATBUpdateOpkg")
, this, ++next, false)); , 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 *** // *** send json files down to device controller ***
m_workList.push_back( m_workList.push_back(
std::make_unique<UpdateJsonCommand>( std::make_unique<UpdateJsonCommand>(
QString("echo ATBDownloadDCJsonFiles") QString("echo ATBUpdateJsonFiles")
//QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid()) //QString("/opt/app/tools/atbupdate/ATBUpdateJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())
, this, ++next, false)); , this, ++next, false));
// sync json files in repo etc-directory with /etc fs-directory // sync json files in repo etc-directory with /etc fs-directory
@ -277,12 +285,6 @@ Worker::Worker(int customerNr,
QString("echo ATBUpdateSync") QString("echo ATBUpdateSync")
, this, ++next)); , 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 // show/send software-status
m_workList.push_back( m_workList.push_back(