From ba68d330f07165e26a3f6a8c25a9b8ecfcb46b97 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Thu, 10 Aug 2017 15:02:19 +0200 Subject: Show proper error message End users will not know what LIBUSB_ERROR_ACCESS means. Instead give a hint to read the manual because most probably they forgot to setup the udev rule. Change-Id: I8237d55dfe64976f4d4a279af31dfa743e8cc29c Reviewed-by: Samuli Piippo --- qdb/server/usb-host/usbconnection.cpp | 7 ++++++- qdb/server/usb-host/usbdeviceenumerator.cpp | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/qdb/server/usb-host/usbconnection.cpp b/qdb/server/usb-host/usbconnection.cpp index 3998aa8..3c8f3e4 100644 --- a/qdb/server/usb-host/usbconnection.cpp +++ b/qdb/server/usb-host/usbconnection.cpp @@ -84,7 +84,12 @@ bool UsbConnection::open(OpenMode mode) ret = libusb_open(m_device.pointer(), &m_handle); if (ret) { - qCDebug(usbC) << "Could not open device:" << libusb_error_name(ret); + if (ret == LIBUSB_ERROR_ACCESS) { + qCWarning(usbC) << "Access to USB device was denied." + << "Check the manual for setting up access to USB devices."; + } else { + qCWarning(usbC) << "Could not open device:" << libusb_error_name(ret); + } return false; } diff --git a/qdb/server/usb-host/usbdeviceenumerator.cpp b/qdb/server/usb-host/usbdeviceenumerator.cpp index 4c2cfa6..3bf8ff9 100644 --- a/qdb/server/usb-host/usbdeviceenumerator.cpp +++ b/qdb/server/usb-host/usbdeviceenumerator.cpp @@ -132,9 +132,16 @@ std::pair makeUsbDeviceIfQdbDevice(libusb_device *device) int ret = libusb_open(device, &handle); if (ret) { const auto address = getAddress(device); - qCWarning(usbC) << "Could not open USB device at" << address.busNumber - << ":" << address.deviceAddress << "for checking serial number:" - << libusb_error_name(ret); + if (ret == LIBUSB_ERROR_ACCESS) { + qCWarning(usbC) << "Access to USB device at" << address.busNumber + << ":" << address.deviceAddress << "was denied." + << "Check the manual for setting up access to USB devices."; + } else { + qCWarning(usbC) << "Could not open USB device at" << address.busNumber + << ":" << address.deviceAddress << "for checking serial number:" + << libusb_error_name(ret); + } + return std::make_pair(false, UsbDevice{}); } ScopeGuard deviceGuard = [=]() { -- cgit v1.2.3