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

OP-958: Add function header doc and give credit to Richard (not mentionned in a previous commit).

I gorgot to mention that the following commit was a patch from Richard.
Thanks to richard for suggesting this patch.

commit 45e18127a33ea2f7a510e921edc4ea67fede384a
Author: Mathieu Rondonneau <Mathieu.Rondonneau@gmail.com>
Date:   Sat May 25 08:06:41 2013 -0700

    OP-958: adding patch for map to use proper lock mechanism.
This commit is contained in:
Mathieu Rondonneau 2013-05-25 19:08:53 -07:00
parent 4b46251ff1
commit f62391028a

View File

@ -40,7 +40,9 @@ static bool HID_GetIntProperty(IOHIDDeviceRef dev, CFStringRef property, int *va
static bool HID_GetStrProperty(IOHIDDeviceRef dev, CFStringRef property, QString & value); static bool HID_GetStrProperty(IOHIDDeviceRef dev, CFStringRef property, QString & value);
/** /**
Initialize the USB monitor here * \brief Initialize the USB monitor
*
* \note
*/ */
USBMonitor::USBMonitor(QObject *parent) : QThread(parent), m_terminate(1) USBMonitor::USBMonitor(QObject *parent) : QThread(parent), m_terminate(1)
{ {
@ -52,17 +54,32 @@ USBMonitor::USBMonitor(QObject *parent) : QThread(parent), m_terminate(1)
start(); start();
} }
/**
* \brief Free the USB monitor
*
* \note
*/
USBMonitor::~USBMonitor() USBMonitor::~USBMonitor()
{ {
m_terminate.tryAcquire(); m_terminate.tryAcquire();
wait(); wait();
} }
/**
* \brief Event received callback
*
* \note
*/
void USBMonitor::deviceEventReceived() void USBMonitor::deviceEventReceived()
{ {
qDebug() << "Device event"; qDebug() << "Device event";
} }
/**
* \brief instace of USB monitor
*
* \note
*/
USBMonitor *USBMonitor::instance() USBMonitor *USBMonitor::instance()
{ {
return m_instance; return m_instance;
@ -71,6 +88,11 @@ USBMonitor *USBMonitor::instance()
USBMonitor *USBMonitor::m_instance = 0; USBMonitor *USBMonitor::m_instance = 0;
/**
* \brief Remove device
*
* \note
*/
void USBMonitor::removeDevice(IOHIDDeviceRef dev) void USBMonitor::removeDevice(IOHIDDeviceRef dev)
{ {
for (int i = 0; i < knowndevices.length(); i++) { for (int i = 0; i < knowndevices.length(); i++) {
@ -85,8 +107,11 @@ void USBMonitor::removeDevice(IOHIDDeviceRef dev)
} }
} }
/** /**
* @brief Static callback for the USB driver to indicate device removed * \brief Static callback for the USB driver to indicate device removed
*
* \note
*/ */
void USBMonitor::detach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev) void USBMonitor::detach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev)
{ {
@ -98,6 +123,12 @@ void USBMonitor::detach_callback(void *context, IOReturn r, void *hid_mgr, IOHID
instance()->removeDevice(dev); instance()->removeDevice(dev);
} }
/**
* \brief Add device
*
* \note
*/
void USBMonitor::addDevice(USBPortInfo info) void USBMonitor::addDevice(USBPortInfo info)
{ {
QMutexLocker locker(listMutex); QMutexLocker locker(listMutex);
@ -107,6 +138,12 @@ void USBMonitor::addDevice(USBPortInfo info)
emit deviceDiscovered(); emit deviceDiscovered();
} }
/**
* \brief Attach device
*
* \note
*/
void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev) void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev)
{ {
Q_UNUSED(context); Q_UNUSED(context);
@ -139,8 +176,11 @@ void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHID
} }
} }
/** /**
Returns a list of all currently available devices * \brief Returns a list of all currently available devices
*
* \note
*/ */
QList<USBPortInfo> USBMonitor::availableDevices() QList<USBPortInfo> USBMonitor::availableDevices()
{ {
@ -174,6 +214,12 @@ QList<USBPortInfo> USBMonitor::availableDevices(int vid, int pid, int bcdDeviceM
return thePortsWeWant; return thePortsWeWant;
} }
/**
* \brief USBMonitor thread
*
* \note
*/
void USBMonitor::run() void USBMonitor::run()
{ {
IOReturn ret; IOReturn ret;
@ -251,3 +297,4 @@ static bool HID_GetStrProperty(IOHIDDeviceRef dev, CFStringRef property, QString
} }
return false; return false;
} }