1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

OP-35 Fix complile issue on Win7 (please confirm), Halt button now puts the mainboard into bootloader mode. Nothing more...

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2055 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-11-01 18:15:48 +00:00 committed by edouard
parent e74927c244
commit 8d2c9c37fb
9 changed files with 248 additions and 19 deletions

View File

@ -33,8 +33,9 @@
#include <stdint.h>
#include <QDebug>
#include <QString>
#include "rawhid_global.h"
class pjrc_rawhid
class RAWHID_EXPORT pjrc_rawhid
{
public:
pjrc_rawhid();

View File

@ -98,9 +98,9 @@ QStringList RawHIDConnection::availableDevices()
QMutexLocker locker(&m_enumMutex);
QStringList devices;
pjrc_rawhid dev;
if (enablePolling) {
pjrc_rawhid dev;
//open all device we can
int opened = dev.open(MAX_DEVICES, VID, PID, USAGE_PAGE, USAGE);

View File

@ -0,0 +1,35 @@
/**
******************************************************************************
*
* @file devicewidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup YModemUploader YModem Serial Uploader Plugin
* @{
* @brief The YModem protocol serial uploader plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "devicewidget.h"
deviceWidget::deviceWidget(QWidget *parent) :
QWidget(parent)
{
myDevice = new Ui_deviceWidget();
myDevice->setupUi(this);
}

View File

@ -0,0 +1,49 @@
/**
******************************************************************************
*
* @file devicewidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup YModemUploader YModem Serial Uploader Plugin
* @{
* @brief The YModem protocol serial uploader plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DEVICEWIDGET_H
#define DEVICEWIDGET_H
#include "ui_devicewidget.h"
#include <QWidget>
class deviceWidget : public QWidget
{
Q_OBJECT
public:
explicit deviceWidget(QWidget *parent = 0);
private:
Ui_deviceWidget *myDevice;
signals:
public slots:
};
#endif // DEVICEWIDGET_H

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>deviceWidget</class>
<widget class="QWidget" name="deviceWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>236</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="2">
<widget class="QLineEdit" name="description"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="deviceID">
<property name="text">
<string>DeviceID</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="deviceACL">
<property name="text">
<string>ReadWrite</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="maxCodeSize">
<property name="text">
<string>MaxCodeSize</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="fwCRC">
<property name="text">
<string>fwCRC</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="BLVersion">
<property name="text">
<string>BootLoaderVersion</string>
</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">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -8,32 +8,29 @@ OP_DFU::OP_DFU(bool _debug): debug(_debug)
send_delay=10;
use_delay=true;
int numDevices=0;
cout<<"Please connect device now\n";
int count=0;
while(numDevices==0)
{
cout<<".";
if (debug)
qDebug() << ".";
delay::msleep(500);
numDevices = hidHandle.open(1,0x20a0,0x4117,0,0); //0xff9c,0x0001);
if(++count==10)
{
cout<<"\r";
cout<<" ";
cout<<"\r";
count=0;
}
}
if(debug)
qDebug() << numDevices << " device(s) opened";
}
bool OP_DFU::SaveByteArrayToFile(QString const & sfile, const QByteArray &array)
{
QFile file(sfile);
//QFile file("in.txt");
if (!file.open(QIODevice::WriteOnly))
{
if(debug)
qDebug()<<"Cant open file";
qDebug()<<"Can't open file";
return false;
}
file.write(array);
@ -59,7 +56,7 @@ bool OP_DFU::enterDFU(int const &devNumber)
if(result<1)
return false;
if(debug)
qDebug() << result << " bytes sent";
qDebug() << "EnterDFU: " << result << " bytes sent";
return true;
}
bool OP_DFU::StartUpload(qint32 const & numberOfBytes, TransferTypes const & type,quint32 crc)
@ -324,6 +321,7 @@ void OP_DFU::JumpToApp()
int result = hidHandle.send(0,buf, BUF_LEN, 500);
}
OP_DFU::Status OP_DFU::StatusRequest()
{
char buf[BUF_LEN];
@ -340,19 +338,18 @@ OP_DFU::Status OP_DFU::StatusRequest()
int result = hidHandle.send(0,buf, BUF_LEN, 10000);
if(debug)
qDebug() << result << " bytes sent";
qDebug() << "StatusRequest: " << result << " bytes sent";
result = hidHandle.receive(0,buf,BUF_LEN,10000);
if(debug)
qDebug() << result << " bytes received";
qDebug() << "StatusRequest: " << result << " bytes received";
if(buf[1]==OP_DFU::Status_Rep)
{
return (OP_DFU::Status)buf[6];
}
else
return OP_DFU::abort;
}
bool OP_DFU::findDevices()
{
devices.clear();

View File

@ -13,7 +13,8 @@ HEADERS += uploadergadget.h \
uploadergadgetwidget.h \
uploaderplugin.h \
op_dfu.h \
delay.h
delay.h \
devicewidget.h
SOURCES += uploadergadget.cpp \
uploadergadgetconfiguration.cpp \
uploadergadgetfactory.cpp \
@ -21,8 +22,10 @@ SOURCES += uploadergadget.cpp \
uploadergadgetwidget.cpp \
uploaderplugin.cpp \
op_dfu.cpp \
delay.cpp
delay.cpp \
devicewidget.cpp
OTHER_FILES += Uploader.pluginspec
FORMS += \
uploader.ui
uploader.ui \
devicewidget.ui

View File

@ -33,6 +33,8 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
currentStep = IAP_STATE_READY;
resetOnly=false;
//m_config->systemElements->addTab((QWidget*)new deviceWidget(),QString("Device"));
connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader()));
connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset()));
@ -62,7 +64,9 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
case IAP_STATE_STEP_1:
if (!success) {
log(QString("Oops, failure step 1"));
log("Reset did NOT happen");
currentStep == IAP_STATE_READY;
disconnect(fwIAP, SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
break;
}
delay::msleep(600);
@ -74,7 +78,9 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
case IAP_STATE_STEP_2:
if (!success) {
log(QString("Oops, failure step 2"));
log("Reset did NOT happen");
currentStep == IAP_STATE_READY;
disconnect(fwIAP, SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
break;
}
delay::msleep(600);
@ -88,12 +94,13 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
if (success) {
log("Oops, unexpected success step 3");
log("Reset did NOT happen");
disconnect(fwIAP, SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
break;
}
// The board is now reset: we have to disconnect telemetry
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
cm->disconnectDevice();
log(QString("Board Reset"));
log("Board Reset");
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
disconnect(fwIAP, SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToBootloader(UAVObject*, bool)));
@ -105,8 +112,29 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
RawHIDConnection *cnx = pm->getObject<RawHIDConnection>();
cnx->suspendPolling();
}
// Tell the mainboard to get into bootloader state:
log("Going into Bootloader mode...");
OP_DFU dfu(true);
dfu.AbortOperation();
if(!dfu.enterDFU(0))
{
log("Could not enter DFU mode.");
}
OP_DFU::Status ret=dfu.StatusRequest();
dfu.findDevices();
log(QString("Found ") + QString::number(dfu.numberOfDevices) + QString(" device(s)."));
// Delete all previous tabs:
for (int i=0; i< m_config->systemElements->count(); i++) {
QWidget *qw = m_config->systemElements->widget(i);
m_config->systemElements->removeTab(i);
delete qw;
}
for(int i=0;i<dfu.numberOfDevices;i++) {
deviceWidget* dw = new deviceWidget();
m_config->systemElements->addTab(dw, QString("Device") + QString::number(i));
}
}
}
}

View File

@ -30,6 +30,8 @@
#include "ui_uploader.h"
#include "delay.h"
#include "devicewidget.h"
#include "op_dfu.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"