1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Raw HID plugin: improve initialization in case another plugin wants to use the USBMonitor.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3049 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-03-20 15:55:02 +00:00 committed by edouard
parent d10dd33016
commit 11f7766ab4
2 changed files with 13 additions and 8 deletions

View File

@ -40,14 +40,15 @@
// **********************************************************************
RawHIDConnection::RawHIDConnection()
: m_usbMonitor(this)
{
//added by andrew
RawHidHandle = NULL;
enablePolling = true;
connect(&m_usbMonitor, SIGNAL(deviceDiscovered(USBPortInfo)), this, SLOT(onDeviceConnected()));
connect(&m_usbMonitor, SIGNAL(deviceRemoved(USBPortInfo)), this, SLOT(onDeviceDisconnected()));
m_usbMonitor = USBMonitor::instance();
connect(m_usbMonitor, SIGNAL(deviceDiscovered(USBPortInfo)), this, SLOT(onDeviceConnected()));
connect(m_usbMonitor, SIGNAL(deviceRemoved(USBPortInfo)), this, SLOT(onDeviceDisconnected()));
}
@ -56,9 +57,6 @@ RawHIDConnection::~RawHIDConnection()
if (RawHidHandle)
if (RawHidHandle->isOpen())
RawHidHandle->close();
m_usbMonitor.quit();
m_usbMonitor.wait(500);
}
/**
@ -85,7 +83,7 @@ QStringList RawHIDConnection::availableDevices()
{
QStringList devices;
QList<USBPortInfo> portsList = m_usbMonitor.availableDevices(USBMonitor::idVendor_OpenPilot, -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);
@ -155,6 +153,8 @@ RawHIDPlugin::RawHIDPlugin()
RawHIDPlugin::~RawHIDPlugin()
{
m_usbMonitor->quit();
m_usbMonitor->wait(500);
}
@ -172,6 +172,9 @@ bool RawHIDPlugin::initialize(const QStringList & arguments, QString * errorStri
Q_UNUSED(arguments);
Q_UNUSED(errorString);
// We have to create the USB Monitor here:
m_usbMonitor = new USBMonitor(this);
return true;
}

View File

@ -76,7 +76,7 @@ private:
protected:
QMutex m_enumMutex;
USBMonitor m_usbMonitor;
USBMonitor* m_usbMonitor;
bool m_deviceOpened;
};
@ -93,6 +93,8 @@ public:
virtual void extensionsInitialized();
private:
RawHIDConnection *hidConnection;
USBMonitor* m_usbMonitor;
};
#endif // RAWHIDPLUGIN_H