mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-35 Further work on uploader gadget.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2057 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
1e0c2eef22
commit
7180c4fe2d
@ -29,7 +29,34 @@
|
||||
deviceWidget::deviceWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
|
||||
myDevice = new Ui_deviceWidget();
|
||||
myDevice->setupUi(this);
|
||||
}
|
||||
|
||||
void deviceWidget::setDeviceID(int devID){
|
||||
deviceID = devID;
|
||||
}
|
||||
|
||||
void deviceWidget::setDfu(OP_DFU *dfu)
|
||||
{
|
||||
m_dfu = dfu;
|
||||
}
|
||||
|
||||
/**
|
||||
Fills the various fields for the device
|
||||
*/
|
||||
void deviceWidget::populate()
|
||||
{
|
||||
int id = m_dfu->devices[deviceID].ID;
|
||||
myDevice->deviceID->setText(QString("ID: ") + QString::number(id));
|
||||
bool r = m_dfu->devices[deviceID].Readable;
|
||||
bool w = m_dfu->devices[deviceID].Writable;
|
||||
myDevice->deviceACL->setText(r ? "R" : "-" + w ? "W" : "-");
|
||||
int size=((OP_DFU::device)m_dfu->devices[deviceID]).SizeOfDesc;
|
||||
m_dfu->enterDFU(deviceID);
|
||||
QString str = m_dfu->DownloadDescription(size);
|
||||
myDevice->description->setMaxLength(size);
|
||||
myDevice->description->setText(str.left(str.indexOf(QChar(255))));
|
||||
|
||||
|
||||
}
|
||||
|
@ -29,16 +29,22 @@
|
||||
#define DEVICEWIDGET_H
|
||||
|
||||
#include "ui_devicewidget.h"
|
||||
#include "op_dfu.h"
|
||||
#include <QWidget>
|
||||
|
||||
class deviceWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit deviceWidget(QWidget *parent = 0);
|
||||
deviceWidget(QWidget *parent = 0);
|
||||
void setDeviceID(int devID);
|
||||
void setDfu(OP_DFU* dfu);
|
||||
void populate();
|
||||
|
||||
private:
|
||||
Ui_deviceWidget *myDevice;
|
||||
int deviceID;
|
||||
OP_DFU *m_dfu;
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QLineEdit" name="description"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
@ -61,37 +61,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QPushButton" name="retrieveButton">
|
||||
<property name="text">
|
||||
<string>Retrieve...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" rowspan="2">
|
||||
<widget class="QGraphicsView" name="devicePicture">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>160</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QPushButton" name="updateButton">
|
||||
<property name="text">
|
||||
<string>Update...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="verifyButton">
|
||||
<property name="text">
|
||||
<string>Verify...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="4">
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="font">
|
||||
@ -105,6 +74,37 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QGraphicsView" name="devicePicture">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>160</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="verifyButton">
|
||||
<property name="text">
|
||||
<string>Verify...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="updateButton">
|
||||
<property name="text">
|
||||
<string>Update...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QPushButton" name="retrieveButton">
|
||||
<property name="text">
|
||||
<string>Retrieve...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -39,7 +39,6 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset()));
|
||||
connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,6 +59,7 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
|
||||
connect(fwIAP,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
|
||||
currentStep = IAP_STATE_STEP_1;
|
||||
fwIAP->updated();
|
||||
clearLog();
|
||||
log(QString("IAP Step 1"));
|
||||
break;
|
||||
case IAP_STATE_STEP_1:
|
||||
@ -120,7 +120,9 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
|
||||
if(!dfu.enterDFU(0))
|
||||
{
|
||||
log("Could not enter DFU mode.");
|
||||
return;
|
||||
}
|
||||
m_config->boardStatus->setText("Bootloader");
|
||||
currentStep = IAP_STATE_BOOTLOADER;
|
||||
OP_DFU::Status ret=dfu.StatusRequest();
|
||||
dfu.findDevices();
|
||||
@ -132,9 +134,14 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
|
||||
delete qw;
|
||||
}
|
||||
for(int i=0;i<dfu.numberOfDevices;i++) {
|
||||
deviceWidget* dw = new deviceWidget();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -159,11 +166,13 @@ void UploaderGadgetWidget::systemReset()
|
||||
void UploaderGadgetWidget::systemBoot()
|
||||
{
|
||||
if (currentStep == IAP_STATE_BOOTLOADER) {
|
||||
clearLog();
|
||||
OP_DFU dfu(true);
|
||||
dfu.AbortOperation();
|
||||
if(!dfu.enterDFU(0))
|
||||
{
|
||||
log("Could not enter DFU mode.");
|
||||
return;
|
||||
}
|
||||
log("Booting system...");
|
||||
dfu.JumpToApp();
|
||||
@ -173,6 +182,10 @@ void UploaderGadgetWidget::systemBoot()
|
||||
RawHIDConnection *cnx = pm->getObject<RawHIDConnection>();
|
||||
cnx->resumePolling();
|
||||
m_config->bootButton->setEnabled(false);
|
||||
m_config->haltButton->setEnabled(true);
|
||||
m_config->resetButton->setEnabled(true);
|
||||
m_config->boardStatus->setText("Running");
|
||||
|
||||
} else {
|
||||
log("Not in bootloader mode!");
|
||||
}
|
||||
@ -180,7 +193,7 @@ void UploaderGadgetWidget::systemBoot()
|
||||
}
|
||||
|
||||
/**
|
||||
Update status
|
||||
Update log entry
|
||||
*/
|
||||
void UploaderGadgetWidget::log(QString str)
|
||||
{
|
||||
@ -188,6 +201,11 @@ void UploaderGadgetWidget::log(QString str)
|
||||
|
||||
}
|
||||
|
||||
void UploaderGadgetWidget::clearLog()
|
||||
{
|
||||
m_config->textBrowser->clear();
|
||||
}
|
||||
|
||||
//user pressed send, send file using a new thread with qymodem library
|
||||
void UploaderGadgetWidget::send()
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ private:
|
||||
IAPStep currentStep;
|
||||
bool resetOnly;
|
||||
void log(QString str);
|
||||
void clearLog();
|
||||
|
||||
QLineEdit* openFileNameLE;
|
||||
QextSerialPort *Port;
|
||||
|
Loading…
x
Reference in New Issue
Block a user