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="gitea@ptu-config.atb-comm.de:ATB"
repository-url="gitea@ptu-config.atb-comm.de:ATB/"
[DIRECTORIES]
plugin-directory="/usr/lib/"
@ -19,21 +19,3 @@ 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]

View File

@ -145,11 +145,14 @@ int main(int argc, char **argv) {
QString libca;
std::unique_ptr<QSettings> settings = internal::readSettings();
if (settings) {
settings->beginGroup("ATBUpdateDC");
settings->beginGroup("COMMON");
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();
settings->endGroup();
}

View File

@ -26,12 +26,14 @@
#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}
@ -133,15 +135,15 @@ Update::sendNextAddress(int bNum) const {
// qDebug() << "addr-block" << bNum << "...";
while (noAnswerCount <= 250) {
DownloadResult res = DownloadResult::OK;
if (!m_debug) {
m_hw->bl_sendAddress(bNum);
#if TEST_DC_DOWNLOAD==0
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::ERROR) {
if (++errorCount >= 10) {
@ -155,7 +157,7 @@ Update::sendNextAddress(int bNum) const {
} else {
noAnswerCount += 1; // no answer by now
}
} // while
}
// wait max. about 3 seconds
return DownloadResult::TIMEOUT;
}
@ -188,12 +190,13 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
while (noAnswerCount <= 250) {
DownloadResult res = DownloadResult::OK;
#if TEST_DC_DOWNLOAD==0
m_hw->bl_sendDataBlock(64, local);
if (!m_debug) {
m_hw->bl_sendDataBlock(64, local);
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::ERROR) {
@ -217,61 +220,60 @@ Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
bool Update::startBootloader() const {
qDebug() << "starting bootloader...";
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 {
#if TEST_DC_DOWNLOAD==0
int nTry = 10;
while (--nTry >= 0) {
m_hw->bl_startBL();
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;
#endif
return false;
}
bool Update::stopBootloader() const {
qDebug() << "stopping bootloader...";
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 {
#if TEST_DC_DOWNLOAD==0
int nTry = 5;
while (--nTry >= 0) {
m_hw->bl_stopBL();
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;
#endif
return false;
}
bool Update::resetDeviceController() const {
qInfo() << nextTimePoint().toUtf8().constData() << "resetting device controller";
if (!m_debug) {
m_hw->bl_rebootDC();
}
#if TEST_DC_DOWNLOAD==0
m_hw->bl_rebootDC();
#endif
// wait maximally 3 seconds, before starting bootloader
QThread::sleep(1);
@ -397,9 +399,9 @@ int Update::run() {
qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName);
}
if (!m_debug) {
m_hw->dc_autoRequest(false);
}
#if TEST_DC_DOWNLOAD==0
m_hw->dc_autoRequest(false);
#endif
qInfo() << "DC auto request OFF";
@ -455,10 +457,9 @@ int Update::run() {
// if starting the bootloader failed
qInfo() << nextTimePoint().toUtf8().constData() << "<DC-UPDATE-SUCCESS>";
if (!m_debug) {
m_hw->dc_autoRequest(true); //restart dc_autoRequest after download else E255!
}
#if TEST_DC_DOWNLOAD==0
m_hw->dc_autoRequest(true); //restart dc_autoRequest after download else E255!
#endif
return -(int)Result::SUCCESS;
}

View File

@ -30,7 +30,7 @@ class Update : public QObject {
QString m_dcFileName{};
hwinf *m_hw = nullptr;
bool m_sys_areDCdataValid{};
bool m_debug{false};
bool m_debug;
bool m_noaction;
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,
QString::number(customerNr),
@ -153,10 +153,8 @@ int main(int argc, char **argv) {
plugInName,
workingDir);
if (!filesToUpdate.empty()) {
update.doUpdate(filesToUpdate, mountPath.has_value());
}
update.doUpdate();
// update.doUpdate(filesToUpdate, mountPath.has_value());
// update.checkJsonVersions();
//update.checkJsonVersions(filesToUpdate);

View File

@ -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,8 +145,7 @@ Update::~Update() {
// unloadDCPlugin();
}
#if 0
bool Update::doUpdate() { // test function
bool Update::doUpdate() {
int numberOfFiles = 3;
@ -179,7 +178,6 @@ bool Update::doUpdate() { // test function
return true;
}
#endif
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_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")) {
@ -123,19 +127,10 @@ 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");
}
}

View File

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

View File

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

View File

@ -231,7 +231,6 @@ class Worker : public QThread{
int sendUpdateSucceededAndActivated();
int sendFinalResult();
public:
struct UpdateProcessRunning {
Worker *m_worker;
@ -396,14 +395,6 @@ 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);

View File

@ -64,8 +64,7 @@ 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{"ATBUpdateTool.ini"};
QString const fileName{settings->applicationName() + ".ini"};
QDir d;
if (!optionalDirName.isEmpty()) {