mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-35 New methods to suspend and resume USB polling by the Raw HID plugin. Required for the Uploader plugin.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2053 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
f19439b1c7
commit
b4a22c5984
@ -77,6 +77,7 @@ RawHIDConnection::RawHIDConnection()
|
||||
{
|
||||
//added by andrew
|
||||
RawHidHandle = NULL;
|
||||
enablePolling = true;
|
||||
|
||||
|
||||
QObject::connect(&m_enumerateThread, SIGNAL(enumerationChanged()),
|
||||
@ -99,14 +100,16 @@ QStringList RawHIDConnection::availableDevices()
|
||||
QStringList devices;
|
||||
pjrc_rawhid dev;
|
||||
|
||||
//open all device we can
|
||||
int opened = dev.open(MAX_DEVICES, VID, PID, USAGE_PAGE, USAGE);
|
||||
if (enablePolling) {
|
||||
//open all device we can
|
||||
int opened = dev.open(MAX_DEVICES, VID, PID, USAGE_PAGE, USAGE);
|
||||
|
||||
//for each devices found, get serial number and close it back
|
||||
for(int i=0; i<opened; i++)
|
||||
{
|
||||
devices.append(dev.getserial(i));
|
||||
dev.close(i);
|
||||
//for each devices found, get serial number and close it back
|
||||
for(int i=0; i<opened; i++)
|
||||
{
|
||||
devices.append(dev.getserial(i));
|
||||
dev.close(i);
|
||||
}
|
||||
}
|
||||
|
||||
return devices;
|
||||
@ -149,6 +152,23 @@ QString RawHIDConnection::shortName()
|
||||
return QString("USB");
|
||||
}
|
||||
|
||||
/**
|
||||
Tells the Raw HID plugin to stop polling for USB devices
|
||||
*/
|
||||
bool RawHIDConnection::suspendPolling()
|
||||
{
|
||||
enablePolling = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Tells the Raw HID plugin to resume polling for USB devices
|
||||
*/
|
||||
bool RawHIDConnection::resumePolling()
|
||||
{
|
||||
enablePolling = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -201,7 +221,8 @@ RawHIDPlugin::~RawHIDPlugin()
|
||||
|
||||
void RawHIDPlugin::extensionsInitialized()
|
||||
{
|
||||
addAutoReleasedObject(new RawHIDConnection);
|
||||
hidConnection = new RawHIDConnection();
|
||||
addAutoReleasedObject(hidConnection);
|
||||
|
||||
//temp for test
|
||||
//addAutoReleasedObject(new RawHIDTestThread);
|
||||
@ -215,5 +236,4 @@ bool RawHIDPlugin::initialize(const QStringList & arguments, QString * errorStri
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Q_EXPORT_PLUGIN(RawHIDPlugin)
|
||||
|
@ -83,6 +83,8 @@ public:
|
||||
|
||||
virtual QString connectionName();
|
||||
virtual QString shortName();
|
||||
bool suspendPolling();
|
||||
bool resumePolling();
|
||||
|
||||
bool deviceOpened() {return m_deviceOpened;}
|
||||
|
||||
@ -91,6 +93,7 @@ protected slots:
|
||||
|
||||
private:
|
||||
RawHID *RawHidHandle;
|
||||
bool enablePolling;
|
||||
|
||||
protected:
|
||||
QMutex m_enumMutex;
|
||||
@ -109,6 +112,8 @@ public:
|
||||
|
||||
virtual bool initialize(const QStringList &arguments, QString *error_message);
|
||||
virtual void extensionsInitialized();
|
||||
private:
|
||||
RawHIDConnection *hidConnection;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user