From 5198b9a8a7b632f850e78d2f85d8c6d8925665bc Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 12 Jun 2020 11:22:06 +0200 Subject: [PATCH] Attempt to fix the progress bar issue on Companion Read Firmware function (DFU mode) --- companion/src/downloaddialog.cpp | 2 +- companion/src/flashfirmwaredialog.cpp | 2 +- companion/src/process_flash.cpp | 17 ++++++++++++++--- companion/src/radiointerface.cpp | 3 +-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/companion/src/downloaddialog.cpp b/companion/src/downloaddialog.cpp index 3f70e6529..d5c037645 100644 --- a/companion/src/downloaddialog.cpp +++ b/companion/src/downloaddialog.cpp @@ -54,7 +54,7 @@ DownloadDialog::DownloadDialog(QWidget *parent, QString src, QString tgt): reply = qnam.get(QNetworkRequest(QUrl(src))); connect(reply, SIGNAL(finished()), this, SLOT(httpFinished())); connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead())); - connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDataReadProgress(qint64,qint64))); + connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(updateDataReadProgress(qint64, qint64))); } } diff --git a/companion/src/flashfirmwaredialog.cpp b/companion/src/flashfirmwaredialog.cpp index 9a2b688ab..fd6046f92 100644 --- a/companion/src/flashfirmwaredialog.cpp +++ b/companion/src/flashfirmwaredialog.cpp @@ -112,7 +112,7 @@ void FlashFirmwareDialog::updateUI() } QImage image; - switch(imageSource) { + switch (imageSource) { case FIRMWARE: ui->useFirmwareSplash->setChecked(true); image = firmware.getSplash(); diff --git a/companion/src/process_flash.cpp b/companion/src/process_flash.cpp index 599d7e653..22baa83c6 100644 --- a/companion/src/process_flash.cpp +++ b/companion/src/process_flash.cpp @@ -134,15 +134,18 @@ void FlashProcess::onKillTimerElapsed() #endif } -void FlashProcess::analyseStandardOutput(const QString &text) +void FlashProcess::analyseStandardOutput(const QString & text) { + +// qDebug() << text; + currStdoutLine.append(text); if (currStdoutLine.contains("size = ")) { int pos = currStdoutLine.lastIndexOf("size = "); QString temp = currStdoutLine.mid(pos+7); pos = temp.lastIndexOf("\n"); int size = temp.left(pos).toInt(); - progress->setMaximum(size/2048); + progress->setMaximum(size / 2048); } if (currStdoutLine.contains("\n")) { int nlPos = currStdoutLine.lastIndexOf("\n"); @@ -168,7 +171,15 @@ void FlashProcess::analyseStandardOutput(const QString &text) int end = text.indexOf("%"); if (start > 0) { start += 9; - int value = text.mid(start, end-start).toInt(); + int value = text.mid(start, end - start).toInt(); + progress->setValue(value); + } + } + + if (text.contains("Upload\t[")) { + int end = text.indexOf("%"); + if (end > 0) { + int value = text.mid(end - 3, 3).toInt(); progress->setValue(value); } } diff --git a/companion/src/radiointerface.cpp b/companion/src/radiointerface.cpp index c3214958a..fbc03186f 100644 --- a/companion/src/radiointerface.cpp +++ b/companion/src/radiointerface.cpp @@ -253,7 +253,6 @@ void resetAvrdudeFuses(bool eepromProtect, ProgressWidget * progress) } } - bool readFirmware(const QString & filename, ProgressWidget * progress) { bool result = false; @@ -274,7 +273,7 @@ bool readFirmware(const QString & filename, ProgressWidget * progress) } } - if (result == false) { + if (!result) { qDebug() << "readFirmware: reading" << filename << "with" << getRadioInterfaceCmd() << getReadFirmwareArgs(filename); FlashProcess flashProcess(getRadioInterfaceCmd(), getReadFirmwareArgs(filename), progress); result = flashProcess.run();