1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

GCS-Made autouploader fetch fw from fw bundle

Fw bundle is built with "make package_resource".
This target is a dependency of the package target but needs testing
on the different systems.
If the bundle is not present the build will not fail and
the wizard will jump the autoupdate page (not working FIXME)
This commit is contained in:
PT_Dreamer 2012-10-06 23:23:44 +01:00
parent f6443fc995
commit 4ef8b78ff8
8 changed files with 27 additions and 11 deletions

View File

@ -13,6 +13,8 @@ AutoUpdatePage::AutoUpdatePage(SetupWizard *wizard, QWidget *parent) :
ui->setupUi(this);
ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance();
UploaderGadgetFactory * uploader=pm->getObject<UploaderGadgetFactory>();
if(!uploader->isAutoUpdateCapable())
wizard->next();//FIXME DOESN'T WORK
connect(ui->startUpdate,SIGNAL(clicked()),uploader,SIGNAL(autoUpdate()));
connect(uploader,SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep,QVariant)),this,SLOT(updateStatus(uploader::AutoUpdateStep,QVariant)));
}

View File

@ -43,6 +43,6 @@ FORMS += \
RESOURCES += \
uploader.qrc
exists( ../../../../build/ground/opfw_resource/opfw_resource.qrc ) {
\ ../../../../build/ground/opfw_resource/opfw_resource.qrc
exists( ../../../../../build/ground/opfw_resource/opfw_resource.qrc ) {
RESOURCES += ../../../../build/ground/opfw_resource/opfw_resource.qrc
}

View File

@ -17,7 +17,4 @@
<file>images/gcs-board-cc3d.png</file>
<file>images/pipx.png</file>
</qresource>
<qresource prefix="/firmware">
<file>firmware/fw_coptercontrol.opfw</file>
</qresource>
</RCC>

View File

@ -33,7 +33,7 @@
#include "uploadergadgetwidget.h"
UploaderGadgetFactory::UploaderGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("Uploader"), tr("Uploader"), parent)
IUAVGadgetFactory(QString("Uploader"), tr("Uploader"), parent),isautocapable(false)
{
}
@ -44,6 +44,7 @@ UploaderGadgetFactory::~UploaderGadgetFactory()
Core::IUAVGadget* UploaderGadgetFactory::createGadget(QWidget *parent)
{
UploaderGadgetWidget* gadgetWidget = new UploaderGadgetWidget(parent);
isautocapable=gadgetWidget->autoUpdateCapable();
connect(this,SIGNAL(autoUpdate()),gadgetWidget,SLOT(autoUpdate()));
connect(gadgetWidget,SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep,QVariant)),this,SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep,QVariant)));
return new UploaderGadget(QString("Uploader"), gadgetWidget, parent);
@ -53,4 +54,7 @@ IUAVGadgetConfiguration *UploaderGadgetFactory::createConfiguration(QSettings* q
{
return new UploaderGadgetConfiguration(QString("Uploader"), qSettings);
}
bool UploaderGadgetFactory::isAutoUpdateCapable()
{
return isautocapable;
}

View File

@ -47,6 +47,9 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
bool isAutoUpdateCapable();
private:
bool isautocapable;
signals:
void autoUpdateSignal(uploader::AutoUpdateStep,QVariant);
void autoUpdate();

View File

@ -432,6 +432,11 @@ void UploaderGadgetWidget::commonSystemBoot(bool safeboot)
delete dfu; // Frees up the USB/Serial port too
dfu = NULL;
}
bool UploaderGadgetWidget::autoUpdateCapable()
{
return QFile::exists(":/build/fw_coptercontrol/fw_coptercontrol.opfw");
}
bool UploaderGadgetWidget::autoUpdate()
{
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
@ -495,18 +500,23 @@ bool UploaderGadgetWidget::autoUpdate()
switch (dfu->devices[0].ID)
{
case 0x401:
filename="fw_coptercontrol.opfw";
filename="fw_coptercontrol";
break;
case 0x402:
filename="fw_coptercontrol.opfw";
filename="fw_coptercontrol";
break;
default:
emit autoUpdateSignal(FAILURE,QVariant());
return false;
break;
}
filename=":/firmware/firmware/"+filename;
filename=":/build/"+filename+"/"+filename+".opfw";
QByteArray firmware;
if(!QFile::exists(filename))
{
emit autoUpdateSignal(FAILURE,QVariant());
return false;
}
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
emit autoUpdateSignal(FAILURE,QVariant());

View File

@ -70,7 +70,7 @@ public:
UploaderGadgetWidget(QWidget *parent = 0);
~UploaderGadgetWidget();
void log(QString str);
bool autoUpdateCapable();
public slots:
void onAutopilotConnect();
void onAutopilotDisconnect();