1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Update uploader gadget to use the USB monitor to get the list of available devices.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3013 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-03-09 00:07:07 +00:00 committed by edouard
parent 51a8a2d525
commit bfed85a9b0
2 changed files with 11 additions and 5 deletions

View File

@ -80,18 +80,23 @@ DFUObject::DFUObject(bool _debug,bool _use_serial,QString portname): debug(_debu
{ {
send_delay=10; send_delay=10;
use_delay=true; use_delay=true;
int numDevices=0; // int numDevices=0;
QList<USBPortInfo> devices;
int count=0; int count=0;
while((numDevices==0) && count < 10) while((devices.length()==0) && count < 10)
{ {
if (debug) if (debug)
qDebug() << "."; qDebug() << ".";
delay::msleep(500); delay::msleep(500);
numDevices = hidHandle.open(1,0x20a0,0x4117,0,0); //0xff9c,0x0001); devices = USBMonitor::instance()->availableDevices(0x20a0,-1,-1,USBMonitor::Bootloader);
count++; count++;
} }
if(debug) if (devices.length()==1) {
qDebug() << numDevices << " device(s) opened"; hidHandle.open(1,devices.first().vendorID,devices.first().productID,0,0);
} else {
qDebug() << "More than one device, don't know what to do!";
}
} }
} }

View File

@ -3,6 +3,7 @@
#include <QByteArray> #include <QByteArray>
#include <rawhid/pjrc_rawhid.h> #include <rawhid/pjrc_rawhid.h>
#include <rawhid/usbmonitor.h>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QThread> #include <QThread>