mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-22 14:19:42 +01:00
Upate RawHID plugin to cope with the new PID/VIDs
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3021 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
3fec8a6d72
commit
cb95edaedc
@ -31,6 +31,7 @@
|
||||
#include "coreplugin/connectionmanager.h"
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <QtGlobal>
|
||||
#include <QList>
|
||||
#include <QMutexLocker>
|
||||
#include <QWaitCondition>
|
||||
|
||||
@ -298,30 +299,27 @@ RawHID::RawHID(const QString &deviceName)
|
||||
m_writeThread(NULL),
|
||||
m_mutex(NULL)
|
||||
{
|
||||
int opened = 0;
|
||||
m_mutex = new QMutex(QMutex::Recursive);
|
||||
|
||||
// detect if the USB device is unplugged
|
||||
QObject::connect(&dev, SIGNAL(deviceUnplugged(int)), this, SLOT(onDeviceUnplugged(int)));
|
||||
|
||||
//find the device the user want to open and close the other
|
||||
int opened = dev.open(USB_MAX_DEVICES, USB_VID, USB_PID, USB_USAGE_PAGE, USB_USAGE);
|
||||
|
||||
//for each devices found, get serial number and close
|
||||
for (int i = 0; i < opened; i++)
|
||||
{
|
||||
if (deviceName == dev.getserial(i))
|
||||
m_deviceNo = i;
|
||||
else
|
||||
dev.close(i);
|
||||
}
|
||||
QList<USBPortInfo> devices = USBMonitor::instance()->availableDevices(USBMonitor::idVendor_OpenPilot,-1,-1,USBMonitor::Running);
|
||||
foreach( USBPortInfo device, devices) {
|
||||
if (deviceName == device.serialNumber) {
|
||||
opened = dev.open(1,device.vendorID, device.productID,USB_USAGE_PAGE,USB_USAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//didn't find the device we are trying to open (shouldnt happen)
|
||||
if (m_deviceNo < 0)
|
||||
if (opened == 0)
|
||||
{
|
||||
qDebug() << "Error: cannot open device " << deviceName;
|
||||
return;
|
||||
}
|
||||
|
||||
m_deviceNo = 0;
|
||||
m_readThread = new RawHIDReadThread(this);
|
||||
m_writeThread = new RawHIDWriteThread(this);
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QByteArray>
|
||||
|
||||
#include "pjrc_rawhid.h"
|
||||
#include "usbmonitor.h"
|
||||
|
||||
//helper classes
|
||||
class RawHIDReadThread;
|
||||
|
@ -85,7 +85,7 @@ QStringList RawHIDConnection::availableDevices()
|
||||
{
|
||||
QStringList devices;
|
||||
|
||||
QList<USBPortInfo> portsList = m_usbMonitor.availableDevices(USB_VID, -1, -1,USBMonitor::Running);
|
||||
QList<USBPortInfo> portsList = m_usbMonitor.availableDevices(USBMonitor::idVendor_OpenPilot, -1, -1,USBMonitor::Running);
|
||||
// We currently list devices by their serial number
|
||||
foreach(USBPortInfo prt, portsList) {
|
||||
devices.append(prt.serialNumber);
|
||||
|
@ -111,6 +111,13 @@ public:
|
||||
Running = 0x02
|
||||
};
|
||||
|
||||
enum USBConstants {
|
||||
idVendor_OpenPilot = 0x20a0,
|
||||
idProduct_OpenPilot = 0x415a,
|
||||
idProduct_PipXtreme = 0x415b,
|
||||
idProduct_CopterControl = 0x415c
|
||||
};
|
||||
|
||||
static USBMonitor *instance();
|
||||
|
||||
USBMonitor(QObject *parent = 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user