Compare commits
11 Commits
9ed8603dfb
...
bc88a9b0be
Author | SHA1 | Date | |
---|---|---|---|
bc88a9b0be | |||
8b3f0991f7 | |||
8123526e11 | |||
57a093e9ae | |||
10536c81a5 | |||
659dc69831 | |||
a47dd60e9e | |||
575a740692 | |||
e22d78cba8 | |||
ad8b9f26c0 | |||
5b5a4504fa |
@ -1,5 +1,5 @@
|
||||
[REPOSITORY_URL]
|
||||
repository-url="gitea@ptu-config.atb-comm.de:ATB/"
|
||||
repository-url="gitea@ptu-config.atb-comm.de:ATB"
|
||||
|
||||
[DIRECTORIES]
|
||||
plugin-directory="/usr/lib/"
|
||||
@ -19,3 +19,21 @@ yocto-version=false
|
||||
yocto-install=false
|
||||
always-download-config=true
|
||||
always-download-dc=false
|
||||
|
||||
|
||||
[ATBUpdateCheck]
|
||||
|
||||
[ATBUpdateDC]
|
||||
debug=true
|
||||
workingDir=/tmp
|
||||
libca=/usr/lib/libCAslave.so
|
||||
|
||||
[ATBUpdateGit]
|
||||
|
||||
[ATBUpdateJsonFiles]
|
||||
|
||||
[ATBUpdateOpkg]
|
||||
|
||||
[ATBUpdateShow]
|
||||
|
||||
[ATBUpdateSync]
|
||||
|
@ -145,14 +145,11 @@ int main(int argc, char **argv) {
|
||||
QString libca;
|
||||
|
||||
std::unique_ptr<QSettings> settings = internal::readSettings();
|
||||
if (settings) {
|
||||
settings->beginGroup("COMMON");
|
||||
debug = settings->value("debug", false).toBool();
|
||||
settings->endGroup();
|
||||
|
||||
settings->beginGroup("RUNTIME");
|
||||
noaction = settings->value("noaction", true).toBool();
|
||||
workingDir = settings->value("workingdir", "/tmp").toBool();
|
||||
if (settings) {
|
||||
settings->beginGroup("ATBUpdateDC");
|
||||
debug = settings->value("debug", false).toBool();
|
||||
workingDir = settings->value("workingdir", "/tmp").toString();
|
||||
libca = settings->value("libca", "/usr/lib/libCAslave.so").toString();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
@ -26,14 +26,12 @@
|
||||
#include <QString>
|
||||
#include <QSerialPort>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QSettings>
|
||||
|
||||
#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}
|
||||
@ -135,15 +133,15 @@ Update::sendNextAddress(int bNum) const {
|
||||
// qDebug() << "addr-block" << bNum << "...";
|
||||
while (noAnswerCount <= 250) {
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
if (!m_debug) {
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
|
||||
QThread::msleep(10); //from 100ms to 20ms
|
||||
QThread::msleep(10); //from 100ms to 20ms
|
||||
//###################################################################################
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
|
||||
#else
|
||||
DownloadResult const res = DownloadResult::OK;
|
||||
#endif
|
||||
res = sendStatus(m_hw->bl_wasSendingAddOK());
|
||||
}
|
||||
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
@ -157,7 +155,7 @@ Update::sendNextAddress(int bNum) const {
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
} // while
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
@ -190,13 +188,12 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
|
||||
while (noAnswerCount <= 250) {
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
#else
|
||||
DownloadResult const res = DownloadResult::OK;
|
||||
#endif
|
||||
if (!m_debug) {
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
res = sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
}
|
||||
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
@ -220,60 +217,61 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
bool Update::startBootloader() const {
|
||||
qDebug() << "starting bootloader...";
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
int nTry = 10;
|
||||
while (--nTry >= 0) {
|
||||
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 ???";
|
||||
if (!m_debug) {
|
||||
int nTry = 10;
|
||||
while (--nTry >= 0) {
|
||||
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);
|
||||
qInfo() << "starting bootloader...OK";
|
||||
}
|
||||
qCritical() << "starting bootloader...FAILED";
|
||||
#else
|
||||
QThread::msleep(1000);
|
||||
qInfo() << "starting bootloader...OK";
|
||||
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::stopBootloader() const {
|
||||
qDebug() << "stopping bootloader...";
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
QThread::msleep(1000);
|
||||
if (!m_hw->bl_isUp()) {
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
return true;
|
||||
if (!m_debug) {
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
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);
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
}
|
||||
qCritical() << "stopping bootloader...FAILED";
|
||||
|
||||
#else // Test code
|
||||
QThread::msleep(1000);
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::resetDeviceController() const {
|
||||
qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller";
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->bl_rebootDC();
|
||||
#endif
|
||||
if (!m_debug) {
|
||||
m_hw->bl_rebootDC();
|
||||
}
|
||||
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
QThread::sleep(1);
|
||||
@ -399,9 +397,9 @@ int Update::run() {
|
||||
qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName);
|
||||
}
|
||||
|
||||
#if TEST_DC_DOWNLOAD==0
|
||||
m_hw->dc_autoRequest(false);
|
||||
#endif
|
||||
if (!m_debug) {
|
||||
m_hw->dc_autoRequest(false);
|
||||
}
|
||||
|
||||
qInfo() << "DC auto request OFF";
|
||||
|
||||
@ -457,9 +455,10 @@ int Update::run() {
|
||||
// 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
|
||||
if (!m_debug) {
|
||||
m_hw->dc_autoRequest(true); //restart dc_autoRequest after download else E255!
|
||||
}
|
||||
|
||||
return -(int)Result::SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Update : public QObject {
|
||||
QString m_dcFileName{};
|
||||
hwinf *m_hw = nullptr;
|
||||
bool m_sys_areDCdataValid{};
|
||||
bool m_debug;
|
||||
bool m_debug{false};
|
||||
bool m_noaction;
|
||||
|
||||
static QPluginLoader pluginLoader;
|
||||
|
@ -144,7 +144,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
// qCritical() << "JSON FILES TO UPDATE" << filesToUpdate;
|
||||
qCritical() << __LINE__ << "JSON FILES TO UPDATE" << filesToUpdate;
|
||||
|
||||
Update update(customerRepo,
|
||||
QString::number(customerNr),
|
||||
@ -153,8 +153,10 @@ int main(int argc, char **argv) {
|
||||
plugInName,
|
||||
workingDir);
|
||||
|
||||
update.doUpdate();
|
||||
// update.doUpdate(filesToUpdate, mountPath.has_value());
|
||||
if (!filesToUpdate.empty()) {
|
||||
update.doUpdate(filesToUpdate, mountPath.has_value());
|
||||
}
|
||||
|
||||
// update.checkJsonVersions();
|
||||
//update.checkJsonVersions(filesToUpdate);
|
||||
|
||||
|
@ -107,7 +107,7 @@ Update::Update(QString customerRepository,
|
||||
char const *serialInterface,
|
||||
char const *baudrate)
|
||||
: QObject(parent)
|
||||
// , m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
|
||||
, m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
|
||||
, m_serialInterface(serialInterface)
|
||||
, m_baudrate(baudrate)
|
||||
, m_customerRepository(customerRepository)
|
||||
@ -145,7 +145,8 @@ Update::~Update() {
|
||||
// unloadDCPlugin();
|
||||
}
|
||||
|
||||
bool Update::doUpdate() {
|
||||
#if 0
|
||||
bool Update::doUpdate() { // test function
|
||||
|
||||
int numberOfFiles = 3;
|
||||
|
||||
@ -178,6 +179,7 @@ bool Update::doUpdate() {
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
||||
|
||||
|
@ -45,10 +45,6 @@ void UpdateCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
//static constexpr const int PERCENT_UPDATE_DC{80};
|
||||
//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 (m_command.contains("ATBUpdateCheck")) {
|
||||
|
||||
@ -127,10 +123,19 @@ void UpdateCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
|
||||
if (m_worker->workList().nextExec()) {
|
||||
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 {
|
||||
bool execShowStatus = true;
|
||||
m_worker->workList().exec(execShowStatus);
|
||||
}
|
||||
} else {
|
||||
Q_ASSERT_X(false,
|
||||
QString("%1:%2").arg(__func__).arg(__LINE__).toUtf8().constData(),
|
||||
"empty worker list");
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
Worker *worker,
|
||||
int nextCommandIndex,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
int finish_timeout = -1);
|
||||
public slots:
|
||||
virtual void readyReadStandardOutput() override;
|
||||
virtual void finished(int exitCode, QProcess::ExitStatus exitStatus) override;
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
unsigned nextExecIndex() const;
|
||||
bool nextExec() const;
|
||||
bool exec(bool last=false);
|
||||
|
||||
unsigned size() { return m_workList.size(); }
|
||||
};
|
||||
|
||||
#endif // WORK_LIST_H_INCLUDED
|
||||
|
@ -231,6 +231,7 @@ class Worker : public QThread{
|
||||
int sendUpdateSucceededAndActivated();
|
||||
int sendFinalResult();
|
||||
|
||||
public:
|
||||
struct UpdateProcessRunning {
|
||||
Worker *m_worker;
|
||||
|
||||
@ -395,6 +396,14 @@ protected:
|
||||
virtual void run();
|
||||
|
||||
public:
|
||||
UPDATE_STEP lastFailedUpdateStep() const {
|
||||
return m_lastFailedUpdateStep;
|
||||
}
|
||||
|
||||
void setLastFailedUpdateStep(UPDATE_STEP step) {
|
||||
m_lastFailedUpdateStep = step;
|
||||
}
|
||||
|
||||
QDebug CONSOLE(QStringList const &lst = QStringList()) {
|
||||
m_debugMsg = lst;
|
||||
return QDebug(QtMsgType::QtInfoMsg);
|
||||
|
@ -64,7 +64,8 @@ QString branchName() {
|
||||
std::unique_ptr<QSettings> readSettings(QString const &optionalDirName) {
|
||||
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;
|
||||
|
||||
if (!optionalDirName.isEmpty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user