1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

OP-334 : reverted opening method in RawHID plugin, as the new pjrc_rawhid class does not play nice with the USBMonitor system in case several devices with the same PID/VID are present on the system (such as two PipX for example)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3031 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-03-13 13:03:11 +00:00 committed by edouard
parent 0c2c70bb60
commit afb7aaf374

View File

@ -299,27 +299,39 @@ 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)));
QList<USBPortInfo> devices = USBMonitor::instance()->availableDevices(USBMonitor::idVendor_OpenPilot,-1,-1,USBMonitor::Running);
int opened = dev.open(USB_MAX_DEVICES, USBMonitor::idVendor_OpenPilot, -1, USB_USAGE_PAGE, USB_USAGE);
for (int i =0; i< opened; i++) {
if (deviceName == dev.getserial(i))
m_deviceNo = i;
else
dev.close(i);
}
/*
// TODO: NOT WORKING FOR MULTIPLE DEVICES with the same PID!
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 (opened == 0)
if (opened < 0)
{
qDebug() << "Error: cannot open device " << deviceName;
return;
}
m_deviceNo = 0;
//m_deviceNo = 0;
m_readThread = new RawHIDReadThread(this);
m_writeThread = new RawHIDWriteThread(this);