diff --git a/ground/src/plugins/uploader/devicewidget.cpp b/ground/src/plugins/uploader/devicewidget.cpp index a0e79353a..6ad096694 100644 --- a/ground/src/plugins/uploader/devicewidget.cpp +++ b/ground/src/plugins/uploader/devicewidget.cpp @@ -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)))); + + +} diff --git a/ground/src/plugins/uploader/devicewidget.h b/ground/src/plugins/uploader/devicewidget.h index 766340657..2118e3fbb 100644 --- a/ground/src/plugins/uploader/devicewidget.h +++ b/ground/src/plugins/uploader/devicewidget.h @@ -29,16 +29,22 @@ #define DEVICEWIDGET_H #include "ui_devicewidget.h" +#include "op_dfu.h" #include 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: diff --git a/ground/src/plugins/uploader/devicewidget.ui b/ground/src/plugins/uploader/devicewidget.ui index 3409cdead..1a38c68ef 100644 --- a/ground/src/plugins/uploader/devicewidget.ui +++ b/ground/src/plugins/uploader/devicewidget.ui @@ -16,7 +16,7 @@ - + @@ -61,37 +61,6 @@ - - - - Retrieve... - - - - - - - - 160 - 160 - - - - - - - - Update... - - - - - - - Verify... - - - @@ -105,6 +74,37 @@ + + + + + 160 + 160 + + + + + + + + Verify... + + + + + + + Update... + + + + + + + Retrieve... + + + diff --git a/ground/src/plugins/uploader/uploadergadgetwidget.cpp b/ground/src/plugins/uploader/uploadergadgetwidget.cpp index cbd2a09a6..ada0b111c 100755 --- a/ground/src/plugins/uploader/uploadergadgetwidget.cpp +++ b/ground/src/plugins/uploader/uploadergadgetwidget.cpp @@ -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;isetDeviceID(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(); 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() { diff --git a/ground/src/plugins/uploader/uploadergadgetwidget.h b/ground/src/plugins/uploader/uploadergadgetwidget.h index 77f5ab6af..f843fad7a 100755 --- a/ground/src/plugins/uploader/uploadergadgetwidget.h +++ b/ground/src/plugins/uploader/uploadergadgetwidget.h @@ -68,6 +68,7 @@ private: IAPStep currentStep; bool resetOnly; void log(QString str); + void clearLog(); QLineEdit* openFileNameLE; QextSerialPort *Port;