Compare commits

..

No commits in common. "4b3a39b0e60c73c5f42dcd22b0a9f105a633a322" and "4b9dcc5e99d443646fd2ae174246b594a078b9a6" have entirely different histories.

13 changed files with 1022 additions and 2070 deletions

View File

@ -35,42 +35,6 @@ DEFINES += QT_DEPRECATED_WARNINGS
# Fix display of UPDATE_SUCCESS when opkg_command fails. Detected when # Fix display of UPDATE_SUCCESS when opkg_command fails. Detected when
# updating apsim failed. # updating apsim failed.
# 1.3.11: Integrate version of ATBUpdateTool in SendLastVersion-ISMAS-message. # 1.3.11: Integrate version of ATBUpdateTool in SendLastVersion-ISMAS-message.
# 1.3.12: Add command parameters for output of yocto-infos about ATBUpdateTool.
# Use 'git pull' instead of 'git fetch'.
# Use 'git clone --filter=blob:none' instead of 'git clone' to speed
# up cloning of customer repository.
# 1.3.13: Fix: if the customer repository is corrupted, remove it and re-clone
# the repository (without checking the ISMAS-trigger (WAIT-)button.
VERSION="1.3.14"
# 1.3.14: Add additional check for sanity of customer repository using
# "git fsck".
# Stream-lined code of update process: massive refactoring.
# Added functionality: If WAIT button is not active, then an existing
# customer repository will be repaired, or a not existing repository
# will be cloned. The process stops then.
# However, if the WAIT button is active, the at least the commands in
# opkg_commands will be executed. Changed files in the customer
# repository will be worked on: tariff-files will be synced with the
# local filesystem, json-files will be downloaded to firmware.
# The device-controller firmware will be handled in a later version.
# PLANNED TODOS:
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
# geklont), aber zusaetzlich werden alle verfuegbaren Dateien als neu
# angesehen und die entsprechenden Aktionen durchgefuehrt: tariff-files
# spiegeln, json-files laden und dc laden. Also VORSICHT: das repository
# muss in diesem fall wirklich in ordnung sein.
# 3: Wurde keine Datei geaendert, kein initiales Clone und der WAIT-button
# nicht aktiv, so (passiert natuerlich nichts) kann man davon ausgehen,
# dass es sich um ein automatisches Update handelt. Dann koennte man im
# ISMAS eine entsprechende Meldung anzeigen als Teil von SEND-LAST-VERSION.
# Wenn der WAIT-button aktiv ist, dann werden zumindest die opkg-commands
# ausgefuehrt.
# 4: rsync: immer alle Dateien soiegeln (bis auf opkg-commands)
# 5: Falls das Tool mal abstuerzt, dann einen Signal-Handler (fuer TERM)
# installieren, sodass zumnidest SEND-LASt-VERSION mit rausgeht.
# 6: rsync: explizites Binary, nicht das in busybox enthaltene.
win32 { win32 {
BUILD_DATE=$$system("date /t") BUILD_DATE=$$system("date /t")
@ -82,6 +46,7 @@ win32 {
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1") GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
VERSION="1.3.11"
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}" EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
INCLUDEPATH += plugins INCLUDEPATH += plugins
@ -94,8 +59,6 @@ DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\" DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\" DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
# keep comments, as /* fall through */
QMAKE_CXXFLAGS += -C
QMAKE_CXXFLAGS += -g QMAKE_CXXFLAGS += -g
QMAKE_CXXFLAGS += -Wno-deprecated-copy QMAKE_CXXFLAGS += -Wno-deprecated-copy
@ -104,14 +67,14 @@ contains( CONFIG, PTU5 ) {
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport
QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7 QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7
# QMAKE_CXXFLAGS += -Wno-deprecated-copy QMAKE_CXXFLAGS += -Wno-deprecated-copy
ARCH = PTU5 ARCH = PTU5
DEFINES+=PTU5 DEFINES+=PTU5
} }
contains( CONFIG, PTU5_YOCTO ) { contains( CONFIG, PTU5_YOCTO ) {
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7 QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
# QMAKE_CXXFLAGS += -Wno-deprecated-copy QMAKE_CXXFLAGS += -Wno-deprecated-copy
PTU5BASEPATH = /opt/devel/ptu5 PTU5BASEPATH = /opt/devel/ptu5
ARCH = PTU5 ARCH = PTU5
DEFINES+=PTU5 DEFINES+=PTU5
@ -125,7 +88,7 @@ contains( CONFIG, DesktopLinux ) {
# QMAKE_CC = ccache $$QMAKE_CC # QMAKE_CC = ccache $$QMAKE_CC
# QMAKE_CXX = ccache $$QMAKE_CXX # QMAKE_CXX = ccache $$QMAKE_CXX
QMAKE_CXXFLAGS += -std=c++17 QMAKE_CXXFLAGS += -std=c++17
# QMAKE_CXXFLAGS += -Wno-deprecated-copy QMAKE_CXXFLAGS += -Wno-deprecated-copy
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments } linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
ARCH = DesktopLinux ARCH = DesktopLinux
DEFINES+=DesktopLinux DEFINES+=DesktopLinux

View File

@ -26,93 +26,29 @@ GitClient::GitClient(QString const &customerNrStr,
} }
bool GitClient::gitCloneCustomerRepository() { bool GitClient::gitCloneCustomerRepository() {
/* Blobless clone QString gitCommand("git clone ");
==============
When using the --filter=blob:none option, the initial git clone will
download all reachable commits and trees, and only download the blobs
for commits when you do a git checkout. This includes the first checkout
inside the git clone operation.
The important thing to notice is that we have a copy of every blob at
HEAD but the blobs in the history are not present. If your repository
has a deep history full of large blobs, then this option can
significantly reduce your git clone times. The commit and tree data is
still present, so any subsequent git checkout only needs to download
the missing blobs. The Git client knows how to batch these requests to
ask the server only for the missing blobs.
Further, when running git fetch in a blobless clone, the server only
sends the new commits and trees. The new blobs are downloaded only
after a git checkout. Note that git pull runs git fetch and then git
merge, so it will download the necessary blobs during the git merge
command.
When using a blobless clone, you will trigger a blob download whenever
you need the contents of a file, but you will not need one if you only
need the OID (object-id) of a file. This means that git log can detect
which commits changed a given path without needing to download extra
data.
This means that blobless clones can perform commands like git
merge-base, git log, or even git log -- <path> with the same performance
as a full clone.
Commands like git diff or git blame <path> require the contents of the
paths to compute diffs, so these will trigger blob downloads the first
time they are run. However, the good news is that after that you will
have those blobs in your repository and do not need to download them a
second time. Most developers only need to run git blame on a small
number of files, so this tradeoff of a slightly slower git blame command
is worth the faster clone and fetch times.
Note: git v2.18 does not support treeless clones: --filter=tree:0.
*/
// Note: for some reason it is necessary to pass "--progress ---v",
// otherwise QProcess returns an error of 128 = 0x80 for the command.
QString gitCommand("git clone --progress -vvv --filter=blob:none ");
gitCommand += m_repositoryPath; gitCommand += m_repositoryPath;
Command c(gitCommand); Command c(gitCommand);
qInfo() << "IN CURRENT WD" << m_workingDirectory qInfo() << "IN CURRENT WD" << m_workingDirectory
<< "CLONE VIA COMMAND" << gitCommand; << "CLONE" << m_repositoryPath << "...";
if (c.execute(m_workingDirectory)) { // execute the command in wd if (c.execute(m_workingDirectory)) { // execute the command in wd
QString const result = c.getCommandResult(); QString const result = c.getCommandResult();
if (!result.isEmpty()) { if (!result.isEmpty()) {
// Cloning into 'customer_281'...\n // Cloning into 'customer_281'...\n
int customer = -1; static QRegularExpression re("(^\\s*Cloning\\s+into\\s+[']\\s*)(.*)(\\s*['].*$)");
int cloning = result.indexOf("Cloning", 0, Qt::CaseInsensitive); QRegularExpressionMatch match = re.match(result);
if (cloning != -1) { if (match.hasMatch()) {
customer = result.indexOf("customer_", cloning, Qt::CaseInsensitive); if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
if (customer != -1) { if (match.captured(2).trimmed() == m_customerNr) {
QString customerNr = result.mid(customer);
static constexpr char const ch = '\'';
int i = customerNr.indexOf(QChar(ch));
if (i != -1) {
if ((customerNr = customerNr.mid(0, i)) == m_customerNr) {
qInfo() << "CLONING" << m_repositoryPath << "OK"; qInfo() << "CLONING" << m_repositoryPath << "OK";
return true; return true;
} }
Utils::printCriticalErrorMsg(
QString("ERROR CLONE RESULT HAS WRONG CUSTOMER-NR. (%1 != %2) CLONE_RESULT=%3")
.arg(customerNr)
.arg(m_customerNr)
.arg(result));
return false;
} }
} }
} }
Utils::printCriticalErrorMsg( Utils::printCriticalErrorMsg(QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT=") + result);
QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONING=%1 CUSTOMER=%2 CLONE_RESULT=%3")
.arg(cloning)
.arg(customer)
.arg(result));
return false;
}
Utils::printCriticalErrorMsg("ERROR CLONE RESULT IS EMPTY");
} }
return false; return false;
} }
@ -279,34 +215,19 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
return std::nullopt; return std::nullopt;
} }
bool GitClient::gitFsck() {
bool r = false;
if (QDir(m_customerRepository).exists()) {
Command c("git fsck");
if ((r = c.execute(m_customerRepository)) == false) {
QString const &s = c.getCommandResult().trimmed();
Utils::printCriticalErrorMsg(QString("GIT FSCK FAILED: %1").arg(s));
}
}
return r;
}
/* /*
Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
*/ */
std::optional<QString> GitClient::gitPull() { std::optional<QString> GitClient::gitFetch() {
if (QDir(m_customerRepository).exists()) { if (QDir(m_customerRepository).exists()) {
qInfo() << "BRANCH NAME" << m_branchName; qInfo() << "BRANCH NAME" << m_branchName;
Command c("git pull"); Command c("git fetch");
if (c.execute(m_customerRepository)) { if (c.execute(m_customerRepository)) {
QString const s = c.getCommandResult().trimmed(); QString const s = c.getCommandResult().trimmed();
if (!s.isEmpty()) { if (!s.isEmpty()) {
QStringList lines = Update::split(s, '\n'); QStringList lines = Update::split(s, '\n');
worker()->CONSOLE(lines) << Worker::UPDATE_STEP::UPDATE_REPOSITORY;
if (!lines.empty()) { if (!lines.empty()) {
static const QRegularExpression alreadyUpToDate("^\\s*Already\\s+up\\s+to\\s+date.*$");
if (std::none_of(lines.cbegin(), lines.cend(),
[](QString const &s) { return s.contains(alreadyUpToDate); })) {
int zoneNr = Utils::read1stLineOfFile("/mnt/system_data/zone_nr"); int zoneNr = Utils::read1stLineOfFile("/mnt/system_data/zone_nr");
m_branchName = (zoneNr != 0) ? QString("zg1/zone%1").arg(zoneNr) : "master"; m_branchName = (zoneNr != 0) ? QString("zg1/zone%1").arg(zoneNr) : "master";
// lines can look like this: // lines can look like this:
@ -325,42 +246,61 @@ std::optional<QString> GitClient::gitPull() {
QRegularExpressionMatch match = re.match(lines.at(i)); QRegularExpressionMatch match = re.match(lines.at(i));
if (match.hasMatch()) { if (match.hasMatch()) {
if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
QString const matchCaptured = match.captured(2); return match.captured(2);
worker()->CONSOLE(QStringList(matchCaptured)) << Worker::UPDATE_STEP::UPDATE_REPOSITORY;
return matchCaptured;
} else { } else {
QStringList lst(QString("(wrong capture count (%1)").arg(re.captureCount())); emit m_worker->showErrorMessage("git fetch",
worker()->GUI(lst) << (worker()->CONSOLE(lst) << Worker::UPDATE_STEP::UPDATE_REPOSITORY_FAILURE); QString("(wrong cap-count (%1)").arg(re.captureCount()));
} }
} else { } else {
QStringList lst("no regex-match for commits"); emit m_worker->showErrorMessage("git fetch",
worker()->GUI(lst) << (worker()->CONSOLE(lst) << Worker::UPDATE_STEP::UPDATE_REPOSITORY_FAILURE); "no regex-match for commits");
Utils::printCriticalErrorMsg("NO REGEX MATCH FOR COMMITS");
} }
} }
} }
if (!found) { if (!found) {
QStringList lst(QString("unknown branch name ") + m_branchName); emit m_worker->showErrorMessage("git fetch",
worker()->GUI(lst) << (worker()->CONSOLE(lst) << Worker::UPDATE_STEP::UPDATE_REPOSITORY_FAILURE); QString("unkown branch name ") + m_branchName);
Utils::printCriticalErrorMsg("UNKNOWN BRANCH NAME " + m_branchName);
} }
} else { } else {
return "Already up to date"; emit m_worker->showErrorMessage("git fetch",
QString("wrong format for result of 'git fetch' ") + s);
Utils::printCriticalErrorMsg(QString("WRONG FORMAT FOR RESULT OF 'GIT FETCH' ") + s);
} }
} else { } else {
QStringList lst(QString("WRONG FORMAT FOR RESULT OF 'GIT PULL' ") + s); // emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'");
worker()->GUI(lst) << (worker()->CONSOLE(lst) << Worker::UPDATE_STEP::UPDATE_REPOSITORY_FAILURE); Utils::printInfoMsg("EMPTY RESULT FOR 'GIT FETCH'");
}
} else {
QStringList lst("EMPTY RESULT FOR 'GIT PULL'");
worker()->GUI(lst) << (worker()->CONSOLE(lst) << Worker::UPDATE_STEP::UPDATE_REPOSITORY_FAILURE);
} }
} }
} else { } else {
QStringList lst(QString("REPOSITORY ") + m_customerRepository + " DOES NOT EXIST"); emit m_worker->showErrorMessage("git fetch", QString("repository ") + m_customerRepository + " does not exist");
worker()->GUI(lst) << (worker()->CONSOLE(lst) << Worker::UPDATE_STEP::UPDATE_REPOSITORY_FAILURE); Utils::printCriticalErrorMsg(QString("REPOSITORY ") + m_customerRepository + " DOES NOT EXIST");
} }
return std::nullopt; return std::nullopt;
} }
bool GitClient::gitFetchAndDiff() {
if (gitFetch()) {
QString gitCommand("git diff --compact-summary HEAD..FETCH_HEAD");
Command c(gitCommand);
return c.execute(m_workingDirectory);
}
return false;
}
bool GitClient::gitPull() {
if (QDir(m_customerRepository).exists()) {
Command c("git pull");
if (c.execute(m_customerRepository)) {
qInfo() << "PULLED INTO" << m_customerRepository;
return true;
}
Utils::printCriticalErrorMsg(QString("PULL INTO " + m_customerRepository + " FAILED"));
}
return false;
}
std::optional<QStringList> GitClient::gitMerge() { std::optional<QStringList> GitClient::gitMerge() {
Command c("git merge"); Command c("git merge");
if (c.execute(m_workingDirectory)) { if (c.execute(m_workingDirectory)) {

View File

@ -43,15 +43,12 @@ class GitClient : public QObject {
bool gitCloneAndCheckoutBranch(); bool gitCloneAndCheckoutBranch();
Worker *worker() { return m_worker; } std::optional<QString> gitFetch();
Worker const *worker() const { return m_worker; } bool gitFetchAndDiff();
bool gitPull();
std::optional<QString> gitPull();
std::optional<QStringList> gitDiff(QString const &commit); std::optional<QStringList> gitDiff(QString const &commit);
std::optional<QStringList> gitMerge(); std::optional<QStringList> gitMerge();
bool gitFsck();
QString gitLastCommit(QString fileName); QString gitLastCommit(QString fileName);
QStringList gitShowReason(QString branchName); QStringList gitShowReason(QString branchName);
static QString gitBlob(QString fileName); static QString gitBlob(QString fileName);

View File

@ -56,12 +56,6 @@ void IsmasClient::printDebugMessage(int port,
QString const &clientIP, QString const &clientIP,
int clientPort, int clientPort,
QString const &message) { QString const &message) {
#if 0
Q_UNUSED(port);
Q_UNUSED(clientIP);
Q_UNUSED(clientPort);
Q_UNUSED(message);
#else
qDebug().noquote() qDebug().noquote()
<< "\n" << "\n"
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n" << "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
@ -70,19 +64,12 @@ void IsmasClient::printDebugMessage(int port,
<< "local address ..." << clientIP << "\n" << "local address ..." << clientIP << "\n"
<< "local port ......" << clientPort << "\n" << "local port ......" << clientPort << "\n"
<< message; << message;
#endif
} }
void IsmasClient::printInfoMessage(int port, void IsmasClient::printInfoMessage(int port,
QString const &clientIP, QString const &clientIP,
int clientPort, int clientPort,
QString const &message) { QString const &message) {
#if 0
Q_UNUSED(port);
Q_UNUSED(clientIP);
Q_UNUSED(clientPort);
Q_UNUSED(message);
#else
qInfo().noquote() qInfo().noquote()
<< "\n" << "\n"
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n" << "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
@ -91,7 +78,6 @@ void IsmasClient::printInfoMessage(int port,
<< "local address ..." << clientIP << "\n" << "local address ..." << clientIP << "\n"
<< "local port ......" << clientPort << "\n" << "local port ......" << clientPort << "\n"
<< message; << message;
#endif
} }
void IsmasClient::printErrorMessage(int port, void IsmasClient::printErrorMessage(int port,
@ -315,7 +301,7 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
} }
} }
// printInfoMessage(port, clientIP, clientPort, QString("MESSAGE RECEIVED ") + buf); printInfoMessage(port, clientIP, clientPort, QString("MESSAGE RECEIVED ") + buf);
QString response(buf); QString response(buf);
if (int idx = response.indexOf("{\"error\":\"ISMAS is offline\"}")) { if (int idx = response.indexOf("{\"error\":\"ISMAS is offline\"}")) {
@ -390,18 +376,16 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
version.toStdString().c_str()); version.toStdString().c_str());
} }
QString IsmasClient::errorGitClone(QString const &info, QString IsmasClient::errorGitClone(int percent, QString const &info, QString const &version) {
QString const &version) {
return updateNewsToIsmas("U0003", return updateNewsToIsmas("U0003",
m_progressInPercent, percent,
RESULT_CODE::INSTALL_ERROR, RESULT_CODE::INSTALL_ERROR,
"CLONE CUSTOMER REPOSITORY FAILED", "CLONE CUSTOMER REPOSITORY FAILED",
info.toStdString().c_str(), info.toStdString().c_str(),
version.toStdString().c_str()); version.toStdString().c_str());
} }
QString IsmasClient::backendConnected(QString const &info, QString IsmasClient::backendConnected(QString const &info, QString const &version) {
QString const &version) {
return updateNewsToIsmas("U0010", return updateNewsToIsmas("U0010",
m_progressInPercent, m_progressInPercent,
RESULT_CODE::SUCCESS, RESULT_CODE::SUCCESS,
@ -410,8 +394,7 @@ QString IsmasClient::backendConnected(QString const &info,
version.toStdString().c_str()); version.toStdString().c_str());
} }
QString IsmasClient::execOpkgCommand(QString const &info, QString IsmasClient::execOpkgCommand(QString const &info, QString const &version) {
QString const &version) {
return updateNewsToIsmas("U0010", return updateNewsToIsmas("U0010",
m_progressInPercent, m_progressInPercent,
RESULT_CODE::SUCCESS, RESULT_CODE::SUCCESS,

View File

@ -177,7 +177,7 @@ public:
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
QString errorGitClone(QString const &info, QString const &version = QString()); QString errorGitClone(int percent, QString const &info, QString const &version = QString());
QString backendConnected(QString const &info, QString const &version = QString()); QString backendConnected(QString const &info, QString const &version = QString());
QString updateTriggerSet(QString const &info, QString const &version = QString()); QString updateTriggerSet(QString const &info, QString const &version = QString());
QString errorUpdateTrigger(QString const &info, QString const &version = QString()); QString errorUpdateTrigger(QString const &info, QString const &version = QString());

View File

@ -116,63 +116,31 @@ int main(int argc, char *argv[]) {
QCoreApplication::translate("main", "Show extended version (including last git commit).")); QCoreApplication::translate("main", "Show extended version (including last git commit)."));
parser.addOption(extendedVersionOption); parser.addOption(extendedVersionOption);
QCommandLineOption yoctoVersionOption(QStringList() << "y" << "yocto-version",
QCoreApplication::translate("main", "Show yocto version of ATBUpdateTool."));
parser.addOption(yoctoVersionOption);
QCommandLineOption yoctoInstallStatusOption(QStringList() << "Y" << "yocto-install",
QCoreApplication::translate("main", "Show yocto install status of ATBUpdateTool."));
parser.addOption(yoctoInstallStatusOption);
// Process the actual command line arguments given by the user // Process the actual command line arguments given by the user
parser.process(a); parser.process(a);
QString plugInDir = parser.value(pluginDirectoryOption); QString plugInDir = parser.value(pluginDirectoryOption);
QString plugInName = parser.value(pluginNameOption); QString plugInName = parser.value(pluginNameOption);
QString workingDir = parser.value(workingDirectoryOption); QString workingDir = parser.value(workingDirectoryOption);
bool const dryRun = parser.isSet(dryRunOption); bool const dryRun = parser.isSet(dryRunOption);
bool const showYoctoVersion = parser.isSet(yoctoVersionOption);
bool const showYoctoInstallStatus = parser.isSet(yoctoInstallStatusOption);
bool const showExtendedVersion = parser.isSet(extendedVersionOption); bool const showExtendedVersion = parser.isSet(extendedVersionOption);
QString const rtPath = QCoreApplication::applicationDirPath(); QString const rtPath = QCoreApplication::applicationDirPath();
int machineNr = Utils::read1stLineOfFile("/etc/machine_nr");
int customerNr = Utils::read1stLineOfFile("/etc/cust_nr");
int zoneNr = Utils::read1stLineOfFile("/etc/zone_nr");
QString const branchName = (zoneNr != 0)
? QString("zg1/zone%1").arg(zoneNr) : "master";
QThread::currentThread()->setObjectName("main thread");
qInfo() << "Main thread" << QThread::currentThreadId();
if (showExtendedVersion) { if (showExtendedVersion) {
printf(APP_EXTENDED_VERSION"\n"); printf(APP_EXTENDED_VERSION"\n");
return 0; return 0;
} }
if (showYoctoVersion) {
printf("%s\n", Worker::getATBUpdateToolYoctoVersion().toStdString().c_str());
return 0;
}
if (showYoctoInstallStatus) {
printf("%s\n", Worker::getATBUpdateToolYoctoInstallationStatus().toStdString().c_str());
return 0;
}
if (!QDir(plugInDir).exists()) { if (!QDir(plugInDir).exists()) {
qCritical() << plugInDir qCritical() << plugInDir
<< "does not exists, but has to contain dc-library"; << "does not exists, but has to contain dc-library";
exit(-1); exit(-1);
} }
qInfo() << "pwd ......................" << rtPath; qInfo() << "pwd ..............." << rtPath;
qInfo() << "plugInDir ................" << plugInDir; qInfo() << "plugInDir ........." << plugInDir;
qInfo() << "plugInName ..............." << plugInName; qInfo() << "plugInName ........" << plugInName;
qInfo() << "workingDir ..............." << workingDir; qInfo() << "workingDir ........" << workingDir;
qInfo() << "dryRun ..................." << dryRun; qInfo() << "dryRun ............" << dryRun;
qInfo() << "extended-version ........." << APP_EXTENDED_VERSION;
//qInfo() << "yocto-version ............" << Worker::getATBUpdateToolYoctoVersion();
//qInfo() << "yocto-install-status ....." << Worker::getATBUpdateToolYoctoInstallationStatus();
// before loading the library, delete all possible shared memory segments // before loading the library, delete all possible shared memory segments
#if defined Q_OS_LINUX || defined Q_OS_UNIX #if defined Q_OS_LINUX || defined Q_OS_UNIX
@ -185,6 +153,15 @@ int main(int argc, char *argv[]) {
hw->dc_autoRequest(true); hw->dc_autoRequest(true);
// hw->dc_openSerial(5, "115200", "ttymxc2", 1); // hw->dc_openSerial(5, "115200", "ttymxc2", 1);
int machineNr = Utils::read1stLineOfFile("/etc/machine_nr");
int customerNr = Utils::read1stLineOfFile("/etc/cust_nr");
int zoneNr = Utils::read1stLineOfFile("/etc/zone_nr");
QString const branchName = (zoneNr != 0)
? QString("zg1/zone%1").arg(zoneNr) : "master";
QThread::currentThread()->setObjectName("main thread");
qInfo() << "Main thread" << QThread::currentThreadId();
Worker worker(customerNr, Worker worker(customerNr,
machineNr, machineNr,
zoneNr, zoneNr,

View File

@ -96,7 +96,7 @@ MainWindow::MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *paren
, m_worker(worker) , m_worker(worker)
, m_width(70) , m_width(70)
, m_progressRunning(false) , m_progressRunning(false)
// , m_progressValue(0) , m_progressValue(0)
, m_update(update) , m_update(update)
, m_updateStep(UpdateDcEvent::UpdateStep::NONE) { , m_updateStep(UpdateDcEvent::UpdateStep::NONE) {
@ -155,8 +155,6 @@ MainWindow::MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *paren
connect(m_worker, SIGNAL(appendText(QString,QString)),this,SLOT(onAppendText(QString,QString))); connect(m_worker, SIGNAL(appendText(QString,QString)),this,SLOT(onAppendText(QString,QString)));
connect(m_worker, SIGNAL(showErrorMessage(QString,QString)),this, SLOT(onShowErrorMessage(QString,QString))); connect(m_worker, SIGNAL(showErrorMessage(QString,QString)),this, SLOT(onShowErrorMessage(QString,QString)));
connect(m_worker, SIGNAL(showStatusMessage(QString,QString)),this, SLOT(onShowStatusMessage(QString,QString))); connect(m_worker, SIGNAL(showStatusMessage(QString,QString)),this, SLOT(onShowStatusMessage(QString,QString)));
connect(m_worker, SIGNAL(showErrorMessage(QStringList)),this, SLOT(onShowErrorMessage(QStringList)));
connect(m_worker, SIGNAL(showStatusMessage(QString,QString)),this, SLOT(onShowStatusMessage(QString,QString)));
connect(m_worker, SIGNAL(replaceLast(QString,QString)),this,SLOT(onReplaceLast(QString,QString))); connect(m_worker, SIGNAL(replaceLast(QString,QString)),this,SLOT(onReplaceLast(QString,QString)));
connect(m_worker, SIGNAL(replaceLast(QStringList,QString)),this, SLOT(onReplaceLast(QStringList,QString))); connect(m_worker, SIGNAL(replaceLast(QStringList,QString)),this, SLOT(onReplaceLast(QStringList,QString)));
} }
@ -180,22 +178,22 @@ void MainWindow::customEvent(QEvent *event) {
case START_PROGRESS_LOOP: { case START_PROGRESS_LOOP: {
m_progressRunning = true; m_progressRunning = true;
ui->updateProgress->reset(); ui->updateProgress->reset();
// m_progressValue = 10; m_progressValue = 10;
QApplication::postEvent(this, new ProgressEvent(this, 1)); QApplication::postEvent(this, new ProgressEvent(this, m_progressValue));
} break; } break;
case STOP_PROGRESS_LOOP: { case STOP_PROGRESS_LOOP: {
m_progressRunning = false; m_progressRunning = false;
// m_progressValue -= 10; m_progressValue -= 10;
// m_worker->setProgress(m_progressValue/10); m_worker->setProgress(m_progressValue/10);
} break; } break;
default: { default: {
if (m_progressRunning) { if (m_progressRunning) {
// m_progressValue = progress; m_progressValue = progress;
ui->updateProgress->setValue(progress); ui->updateProgress->setValue(progress/10);
// ueberpruefen: hauptfenster schickt sich selber ein event QApplication::postEvent(this, new ProgressEvent(this, progress+10));
// QApplication::postEvent(this, new ProgressEvent(this, progress)); QThread::msleep(500);
// QThread::msleep(500); }
}} }
} }
} else } else
if (sender == m_worker) { if (sender == m_worker) {
@ -329,18 +327,8 @@ void MainWindow::onRestartExitTimer() {
void MainWindow::onQuit() { void MainWindow::onQuit() {
m_exitTimer->stop(); m_exitTimer->stop();
int errorCode = 0; qCritical() << QString("ON QUIT: EXIT CODE %1").arg(m_worker->returnCode());
qApp->exit(m_worker->returnCode());
qCritical()
<< QString("ON QUIT: CURRENT STEP %1")
.arg(m_worker->getSmap()[m_worker->currentStep()]);
// TODO: replace SEND_LAST_VERSION with UPDATE_SUCCEEDED
if (m_worker->currentStep() != Worker::UPDATE_STEP::SEND_LAST_VERSION) {
errorCode = -1;
}
qCritical() << QString("ON QUIT: EXIT CODE %1").arg(errorCode);
qApp->exit(errorCode);
} }
void MainWindow::scrollDownTextEdit() { void MainWindow::scrollDownTextEdit() {
@ -460,21 +448,3 @@ void MainWindow::onShowErrorMessage(QString title, QString text) {
void MainWindow::onShowStatusMessage(QString title, QString text) { void MainWindow::onShowStatusMessage(QString title, QString text) {
onShowMessage(title, text); onShowMessage(title, text);
} }
void MainWindow::onShowErrorMessage(QStringList lst) {
if (lst.size() >= 2) {
onShowMessage(lst.at(0), lst.at(1));
}
if (lst.size() == 1) {
onShowMessage(lst.at(0), "");
}
}
void MainWindow::onShowStatusMessage(QStringList lst) {
if (lst.size() >= 2) {
onShowMessage(lst.at(0), lst.at(1));
}
if (lst.size() == 1) {
onShowMessage(lst.at(0), "");
}
}

View File

@ -34,7 +34,7 @@ public:
static const int BL_IS_UP_COUNT = 5; static const int BL_IS_UP_COUNT = 5;
static const int BL_STOP_COUNT = 5; static const int BL_STOP_COUNT = 5;
// int progressValue() const { return m_progressValue; } int progressValue() const { return m_progressValue; }
hwinf *getPlugin() { return m_hw; } hwinf *getPlugin() { return m_hw; }
hwinf const *getPlugin() const { return m_hw; } hwinf const *getPlugin() const { return m_hw; }
Update *getUpdate() { return m_update; } Update *getUpdate() { return m_update; }
@ -48,8 +48,6 @@ public slots:
void onReplaceLast(QString, QString suffix = ""); void onReplaceLast(QString, QString suffix = "");
void onShowErrorMessage(QString, QString); void onShowErrorMessage(QString, QString);
void onShowStatusMessage(QString, QString); void onShowStatusMessage(QString, QString);
void onShowErrorMessage(QStringList);
void onShowStatusMessage(QStringList);
void onStopStartTimer(); void onStopStartTimer();
void onRestartExitTimer(); void onRestartExitTimer();
void onEnableExit(); void onEnableExit();
@ -78,7 +76,7 @@ private:
QTimer *m_startTimer; QTimer *m_startTimer;
QTimer *m_exitTimer; QTimer *m_exitTimer;
bool m_progressRunning; bool m_progressRunning;
//int m_progressValue; int m_progressValue;
Update *m_update; Update *m_update;
UpdateDcEvent::UpdateStep m_updateStep; UpdateDcEvent::UpdateStep m_updateStep;
}; };

View File

@ -846,8 +846,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn; qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false; res = false;
} }
// m_worker->stopProgressLoop(); m_worker->stopProgressLoop();
// m_worker->setProgress(100); m_worker->setProgress(100);
if (res == false) { if (res == false) {
break; break;

View File

@ -46,70 +46,17 @@ QString Utils::zoneName(quint8 i) {
return "N/A"; return "N/A";
} }
void Utils::printCriticalErrorMsg(QString const &errorMsg, bool upper, bool lower) { void Utils::printCriticalErrorMsg(QString const &errorMsg) {
if (upper) qCritical() << QString(80, 'E'); qCritical() << QString(80, '!');
qCritical() << errorMsg; qCritical() << errorMsg;
qCritical() << QString(80, '!');
if (lower) qCritical() << QString(80, 'E');
} }
void Utils::printCriticalErrorMsg(QStringList const &errorMsg) { void Utils::printInfoMsg(QString const &infoMsg) {
qCritical() << QString(80, 'E'); qCritical() << QString(80, '=');
for (int i = 0; i < errorMsg.size(); ++i) {
qCritical() << errorMsg.at(i);
}
qCritical() << QString(80, 'E');
}
void Utils::printUpdateStatusMsg(QDebug &debug, QStringList const &updateMsg) {
debug << QString(80, 'U');
for (int i = 0; i < updateMsg.size(); ++i) {
debug << updateMsg.at(i);
}
debug << QString(80, 'U');
}
void Utils::printUpdateStatusMsg(QStringList const &updateMsg) {
qCritical() << QString(80, 'U');
for (int i = 0; i < updateMsg.size(); ++i) {
qCritical() << updateMsg.at(i);
}
qCritical() << QString(80, 'U');
}
void Utils::printUpdateStatusMsg(QString const &updateMsg, bool upper, bool lower) {
if (upper) qCritical() << QString(80, 'U');
qCritical() << updateMsg;
if (lower) qCritical() << QString(80, 'U');
}
void Utils::printUpdateStatusMsg(QDebug &debug, QString const &updateMsg,
bool upper, bool lower) {
if (upper) debug << QString(80, 'U');
debug << updateMsg;
if (lower) debug << QString(80, 'U');
}
void Utils::printInfoMsg(QString const &infoMsg, bool upper, bool lower) {
if (upper) qCritical() << QString(80, 'I');
qCritical() << infoMsg; qCritical() << infoMsg;
qCritical() << QString(80, '=');
if (lower) qCritical() << QString(80, 'I');
}
void Utils::printInfoMsg(QStringList const &infoMsg) {
qCritical() << QString(80, 'I');
for (int i = 0; i < infoMsg.size(); ++i) {
qCritical() << infoMsg.at(i);
}
qCritical() << QString(80, 'I');
} }
void Utils::printLineEditInfo(QStringList const &lines) { void Utils::printLineEditInfo(QStringList const &lines) {

11
utils.h
View File

@ -8,19 +8,12 @@
#include <QFileInfo> #include <QFileInfo>
#include <QDateTime> #include <QDateTime>
#include <QDir> #include <QDir>
#include <QDebug>
namespace Utils { namespace Utils {
int read1stLineOfFile(QString fileName); int read1stLineOfFile(QString fileName);
QString zoneName(quint8 i); QString zoneName(quint8 i);
void printCriticalErrorMsg(QString const &errorMsg, bool upper=false, bool lower=false); void printCriticalErrorMsg(QString const &errorMsg);
void printCriticalErrorMsg(QStringList const &errorMsg); void printInfoMsg(QString const &infoMsg);
void printInfoMsg(QString const &infoMsg, bool upper=false, bool lower=false);
void printInfoMsg(QStringList const &infoMsg);
void printUpdateStatusMsg(QDebug &debug, QStringList const &updateMsg);
void printUpdateStatusMsg(QStringList const &updateMsg);
void printUpdateStatusMsg(QString const &updateMsg, bool upper=false, bool lower=false);
void printUpdateStatusMsg(QDebug &debug, QString const &updateMsg, bool upper=false, bool lower=false);
void printLineEditInfo(QStringList const &lines); void printLineEditInfo(QStringList const &lines);
QString getTariffLoadTime(QString fileName); QString getTariffLoadTime(QString fileName);
QString rstrip(QString const &str); QString rstrip(QString const &str);

1418
worker.cpp

File diff suppressed because it is too large Load Diff

1114
worker.h

File diff suppressed because it is too large Load Diff