1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

More checks on the uploader gadget, to prevent potential crashes in case something goes wrong when halting the board.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2373 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-01-10 20:12:12 +00:00 committed by edouard
parent 2fee1781ec
commit 7aab98f3ee
2 changed files with 19 additions and 5 deletions

View File

@ -120,6 +120,7 @@ namespace OP_DFU {
OP_DFU::Status StatusRequest(); OP_DFU::Status StatusRequest();
bool EndOperation(); bool EndOperation();
int AbortOperation(void); int AbortOperation(void);
bool ready() { return mready; }
// Upload (send to device) commands // Upload (send to device) commands
OP_DFU::Status UploadDescription(QString description); OP_DFU::Status UploadDescription(QString description);

View File

@ -151,9 +151,9 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
fwIAP->getField("Command")->setValue("1122"); fwIAP->getField("Command")->setValue("1122");
connect(fwIAP,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool))); connect(fwIAP,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
currentStep = IAP_STATE_STEP_1; currentStep = IAP_STATE_STEP_1;
fwIAP->updated();
clearLog(); clearLog();
log(QString("IAP Step 1")); log(QString("IAP Step 1"));
fwIAP->updated();
break; break;
case IAP_STATE_STEP_1: case IAP_STATE_STEP_1:
if (!success) { if (!success) {
@ -166,8 +166,8 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
delay::msleep(600); delay::msleep(600);
fwIAP->getField("Command")->setValue("2233"); fwIAP->getField("Command")->setValue("2233");
currentStep = IAP_STATE_STEP_2; currentStep = IAP_STATE_STEP_2;
fwIAP->updated();
log(QString("IAP Step 2")); log(QString("IAP Step 2"));
fwIAP->updated();
break; break;
case IAP_STATE_STEP_2: case IAP_STATE_STEP_2:
if (!success) { if (!success) {
@ -180,8 +180,8 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
delay::msleep(600); delay::msleep(600);
fwIAP->getField("Command")->setValue("3344"); fwIAP->getField("Command")->setValue("3344");
currentStep = IAP_STEP_RESET; currentStep = IAP_STEP_RESET;
fwIAP->updated();
log(QString("IAP Step 3")); log(QString("IAP Step 3"));
fwIAP->updated();
break; break;
case IAP_STEP_RESET: case IAP_STEP_RESET:
{ {
@ -224,15 +224,28 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
else else
dfu = new DFUObject(DFU_DEBUG,true, getPortDevice(dli)); dfu = new DFUObject(DFU_DEBUG,true, getPortDevice(dli));
} }
if (!dfu->ready())
{
log("Could not enter DFU mode.");
delete dfu;
dfu = NULL;
return;
}
dfu->AbortOperation(); dfu->AbortOperation();
if(!dfu->enterDFU(0)) if(!dfu->enterDFU(0))
{ {
log("Could not enter DFU mode."); log("Could not enter DFU mode.");
delete dfu;
dfu = NULL;
return; return;
} }
//dfu.StatusRequest(); //dfu.StatusRequest();
dfu->findDevices(); dfu->findDevices();
log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s).")); log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s)."));
if (dfu->numberOfDevices < 0 || dfu->numberOfDevices > 3) {
log("Inconsistent number of devices! Aborting");
return;
}
// Delete all previous tabs: // Delete all previous tabs:
while (m_config->systemElements->count()) { while (m_config->systemElements->count()) {
QWidget *qw = m_config->systemElements->widget(0); QWidget *qw = m_config->systemElements->widget(0);
@ -340,7 +353,6 @@ void UploaderGadgetWidget::systemBoot()
log("You can now reconnect telemetry..."); log("You can now reconnect telemetry...");
delete dfu; // Frees up the USB/Serial port too delete dfu; // Frees up the USB/Serial port too
dfu = NULL; dfu = NULL;
} }
/** /**
@ -369,6 +381,7 @@ void UploaderGadgetWidget::systemRescue()
delete dfu; delete dfu;
dfu = NULL; dfu = NULL;
} }
// Now we're good to go:
clearLog(); clearLog();
log("**********************************************************"); log("**********************************************************");
log("** Follow those instructions to attempt a system rescue **"); log("** Follow those instructions to attempt a system rescue **");