Commit 56efe884 authored by Michael Carpenter's avatar Michael Carpenter

Initial commit of APM2.5 Firmware loading config screen via Avrdude

parent 95e4e9bf
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -262,8 +262,9 @@ FORMS += src/ui/MainWindow.ui \
src/ui/configuration/AdvParameterList.ui \
src/ui/configuration/ArduRoverPidConfig.ui \
src/ui/configuration/terminalconsole.ui \
src/ui/configuration/SerialSettingsDialog.ui
src/ui/configuration/SerialSettingsDialog.ui \
src/ui/configuration/ApmFirmwareConfig.ui \
src/ui/configuration/ApmFirmwareStatus.ui
INCLUDEPATH += src \
src/ui \
src/ui/linechart \
......@@ -453,7 +454,9 @@ HEADERS += src/MG.h \
src/ui/configuration/console.h \
src/ui/configuration/SerialSettingsDialog.h \
src/ui/configuration/terminalconsole.h \
src/ui/configuration/ApmHighlighter.h
src/ui/configuration/ApmHighlighter.h \
src/ui/configuration/ApmFirmwareConfig.h \
src/ui/configuration/ApmFirmwareStatus.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
......@@ -662,7 +665,9 @@ SOURCES += src/main.cc \
src/ui/configuration/terminalconsole.cpp \
src/ui/configuration/console.cpp \
src/ui/configuration/SerialSettingsDialog.cc \
src/ui/configuration/ApmHighlighter.cc
src/ui/configuration/ApmHighlighter.cc \
src/ui/configuration/ApmFirmwareConfig.cc \
src/ui/configuration/ApmFirmwareStatus.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
......
......@@ -119,6 +119,43 @@
<file>files/images/devices/cameraGimalRoll1.png</file>
<file>files/images/devices/cameraGimalYaw.png</file>
<file>files/images/devices/Shutter.png</file>
<file>files/images/firmware/apmcopter.png</file>
<file>files/images/firmware/apmplane.png</file>
<file>files/images/firmware/apmrover.png</file>
<file>files/images/firmware/FW icons 2013+logos.ai</file>
<file>files/images/firmware/heli.png</file>
<file>files/images/firmware/heli_off.png</file>
<file>files/images/firmware/heli_on.png</file>
<file>files/images/firmware/hexa_off.png</file>
<file>files/images/firmware/hexa_on.png</file>
<file>files/images/firmware/hexaplus.png</file>
<file>files/images/firmware/hexax.png</file>
<file>files/images/firmware/hexay.png</file>
<file>files/images/firmware/octaplus.png</file>
<file>files/images/firmware/octax.png</file>
<file>files/images/firmware/octo_off.png</file>
<file>files/images/firmware/octo_on.png</file>
<file>files/images/firmware/octx.png</file>
<file>files/images/firmware/plane.png</file>
<file>files/images/firmware/plane_off.png</file>
<file>files/images/firmware/plane_on.png</file>
<file>files/images/firmware/quad_off.png</file>
<file>files/images/firmware/quad_on.png</file>
<file>files/images/firmware/quad_T_off.png</file>
<file>files/images/firmware/quad_T_on.png</file>
<file>files/images/firmware/quadplus.png</file>
<file>files/images/firmware/quadx.png</file>
<file>files/images/firmware/quady.png</file>
<file>files/images/firmware/rover.png</file>
<file>files/images/firmware/rover_off.png</file>
<file>files/images/firmware/rover_on.png</file>
<file>files/images/firmware/Tir_off.png</file>
<file>files/images/firmware/Tir_on.png</file>
<file>files/images/firmware/triy.png</file>
<file>files/images/firmware/X8.png</file>
<file>files/images/firmware/X8_on.png</file>
<file>files/images/firmware/Y6_off.png</file>
<file>files/images/firmware/Y6_on.png</file>
</qresource>
<qresource prefix="/general">
<file alias="vera.ttf">files/styles/Vera.ttf</file>
......
#include "ApmFirmwareConfig.h"
#include <QXmlStreamReader>
#include <QMessageBox>
#include <QProcess>
#include "LinkManager.h"
#include "LinkInterface.h"
#include "qserialport.h"
#include "qserialportinfo.h"
#include "SerialLink.h"
ApmFirmwareConfig::ApmFirmwareConfig(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
firmwareStatus = 0;
m_betaFirmwareChecked = false;
m_tempFirmwareFile=0;
//
//QNetworkRequest req(QUrl("https://raw.github.com/diydrones/binary/master/Firmware/firmware2.xml"));
m_networkManager = new QNetworkAccessManager(this);
connect(ui.roverPushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked()));
connect(ui.planePushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked()));
connect(ui.copterPushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked()));
connect(ui.hexaPushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked()));
connect(ui.octaQuadPushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked()));
connect(ui.octaPushButton,SIGNAL(clicked()),this,SLOT(burnButtonClicked()));
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()));
}
void ApmFirmwareConfig::requestFirmwares(bool beta)
{
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";
//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...";
}
}
void ApmFirmwareConfig::betaFirmwareButtonClicked()
{
if (!m_betaFirmwareChecked)
{
m_betaFirmwareChecked = true;
requestFirmwares(true);
}
else
{
m_betaFirmwareChecked = false;
requestFirmwares(false);
}
}
void ApmFirmwareConfig::firmwareProcessFinished(int status)
{
QProcess *proc = qobject_cast<QProcess*>(sender());
if (!proc)
{
return;
}
//qDebug() << "Error:" << proc->errorString();
//qDebug() << "Upload finished!" << QString::number(status);
m_tempFirmwareFile->deleteLater(); //This will remove the temporary file.
m_tempFirmwareFile = 0;
}
void ApmFirmwareConfig::firmwareProcessReadyRead()
{
QProcess *proc = qobject_cast<QProcess*>(sender());
if (!proc)
{
return;
}
QString error = proc->readAllStandardError() + proc->readAllStandardOutput();
if (error.contains("Writing"))
{
firmwareStatus->resetProgress();
}
else if (error.contains("Reading"))
{
firmwareStatus->resetProgress();
}
if (error.startsWith("#"))
{
firmwareStatus->progressTick();
}
else
{
firmwareStatus->passMessage(error);
}
qDebug() << "E:" << error;
//qDebug() << "AVR Output:" << proc->readAllStandardOutput();
//qDebug() << "AVR Output:" << proc->readAllStandardError();
}
void ApmFirmwareConfig::downloadFinished()
{
qDebug() << "Download finished, burning firmware";
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (!reply)
{
return;
}
QByteArray hex = reply->readAll();
m_tempFirmwareFile = new QTemporaryFile();
m_tempFirmwareFile->open();
m_tempFirmwareFile->write(hex);
m_tempFirmwareFile->flush();
m_tempFirmwareFile->close();
//tempfirmware.fileName()
QProcess *process = new QProcess(this);
connect(process,SIGNAL(finished(int)),this,SLOT(firmwareProcessFinished(int)));
connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(firmwareProcessReadyRead()));
connect(process,SIGNAL(readyReadStandardError()),this,SLOT(firmwareProcessReadyRead()));
connect(process,SIGNAL(error(QProcess::ProcessError)),this,SLOT(firmwareProcessError(QProcess::ProcessError)));
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
foreach (const QSerialPortInfo &info, portList)
{
qDebug() << "PortName : " << info.portName()
<< "Description : " << info.description();
qDebug() << "Manufacturer: " << info.manufacturer();
}
//info.manufacturer() == "Arduino LLC (www.arduino.cc)"
//info.description() == "%mega2560.name%"
bool foundconnected = false;
QString detectedcomport = "COM4";
for (int i=0;i<LinkManager::instance()->getLinks().size();i++)
{
if (LinkManager::instance()->getLinks()[i]->isConnected())
{
//This is likely the serial link we want.
SerialLink *link = qobject_cast<SerialLink*>(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.open(QIODevice::ReadWrite);
port.setDataTerminalReady(true);
port.waitForBytesWritten(250);
port.setDataTerminalReady(false);
port.close();
firmwareStatus->setStatus("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"));
#else
process->start("avrdude",QStringList() << "-Cavrdude/avrdude.conf" << "-pm2560" << "-cstk500" << QString("-P").append(detectedcomport) << QString("-Uflash:w:").append(m_tempFirmwareFile->fileName()).append(":i"));
#endif
}
void ApmFirmwareConfig::firmwareProcessError(QProcess::ProcessError error)
{
qDebug() << "Error:" << error;
}
void ApmFirmwareConfig::burnButtonClicked()
{
QPushButton *senderbtn = qobject_cast<QPushButton*>(sender());
if (m_buttonToUrlMap.contains(senderbtn))
{
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");
}
}
void ApmFirmwareConfig::firmwareListError(QNetworkReply::NetworkError error)
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
qDebug() << "Error!" << reply->errorString();
}
bool ApmFirmwareConfig::stripVersionFromGitReply(QString url, QString reply,QString type,QString stable,QString *out)
{
if (url.contains(type) && url.contains("git-version.txt") && url.contains(stable))
{
QString version = reply.mid(reply.indexOf("APMVERSION:")+12).replace("\n","").replace("\r","").trimmed();
*out = version;
return true;
}
return false;
}
void ApmFirmwareConfig::firmwareListFinished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QString replystr = reply->readAll();
QString outstr = "";
if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-heli",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
ui.copterLabel->setText(outstr);
return;
}
if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-quad",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
ui.quadLabel->setText(outstr);
return;
}
if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-hexa",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
ui.hexaLabel->setText(outstr);
return;
}
if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-octa",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
ui.octaLabel->setText(outstr);
return;
}
if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-octa-quad",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
ui.octaQuadLabel->setText(outstr);
return;
}
if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-tri",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
ui.triLabel->setText(outstr);
return;
}
if (stripVersionFromGitReply(reply->url().toString(),replystr,"apm2-y6",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
ui.y6Label->setText(outstr);
return;
}
if (stripVersionFromGitReply(reply->url().toString(),replystr,"Plane",(m_betaFirmwareChecked ? "beta" : "stable"),&outstr))
{
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())
{
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();
}
}
xml.readNext();
}*/
}
ApmFirmwareConfig::~ApmFirmwareConfig()
{
}
#ifndef APMFIRMWARECONFIG_H
#define APMFIRMWARECONFIG_H
#include <QWidget>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>
#include <QTemporaryFile>
#include <QProcess>
#include "qserialport.h"
#include "ui_ApmFirmwareConfig.h"
#include "ApmFirmwareStatus.h"
class ApmFirmwareConfig : public QWidget
{
Q_OBJECT
public:
explicit ApmFirmwareConfig(QWidget *parent = 0);
~ApmFirmwareConfig();
private slots:
void firmwareListFinished();
void firmwareListError(QNetworkReply::NetworkError error);
void burnButtonClicked();
void betaFirmwareButtonClicked();
void downloadFinished();
void firmwareProcessFinished(int status);
void firmwareProcessReadyRead();
void firmwareProcessError(QProcess::ProcessError error);
private:
ApmFirmwareStatus *firmwareStatus;
QTemporaryFile *m_tempFirmwareFile;
QNetworkAccessManager *m_networkManager;
void requestFirmwares(bool beta);
bool stripVersionFromGitReply(QString url,QString reply,QString type,QString stable,QString *out);
bool m_betaFirmwareChecked;
QMap<QPushButton*,QString> m_buttonToUrlMap;
Ui::ApmFirmwareConfig ui;
class FirmwareDef
{
public:
QString url;
QString url2560;
QString url25602;
QString urlpx4;
QString type;
QString name;
QString desc;
int version;
};
QList<FirmwareDef> m_firmwareList;
};
#endif // APMFIRMWARECONFIG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ApmFirmwareConfig</class>
<widget class="QWidget" name="ApmFirmwareConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>958</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>&lt;h2&gt;Firmware&lt;/h2&gt;</string>
</property>
</widget>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>30</x>
<y>60</y>
<width>801</width>
<height>371</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="copterPushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/heli.png</normaloff>:/files/images/firmware/heli.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="copterLabel">
<property name="text">
<string>ArduCopter vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QPushButton" name="quadPushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/quadplus.png</normaloff>:/files/images/firmware/quadplus.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="quadLabel">
<property name="text">
<string>ArduCopter vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="planePushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/plane.png</normaloff>:/files/images/firmware/plane.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="planeLabel">
<property name="text">
<string>ArduPlane vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QPushButton" name="triPushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/triy.png</normaloff>:/files/images/firmware/triy.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="triLabel">
<property name="text">
<string>ArduCopter vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="3">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QPushButton" name="y6PushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/hexay.png</normaloff>:/files/images/firmware/hexay.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="y6Label">
<property name="text">
<string>ArduCopter vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="roverPushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/rover.png</normaloff>:/files/images/firmware/rover.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="roverLabel">
<property name="text">
<string>ArduRover vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="4">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QPushButton" name="octaPushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/octaplus.png</normaloff>:/files/images/firmware/octaplus.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="octaLabel">
<property name="text">
<string>ArduCopter vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="4">
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QPushButton" name="octaQuadPushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/octx.png</normaloff>:/files/images/firmware/octx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="octaQuadLabel">
<property name="text">
<string>ArduCopter vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="3">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QPushButton" name="hexaPushButton">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/firmware/hexaplus.png</normaloff>:/files/images/firmware/hexaplus.png</iconset>
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="hexaLabel">
<property name="text">
<string>ArduCopter vX.XX</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QPushButton" name="betaFirmwareButton">
<property name="geometry">
<rect>
<x>760</x>
<y>440</y>
<width>91</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Beta firmwares</string>
</property>
</widget>
</widget>
<resources>
<include location="../../../qgroundcontrol.qrc"/>
</resources>
<connections/>
</ui>
#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("<h2>" + message + "</h2>");
}
void ApmFirmwareStatus::resetProgress()
{
ui.progressBar->setValue(0);
}
void ApmFirmwareStatus::progressTick()
{
ui.progressBar->setValue(ui.progressBar->value()+1);
}
#ifndef APMFIRMWARESTATUS_H
#define APMFIRMWARESTATUS_H
#include <QWidget>
#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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ApmFirmwareStatus</class>
<widget class="QWidget" name="ApmFirmwareStatus">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>889</width>
<height>313</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="closePushButton">
<property name="geometry">
<rect>
<x>390</x>
<y>110</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
<widget class="QTextBrowser" name="textBrowser">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<width>871</width>
<height>141</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>291</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>&lt;h2&gt;Status&lt;/h2&gt;</string>
</property>
</widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>851</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
......@@ -60,9 +60,9 @@ ApmHardwareConfig::ApmHardwareConfig(QWidget *parent) : QWidget(parent)
connect(ui.frameTypeButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
QWidget *widget = new QWidget(this);
ui.stackedWidget->addWidget(widget); //Firmware placeholder.
m_buttonToConfigWidgetMap[ui.firmwareButton] = widget;
m_apmFirmwareConfig = new ApmFirmwareConfig(this);
ui.stackedWidget->addWidget(m_apmFirmwareConfig); //Firmware placeholder.
m_buttonToConfigWidgetMap[ui.firmwareButton] = m_apmFirmwareConfig;
connect(ui.firmwareButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_frameConfig = new FrameTypeConfig(this);
......
......@@ -49,6 +49,7 @@ This file is part of the QGROUNDCONTROL project
#include "CameraGimbalConfig.h"
#include "AntennaTrackerConfig.h"
#include "ApmPlaneLevel.h"
#include "ApmFirmwareConfig.h"
class ApmHardwareConfig : public QWidget
{
......@@ -63,6 +64,7 @@ private:
AccelCalibrationConfig *m_accelConfig;
RadioCalibrationConfig *m_radioConfig;
ApmFirmwareConfig *m_apmFirmwareConfig;
Radio3DRConfig *m_radio3drConfig;
BatteryMonitorConfig *m_batteryConfig;
SonarConfig *m_sonarConfig;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment