Compare commits

..

No commits in common. "bc88a9b0be38bf5c0128d2348121cf0ee2373bef" and "9ed8603dfb9419047ecb6be55ba84803fe699dd7" have entirely different histories.

11 changed files with 79 additions and 114 deletions

View File

@ -1,5 +1,5 @@
[REPOSITORY_URL] [REPOSITORY_URL]
repository-url="gitea@ptu-config.atb-comm.de:ATB" repository-url="gitea@ptu-config.atb-comm.de:ATB/"
[DIRECTORIES] [DIRECTORIES]
plugin-directory="/usr/lib/" plugin-directory="/usr/lib/"
@ -19,21 +19,3 @@ yocto-version=false
yocto-install=false yocto-install=false
always-download-config=true always-download-config=true
always-download-dc=false always-download-dc=false
[ATBUpdateCheck]
[ATBUpdateDC]
debug=true
workingDir=/tmp
libca=/usr/lib/libCAslave.so
[ATBUpdateGit]
[ATBUpdateJsonFiles]
[ATBUpdateOpkg]
[ATBUpdateShow]
[ATBUpdateSync]

View File

@ -145,11 +145,14 @@ int main(int argc, char **argv) {
QString libca; QString libca;
std::unique_ptr<QSettings> settings = internal::readSettings(); std::unique_ptr<QSettings> settings = internal::readSettings();
if (settings) { if (settings) {
settings->beginGroup("ATBUpdateDC"); settings->beginGroup("COMMON");
debug = settings->value("debug", false).toBool(); debug = settings->value("debug", false).toBool();
workingDir = settings->value("workingdir", "/tmp").toString(); settings->endGroup();
settings->beginGroup("RUNTIME");
noaction = settings->value("noaction", true).toBool();
workingDir = settings->value("workingdir", "/tmp").toBool();
libca = settings->value("libca", "/usr/lib/libCAslave.so").toString(); libca = settings->value("libca", "/usr/lib/libCAslave.so").toString();
settings->endGroup(); settings->endGroup();
} }

View File

@ -26,12 +26,14 @@
#include <QString> #include <QString>
#include <QSerialPort> #include <QSerialPort>
#include <QSerialPortInfo> #include <QSerialPortInfo>
#include <QSettings>
#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}
@ -133,15 +135,15 @@ Update::sendNextAddress(int bNum) const {
// qDebug() << "addr-block" << bNum << "..."; // qDebug() << "addr-block" << bNum << "...";
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
DownloadResult res = DownloadResult::OK; #if TEST_DC_DOWNLOAD==0
if (!m_debug) { m_hw->bl_sendAddress(bNum);
m_hw->bl_sendAddress(bNum);
QThread::msleep(10); //from 100ms to 20ms QThread::msleep(10); //from 100ms to 20ms
//################################################################################### //###################################################################################
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) {
@ -155,7 +157,7 @@ Update::sendNextAddress(int bNum) const {
} else { } else {
noAnswerCount += 1; // no answer by now noAnswerCount += 1; // no answer by now
} }
} // while }
// wait max. about 3 seconds // wait max. about 3 seconds
return DownloadResult::TIMEOUT; return DownloadResult::TIMEOUT;
} }
@ -188,12 +190,13 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
while (noAnswerCount <= 250) { while (noAnswerCount <= 250) {
DownloadResult res = DownloadResult::OK; #if TEST_DC_DOWNLOAD==0
m_hw->bl_sendDataBlock(64, local);
if (!m_debug) { DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
m_hw->bl_sendDataBlock(64, local); #else
res = sendStatus(m_hw->bl_wasSendingDataOK()); DownloadResult const res = DownloadResult::OK;
} #endif
if (res != DownloadResult::NOP) { if (res != DownloadResult::NOP) {
if (res == DownloadResult::ERROR) { if (res == DownloadResult::ERROR) {
@ -217,61 +220,60 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
bool Update::startBootloader() const { bool Update::startBootloader() const {
qDebug() << "starting bootloader..."; qDebug() << "starting bootloader...";
if (!m_debug) { #if TEST_DC_DOWNLOAD==0
int nTry = 10; int nTry = 10;
while (--nTry >= 0) { while (--nTry >= 0) {
m_hw->bl_startBL(); m_hw->bl_startBL();
QThread::msleep(1000);
m_hw->bl_checkBL();
if (m_hw->bl_isUp()) {
qInfo() << "starting bootloader...OK";
QThread::msleep(5000);
return true;
} else {
qCritical() << "bootloader not up (" << nTry << ")";
qCritical() << "IS BOOTLOADER INSTALLED ???";
}
}
qCritical() << "starting bootloader...FAILED";
return false;
} else {
QThread::msleep(1000); QThread::msleep(1000);
qInfo() << "starting bootloader...OK"; m_hw->bl_checkBL();
if (m_hw->bl_isUp()) {
qInfo() << "starting bootloader...OK";
QThread::msleep(5000);
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; return true;
#endif
return false;
} }
bool Update::stopBootloader() const { bool Update::stopBootloader() const {
qDebug() << "stopping bootloader..."; qDebug() << "stopping bootloader...";
if (!m_debug) { #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(1000);
if (!m_hw->bl_isUp()) {
qInfo() << "stopping bootloader...OK";
return true;
}
}
qCritical() << "stopping bootloader...FAILED";
return false;
} else {
QThread::msleep(1000); QThread::msleep(1000);
qInfo() << "stopping bootloader...OK"; 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; return true;
#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 (!m_debug) { #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);
@ -397,9 +399,9 @@ int Update::run() {
qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName); qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName);
} }
if (!m_debug) { #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";
@ -455,10 +457,9 @@ int Update::run() {
// 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 (!m_debug) { #if TEST_DC_DOWNLOAD==0
m_hw->dc_autoRequest(true); //restart dc_autoRequest after download else E255! m_hw->dc_autoRequest(true); //restart dc_autoRequest after download else E255!
} #endif
return -(int)Result::SUCCESS; return -(int)Result::SUCCESS;
} }

View File

@ -30,7 +30,7 @@ class Update : public QObject {
QString m_dcFileName{}; QString m_dcFileName{};
hwinf *m_hw = nullptr; hwinf *m_hw = nullptr;
bool m_sys_areDCdataValid{}; bool m_sys_areDCdataValid{};
bool m_debug{false}; bool m_debug;
bool m_noaction; bool m_noaction;
static QPluginLoader pluginLoader; static QPluginLoader pluginLoader;

View File

@ -144,7 +144,7 @@ int main(int argc, char **argv) {
} }
} }
qCritical() << __LINE__ << "JSON FILES TO UPDATE" << filesToUpdate; // qCritical() << "JSON FILES TO UPDATE" << filesToUpdate;
Update update(customerRepo, Update update(customerRepo,
QString::number(customerNr), QString::number(customerNr),
@ -153,10 +153,8 @@ int main(int argc, char **argv) {
plugInName, plugInName,
workingDir); workingDir);
if (!filesToUpdate.empty()) { update.doUpdate();
update.doUpdate(filesToUpdate, mountPath.has_value()); // update.doUpdate(filesToUpdate, mountPath.has_value());
}
// update.checkJsonVersions(); // update.checkJsonVersions();
//update.checkJsonVersions(filesToUpdate); //update.checkJsonVersions(filesToUpdate);

View File

@ -107,7 +107,7 @@ Update::Update(QString customerRepository,
char const *serialInterface, char const *serialInterface,
char const *baudrate) char const *baudrate)
: QObject(parent) : QObject(parent)
, m_hw(loadDCPlugin(QDir(plugInDir), pluginName)) // , m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
, m_serialInterface(serialInterface) , m_serialInterface(serialInterface)
, m_baudrate(baudrate) , m_baudrate(baudrate)
, m_customerRepository(customerRepository) , m_customerRepository(customerRepository)
@ -145,8 +145,7 @@ Update::~Update() {
// unloadDCPlugin(); // unloadDCPlugin();
} }
#if 0 bool Update::doUpdate() {
bool Update::doUpdate() { // test function
int numberOfFiles = 3; int numberOfFiles = 3;
@ -179,7 +178,6 @@ bool Update::doUpdate() { // test function
return true; return true;
} }
#endif
bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) { bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {

View File

@ -45,6 +45,10 @@ void UpdateCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
//static constexpr const int PERCENT_UPDATE_DC{80}; //static constexpr const int PERCENT_UPDATE_DC{80};
//static constexpr const int PERCENT_SHOW_FINAL_STATUS{90}; //static constexpr const int PERCENT_SHOW_FINAL_STATUS{90};
qCritical() << __func__ << ":" << __LINE__ << m_command
<< "exitCode" << exitCode
<< "exitStatus" << exitStatus;
if (exitCode == 0 && exitStatus == QProcess::ExitStatus::NormalExit) { if (exitCode == 0 && exitStatus == QProcess::ExitStatus::NormalExit) {
if (m_command.contains("ATBUpdateCheck")) { if (m_command.contains("ATBUpdateCheck")) {
@ -123,19 +127,10 @@ void UpdateCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
if (m_worker->workList().nextExec()) { if (m_worker->workList().nextExec()) {
m_worker->workList().exec(); m_worker->workList().exec();
} else {
// testing
qCritical() << __func__ << ":" << __LINE__ << "TEST: SEND UPDATE SUCCEEDED TO ISMAS";
m_worker->setLastFailedUpdateStep(Worker::UPDATE_STEP::NONE);
Worker::UpdateProcessRunning _(m_worker);
} }
} else { } else {
bool execShowStatus = true; bool execShowStatus = true;
m_worker->workList().exec(execShowStatus); m_worker->workList().exec(execShowStatus);
} }
} else {
Q_ASSERT_X(false,
QString("%1:%2").arg(__func__).arg(__LINE__).toUtf8().constData(),
"empty worker list");
} }
} }

View File

@ -9,7 +9,7 @@ public:
Worker *worker, Worker *worker,
int nextCommandIndex, int nextCommandIndex,
int start_timeout = 100000, int start_timeout = 100000,
int finish_timeout = -1); int finish_timeout = 100000);
public slots: public slots:
virtual void readyReadStandardOutput() override; virtual void readyReadStandardOutput() override;
virtual void finished(int exitCode, QProcess::ExitStatus exitStatus) override; virtual void finished(int exitCode, QProcess::ExitStatus exitStatus) override;

View File

@ -31,8 +31,6 @@ public:
unsigned nextExecIndex() const; unsigned nextExecIndex() const;
bool nextExec() const; bool nextExec() const;
bool exec(bool last=false); bool exec(bool last=false);
unsigned size() { return m_workList.size(); }
}; };
#endif // WORK_LIST_H_INCLUDED #endif // WORK_LIST_H_INCLUDED

View File

@ -231,7 +231,6 @@ class Worker : public QThread{
int sendUpdateSucceededAndActivated(); int sendUpdateSucceededAndActivated();
int sendFinalResult(); int sendFinalResult();
public:
struct UpdateProcessRunning { struct UpdateProcessRunning {
Worker *m_worker; Worker *m_worker;
@ -396,14 +395,6 @@ protected:
virtual void run(); virtual void run();
public: public:
UPDATE_STEP lastFailedUpdateStep() const {
return m_lastFailedUpdateStep;
}
void setLastFailedUpdateStep(UPDATE_STEP step) {
m_lastFailedUpdateStep = step;
}
QDebug CONSOLE(QStringList const &lst = QStringList()) { QDebug CONSOLE(QStringList const &lst = QStringList()) {
m_debugMsg = lst; m_debugMsg = lst;
return QDebug(QtMsgType::QtInfoMsg); return QDebug(QtMsgType::QtInfoMsg);

View File

@ -64,8 +64,7 @@ QString branchName() {
std::unique_ptr<QSettings> readSettings(QString const &optionalDirName) { std::unique_ptr<QSettings> readSettings(QString const &optionalDirName) {
std::unique_ptr<QSettings> settings{std::make_unique<QSettings>()}; std::unique_ptr<QSettings> settings{std::make_unique<QSettings>()};
//QString const fileName{settings->applicationName() + ".ini"}; QString const fileName{settings->applicationName() + ".ini"};
QString const fileName{"ATBUpdateTool.ini"};
QDir d; QDir d;
if (!optionalDirName.isEmpty()) { if (!optionalDirName.isEmpty()) {