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