mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-35 : Attempt at implementing a "Manual" mode which guides the use to get into AHRS + MB BL Mode.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2130 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
03af1cdbc4
commit
05d8e2e36a
@ -13,16 +13,19 @@ DFUObject::DFUObject(bool _debug): debug(_debug)
|
||||
use_delay=true;
|
||||
int numDevices=0;
|
||||
int count=0;
|
||||
while(numDevices==0)
|
||||
while((numDevices==0) && count < 10)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << ".";
|
||||
delay::msleep(500);
|
||||
numDevices = hidHandle.open(1,0x20a0,0x4117,0,0); //0xff9c,0x0001);
|
||||
count++;
|
||||
/*
|
||||
if(++count==10)
|
||||
{
|
||||
count=0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
if(debug)
|
||||
qDebug() << numDevices << " device(s) opened";
|
||||
@ -30,6 +33,7 @@ DFUObject::DFUObject(bool _debug): debug(_debug)
|
||||
|
||||
DFUObject::~DFUObject()
|
||||
{
|
||||
hidHandle.close(0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,3,1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
@ -51,6 +51,17 @@ Only enabled if the system is halted.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="rescueButton">
|
||||
<property name="toolTip">
|
||||
<string>Start a guided procedure to manually
|
||||
recover a system which does not boot.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rescue</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
@ -80,19 +91,23 @@ Only enabled if the system is halted.</string>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="systemElements">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Mainboard</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<widget class="QTabWidget" name="systemElements">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Mainboard</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
@ -103,25 +118,24 @@ p, li { white-space: pre-wrap; }
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- You will get a list of devices.</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- You can then upload/download to/from each board as you wish</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- You can resume operations by pressing &quot;Boot&quot;</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Please connect your board through USB for firmware upload.</span></p></body></html></string>
|
||||
</property>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -31,6 +31,7 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
m_config = new Ui_UploaderWidget();
|
||||
m_config->setupUi(this);
|
||||
currentStep = IAP_STATE_READY;
|
||||
rescueStep = RESCUE_STEP0;
|
||||
resetOnly=false;
|
||||
dfu = NULL;
|
||||
|
||||
@ -39,6 +40,7 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader()));
|
||||
connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset()));
|
||||
connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot()));
|
||||
connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue()));
|
||||
|
||||
}
|
||||
|
||||
@ -132,9 +134,9 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
|
||||
dfu->findDevices();
|
||||
log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s)."));
|
||||
// Delete all previous tabs:
|
||||
for (int i=0; i< m_config->systemElements->count(); i++) {
|
||||
QWidget *qw = m_config->systemElements->widget(i);
|
||||
m_config->systemElements->removeTab(i);
|
||||
while (m_config->systemElements->count()) {
|
||||
QWidget *qw = m_config->systemElements->widget(0);
|
||||
m_config->systemElements->removeTab(0);
|
||||
delete qw;
|
||||
}
|
||||
for(int i=0;i<dfu->numberOfDevices;i++) {
|
||||
@ -207,6 +209,104 @@ void UploaderGadgetWidget::systemBoot()
|
||||
} else {
|
||||
log("Not in bootloader mode!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Attempt a guided procedure to put both boards in BL mode when
|
||||
the system is not bootable
|
||||
*/
|
||||
void UploaderGadgetWidget::systemRescue()
|
||||
{
|
||||
switch (rescueStep) {
|
||||
case RESCUE_STEP0: {
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
cm->disconnectDevice();
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
// stop the polling thread: otherwise it will mess up DFU
|
||||
RawHIDConnection *cnx = pm->getObject<RawHIDConnection>();
|
||||
cnx->suspendPolling();
|
||||
// Delete all previous tabs:
|
||||
while (m_config->systemElements->count()) {
|
||||
QWidget *qw = m_config->systemElements->widget(0);
|
||||
m_config->systemElements->removeTab(0);
|
||||
delete qw;
|
||||
}
|
||||
if (dfu) {
|
||||
delete dfu;
|
||||
dfu = NULL;
|
||||
}
|
||||
clearLog();
|
||||
log("**********************************************************");
|
||||
log("** Follow those instructions to attempt a system rescue **");
|
||||
log("**********************************************************");
|
||||
log("You will be prompted to first connect USB, then system power");
|
||||
log ("Connect USB in 3 seconds...");
|
||||
rescueStep = RESCUE_STEP1;
|
||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
||||
}
|
||||
break;
|
||||
case RESCUE_STEP1:
|
||||
rescueStep = RESCUE_STEP2;
|
||||
log (" ...2...");
|
||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
||||
break;
|
||||
case RESCUE_STEP2:
|
||||
rescueStep = RESCUE_STEP3;
|
||||
log(" ...1...");
|
||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
||||
break;
|
||||
case RESCUE_STEP3:
|
||||
log("... NOW!\n***\n");
|
||||
log("Connect Power in 1 second...");
|
||||
rescueStep = RESCUE_POWER2;
|
||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
||||
break;
|
||||
case RESCUE_POWER1:
|
||||
rescueStep = RESCUE_POWER2;
|
||||
log(" ...1...");
|
||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
||||
break;
|
||||
case RESCUE_POWER2:
|
||||
log("... NOW!\n***\nWaiting...");
|
||||
rescueStep = RESCUE_DETECT;
|
||||
QTimer::singleShot(3000, this, SLOT(systemRescue()));
|
||||
break;
|
||||
case RESCUE_DETECT:
|
||||
rescueStep = RESCUE_STEP0;
|
||||
log("Polling for devices...");
|
||||
repaint();
|
||||
if (!dfu)
|
||||
dfu = new DFUObject(true);
|
||||
if(!dfu->enterDFU(0))
|
||||
{
|
||||
log("Could not enter DFU mode.");
|
||||
return;
|
||||
}
|
||||
if(!dfu->findDevices())
|
||||
{
|
||||
log("Could not detect devices.");
|
||||
return;
|
||||
}
|
||||
log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s)."));
|
||||
if (dfu->numberOfDevices > 5) {
|
||||
log("Inconsistent number of devices, aborting!");
|
||||
return;
|
||||
}
|
||||
for(int i=0;i<dfu->numberOfDevices;i++) {
|
||||
deviceWidget* dw = new deviceWidget(this);
|
||||
dw->setDeviceID(i);
|
||||
dw->setDfu(dfu);
|
||||
dw->populate();
|
||||
m_config->systemElements->addTab(dw, QString("Device") + QString::number(i));
|
||||
}
|
||||
m_config->haltButton->setEnabled(false);
|
||||
m_config->resetButton->setEnabled(false);
|
||||
m_config->bootButton->setEnabled(true);
|
||||
currentStep = IAP_STATE_BOOTLOADER; // So that we can boot from the GUI afterwards.
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -216,6 +316,7 @@ void UploaderGadgetWidget::systemBoot()
|
||||
void UploaderGadgetWidget::log(QString str)
|
||||
{
|
||||
m_config->textBrowser->append(str);
|
||||
m_config->textBrowser->repaint();
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QThread>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
using namespace OP_DFU;
|
||||
@ -55,12 +56,14 @@ public:
|
||||
UploaderGadgetWidget(QWidget *parent = 0);
|
||||
~UploaderGadgetWidget();
|
||||
typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1, IAP_STATE_STEP_2, IAP_STEP_RESET, IAP_STATE_BOOTLOADER} IAPStep;
|
||||
typedef enum { RESCUE_STEP0, RESCUE_STEP1, RESCUE_STEP2, RESCUE_STEP3, RESCUE_POWER1, RESCUE_POWER2, RESCUE_DETECT } RescueStep;
|
||||
|
||||
|
||||
private:
|
||||
Ui_UploaderWidget *m_config;
|
||||
DFUObject *dfu;
|
||||
IAPStep currentStep;
|
||||
RescueStep rescueStep;
|
||||
bool resetOnly;
|
||||
void log(QString str);
|
||||
void clearLog();
|
||||
@ -73,6 +76,7 @@ private slots:
|
||||
void goToBootloader(UAVObject* = NULL, bool = false);
|
||||
void systemReset();
|
||||
void systemBoot();
|
||||
void systemRescue();
|
||||
};
|
||||
|
||||
#endif // UPLOADERGADGETWIDGET_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user