From bfed85a9b0228da3c36a9e6ef05aa1cecae3d300 Mon Sep 17 00:00:00 2001 From: edouard Date: Wed, 9 Mar 2011 00:07:07 +0000 Subject: [PATCH] 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 --- .../openpilotgcs/src/plugins/uploader/op_dfu.cpp | 15 ++++++++++----- ground/openpilotgcs/src/plugins/uploader/op_dfu.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp b/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp index b69d6e429..f1291fb1c 100644 --- a/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp @@ -80,18 +80,23 @@ DFUObject::DFUObject(bool _debug,bool _use_serial,QString portname): debug(_debu { send_delay=10; use_delay=true; - int numDevices=0; +// int numDevices=0; + QList devices; int count=0; - while((numDevices==0) && count < 10) + while((devices.length()==0) && count < 10) { if (debug) qDebug() << "."; delay::msleep(500); - numDevices = hidHandle.open(1,0x20a0,0x4117,0,0); //0xff9c,0x0001); + devices = USBMonitor::instance()->availableDevices(0x20a0,-1,-1,USBMonitor::Bootloader); count++; } - if(debug) - qDebug() << numDevices << " device(s) opened"; + if (devices.length()==1) { + hidHandle.open(1,devices.first().vendorID,devices.first().productID,0,0); + } else { + qDebug() << "More than one device, don't know what to do!"; + } + } } diff --git a/ground/openpilotgcs/src/plugins/uploader/op_dfu.h b/ground/openpilotgcs/src/plugins/uploader/op_dfu.h index 9e2c471ac..3ca773974 100644 --- a/ground/openpilotgcs/src/plugins/uploader/op_dfu.h +++ b/ground/openpilotgcs/src/plugins/uploader/op_dfu.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include