mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
OP-35 Uploader gadget: the "Reset" button now works. YMMV, please report. Other buttons do nothing so far. Also, small fix to uavtalk.cpp where a 'disconnect' call triggered segfaults on my system.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2054 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
b4a22c5984
commit
e74927c244
@ -73,7 +73,9 @@ UAVTalk::UAVTalk(QIODevice* iodev, UAVObjectManager* objMngr)
|
||||
|
||||
UAVTalk::~UAVTalk()
|
||||
{
|
||||
disconnect(io, SIGNAL(readyRead()), this, SLOT(processInputStream()));
|
||||
// According to Qt, it is not necessary to disconnect upon
|
||||
// object deletion.
|
||||
//disconnect(io, SIGNAL(readyRead()), this, SLOT(processInputStream()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,9 +2,11 @@
|
||||
<vendor>The OpenPilot Project</vendor>
|
||||
<copyright>(C) 2010 Jose Barros A.K.A. PT_Dreamer</copyright>
|
||||
<license>The GNU Public License (GPL) Version 3</license>
|
||||
<description>A plugin to Upload Firmware to the OpenPilot HW via Ymodem protocol</description>
|
||||
<description>A plugin to Upload Firmware to the OpenPilot HW via USB DFU</description>
|
||||
<url>http://www.openpilot.org</url>
|
||||
<dependencyList>
|
||||
<dependency name="Core" version="1.0.0"/>
|
||||
<dependency name="UAVObjects" version="1.0.0"/>
|
||||
<dependency name="RAWHid" version="1.0.0"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
||||
|
@ -2,7 +2,9 @@ TEMPLATE = lib
|
||||
TARGET = Uploader
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../plugins/uavobjects/uavobjects.pri)
|
||||
include(../../libs/qextserialport/qextserialport.pri)
|
||||
include(../../plugins/rawhid/rawhid.pri)
|
||||
include(../../libs/qymodem/qymodem.pri)
|
||||
HEADERS += uploadergadget.h \
|
||||
uploadergadgetconfiguration.h \
|
||||
|
@ -30,9 +30,109 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_config = new Ui_UploaderWidget();
|
||||
m_config->setupUi(this);
|
||||
currentStep = IAP_STATE_READY;
|
||||
resetOnly=false;
|
||||
|
||||
connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader()));
|
||||
connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Tell the mainboard to go to bootloader:
|
||||
- Send the relevant IAP commands
|
||||
- setup callback for MoBo acknowledge
|
||||
*/
|
||||
void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVObject *fwIAP = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("FirmwareIAPObj")));
|
||||
|
||||
switch (currentStep) {
|
||||
case IAP_STATE_READY:
|
||||
// The board is running, send the 1st IAP Reset order:
|
||||
fwIAP->getField("Command")->setValue("1122");
|
||||
connect(fwIAP,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
|
||||
currentStep = IAP_STATE_STEP_1;
|
||||
fwIAP->updated();
|
||||
log(QString("IAP Step 1"));
|
||||
break;
|
||||
case IAP_STATE_STEP_1:
|
||||
if (!success) {
|
||||
log(QString("Oops, failure step 1"));
|
||||
currentStep == IAP_STATE_READY;
|
||||
break;
|
||||
}
|
||||
delay::msleep(600);
|
||||
fwIAP->getField("Command")->setValue("2233");
|
||||
currentStep = IAP_STATE_STEP_2;
|
||||
fwIAP->updated();
|
||||
log(QString("IAP Step 2"));
|
||||
break;
|
||||
case IAP_STATE_STEP_2:
|
||||
if (!success) {
|
||||
log(QString("Oops, failure step 2"));
|
||||
currentStep == IAP_STATE_READY;
|
||||
break;
|
||||
}
|
||||
delay::msleep(600);
|
||||
fwIAP->getField("Command")->setValue("3344");
|
||||
currentStep = IAP_STEP_RESET;
|
||||
fwIAP->updated();
|
||||
log(QString("IAP Step 3"));
|
||||
break;
|
||||
case IAP_STEP_RESET: {
|
||||
currentStep = IAP_STATE_READY;
|
||||
if (success) {
|
||||
log("Oops, unexpected success step 3");
|
||||
log("Reset did NOT happen");
|
||||
break;
|
||||
}
|
||||
// The board is now reset: we have to disconnect telemetry
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
cm->disconnectDevice();
|
||||
log(QString("Board Reset"));
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
disconnect(fwIAP, SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
|
||||
if (resetOnly) {
|
||||
resetOnly=false;
|
||||
break;
|
||||
}
|
||||
// stop the polling thread: otherwise it will mess up DFU
|
||||
RawHIDConnection *cnx = pm->getObject<RawHIDConnection>();
|
||||
cnx->suspendPolling();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Tell the mainboard to reset:
|
||||
- Send the relevant IAP commands
|
||||
- setup callback for MoBo acknowledge
|
||||
*/
|
||||
void UploaderGadgetWidget::systemReset()
|
||||
{
|
||||
resetOnly = true;
|
||||
m_config->textBrowser->clear();
|
||||
log("Board Reset initiated.");
|
||||
goToBootloader();
|
||||
}
|
||||
|
||||
/**
|
||||
Update status
|
||||
*/
|
||||
void UploaderGadgetWidget::log(QString str)
|
||||
{
|
||||
m_config->textBrowser->append(str);
|
||||
|
||||
}
|
||||
|
||||
//user pressed send, send file using a new thread with qymodem library
|
||||
void UploaderGadgetWidget::send()
|
||||
{
|
||||
|
@ -29,6 +29,13 @@
|
||||
#define UPLOADERGADGETWIDGET_H
|
||||
|
||||
#include "ui_uploader.h"
|
||||
#include "delay.h"
|
||||
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
#include "uavobjects/uavobject.h"
|
||||
|
||||
#include "rawhid/rawhidplugin.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
#include <qymodem/src/qymodemsend.h>
|
||||
@ -41,7 +48,6 @@
|
||||
#include <QMessageBox>
|
||||
//using namespace qmapcontrol;
|
||||
|
||||
class Ui_UploaderWidget;
|
||||
|
||||
class UploaderGadgetWidget : public QWidget
|
||||
{
|
||||
@ -50,12 +56,16 @@ class UploaderGadgetWidget : public QWidget
|
||||
public:
|
||||
UploaderGadgetWidget(QWidget *parent = 0);
|
||||
~UploaderGadgetWidget();
|
||||
typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1, IAP_STATE_STEP_2, IAP_STEP_RESET} IAPStep;
|
||||
|
||||
void setPort(QextSerialPort* port);
|
||||
|
||||
|
||||
private:
|
||||
Ui_UploaderWidget *m_config;
|
||||
IAPStep currentStep;
|
||||
bool resetOnly;
|
||||
void log(QString str);
|
||||
|
||||
QLineEdit* openFileNameLE;
|
||||
QextSerialPort *Port;
|
||||
@ -70,6 +80,8 @@ private slots:
|
||||
void error(QString errorString,int errorNumber);
|
||||
void info(QString infoString,int infoNumber);
|
||||
void updatePercSlot(int);
|
||||
void goToBootloader(UAVObject* = NULL, bool = false);
|
||||
void systemReset();
|
||||
};
|
||||
|
||||
#endif // UPLOADERGADGETWIDGET_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user