C# Class LibUsbDotNet.LudnMonoLibUsb.MonoUsbDevice

This is the LibUsbDotNet Libusb-1.0 implementation of a UsbDevice.

This class is used for perform I/O and other operations on Libusb-1.0 devices using with LibUsbDotNet.

This class is not a part of the low-level MonLibUsb API. This is UsbDevice class LibUsbDotNet uses to implement the low-level MonoLibUsb API.

Inheritance: UsbDevice, IUsbDevice
Datei anzeigen Open project: arvydas/BlinkStickDotNet Class Usage Examples

Private Properties

Property Type Description
GetConfigs ErrorCode
MonoUsbDevice System
RefreshProfileList int

Public Methods

Method Description
ClaimInterface ( int interfaceID ) : bool

Claims the specified interface of the device.

Close ( ) : bool

Closes the UsbDevice and disposes any UsbDevice.ActiveEndpoints.

ControlTransfer ( UsbSetupPacket &setupPacket, IntPtr buffer, int bufferLength, int &lengthTransferred ) : bool

Transmits control data over a default control endpoint.

GetConfiguration ( byte &config ) : bool

Gets the USB devices active configuration value.

GetDescriptor ( byte descriptorType, byte index, short langId, IntPtr buffer, int bufferLength, int &transferLength ) : bool

Gets a descriptor from the device. See DescriptorType for more information.

Init ( ) : void

Initializes the MonoUsbEventHandler.SessionHandle with MonoUsbEventHandler.Init() and starts the static handle events thread with MonoUsbEventHandler.Start.

This is done automatically when needed.

Usually there is no need to call this functions externally.

Open ( ) : bool

Opens the USB device handle.

OpenEndpointReader ( ReadEndpointID readEndpointID, int readBufferSize, EndpointType endpointType ) : UsbEndpointReader

Opens an endpoint for reading

OpenEndpointWriter ( WriteEndpointID writeEndpointID, EndpointType endpointType ) : UsbEndpointWriter

Opens an endpoint for writing

ReleaseInterface ( int interfaceID ) : bool

Releases an interface that was previously claimed with ClaimInterface.

ResetDevice ( ) : bool

Sends a usb device reset command.

After calling ResetDevice, the MonoUsbDevice instance is disposed and no longer usable. A new MonoUsbDevice instance must be obtained from the device list.

SetAltInterface ( int alternateID ) : bool

Sets an alternate interface for the most recent claimed interface.

SetConfiguration ( byte config ) : bool

Sets the USB devices active configuration value.

A USB device can have several different configurations, but only one active configuration.

Private Methods

Method Description
GetConfigs ( MonoUsbDevice usbDevice, List &configInfoListRtn ) : ErrorCode
MonoUsbDevice ( MonoUsbProfile &monoUSBProfile ) : System
RefreshProfileList ( ) : int

Method Details

ClaimInterface() public method

Claims the specified interface of the device.
public ClaimInterface ( int interfaceID ) : bool
interfaceID int The interface to claim.
return bool

Close() public method

Closes the UsbDevice and disposes any UsbDevice.ActiveEndpoints.
public Close ( ) : bool
return bool

ControlTransfer() public method

Transmits control data over a default control endpoint.
public ControlTransfer ( UsbSetupPacket &setupPacket, IntPtr buffer, int bufferLength, int &lengthTransferred ) : bool
setupPacket LibUsbDotNet.Main.UsbSetupPacket An 8-byte setup packet which contains parameters for the control request. /// See section 9.3 USB Device Requests of the Universal Serial Bus Specification Revision 2.0 for more information.
buffer System.IntPtr Data to be sent/received from the device.
bufferLength int Length of the buffer param.
lengthTransferred int Number of bytes sent or received (depends on the direction of the control transfer).
return bool

GetConfiguration() public method

Gets the USB devices active configuration value.
public GetConfiguration ( byte &config ) : bool
config byte The active configuration value. A zero value means the device is not configured and a non-zero value indicates the device is configured.
return bool

GetDescriptor() public method

Gets a descriptor from the device. See DescriptorType for more information.
public GetDescriptor ( byte descriptorType, byte index, short langId, IntPtr buffer, int bufferLength, int &transferLength ) : bool
descriptorType byte The descriptor type ID to retrieve; this is usually one of the enumerations.
index byte Descriptor index.
langId short Descriptor language id.
buffer System.IntPtr Memory to store the returned descriptor in.
bufferLength int Length of the buffer parameter in bytes.
transferLength int The number of bytes transferred to buffer upon success.
return bool

Init() public static method

Initializes the MonoUsbEventHandler.SessionHandle with MonoUsbEventHandler.Init() and starts the static handle events thread with MonoUsbEventHandler.Start.
This is done automatically when needed.

Usually there is no need to call this functions externally.

public static Init ( ) : void
return void

Open() public method

Opens the USB device handle.
public Open ( ) : bool
return bool

OpenEndpointReader() public method

Opens an endpoint for reading
public OpenEndpointReader ( ReadEndpointID readEndpointID, int readBufferSize, EndpointType endpointType ) : UsbEndpointReader
readEndpointID ReadEndpointID Endpoint number for read operations.
readBufferSize int Size of the read buffer allocated for the event.
endpointType EndpointType The type of endpoint to open.
return UsbEndpointReader

OpenEndpointWriter() public method

Opens an endpoint for writing
public OpenEndpointWriter ( WriteEndpointID writeEndpointID, EndpointType endpointType ) : UsbEndpointWriter
writeEndpointID WriteEndpointID Endpoint number for read operations.
endpointType EndpointType The type of endpoint to open.
return UsbEndpointWriter

ReleaseInterface() public method

Releases an interface that was previously claimed with ClaimInterface.
public ReleaseInterface ( int interfaceID ) : bool
interfaceID int The interface to release.
return bool

ResetDevice() public method

Sends a usb device reset command.
After calling ResetDevice, the MonoUsbDevice instance is disposed and no longer usable. A new MonoUsbDevice instance must be obtained from the device list.
public ResetDevice ( ) : bool
return bool

SetAltInterface() public method

Sets an alternate interface for the most recent claimed interface.
public SetAltInterface ( int alternateID ) : bool
alternateID int The alternate interface to select for the most recent claimed interface See .
return bool

SetConfiguration() public method

Sets the USB devices active configuration value.
A USB device can have several different configurations, but only one active configuration.
public SetConfiguration ( byte config ) : bool
config byte The active configuration value. A zero value means the device is not configured and a non-zero value indicates the device is configured.
return bool