mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +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:
parent
0c2c70bb60
commit
afb7aaf374
@ -299,11 +299,22 @@ RawHID::RawHID(const QString &deviceName)
|
|||||||
m_writeThread(NULL),
|
m_writeThread(NULL),
|
||||||
m_mutex(NULL)
|
m_mutex(NULL)
|
||||||
{
|
{
|
||||||
int opened = 0;
|
|
||||||
m_mutex = new QMutex(QMutex::Recursive);
|
m_mutex = new QMutex(QMutex::Recursive);
|
||||||
|
|
||||||
// detect if the USB device is unplugged
|
// detect if the USB device is unplugged
|
||||||
QObject::connect(&dev, SIGNAL(deviceUnplugged(int)), this, SLOT(onDeviceUnplugged(int)));
|
QObject::connect(&dev, SIGNAL(deviceUnplugged(int)), this, SLOT(onDeviceUnplugged(int)));
|
||||||
|
|
||||||
|
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);
|
QList<USBPortInfo> devices = USBMonitor::instance()->availableDevices(USBMonitor::idVendor_OpenPilot,-1,-1,USBMonitor::Running);
|
||||||
foreach( USBPortInfo device, devices) {
|
foreach( USBPortInfo device, devices) {
|
||||||
if (deviceName == device.serialNumber) {
|
if (deviceName == device.serialNumber) {
|
||||||
@ -311,15 +322,16 @@ RawHID::RawHID(const QString &deviceName)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//didn't find the device we are trying to open (shouldnt happen)
|
//didn't find the device we are trying to open (shouldnt happen)
|
||||||
if (opened == 0)
|
if (opened < 0)
|
||||||
{
|
{
|
||||||
qDebug() << "Error: cannot open device " << deviceName;
|
qDebug() << "Error: cannot open device " << deviceName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_deviceNo = 0;
|
//m_deviceNo = 0;
|
||||||
m_readThread = new RawHIDReadThread(this);
|
m_readThread = new RawHIDReadThread(this);
|
||||||
m_writeThread = new RawHIDWriteThread(this);
|
m_writeThread = new RawHIDWriteThread(this);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user