* -# If the device is already in the desired configuration, calling
* libusb_set_configuration() using the same configuration value will cause
* a lightweight device reset. This may not be desirable behaviour.
- * -# libusb will be unable to change configuration if the device is in
- * another configuration and other programs or drivers have claimed
- * interfaces under that configuration.
* -# In the case where the desired configuration is already active, libusb
* may not even be able to perform a lightweight device reset. For example,
* take my USB keyboard with fingerprint reader: I'm interested in driving
* Because the kernel has claimed an interface, it is not even possible to
* perform the lightweight device reset, so libusb_set_configuration() will
* fail. (Luckily the device in question only has a single configuration.)
+ * -# libusb will be unable to set a configuration if other programs or
+ * drivers have claimed interfaces. In particular, this means that kernel
+ * drivers must be detached from all the interfaces before
+ * libusb_set_configuration() may succeed.
*
* One solution to some of the above problems is to consider the currently
* active configuration. If the configuration we want is already active, then
* we don't have to select any configuration:
\code
-cfg = libusb_get_configuration(dev);
+cfg = -1;
+libusb_get_configuration(dev, &cfg);
if (cfg != desired)
libusb_set_configuration(dev, desired);
\endcode
return 0;
}
-/*
- * Interrupt the iteration of the event handling thread, so that it picks
- * up the new fd.
- */
-void usbi_fd_notification(struct libusb_context *ctx)
-{
- int pending_events;
-
- /* Record that there is a new poll fd.
- * Only signal an event if there are no prior pending events. */
- usbi_mutex_lock(&ctx->event_data_lock);
- pending_events = usbi_pending_events(ctx);
- ctx->fd_notify = 1;
- if (!pending_events)
- usbi_signal_event(ctx);
- usbi_mutex_unlock(&ctx->event_data_lock);
-}
-
/** \ingroup dev
* Open a device and obtain a device handle. A handle allows you to perform
* I/O on the device in question.
usbi_mutex_unlock(&ctx->open_devs_lock);
*handle = _handle;
- if (usbi_backend->caps & USBI_CAP_HAS_POLLABLE_DEVICE_FD) {
- /* At this point, we want to interrupt any existing event handlers so
- * that they realise the addition of the new device's poll fd. One
- * example when this is desirable is if the user is running a separate
- * dedicated libusb events handling thread, which is running with a long
- * or infinite timeout. We want to interrupt that iteration of the loop,
- * so that it picks up the new fd, and then continues. */
- usbi_fd_notification(ctx);
- }
-
return 0;
}
usbi_dbg("created default context");
}
- usbi_dbg("libusb v%d.%d.%d.%d", libusb_version_internal.major, libusb_version_internal.minor,
- libusb_version_internal.micro, libusb_version_internal.nano);
+ usbi_dbg("libusb v%u.%u.%u.%u%s", libusb_version_internal.major, libusb_version_internal.minor,
+ libusb_version_internal.micro, libusb_version_internal.nano, libusb_version_internal.rc);
usbi_mutex_init(&ctx->usb_devs_lock, NULL);
usbi_mutex_init(&ctx->open_devs_lock, NULL);
usbi_gettimeofday(&now, NULL);
if ((global_debug) && (!has_debug_header_been_displayed)) {
has_debug_header_been_displayed = 1;
- usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "[timestamp] [threadID] facility level [function call] <message>\n");
- usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "--------------------------------------------------------------------------------\n");
+ usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "[timestamp] [threadID] facility level [function call] <message>" USBI_LOG_LINE_END);
+ usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "--------------------------------------------------------------------------------" USBI_LOG_LINE_END);
}
if (now.tv_usec < timestamp_origin.tv_usec) {
now.tv_sec--;