From f62391028acb2bb3a0b0e1307e5ec0ceca5a6902 Mon Sep 17 00:00:00 2001 From: Mathieu Rondonneau Date: Sat, 25 May 2013 19:08:53 -0700 Subject: [PATCH] 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 Date: Sat May 25 08:06:41 2013 -0700 OP-958: adding patch for map to use proper lock mechanism. --- .../plugins/ophid/src/ophid_usbmon_mac.cpp | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_mac.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_mac.cpp index 8d308a8cf..8524c4b57 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_mac.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_mac.cpp @@ -40,7 +40,9 @@ static bool HID_GetIntProperty(IOHIDDeviceRef dev, CFStringRef property, int *va 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) { @@ -52,17 +54,32 @@ USBMonitor::USBMonitor(QObject *parent) : QThread(parent), m_terminate(1) start(); } +/** + * \brief Free the USB monitor + * + * \note + */ USBMonitor::~USBMonitor() { m_terminate.tryAcquire(); wait(); } +/** + * \brief Event received callback + * + * \note + */ void USBMonitor::deviceEventReceived() { qDebug() << "Device event"; } +/** + * \brief instace of USB monitor + * + * \note + */ USBMonitor *USBMonitor::instance() { return m_instance; @@ -71,6 +88,11 @@ USBMonitor *USBMonitor::instance() USBMonitor *USBMonitor::m_instance = 0; +/** + * \brief Remove device + * + * \note + */ void USBMonitor::removeDevice(IOHIDDeviceRef dev) { 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) { @@ -98,6 +123,12 @@ void USBMonitor::detach_callback(void *context, IOReturn r, void *hid_mgr, IOHID instance()->removeDevice(dev); } + +/** + * \brief Add device + * + * \note + */ void USBMonitor::addDevice(USBPortInfo info) { QMutexLocker locker(listMutex); @@ -107,6 +138,12 @@ void USBMonitor::addDevice(USBPortInfo info) emit deviceDiscovered(); } + +/** + * \brief Attach device + * + * \note + */ void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev) { 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 USBMonitor::availableDevices() { @@ -174,6 +214,12 @@ QList USBMonitor::availableDevices(int vid, int pid, int bcdDeviceM return thePortsWeWant; } + +/** + * \brief USBMonitor thread + * + * \note + */ void USBMonitor::run() { IOReturn ret; @@ -251,3 +297,4 @@ static bool HID_GetStrProperty(IOHIDDeviceRef dev, CFStringRef property, QString } return false; } +