Compare commits

..

No commits in common. "af337874a68c58eac73f9ece32255127ccee9849" and "85bec3364f459bba0b792523330bf68e42dc2207" have entirely different histories.

2 changed files with 14 additions and 23 deletions

View File

@ -43,8 +43,6 @@ Update::Update(QString update_ctrl_file,
, m_init(true)
, m_delete(hw == nullptr) {
qCritical() << "workingDir" << m_workingDir;
execUpdateScript();
if (!m_update_ctrl_file.exists()) {
@ -74,11 +72,9 @@ Update::~Update() {
bool Update::execUpdateScript() {
// path of update-script 'update_psa'
QString update_psa("/opt/app/tools/atbupdate/update_psa -m --wdir ");
QString update_psa("/opt/app/tools/atbupdate/update_psa --wdir ");
update_psa += m_workingDir;
qCritical() << "update_psa: " << update_psa;
//QStringList const params(QStringList() << "-c" << update_psa);
QScopedPointer<QProcess> p(new QProcess(this));
@ -103,12 +99,10 @@ 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,
@ -133,12 +127,12 @@ QStringList Update::getOpenLines() {
return openLines;
}
QStringList Update::split(QString line, QChar sep) {
QStringList Update::split(QString line) {
QStringList lst;
QString next;
int start = 0, end;
while ((end = line.indexOf(sep, start)) != -1) {
while ((end = line.indexOf(QChar(','), start)) != -1) {
next = line.mid(start, end - start).trimmed();
lst << next;
start = end + 1;
@ -166,9 +160,6 @@ bool Update::doUpdate() {
# RESULT: SUCCESS or ERROR (possibly with description)
#
*/
// qCritical() << "Device Controller SW-version" << m_hw->dc_getSWversion();
if (!m_init) {
return false;
}
@ -208,13 +199,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();
@ -224,9 +215,8 @@ bool Update::doUpdate() {
if (p->waitForStarted(1000)) {
if (p->state() == QProcess::ProcessState::Running) {
if (p->waitForFinished(10000)) {
QString output = p->readAllStandardOutput();
QStringList outputLst = split(output, QChar('\n'));
qDebug() << outputLst;
QByteArray output = p->readAllStandardOutput();
qDebug() << output;
res = true;
qInfo() << "EXECUTED" << name;
}

View File

@ -38,7 +38,8 @@ class Update : public QObject {
bool updatePrinterConf(int nrOfTemplate, char const *fileToSendToDC);
bool finishUpdate(bool finish);
QStringList getOpenLines();
QStringList split(QString line, QChar sep = ',');
QStringList split(QString line);
static constexpr QChar SEPARATOR = QChar(',');
bool execUpdateScript();
public: