Skip to content

Commit

Permalink
example/hotplugtest: Ignore unavailable devices
Browse files Browse the repository at this point in the history
Depending on the devices or drivers, open() may return
 LIBUSB_ERROR_ACCESS
 LIBUSB_ERROR_NOT_FOUND
 LIBUSB_ERROR_NOT_SUPPORTED
for devices "out of reach" to libusb.
  • Loading branch information
sonatique committed Feb 13, 2024
1 parent d52e355 commit 5a05636
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/hotplugtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <config.h>

#include <stdlib.h>
#include <stdio.h>

Expand Down Expand Up @@ -51,7 +53,13 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
}

rc = libusb_open (dev, &handle);
if (LIBUSB_SUCCESS != rc) {
if (LIBUSB_SUCCESS != rc
&& LIBUSB_ERROR_ACCESS != rc
#if defined(PLATFORM_WINDOWS)
&& LIBUSB_ERROR_NOT_SUPPORTED != rc
&& LIBUSB_ERROR_NOT_FOUND != rc
#endif
) {
fprintf (stderr, "No access to device: %s\n",
libusb_strerror((enum libusb_error)rc));
}
Expand Down

0 comments on commit 5a05636

Please sign in to comment.