1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-11 01:54:14 +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:
edouard 2010-11-01 13:35:12 +00:00 committed by edouard
parent f19439b1c7
commit b4a22c5984
2 changed files with 34 additions and 9 deletions

View File

@ -77,6 +77,7 @@ RawHIDConnection::RawHIDConnection()
{ {
//added by andrew //added by andrew
RawHidHandle = NULL; RawHidHandle = NULL;
enablePolling = true;
QObject::connect(&m_enumerateThread, SIGNAL(enumerationChanged()), QObject::connect(&m_enumerateThread, SIGNAL(enumerationChanged()),
@ -99,6 +100,7 @@ QStringList RawHIDConnection::availableDevices()
QStringList devices; QStringList devices;
pjrc_rawhid dev; pjrc_rawhid dev;
if (enablePolling) {
//open all device we can //open all device we can
int opened = dev.open(MAX_DEVICES, VID, PID, USAGE_PAGE, USAGE); int opened = dev.open(MAX_DEVICES, VID, PID, USAGE_PAGE, USAGE);
@ -108,6 +110,7 @@ QStringList RawHIDConnection::availableDevices()
devices.append(dev.getserial(i)); devices.append(dev.getserial(i));
dev.close(i); dev.close(i);
} }
}
return devices; return devices;
} }
@ -149,6 +152,23 @@ QString RawHIDConnection::shortName()
return QString("USB"); 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() void RawHIDPlugin::extensionsInitialized()
{ {
addAutoReleasedObject(new RawHIDConnection); hidConnection = new RawHIDConnection();
addAutoReleasedObject(hidConnection);
//temp for test //temp for test
//addAutoReleasedObject(new RawHIDTestThread); //addAutoReleasedObject(new RawHIDTestThread);
@ -215,5 +236,4 @@ bool RawHIDPlugin::initialize(const QStringList & arguments, QString * errorStri
return true; return true;
} }
Q_EXPORT_PLUGIN(RawHIDPlugin) Q_EXPORT_PLUGIN(RawHIDPlugin)

View File

@ -83,6 +83,8 @@ public:
virtual QString connectionName(); virtual QString connectionName();
virtual QString shortName(); virtual QString shortName();
bool suspendPolling();
bool resumePolling();
bool deviceOpened() {return m_deviceOpened;} bool deviceOpened() {return m_deviceOpened;}
@ -91,6 +93,7 @@ protected slots:
private: private:
RawHID *RawHidHandle; RawHID *RawHidHandle;
bool enablePolling;
protected: protected:
QMutex m_enumMutex; QMutex m_enumMutex;
@ -109,6 +112,8 @@ public:
virtual bool initialize(const QStringList &arguments, QString *error_message); virtual bool initialize(const QStringList &arguments, QString *error_message);
virtual void extensionsInitialized(); virtual void extensionsInitialized();
private:
RawHIDConnection *hidConnection;
}; };