1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

GCS USB: Get rid of some unnecessary code

This commit is contained in:
James Cotton 2012-09-08 20:04:44 -05:00
parent cf1c986550
commit 44d271ac79

View File

@ -300,29 +300,18 @@ RawHID::RawHID(const QString &deviceName)
m_mutex(NULL)
{
m_mutex = new QMutex(QMutex::Recursive);
m_mutex = new QMutex(QMutex::Recursive);
// detect if the USB device is unplugged
QObject::connect(&dev, SIGNAL(deviceUnplugged(int)), this, SLOT(onDeviceUnplugged(int)));
// detect if the USB device is unplugged
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);
foreach( USBPortInfo device, devices) {
if (deviceName == device.serialNumber) {
opened = dev.open(1,device.vendorID, device.productID,USB_USAGE_PAGE,USB_USAGE);
break;
}
}
*/
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);
}
//didn't find the device we are trying to open (shouldnt happen)
if (opened < 0)
@ -369,14 +358,10 @@ bool RawHID::open(OpenMode mode)
QIODevice::open(mode);
if (!m_readThread)
m_readThread = new RawHIDReadThread(this);
if (!m_writeThread)
m_writeThread = new RawHIDWriteThread(this);
if (m_readThread) m_readThread->start(); // Pip
if (m_writeThread) m_writeThread->start(); // Pip
Q_ASSERT(m_readThread);
Q_ASSERT(m_writeThread);
if (m_readThread) m_readThread->start();
if (m_writeThread) m_writeThread->start();
return true;
}