mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
OP-1798 reduced verbosity of ophid gcs plugin
This commit is contained in:
parent
be9f4aec6a
commit
9631018320
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 ??";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -95,7 +95,7 @@ void RawHIDConnection::onDeviceConnected()
|
||||
*/
|
||||
void RawHIDConnection::onDeviceDisconnected()
|
||||
{
|
||||
qDebug() << "onDeviceDisconnected()";
|
||||
// qDebug() << "onDeviceDisconnected()";
|
||||
if (enablePolling) {
|
||||
emit availableDevChanged(this);
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -122,11 +122,9 @@ QList<USBPortInfo> 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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user