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 )
- 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
- 0 on success
- ErrorNotFound if the requested configuration does not exist
- ErrorBusy if interfaces are currently claimed
- ErrorNoDevice if the device has been disconnected
- another MonoUsbError code on other failure
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.