From 96310183208279851543fa878678ca055605772c Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Thu, 19 Mar 2015 09:08:24 +0100 Subject: [PATCH] OP-1798 reduced verbosity of ophid gcs plugin --- .../src/plugins/ophid/hidapi/windows/hid.c | 3 ++- .../src/plugins/ophid/inc/ophid_const.h | 3 ++- .../src/plugins/ophid/src/ophid.cpp | 8 +++--- .../src/plugins/ophid/src/ophid_hidapi.cpp | 4 +++ .../src/plugins/ophid/src/ophid_plugin.cpp | 2 +- .../plugins/ophid/src/ophid_usbmon_linux.cpp | 2 +- .../plugins/ophid/src/ophid_usbmon_mac.cpp | 8 +++--- .../plugins/ophid/src/ophid_usbmon_win.cpp | 27 +++++++------------ .../src/plugins/ophid/src/ophid_usbsignal.cpp | 2 +- 9 files changed, 29 insertions(+), 30 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/ophid/hidapi/windows/hid.c b/ground/openpilotgcs/src/plugins/ophid/hidapi/windows/hid.c index 9286b1ff6..04102a2e7 100644 --- a/ground/openpilotgcs/src/plugins/ophid/hidapi/windows/hid.c +++ b/ground/openpilotgcs/src/plugins/ophid/hidapi/windows/hid.c @@ -166,6 +166,7 @@ static void free_hid_device(hid_device *dev) static void register_error(hid_device *device, const char *op) { + (void)op; // avoid unused arg warning WCHAR *ptr, *msg; FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -232,7 +233,7 @@ static HANDLE open_device(const char *path, BOOL enumerate) OPEN_EXISTING, FILE_FLAG_OVERLAPPED,/*FILE_ATTRIBUTE_NORMAL,*/ 0); - DWORD error = GetLastError(); + /*DWORD error =*/ GetLastError(); return handle; } diff --git a/ground/openpilotgcs/src/plugins/ophid/inc/ophid_const.h b/ground/openpilotgcs/src/plugins/ophid/inc/ophid_const.h index bd8a429a3..5cb9fa8af 100644 --- a/ground/openpilotgcs/src/plugins/ophid/inc/ophid_const.h +++ b/ground/openpilotgcs/src/plugins/ophid/inc/ophid_const.h @@ -29,7 +29,8 @@ #define OPHID_CONST_H #include "QtDebug" -#define OPHID_DEBUG_ON 1 +// #define OPHID_DEBUG_ON 1 + #ifdef OPHID_DEBUG_ON #define OPHID_DEBUG(fmt, args ...) qDebug("[DEBUG] "fmt,##args) #define OPHID_TRACE(fmt, args ...) qDebug("[TRACE] %s:%s:%d: "fmt, __FILE__, __func__, __LINE__,##args) diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp index 447fa2f98..4b176d8ee 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp @@ -146,7 +146,7 @@ RawHIDReadThread::~RawHIDReadThread() m_running = false; // wait for the thread to terminate if (wait(10000) == false) { - qDebug() << "Cannot terminate RawHIDReadThread"; + qWarning() << "Cannot terminate RawHIDReadThread"; } } @@ -219,7 +219,7 @@ RawHIDWriteThread::~RawHIDWriteThread() m_running = false; // wait for the thread to terminate if (wait(10000) == false) { - qDebug() << "Cannot terminate RawHIDReadThread"; + qWarning() << "Cannot terminate RawHIDReadThread"; } } @@ -264,9 +264,9 @@ void RawHIDWriteThread::run() } else if (ret < 0) { // < 0 => error // TODO! make proper error handling, this only quick hack for unplug freeze m_running = false; - qDebug() << "Error writing to device (" << ret << ")"; + qCritical() << "Error writing to device (" << ret << ")"; } else { - qDebug() << "No data written to device ??"; + qCritical() << "No data written to device ??"; } } } diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid_hidapi.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid_hidapi.cpp index 658c1db38..7a8f197ea 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid_hidapi.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid_hidapi.cpp @@ -129,6 +129,10 @@ int opHID_hidapi::enumerate(struct hid_device_info * *current_device_pptr, int * */ int opHID_hidapi::open(int max, int vid, int pid, int usage_page, int usage) { + Q_UNUSED(max); + Q_UNUSED(usage_page); + Q_UNUSED(usage); + int devices_found = false; struct hid_device_info *current_device_ptr = NULL; struct hid_device_info *tmp_device_ptr = NULL; diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid_plugin.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid_plugin.cpp index 248f08122..13d72fc09 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid_plugin.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid_plugin.cpp @@ -95,7 +95,7 @@ void RawHIDConnection::onDeviceConnected() */ void RawHIDConnection::onDeviceDisconnected() { - qDebug() << "onDeviceDisconnected()"; + // qDebug() << "onDeviceDisconnected()"; if (enablePolling) { emit availableDevChanged(this); } diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_linux.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_linux.cpp index 8e08dd916..74e93d654 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_linux.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_linux.cpp @@ -73,7 +73,7 @@ void USBMonitor::deviceEventReceived() // this->monitorNotifier->setEnabled(0); QString action = QString(udev_device_get_action(dev)); QString devtype = QString(udev_device_get_devtype(dev)); - qDebug() << "[DEBUG] Action: " << action << " device: " << devtype; + // qDebug() << "[DEBUG] Action: " << action << " device: " << devtype; if (action == "add" && devtype == "usb_device") { printPortInfo(dev); emit deviceDiscovered(makePortInfo(dev)); 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 ca907a301..89e74cd4c 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_mac.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_mac.cpp @@ -72,7 +72,7 @@ USBMonitor::~USBMonitor() */ void USBMonitor::deviceEventReceived() { - qDebug() << "Device event"; + // qDebug() << "Device event"; } /** @@ -119,7 +119,7 @@ void USBMonitor::detach_callback(void *context, IOReturn r, void *hid_mgr, IOHID Q_UNUSED(r); Q_UNUSED(hid_mgr); - qDebug() << "USBMonitor: Device detached event"; + // qDebug() << "USBMonitor: Device detached event"; instance()->removeDevice(dev); } @@ -156,7 +156,7 @@ void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHID deviceInfo.dev_handle = dev; - qDebug() << "USBMonitor: Device attached event"; + // qDebug() << "USBMonitor: Device attached event"; // Populate the device info structure got_properties &= HID_GetIntProperty(dev, CFSTR(kIOHIDVendorIDKey), &deviceInfo.vendorID); @@ -171,7 +171,7 @@ void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHID // Currently only enumerating objects that have the complete list of properties if (got_properties) { - qDebug() << "USBMonitor: Adding device"; + // qDebug() << "USBMonitor: Adding device"; instance()->addDevice(deviceInfo); } } diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_win.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_win.cpp index 7a6eac89a..51f5c9065 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_win.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbmon_win.cpp @@ -122,11 +122,9 @@ QList USBMonitor::availableDevices(int vid, int pid, int bcdDeviceM OPHID_TRACE("IN"); // Print the list - qDebug() << "List off (" << knowndevices.length() << ") devices that are tracked:"; + // qDebug() << "List off (" << knowndevices.length() << ") devices that are tracked:"; foreach(USBPortInfo info, knowndevices /*thePortsWeWant*/) { - qDebug() << "product:" << info.product - << " bcdDevice:" << info.bcdDevice - << " devicePath:" << info.devicePath; + // qDebug() << "product:" << info.product << " bcdDevice:" << info.bcdDevice << " devicePath:" << info.devicePath; // Filter to return only the one request (if exists) if ((info.vendorID == vid || vid == -1) && @@ -249,7 +247,7 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G { OPHID_TRACE("IN"); - qDebug() << "[STATUS CHANGE] from device ID: " << deviceID; + // qDebug() << "[STATUS CHANGE] from device ID: " << deviceID; bool rc; SP_DEVINFO_DATA spDevInfoData; DWORD dwFlag = (DBT_DEVICEARRIVAL == wParam) ? DIGCF_PRESENT : 0 /*DIGCF_ALLCLASSES*/; @@ -263,13 +261,13 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G DWORD nSize = 0; TCHAR buf[MAX_PATH]; rc = SetupDiGetDeviceInstanceId(devInfo, &spDevInfoData, buf, MAX_PATH, &nSize); - qDebug() << "Found:" << TCHARToQString(buf); + // qDebug() << "Found:" << TCHARToQString(buf); if (rc && deviceID.contains(TCHARToQString(buf))) { - qDebug() << "[MATCH] " << TCHARToQString(buf); + // qDebug() << "[MATCH] " << TCHARToQString(buf); USBPortInfo info; info.devicePath = deviceID; if (wParam == DBT_DEVICEARRIVAL) { - qDebug() << "[INSERTED]"; + // qDebug() << "[INSERTED]"; if (infoFromHandle(guid, info, devInfo, i) != OPHID_NO_ERROR) { OPHID_ERROR("Not found"); break; @@ -290,18 +288,14 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G break; } knowndevices.append(info); - qDebug() << "[SIGNAL] Device discovered on device:" - << info.product - << info.bcdDevice; + // qDebug() << "[SIGNAL] Device discovered on device:" << info.product << info.bcdDevice; emit deviceDiscovered(info); break; } else if (wParam == DBT_DEVICEREMOVECOMPLETE) { for (int x = 0; x < knowndevices.count(); ++x) { USBPortInfo temp = knowndevices.at(x); knowndevices.removeAt(x); - qDebug() << "[SIGNAL] Device removed on device:" - << temp.product - << temp.bcdDevice; + // qDebug() << "[SIGNAL] Device removed on device:" << temp.product << temp.bcdDevice; } emit deviceRemoved(info); break; @@ -429,7 +423,7 @@ int USBMonitor::infoFromHandle(const GUID & guid, USBPortInfo & info, HDEVINFO & goto leave; } - qDebug() << "Found device with valid PATH: " << qDevicePath; + // qDebug() << "Found device with valid PATH: " << qDevicePath; h = CreateFile(details->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -449,8 +443,7 @@ int USBMonitor::infoFromHandle(const GUID & guid, USBPortInfo & info, HDEVINFO & goto leave; } - qDebug() << "Problem opening handle, path: " - << QString().fromWCharArray(details->DevicePath); + // qDebug() << "Problem opening handle, path: " << QString().fromWCharArray(details->DevicePath); free(details); ret = OPHID_ERROR_RET; diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbsignal.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbsignal.cpp index 6e1335f16..b897a0948 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbsignal.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid_usbsignal.cpp @@ -42,7 +42,7 @@ void USBSignalFilter::m_deviceDiscovered(USBPortInfo port) (port.productID == m_pid || m_pid == -1) && ((port.bcdDevice >> 8) == m_boardModel || m_boardModel == -1) && ((port.bcdDevice & 0x00ff) == m_runState || m_runState == -1)) { - qDebug() << "USBSignalFilter emit device discovered"; + // qDebug() << "USBSignalFilter emit device discovered"; emit deviceDiscovered(); } }