save for christmas

This commit is contained in:
2024-12-20 13:01:34 +01:00
parent 2ec7b61682
commit 7bfb7f5a3b
19 changed files with 624 additions and 92 deletions

View File

@@ -52,7 +52,7 @@ int main(int argc, char **argv) {
}
// qputenv("XDG_RUNTIME_DIR", "/var/run/user/0");
openlog("ATB-UPDATE-DC-FIRMWARE", LOG_PERROR | LOG_PID | LOG_CONS, LOG_USER);
openlog("DC", LOG_PERROR | LOG_CONS, LOG_USER);
QApplication a(argc, argv);
QApplication::setApplicationName("ATBDownloadDCFirmware");
@@ -73,7 +73,7 @@ int main(int argc, char **argv) {
QString workingDir = parser.workingDir();
QString psaConfigDir = parser.psaConfigDir();
QString psaTariffDir = parser.psaTariffDir();
QString dcDir = parser.dcDir();
QString psaDcDir = parser.dcDir();
QString iniFileName = parser.iniFileName();
bool const dryRun = parser.dryRun();
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
@@ -112,13 +112,12 @@ int main(int argc, char **argv) {
qInfo() << "customerNr ..............." << customerNr;
qInfo() << "zoneNr ..................." << zoneNr;
qInfo() << "readDCVersion ............" << readDCVersion;
qInfo() << "dcDir ...................." << dcDir;
qInfo() << "dcDir ...................." << psaDcDir;
if (readDCVersion) {
qInfo() << "dc-version ..............." << Update::dcVersion(
QDir::cleanPath(rtPath + QDir::separator()
+ QString("customer_%1").arg(customerNr) + QDir::separator()
+ dcDir + QDir::separator() + "dc2c.bin"));
if (!QDir(plugInDir).exists()) {
qCritical() << plugInDir
<< "does not exists, but has to contain dc-library";
exit(-1);
}
if (showExtendedVersion) {
@@ -126,12 +125,47 @@ int main(int argc, char **argv) {
return 0;
}
QString const &customerRepo
= QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
// QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
// QStringList filesToUpdate;
// etc/dc: located under mount-path
std::optional<QString> mountPath = System::checkForUSBStick(psaDcDir);
QFileInfo fi;
if (mountPath.has_value()) {
fi.setFile(mountPath.value(), System::getDCFileOnUsbStick(mountPath.value()));
} else
if ((mountPath = System::checkForSDCard(psaDcDir)).has_value()) {
fi.setFile(mountPath.value(), System::getDCFileOnSDCard(mountPath.value()));
} else {
qInfo() << "using customer repository" << customerRepo;
QDir dir(QDir::cleanPath(customerRepo + QDir::separator() + "etc/dc"));
if (dir.exists()) {
fi.setFile(dir, dir.absoluteFilePath("dc2c.bin"));
} else {
qCritical() << "DIRECTORY" << dir << "DOES NOT EXIST";
return -1;
}
}
qInfo() << "downloading dc-firmware .." << fi.absoluteFilePath();
qInfo() << "dc-firmware size (bytes) ." << fi.size();
if (readDCVersion) {
qInfo() << "dc-version ..............." << Update::dcVersion(fi.absoluteFilePath());
}
QThread::currentThread()->setObjectName("main thread");
qInfo() << "Main thread" << QThread::currentThreadId();
// qInfo() << "Main thread" << QThread::currentThreadId();
Update update(customerRepo,
QString::number(customerNr),
branchName,
plugInDir,
plugInName,
workingDir,
psaDcDir);
update.doUpdate(fi.absoluteFilePath());
// MainWindow mw;
@@ -142,6 +176,8 @@ int main(int argc, char **argv) {
// mw.show();
qInfo() << "<DC-UPDATE-FINISH>";
return 0;
// return a.exec();
}