SetConfiguration Method (deviceHandle, configuration)

LibUsbDotNet

LibUsbDotNet 2.2.8 SetConfiguration Method (deviceHandle, configuration)
Library ReferenceMonoLibUsbMonoUsbApiSetConfiguration(MonoUsbDeviceHandle, Int32)
LibUsbDotNet on SourceForge
Set the active configuration for a device.
Declaration Syntax
C# Visual Basic Visual C++
public static int SetConfiguration(
	MonoUsbDeviceHandle deviceHandle,
	int configuration
)
Public Shared Function SetConfiguration ( _
	deviceHandle As MonoUsbDeviceHandle, _
	configuration As Integer _
) As Integer
public:
static int SetConfiguration(
	[InAttribute] MonoUsbDeviceHandle^ deviceHandle, 
	int configuration
)
Parameters
deviceHandle (MonoUsbDeviceHandle)
A device handle.
configuration (Int32)
The bConfigurationValue of the configuration you wish to activate, or -1 if you wish to put the device in unconfigured state
Return Value
Remarks

The operating system may or may not have already set an active configuration on the device. It is up to your application to ensure the correct configuration is selected before you attempt to claim interfaces and perform other operations.

If you call this function on a device already configured with the selected configuration, then this function will act as a lightweight device reset: it will issue a SET_CONFIGURATION request using the current configuration, causing most USB-related device state to be reset (altsetting reset to zero, endpoint halts cleared, toggles reset).

You cannot change/reset configuration if your application has claimed interfaces - you should free them with ReleaseInterface(MonoUsbDeviceHandle, Int32) first. You cannot change/reset configuration if other applications or drivers have claimed interfaces.

A configuration value of -1 will put the device in unconfigured state. The USB specifications state that a configuration value of 0 does this, however buggy devices exist which actually have a configuration 0.

You should always use this function rather than formulating your own SET_CONFIGURATION control request. This is because the underlying operating system needs to know when such changes happen.

This is a blocking function.

Note: Member documentation was originally generated using the Libusb-1.0 API documentation: Device handling and enumeration

Assembly: LibUsbDotNet (Module: LibUsbDotNet) Version: 2.2.8.104 (2.2.8.104)