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:
parent
d10dd33016
commit
11f7766ab4
@ -40,14 +40,15 @@
|
|||||||
// **********************************************************************
|
// **********************************************************************
|
||||||
|
|
||||||
RawHIDConnection::RawHIDConnection()
|
RawHIDConnection::RawHIDConnection()
|
||||||
: m_usbMonitor(this)
|
|
||||||
{
|
{
|
||||||
//added by andrew
|
//added by andrew
|
||||||
RawHidHandle = NULL;
|
RawHidHandle = NULL;
|
||||||
enablePolling = true;
|
enablePolling = true;
|
||||||
|
|
||||||
connect(&m_usbMonitor, SIGNAL(deviceDiscovered(USBPortInfo)), this, SLOT(onDeviceConnected()));
|
m_usbMonitor = USBMonitor::instance();
|
||||||
connect(&m_usbMonitor, SIGNAL(deviceRemoved(USBPortInfo)), this, SLOT(onDeviceDisconnected()));
|
|
||||||
|
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)
|
||||||
if (RawHidHandle->isOpen())
|
if (RawHidHandle->isOpen())
|
||||||
RawHidHandle->close();
|
RawHidHandle->close();
|
||||||
|
|
||||||
m_usbMonitor.quit();
|
|
||||||
m_usbMonitor.wait(500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +83,7 @@ QStringList RawHIDConnection::availableDevices()
|
|||||||
{
|
{
|
||||||
QStringList devices;
|
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
|
// We currently list devices by their serial number
|
||||||
foreach(USBPortInfo prt, portsList) {
|
foreach(USBPortInfo prt, portsList) {
|
||||||
devices.append(prt.serialNumber);
|
devices.append(prt.serialNumber);
|
||||||
@ -155,6 +153,8 @@ RawHIDPlugin::RawHIDPlugin()
|
|||||||
|
|
||||||
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(arguments);
|
||||||
Q_UNUSED(errorString);
|
Q_UNUSED(errorString);
|
||||||
|
|
||||||
|
// We have to create the USB Monitor here:
|
||||||
|
m_usbMonitor = new USBMonitor(this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QMutex m_enumMutex;
|
QMutex m_enumMutex;
|
||||||
USBMonitor m_usbMonitor;
|
USBMonitor* m_usbMonitor;
|
||||||
bool m_deviceOpened;
|
bool m_deviceOpened;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,6 +93,8 @@ public:
|
|||||||
virtual void extensionsInitialized();
|
virtual void extensionsInitialized();
|
||||||
private:
|
private:
|
||||||
RawHIDConnection *hidConnection;
|
RawHIDConnection *hidConnection;
|
||||||
|
USBMonitor* m_usbMonitor;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RAWHIDPLUGIN_H
|
#endif // RAWHIDPLUGIN_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user