From 09cc683c2795569cd3abca3563438336855ad7f9 Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Mon, 29 Jul 2013 15:29:14 -0400 Subject: [PATCH] More changes for a better looking and functioning ApmFirmwareConfig screen --- qgroundcontrol.pro | 9 +- src/ui/configuration/ApmFirmwareConfig.cc | 480 ++++++++++++---------- src/ui/configuration/ApmFirmwareConfig.h | 12 +- src/ui/configuration/ApmFirmwareConfig.ui | 67 ++- src/ui/configuration/ApmFirmwareStatus.cc | 30 -- src/ui/configuration/ApmFirmwareStatus.h | 23 -- src/ui/configuration/ApmFirmwareStatus.ui | 68 --- 7 files changed, 342 insertions(+), 347 deletions(-) delete mode 100644 src/ui/configuration/ApmFirmwareStatus.cc delete mode 100644 src/ui/configuration/ApmFirmwareStatus.h delete mode 100644 src/ui/configuration/ApmFirmwareStatus.ui diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 8ac89950f..ea7265e23 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -263,8 +263,7 @@ FORMS += src/ui/MainWindow.ui \ src/ui/configuration/ArduRoverPidConfig.ui \ src/ui/configuration/terminalconsole.ui \ src/ui/configuration/SerialSettingsDialog.ui \ - src/ui/configuration/ApmFirmwareConfig.ui \ - src/ui/configuration/ApmFirmwareStatus.ui + src/ui/configuration/ApmFirmwareConfig.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -455,8 +454,7 @@ HEADERS += src/MG.h \ src/ui/configuration/SerialSettingsDialog.h \ src/ui/configuration/terminalconsole.h \ src/ui/configuration/ApmHighlighter.h \ - src/ui/configuration/ApmFirmwareConfig.h \ - src/ui/configuration/ApmFirmwareStatus.h + src/ui/configuration/ApmFirmwareConfig.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -666,8 +664,7 @@ SOURCES += src/main.cc \ src/ui/configuration/console.cpp \ src/ui/configuration/SerialSettingsDialog.cc \ src/ui/configuration/ApmHighlighter.cc \ - src/ui/configuration/ApmFirmwareConfig.cc \ - src/ui/configuration/ApmFirmwareStatus.cc + src/ui/configuration/ApmFirmwareConfig.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/ui/configuration/ApmFirmwareConfig.cc b/src/ui/configuration/ApmFirmwareConfig.cc index ba713bbc8..ed3b526da 100644 --- a/src/ui/configuration/ApmFirmwareConfig.cc +++ b/src/ui/configuration/ApmFirmwareConfig.cc @@ -1,16 +1,15 @@ -#include "ApmFirmwareConfig.h" -#include -#include -#include #include "LinkManager.h" #include "LinkInterface.h" #include "qserialport.h" #include "qserialportinfo.h" #include "SerialLink.h" + +#include "ApmFirmwareConfig.h" + ApmFirmwareConfig::ApmFirmwareConfig(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - firmwareStatus = 0; + //firmwareStatus = 0; m_betaFirmwareChecked = false; m_tempFirmwareFile=0; // @@ -30,111 +29,122 @@ ApmFirmwareConfig::ApmFirmwareConfig(QWidget *parent) : QWidget(parent) connect(ui.quadPushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked())); connect(ui.triPushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked())); connect(ui.y6PushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked())); - requestFirmwares(false); - connect(ui.betaFirmwareButton,SIGNAL(clicked()),this,SLOT(betaFirmwareButtonClicked())); + requestFirmwares(); + connect(ui.betaFirmwareButton,SIGNAL(clicked(bool)),this,SLOT(betaFirmwareButtonClicked(bool))); + + ui.progressBar->setMaximum(100); + ui.progressBar->setValue(0); + ui.progressBar->setVisible(false); + + ui.textBrowser->setVisible(false); + connect(ui.showOutputCheckBox,SIGNAL(clicked(bool)),ui.textBrowser,SLOT(setShown(bool))); } -void ApmFirmwareConfig::requestFirmwares(bool beta) + + +void ApmFirmwareConfig::requestBetaFirmwares() { + m_betaFirmwareChecked = true; + QNetworkReply *reply1 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-heli/git-version.txt"))); + QNetworkReply *reply2 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-quad/git-version.txt"))); + QNetworkReply *reply3 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-hexa/git-version.txt"))); + QNetworkReply *reply4 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-octa/git-version.txt"))); + QNetworkReply *reply5 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-octa-quad/git-version.txt"))); + QNetworkReply *reply6 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-tri/git-version.txt"))); + QNetworkReply *reply7 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-y6/git-version.txt"))); + QNetworkReply *reply8 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Plane/beta/apm2/git-version.txt"))); + QNetworkReply *reply9 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Rover/beta/apm2/git-version.txt"))); - if (!beta) - { - QNetworkReply *reply1 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-heli/git-version.txt"))); - QNetworkReply *reply2 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-quad/git-version.txt"))); - QNetworkReply *reply3 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-hexa/git-version.txt"))); - QNetworkReply *reply4 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-octa/git-version.txt"))); - QNetworkReply *reply5 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-octa-quad/git-version.txt"))); - QNetworkReply *reply6 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-tri/git-version.txt"))); - QNetworkReply *reply7 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-y6/git-version.txt"))); - QNetworkReply *reply8 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Plane/stable/apm2/git-version.txt"))); - QNetworkReply *reply9 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Rover/stable/apm2/git-version.txt"))); - - m_buttonToUrlMap[ui.roverPushButton] = "http://firmware.diydrones.com/Rover/stable/apm2/APMrover2.hex"; - m_buttonToUrlMap[ui.planePushButton] = "http://firmware.diydrones.com/Plane/stable/apm2/ArduPlane.hex"; - m_buttonToUrlMap[ui.copterPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-heli/ArduCopter.hex"; - m_buttonToUrlMap[ui.hexaPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-hexa/ArduCopter.hex"; - m_buttonToUrlMap[ui.octaQuadPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-octa-quad/ArduCopter.hex"; - m_buttonToUrlMap[ui.octaPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-octa/ArduCopter.hex"; - m_buttonToUrlMap[ui.quadPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-quad/ArduCopter.hex"; - m_buttonToUrlMap[ui.triPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-tri/ArduCopter.hex"; - m_buttonToUrlMap[ui.y6PushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-y6/ArduCopter.hex"; + m_buttonToUrlMap[ui.roverPushButton] = "http://firmware.diydrones.com/Rover/beta/apm2/APMrover2.hex"; + m_buttonToUrlMap[ui.planePushButton] = "http://firmware.diydrones.com/Plane/beta/apm2/ArduPlane.hex"; + m_buttonToUrlMap[ui.copterPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-heli/ArduCopter.hex"; + m_buttonToUrlMap[ui.hexaPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-hexa/ArduCopter.hex"; + m_buttonToUrlMap[ui.octaQuadPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-octa-quad/ArduCopter.hex"; + m_buttonToUrlMap[ui.octaPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-octa/ArduCopter.hex"; + m_buttonToUrlMap[ui.quadPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-quad/ArduCopter.hex"; + m_buttonToUrlMap[ui.triPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-tri/ArduCopter.hex"; + m_buttonToUrlMap[ui.y6PushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-y6/ArduCopter.hex"; - //http://firmware.diydrones.com/Plane/stable/apm2/ArduPlane.hex - connect(reply1,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply1,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply2,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply2,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply3,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply3,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply4,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply4,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply5,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply5,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply6,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply6,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply7,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply7,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply8,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply8,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply9,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply9,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - qDebug() << "Getting Stable firmware..."; - } - else - { - QNetworkReply *reply1 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-heli/git-version.txt"))); - QNetworkReply *reply2 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-quad/git-version.txt"))); - QNetworkReply *reply3 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-hexa/git-version.txt"))); - QNetworkReply *reply4 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-octa/git-version.txt"))); - QNetworkReply *reply5 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-octa-quad/git-version.txt"))); - QNetworkReply *reply6 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-tri/git-version.txt"))); - QNetworkReply *reply7 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/beta/apm2-y6/git-version.txt"))); - QNetworkReply *reply8 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Plane/beta/apm2/git-version.txt"))); - QNetworkReply *reply9 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Rover/beta/apm2/git-version.txt"))); - - m_buttonToUrlMap[ui.roverPushButton] = "http://firmware.diydrones.com/Rover/beta/apm2/APMrover2.hex"; - m_buttonToUrlMap[ui.planePushButton] = "http://firmware.diydrones.com/Plane/beta/apm2/ArduPlane.hex"; - m_buttonToUrlMap[ui.copterPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-heli/ArduCopter.hex"; - m_buttonToUrlMap[ui.hexaPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-hexa/ArduCopter.hex"; - m_buttonToUrlMap[ui.octaQuadPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-octa-quad/ArduCopter.hex"; - m_buttonToUrlMap[ui.octaPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-octa/ArduCopter.hex"; - m_buttonToUrlMap[ui.quadPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-quad/ArduCopter.hex"; - m_buttonToUrlMap[ui.triPushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-tri/ArduCopter.hex"; - m_buttonToUrlMap[ui.y6PushButton] = "http://firmware.diydrones.com/Copter/beta/apm2-y6/ArduCopter.hex"; + //http://firmware.diydrones.com/Plane/stable/apm2/ArduPlane.hex + connect(reply1,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply1,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply2,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply2,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply3,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply3,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply4,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply4,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply5,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply5,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply6,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply6,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply7,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply7,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply8,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply8,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply9,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply9,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + qDebug() << "Getting Beta firmware..."; +} - //http://firmware.diydrones.com/Plane/stable/apm2/ArduPlane.hex - connect(reply1,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply1,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply2,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply2,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply3,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply3,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply4,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply4,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply5,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply5,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply6,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply6,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply7,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply7,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply8,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply8,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - connect(reply9,SIGNAL(finished()),this,SLOT(firmwareListFinished())); - connect(reply9,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - qDebug() << "Getting Beta firmware..."; - } +void ApmFirmwareConfig::requestFirmwares() +{ + m_betaFirmwareChecked = false; + QNetworkReply *reply1 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-heli/git-version.txt"))); + QNetworkReply *reply2 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-quad/git-version.txt"))); + QNetworkReply *reply3 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-hexa/git-version.txt"))); + QNetworkReply *reply4 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-octa/git-version.txt"))); + QNetworkReply *reply5 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-octa-quad/git-version.txt"))); + QNetworkReply *reply6 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-tri/git-version.txt"))); + QNetworkReply *reply7 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Copter/stable/apm2-y6/git-version.txt"))); + QNetworkReply *reply8 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Plane/stable/apm2/git-version.txt"))); + QNetworkReply *reply9 = m_networkManager->get(QNetworkRequest(QUrl("http://firmware.diydrones.com/Rover/stable/apm2/git-version.txt"))); + + m_buttonToUrlMap[ui.roverPushButton] = "http://firmware.diydrones.com/Rover/stable/apm2/APMrover2.hex"; + m_buttonToUrlMap[ui.planePushButton] = "http://firmware.diydrones.com/Plane/stable/apm2/ArduPlane.hex"; + m_buttonToUrlMap[ui.copterPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-heli/ArduCopter.hex"; + m_buttonToUrlMap[ui.hexaPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-hexa/ArduCopter.hex"; + m_buttonToUrlMap[ui.octaQuadPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-octa-quad/ArduCopter.hex"; + m_buttonToUrlMap[ui.octaPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-octa/ArduCopter.hex"; + m_buttonToUrlMap[ui.quadPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-quad/ArduCopter.hex"; + m_buttonToUrlMap[ui.triPushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-tri/ArduCopter.hex"; + m_buttonToUrlMap[ui.y6PushButton] = "http://firmware.diydrones.com/Copter/stable/apm2-y6/ArduCopter.hex"; + + //http://firmware.diydrones.com/Plane/stable/apm2/ArduPlane.hex + connect(reply1,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply1,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply2,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply2,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply3,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply3,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply4,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply4,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply5,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply5,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply6,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply6,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply7,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply7,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply8,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply8,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + connect(reply9,SIGNAL(finished()),this,SLOT(firmwareListFinished())); + connect(reply9,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); + qDebug() << "Getting Stable firmware..."; } -void ApmFirmwareConfig::betaFirmwareButtonClicked() +void ApmFirmwareConfig::betaFirmwareButtonClicked(bool betafirmwareenabled) { - if (!m_betaFirmwareChecked) + if (betafirmwareenabled) { - m_betaFirmwareChecked = true; - requestFirmwares(true); + QMessageBox::information(0,"Warning","Beta firmwares are from the latest trunk. Use at your own risk!!"); + ui.label->setText("

Beta Firmware

"); + ui.betaFirmwareButton->setText("Stable Firmware"); + requestBetaFirmwares(); } else { - m_betaFirmwareChecked = false; - requestFirmwares(false); + ui.label->setText("

Firmware

"); + ui.betaFirmwareButton->setText("Beta Firmware"); + requestFirmwares(); } } void ApmFirmwareConfig::firmwareProcessFinished(int status) @@ -144,7 +154,26 @@ void ApmFirmwareConfig::firmwareProcessFinished(int status) { return; } - //qDebug() << "Error:" << proc->errorString(); + if (status != 0) + { + //Error of some kind + QMessageBox::information(0,"Error","An error has occured during the upload process. See window for details"); + ui.textBrowser->setVisible(true); + ui.showOutputCheckBox->setChecked(true); + ui.textBrowser->setPlainText(ui.textBrowser->toPlainText().append("\n\nERROR!!\n" + proc->errorString())); + QScrollBar *sb = ui.textBrowser->verticalScrollBar(); + if (sb) + { + sb->setValue(sb->maximum()); + } + ui.statusLabel->setText("Error during upload"); + } + else + { + //Ensure we're reading 100% + ui.progressBar->setValue(100); + ui.statusLabel->setText("Upload complete"); + } //qDebug() << "Upload finished!" << QString::number(status); m_tempFirmwareFile->deleteLater(); //This will remove the temporary file. m_tempFirmwareFile = 0; @@ -157,24 +186,38 @@ void ApmFirmwareConfig::firmwareProcessReadyRead() { return; } - QString error = proc->readAllStandardError() + proc->readAllStandardOutput(); - if (error.contains("Writing")) + QString output = proc->readAllStandardError() + proc->readAllStandardOutput(); + if (output.contains("Writing")) { - firmwareStatus->resetProgress(); + //firmwareStatus->resetProgress(); + ui.progressBar->setValue(0); } - else if (error.contains("Reading")) + else if (output.contains("Reading")) { - firmwareStatus->resetProgress(); + ui.progressBar->setValue(50); } - if (error.startsWith("#")) + if (output.startsWith("#")) { - firmwareStatus->progressTick(); + ui.progressBar->setValue(ui.progressBar->value()+1); + + ui.textBrowser->setPlainText(ui.textBrowser->toPlainText().append(output)); + QScrollBar *sb = ui.textBrowser->verticalScrollBar(); + if (sb) + { + sb->setValue(sb->maximum()); + } } else { - firmwareStatus->passMessage(error); + ui.textBrowser->setPlainText(ui.textBrowser->toPlainText().append(output + "\n")); + QScrollBar *sb = ui.textBrowser->verticalScrollBar(); + if (sb) + { + sb->setValue(sb->maximum()); + } } - qDebug() << "E:" << error; + + qDebug() << "E:" << output; //qDebug() << "AVR Output:" << proc->readAllStandardOutput(); //qDebug() << "AVR Output:" << proc->readAllStandardError(); } @@ -213,68 +256,78 @@ void ApmFirmwareConfig::downloadFinished() //info.manufacturer() == "Arduino LLC (www.arduino.cc)" //info.description() == "%mega2560.name%" - bool foundconnected = false; - QString detectedcomport = "COM4"; - for (int i=0;igetLinks().size();i++) - { - if (LinkManager::instance()->getLinks()[i]->isConnected()) - { - //This is likely the serial link we want. - SerialLink *link = qobject_cast(LinkManager::instance()->getLinks()[i]); - if (!link) - { - qDebug() << "Eror, trying to program over a non serial link. This should not happen"; - return; - } - detectedcomport = link->getPortName(); - link->requestReset(); - foundconnected = true; - link->disconnect(); - link->wait(1000); // Wait 1 second for it to disconnect. - } - } - if (!foundconnected) - { - QMessageBox::information(0,"Error","You must be connected to a MAV over serial link to flash firmware"); - return; - } + qDebug() << "Attempting to reset port"; QSerialPort port; - port.setPortName(detectedcomport); + port.setPortName(m_detectedComPort); port.open(QIODevice::ReadWrite); port.setDataTerminalReady(true); port.waitForBytesWritten(250); port.setDataTerminalReady(false); port.close(); - firmwareStatus->setStatus("Burning"); + ui.statusLabel->setText("Burning"); #ifdef Q_OS_WIN - process->start("avrdude/avrdude.exe",QStringList() << "-Cavrdude/avrdude.conf" << "-pm2560" << "-cstk500" << QString("-P").append(detectedcomport) << QString("-Uflash:w:").append(m_tempFirmwareFile->fileName()).append(":i")); + process->start("avrdude/avrdude.exe",QStringList() << "-Cavrdude/avrdude.conf" << "-pm2560" << "-cstk500" << QString("-P").append(m_detectedComPort) << QString("-Uflash:w:").append(m_tempFirmwareFile->fileName()).append(":i")); #else - process->start("avrdude",QStringList() << "-Cavrdude/avrdude.conf" << "-pm2560" << "-cstk500" << QString("-P").append(detectedcomport) << QString("-Uflash:w:").append(m_tempFirmwareFile->fileName()).append(":i")); + process->start("avrdude",QStringList() << "-Cavrdude/avrdude.conf" << "-pm2560" << "-cstk500" << QString("-P").append(m_detectedComPort) << QString("-Uflash:w:").append(m_tempFirmwareFile->fileName()).append(":i")); #endif } void ApmFirmwareConfig::firmwareProcessError(QProcess::ProcessError error) { qDebug() << "Error:" << error; } +void ApmFirmwareConfig::firmwareDownloadProgress(qint64 received,qint64 total) +{ + ui.progressBar->setValue( 100.0 * ((double)received/(double)total)); +} void ApmFirmwareConfig::burnButtonClicked() { QPushButton *senderbtn = qobject_cast(sender()); if (m_buttonToUrlMap.contains(senderbtn)) { + bool foundconnected = false; + for (int i=0;igetLinks().size();i++) + { + if (LinkManager::instance()->getLinks()[i]->isConnected()) + { + //This is likely the serial link we want. + SerialLink *link = qobject_cast(LinkManager::instance()->getLinks()[i]); + if (!link) + { + qDebug() << "Eror, trying to program over a non serial link. This should not happen"; + return; + } + if (!(QMessageBox::question(this,"WARNING","You are about to upload new firmware to your board. This will disconnect you if you are currently connected. Be sure the MAV is on the ground, and connected over USB/Serial link.\n\nDo you wish to proceed?",QMessageBox::Yes,QMessageBox::No) == QMessageBox::Yes)) + { + return; + } + + m_detectedComPort = link->getPortName(); + link->requestReset(); + foundconnected = true; + link->disconnect(); + link->wait(1000); // Wait 1 second for it to disconnect. + } + } + if (!foundconnected) + { + QMessageBox::information(0,"Error","You must be connected to a MAV over serial link to flash firmware. Please connect to a MAV then try again"); + return; + } + qDebug() << "Go download:" << m_buttonToUrlMap[senderbtn]; QNetworkReply *reply = m_networkManager->get(QNetworkRequest(QUrl(m_buttonToUrlMap[senderbtn]))); //http://firmware.diydrones.com/Plane/stable/apm2/ArduPlane.hex connect(reply,SIGNAL(finished()),this,SLOT(downloadFinished())); connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(firmwareListError(QNetworkReply::NetworkError))); - firmwareStatus = new ApmFirmwareStatus(); - firmwareStatus->show(); - firmwareStatus->setStatus("Downloading"); + connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(firmwareDownloadProgress(qint64,qint64))); + ui.statusLabel->setText("Downloading"); + ui.progressBar->setVisible(true); } } @@ -302,109 +355,114 @@ void ApmFirmwareConfig::firmwareListFinished() QString outstr = ""; if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-heli",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.copterLabel->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.copterLabel->setText("BETA " + outstr); + } + else + { + ui.copterLabel->setText(outstr); + } return; } if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-quad",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.quadLabel->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.quadLabel->setText("BETA " + outstr); + } + else + { + ui.quadLabel->setText(outstr); + } return; } if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-hexa",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.hexaLabel->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.hexaLabel->setText("BETA " + outstr); + } + else + { + ui.hexaLabel->setText(outstr); + } return; } - if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-octa",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) + if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-octa-quad",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.octaLabel->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.octaQuadLabel->setText("BETA " + outstr); + } + else + { + ui.octaQuadLabel->setText(outstr); + } return; } - if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-octa-quad",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) + if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-octa",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.octaQuadLabel->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.octaLabel->setText("BETA " + outstr); + } + else + { + ui.octaLabel->setText(outstr); + } return; } if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-tri",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.triLabel->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.triLabel->setText("BETA " + outstr); + } + else + { + ui.triLabel->setText(outstr); + } return; } if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-y6",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.y6Label->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.y6Label->setText("BETA " + outstr); + } + else + { + ui.y6Label->setText(outstr); + } return; } if (stripVersionFromGitReply(reply->url().toString(),replystr,"Plane",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.planeLabel->setText(outstr); + if (m_betaFirmwareChecked) + { + ui.planeLabel->setText("BETA " + outstr); + } + else + { + ui.planeLabel->setText(outstr); + } return; } if (stripVersionFromGitReply(reply->url().toString(),replystr,"Rover",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr)) { - ui.roverLabel->setText(outstr); - return; - } - //qDebug() << replystr; - /* - QXmlStreamReader xml(replystr); - while (!xml.atEnd()) - { - if (xml.name() == "options" && xml.isStartElement()) + if (m_betaFirmwareChecked) { - xml.readNext(); - while (xml.name() != "options") - { - if (xml.name() == "Firmware" && xml.isStartElement()) - { - xml.readNext(); - FirmwareDef def; - while (xml.name() != "Firmware") - { - if (xml.name() == "url" && xml.isStartElement()) - { - xml.readNext(); - def.url = xml.text().toString(); - } - else if (xml.name() == "url2560" && xml.isStartElement()) - { - xml.readNext(); - def.url2560 = xml.text().toString(); - } - else if (xml.name() == "url2560-2" && xml.isStartElement()) - { - xml.readNext(); - def.url25602 = xml.text().toString(); - } - else if (xml.name() == "urlpx4" && xml.isStartElement()) - { - xml.readNext(); - def.urlpx4 = xml.text().toString(); - } - else if (xml.name() == "name" && xml.isStartElement()) - { - xml.readNext(); - def.name = xml.text().toString(); - } - else if (xml.name() == "desc" && xml.isStartElement()) - { - xml.readNext(); - def.desc = xml.text().toString(); - } - else if (xml.name() == "format_version" && xml.isStartElement()) - { - xml.readNext(); - def.version = xml.text().toString().toInt(); - } - - xml.readNext(); - } - } - xml.readNext(); - } + ui.roverLabel->setText("BETA " + outstr); + } + else + { + ui.roverLabel->setText(outstr); } - xml.readNext(); - }*/ + return; + } + qDebug() << "Match not found for:" << reply->url(); + qDebug() << "Git version line:" << replystr; } ApmFirmwareConfig::~ApmFirmwareConfig() diff --git a/src/ui/configuration/ApmFirmwareConfig.h b/src/ui/configuration/ApmFirmwareConfig.h index aca500a3f..bc1bf0964 100644 --- a/src/ui/configuration/ApmFirmwareConfig.h +++ b/src/ui/configuration/ApmFirmwareConfig.h @@ -8,6 +8,9 @@ #include #include #include +#include +#include +#include #include "qserialport.h" #include "ui_ApmFirmwareConfig.h" #include "ApmFirmwareStatus.h" @@ -23,16 +26,19 @@ private slots: void firmwareListFinished(); void firmwareListError(QNetworkReply::NetworkError error); void burnButtonClicked(); - void betaFirmwareButtonClicked(); + void betaFirmwareButtonClicked(bool betafirmwareenabled); void downloadFinished(); void firmwareProcessFinished(int status); void firmwareProcessReadyRead(); void firmwareProcessError(QProcess::ProcessError error); + void firmwareDownloadProgress(qint64 received,qint64 total); private: - ApmFirmwareStatus *firmwareStatus; + //ApmFirmwareStatus *firmwareStatus; + QString m_detectedComPort; QTemporaryFile *m_tempFirmwareFile; QNetworkAccessManager *m_networkManager; - void requestFirmwares(bool beta); + void requestFirmwares(); + void requestBetaFirmwares(); bool stripVersionFromGitReply(QString url,QString reply,QString type,QString stable,QString *out); bool m_betaFirmwareChecked; QMap m_buttonToUrlMap; diff --git a/src/ui/configuration/ApmFirmwareConfig.ui b/src/ui/configuration/ApmFirmwareConfig.ui index b6640b626..b49f8318c 100644 --- a/src/ui/configuration/ApmFirmwareConfig.ui +++ b/src/ui/configuration/ApmFirmwareConfig.ui @@ -6,8 +6,8 @@ 0 0 - 958 - 497 + 868 + 661 @@ -18,7 +18,7 @@ 10 20 - 91 + 211 31 @@ -428,14 +428,69 @@ - 760 + 700 440 - 91 + 131 23 - Beta firmwares + Beta firmware + + + true + + + false + + + + + + 50 + 470 + 791 + 23 + + + + 24 + + + + + + 60 + 500 + 741 + 151 + + + + + + + 600 + 440 + 101 + 17 + + + + Show Output + + + + + + 60 + 440 + 141 + 21 + + + + Status diff --git a/src/ui/configuration/ApmFirmwareStatus.cc b/src/ui/configuration/ApmFirmwareStatus.cc deleted file mode 100644 index aec009f4e..000000000 --- a/src/ui/configuration/ApmFirmwareStatus.cc +++ /dev/null @@ -1,30 +0,0 @@ -#include "ApmFirmwareStatus.h" - - -ApmFirmwareStatus::ApmFirmwareStatus(QWidget *parent) : QWidget(parent) -{ - ui.setupUi(this); - ui.progressBar->setMaximum(50); -} - -ApmFirmwareStatus::~ApmFirmwareStatus() -{ -} -void ApmFirmwareStatus::passMessage(QString msg) -{ - ui.textBrowser->append(msg); -} -void ApmFirmwareStatus::setStatus(QString message) -{ - ui.label->setText("

" + message + "

"); -} - -void ApmFirmwareStatus::resetProgress() -{ - ui.progressBar->setValue(0); -} - -void ApmFirmwareStatus::progressTick() -{ - ui.progressBar->setValue(ui.progressBar->value()+1); -} diff --git a/src/ui/configuration/ApmFirmwareStatus.h b/src/ui/configuration/ApmFirmwareStatus.h deleted file mode 100644 index 633469220..000000000 --- a/src/ui/configuration/ApmFirmwareStatus.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef APMFIRMWARESTATUS_H -#define APMFIRMWARESTATUS_H - -#include -#include "ui_ApmFirmwareStatus.h" - -class ApmFirmwareStatus : public QWidget -{ - Q_OBJECT - -public: - explicit ApmFirmwareStatus(QWidget *parent = 0); - ~ApmFirmwareStatus(); - void passMessage(QString msg); - void setStatus(QString message); - void resetProgress(); - void progressTick(); - -private: - Ui::ApmFirmwareStatus ui; -}; - -#endif // APMFIRMWARESTATUS_H diff --git a/src/ui/configuration/ApmFirmwareStatus.ui b/src/ui/configuration/ApmFirmwareStatus.ui deleted file mode 100644 index a9a09fc8e..000000000 --- a/src/ui/configuration/ApmFirmwareStatus.ui +++ /dev/null @@ -1,68 +0,0 @@ - - - ApmFirmwareStatus - - - - 0 - 0 - 889 - 313 - - - - Form - - - - - 390 - 110 - 75 - 23 - - - - Close - - - - - - 10 - 150 - 871 - 141 - - - - - - - 20 - 20 - 291 - 31 - - - - <h2>Status</h2> - - - - - - 10 - 70 - 851 - 23 - - - - 0 - - - - - - -- 2.22.0