summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2017-08-10 15:02:19 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2017-08-31 09:12:09 +0000
commitba68d330f07165e26a3f6a8c25a9b8ecfcb46b97 (patch)
tree2cae82ec7109271499873b9609241878daa9137e
parentea91809c5afb48bcec0b6ee180dc14a5b1fb6b2b (diff)
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 <samuli.piippo@qt.io>
-rw-r--r--qdb/server/usb-host/usbconnection.cpp7
-rw-r--r--qdb/server/usb-host/usbdeviceenumerator.cpp13
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<bool, UsbDevice> 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 = [=]() {