From 34509ad6d651d76d86ee1c39dd81eba82dcc5f0a Mon Sep 17 00:00:00 2001 From: rockerbacon Date: Fri, 20 Sep 2019 18:15:52 -0300 Subject: [PATCH] Using error code to check for resource error --- src/logid/DeviceFinder.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/logid/DeviceFinder.cpp b/src/logid/DeviceFinder.cpp index 8c38c4b..5c0bc4a 100644 --- a/src/logid/DeviceFinder.cpp +++ b/src/logid/DeviceFinder.cpp @@ -132,13 +132,18 @@ void DeviceFinder::addDevice(const char *path) } catch(HIDPP10::Error &e) { - if(e.errorCode() != HIDPP10::Error::UnknownDevice) + if (e.errorCode() == HIDPP10::Error::ResourceError) { if(remaining_tries == 1) { - log_printf(WARN, "While querying %s, wireless device %d: %s", string_path.c_str(), index, e.what()); - remaining_tries += MAX_CONNECTION_TRIES; // asleep wireless devices may raise this error, so warn but do not stop querying device - } + log_printf(WARN, "While querying %s (possibly asleep), wireless device %d: %s", string_path.c_str(), index, e.what()); + remaining_tries += MAX_CONNECTION_TRIES; // asleep devices may raise a resource error, so do not count this try + } + } + else if(e.errorCode() != HIDPP10::Error::UnknownDevice) + { + if(remaining_tries == 1) + log_printf(ERROR, "While querying %s, wireless device %d: %s", string_path.c_str(), index, e.what()); } else device_unknown = true; }