removed handling of tariff, as this is not downloaded to dc

This commit is contained in:
Gerhard Hoffmann 2023-05-30 16:47:00 +02:00
parent f016e9777e
commit af337874a6

View File

@ -43,6 +43,8 @@ Update::Update(QString update_ctrl_file,
, m_init(true)
, m_delete(hw == nullptr) {
qCritical() << "workingDir" << m_workingDir;
execUpdateScript();
if (!m_update_ctrl_file.exists()) {
@ -72,9 +74,11 @@ Update::~Update() {
bool Update::execUpdateScript() {
// path of update-script 'update_psa'
QString update_psa("/opt/app/tools/atbupdate/update_psa --wdir ");
QString update_psa("/opt/app/tools/atbupdate/update_psa -m --wdir ");
update_psa += m_workingDir;
qCritical() << "update_psa: " << update_psa;
//QStringList const params(QStringList() << "-c" << update_psa);
QScopedPointer<QProcess> p(new QProcess(this));
@ -99,10 +103,12 @@ bool Update::execUpdateScript() {
}
bool Update::updateBinary(char const *fileToSendToDC) {
return true; // debug
return m_hw->dc_updateDC(fileToSendToDC, m_baudrate, m_serialInterface);
}
bool Update::updatePrinterConf(int nrOfTemplate, char const *fileToSendToDC) {
return true; // debug
QVector<int> printTemplates{ nrOfTemplate };
QVector<QString> filesToSend{ fileToSendToDC };
return m_hw->dc_updatePrinterTemplate(hwapi::FileTypeJson::PRINTER,
@ -127,12 +133,12 @@ QStringList Update::getOpenLines() {
return openLines;
}
QStringList Update::split(QString line) {
QStringList Update::split(QString line, QChar sep) {
QStringList lst;
QString next;
int start = 0, end;
while ((end = line.indexOf(QChar(','), start)) != -1) {
while ((end = line.indexOf(sep, start)) != -1) {
next = line.mid(start, end - start).trimmed();
lst << next;
start = end + 1;
@ -160,6 +166,9 @@ bool Update::doUpdate() {
# RESULT: SUCCESS or ERROR (possibly with description)
#
*/
// qCritical() << "Device Controller SW-version" << m_hw->dc_getSWversion();
if (!m_init) {
return false;
}
@ -199,13 +208,13 @@ bool Update::doUpdate() {
qInfo() << "Downloaded" << name;
}
} else
if (name.contains("tariff") && name.endsWith(".json")) {
int i = name.indexOf("tariff");
int templateIdx = name.mid(i).midRef(6, 2).toInt();
if ((res = updatePrinterConf(templateIdx, name.toStdString().c_str())) == true) {
qInfo() << "Downloaded" << name;
}
} else
//if (name.contains("tariff") && name.endsWith(".json")) {
// int i = name.indexOf("tariff");
// int templateIdx = name.mid(i).midRef(6, 2).toInt();
// if ((res = updatePrinterConf(templateIdx, name.toStdString().c_str())) == true) {
// qInfo() << "Downloaded" << name;
// }
//} else
if (name.contains("opkg")) {
int i = name.indexOf("opkg ");
QString rest = name.mid(i+5).trimmed();
@ -215,8 +224,9 @@ bool Update::doUpdate() {
if (p->waitForStarted(1000)) {
if (p->state() == QProcess::ProcessState::Running) {
if (p->waitForFinished(10000)) {
QByteArray output = p->readAllStandardOutput();
qDebug() << output;
QString output = p->readAllStandardOutput();
QStringList outputLst = split(output, QChar('\n'));
qDebug() << outputLst;
res = true;
qInfo() << "EXECUTED" << name;
}