mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Merge remote-tracking branch 'remotes/origin/PT-bugfix-ground' into bugfix-ground
This commit is contained in:
commit
d591d509ed
@ -33,7 +33,6 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
m_config = new Ui_UploaderWidget();
|
m_config = new Ui_UploaderWidget();
|
||||||
m_config->setupUi(this);
|
m_config->setupUi(this);
|
||||||
currentStep = IAP_STATE_READY;
|
currentStep = IAP_STATE_READY;
|
||||||
rescueStep = RESCUE_STEP0;
|
|
||||||
resetOnly=false;
|
resetOnly=false;
|
||||||
dfu = NULL;
|
dfu = NULL;
|
||||||
|
|
||||||
@ -393,8 +392,6 @@ void UploaderGadgetWidget::systemBoot()
|
|||||||
void UploaderGadgetWidget::systemRescue()
|
void UploaderGadgetWidget::systemRescue()
|
||||||
{
|
{
|
||||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||||
switch (rescueStep) {
|
|
||||||
case RESCUE_STEP0: {
|
|
||||||
cm->disconnectDevice();
|
cm->disconnectDevice();
|
||||||
// stop the polling thread: otherwise it will mess up DFU
|
// stop the polling thread: otherwise it will mess up DFU
|
||||||
cm->suspendPolling();
|
cm->suspendPolling();
|
||||||
@ -419,29 +416,48 @@ void UploaderGadgetWidget::systemRescue()
|
|||||||
log("** Follow those instructions to attempt a system rescue **");
|
log("** Follow those instructions to attempt a system rescue **");
|
||||||
log("**********************************************************");
|
log("**********************************************************");
|
||||||
log("You will be prompted to first connect USB, then system power");
|
log("You will be prompted to first connect USB, then system power");
|
||||||
log ("Connect USB in 2 seconds...");
|
if(USBMonitor::instance()->availableDevices(0x20a0,-1,-1,-1).length()>0)
|
||||||
rescueStep = RESCUE_STEP1;
|
{
|
||||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
if(QMessageBox::warning(this,tr("OpenPilot Uploader"),tr("Please disconnect all openpilot boards"),QMessageBox::Ok,QMessageBox::Cancel)==QMessageBox::Cancel)
|
||||||
|
{
|
||||||
|
m_config->rescueButton->setEnabled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case RESCUE_STEP1:
|
// Now we're good to go:
|
||||||
rescueStep = RESCUE_STEP2;
|
clearLog();
|
||||||
log (" ...1...");
|
log("**********************************************************");
|
||||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
log("** Follow those instructions to attempt a system rescue **");
|
||||||
break;
|
log("**********************************************************");
|
||||||
case RESCUE_STEP2:
|
log("You will be prompted to first connect USB, then system power");
|
||||||
rescueStep = RESCUE_STEP3;
|
pd = new QProgressDialog(tr("Please connect the board (USB only!)"), tr("Cancel"), 0, 20);
|
||||||
log(" ...Now!");
|
QProgressBar * bar=new QProgressBar(pd);
|
||||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
bar->setFormat("Timeout");
|
||||||
break;
|
pd->setBar(bar);
|
||||||
case RESCUE_STEP3:
|
pd->setMinimumDuration(0);
|
||||||
|
pd->setRange(0,20);
|
||||||
|
connect(pd, SIGNAL(canceled()), this, SLOT(cancel()));
|
||||||
|
t = new QTimer(this);
|
||||||
|
connect(t, SIGNAL(timeout()), this, SLOT(perform()));
|
||||||
|
t->start(1000);
|
||||||
|
connect(USBMonitor::instance(), SIGNAL(deviceDiscovered(USBPortInfo)),&q, SLOT(quit()));
|
||||||
|
q.exec();
|
||||||
|
if(!t->isActive())
|
||||||
|
{
|
||||||
|
pd->close();
|
||||||
|
t->stop();
|
||||||
|
QMessageBox::warning(this,tr("Openpilot Uploader"),tr("No board connection was detected!"));
|
||||||
|
m_config->rescueButton->setEnabled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pd->close();
|
||||||
|
t->stop();
|
||||||
log("... Detecting First Board...");
|
log("... Detecting First Board...");
|
||||||
repaint();
|
repaint();
|
||||||
dfu = new DFUObject(DFU_DEBUG, false, QString());
|
dfu = new DFUObject(DFU_DEBUG, false, QString());
|
||||||
dfu->AbortOperation();
|
dfu->AbortOperation();
|
||||||
if(!dfu->enterDFU(0))
|
if(!dfu->enterDFU(0))
|
||||||
{
|
{
|
||||||
rescueStep = RESCUE_STEP0;
|
|
||||||
log("Could not enter DFU mode.");
|
log("Could not enter DFU mode.");
|
||||||
delete dfu;
|
delete dfu;
|
||||||
dfu = NULL;
|
dfu = NULL;
|
||||||
@ -451,7 +467,6 @@ void UploaderGadgetWidget::systemRescue()
|
|||||||
}
|
}
|
||||||
if(!dfu->findDevices() || (dfu->numberOfDevices != 1))
|
if(!dfu->findDevices() || (dfu->numberOfDevices != 1))
|
||||||
{
|
{
|
||||||
rescueStep = RESCUE_STEP0;
|
|
||||||
log("Could not detect a board, aborting!");
|
log("Could not detect a board, aborting!");
|
||||||
delete dfu;
|
delete dfu;
|
||||||
dfu = NULL;
|
dfu = NULL;
|
||||||
@ -459,23 +474,11 @@ void UploaderGadgetWidget::systemRescue()
|
|||||||
m_config->rescueButton->setEnabled(true);
|
m_config->rescueButton->setEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rescueStep = RESCUE_POWER1;
|
if(QMessageBox::question(this,tr("OpenPilot Uploader"),tr("If you want to search for other boards connect power now and press Yes"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
||||||
log("Connect Power in 2 second...");
|
{
|
||||||
log("(not required on CopterControl)");
|
log("\nWaiting...");
|
||||||
QTimer::singleShot(1000, this, SLOT(systemRescue()));
|
QTimer::singleShot(3000, &q, SLOT(quit()));
|
||||||
break;
|
q.exec();
|
||||||
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(5000, this, SLOT(systemRescue()));
|
|
||||||
break;
|
|
||||||
case RESCUE_DETECT:
|
|
||||||
rescueStep = RESCUE_STEP0;
|
|
||||||
log("Detecting second board...");
|
log("Detecting second board...");
|
||||||
repaint();
|
repaint();
|
||||||
if(!dfu->findDevices())
|
if(!dfu->findDevices())
|
||||||
@ -489,6 +492,7 @@ void UploaderGadgetWidget::systemRescue()
|
|||||||
m_config->rescueButton->setEnabled(true);
|
m_config->rescueButton->setEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s)."));
|
log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s)."));
|
||||||
if (dfu->numberOfDevices > 5) {
|
if (dfu->numberOfDevices > 5) {
|
||||||
log("Inconsistent number of devices, aborting!");
|
log("Inconsistent number of devices, aborting!");
|
||||||
@ -510,7 +514,20 @@ void UploaderGadgetWidget::systemRescue()
|
|||||||
m_config->bootButton->setEnabled(true);
|
m_config->bootButton->setEnabled(true);
|
||||||
m_config->rescueButton->setEnabled(false);
|
m_config->rescueButton->setEnabled(false);
|
||||||
currentStep = IAP_STATE_BOOTLOADER; // So that we can boot from the GUI afterwards.
|
currentStep = IAP_STATE_BOOTLOADER; // So that we can boot from the GUI afterwards.
|
||||||
|
}
|
||||||
|
void UploaderGadgetWidget::perform()
|
||||||
|
{
|
||||||
|
if(pd->value()==19)
|
||||||
|
{
|
||||||
|
t->stop();
|
||||||
|
q.exit();
|
||||||
}
|
}
|
||||||
|
pd->setValue(pd->value()+1);
|
||||||
|
}
|
||||||
|
void UploaderGadgetWidget::cancel()
|
||||||
|
{
|
||||||
|
t->stop();
|
||||||
|
q.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -538,6 +555,11 @@ UploaderGadgetWidget::~UploaderGadgetWidget()
|
|||||||
m_config->systemElements->removeTab(0);
|
m_config->systemElements->removeTab(0);
|
||||||
delete qw;
|
delete qw;
|
||||||
}
|
}
|
||||||
|
if (pd)
|
||||||
|
delete pd;
|
||||||
|
if (t)
|
||||||
|
delete t;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
using namespace OP_DFU;
|
using namespace OP_DFU;
|
||||||
|
|
||||||
@ -64,7 +65,6 @@ public:
|
|||||||
UploaderGadgetWidget(QWidget *parent = 0);
|
UploaderGadgetWidget(QWidget *parent = 0);
|
||||||
~UploaderGadgetWidget();
|
~UploaderGadgetWidget();
|
||||||
typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1, IAP_STATE_STEP_2, IAP_STEP_RESET, IAP_STATE_BOOTLOADER} IAPStep;
|
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;
|
|
||||||
void log(QString str);
|
void log(QString str);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -75,13 +75,13 @@ private:
|
|||||||
Ui_UploaderWidget *m_config;
|
Ui_UploaderWidget *m_config;
|
||||||
DFUObject *dfu;
|
DFUObject *dfu;
|
||||||
IAPStep currentStep;
|
IAPStep currentStep;
|
||||||
RescueStep rescueStep;
|
|
||||||
bool resetOnly;
|
bool resetOnly;
|
||||||
void clearLog();
|
void clearLog();
|
||||||
QString getPortDevice(const QString &friendName);
|
QString getPortDevice(const QString &friendName);
|
||||||
|
QProgressDialog* pd;
|
||||||
|
QTimer* t;
|
||||||
QLineEdit* openFileNameLE;
|
QLineEdit* openFileNameLE;
|
||||||
|
QEventLoop q;
|
||||||
private slots:
|
private slots:
|
||||||
void error(QString errorString,int errorNumber);
|
void error(QString errorString,int errorNumber);
|
||||||
void info(QString infoString,int infoNumber);
|
void info(QString infoString,int infoNumber);
|
||||||
@ -90,6 +90,8 @@ private slots:
|
|||||||
void systemBoot();
|
void systemBoot();
|
||||||
void systemRescue();
|
void systemRescue();
|
||||||
void getSerialPorts();
|
void getSerialPorts();
|
||||||
|
void perform();
|
||||||
|
void cancel();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user