C# 클래스 LibUsbDotNet.UsbDevice

Contains non-driver specific USB device communication members.
This class is compatible with WinUSB, LibUsb-Win32, and linux libusb v1.x. Platform independent applications should only use usb device members from this class. If more functionality is required, it is up to the application to handle multi-driver and/or multi-platfrom requirements.
파일 보기 프로젝트 열기: arvydas/BlinkStickDotNet 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
ForceLibUsbWinBack bool

Private Properties

프로퍼티 타입 설명
FireUsbError void
GetDeviceConfigs List
UsbDevice System

공개 메소드들

메소드 설명
Close ( ) : bool

Closes the UsbDevice and disposes any ActiveEndpoints.

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

Transmits control data over a default control endpoint.

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

Transmits control data over a default control endpoint.

Exit ( ) : void

De-initializes the USB driver.

If this method is not called before the application exits, it can cause it to hang indefinitely.

Calling this method multiple times will have no effect.

GetAltInterfaceSetting ( byte interfaceID, byte &selectedAltInterfaceID ) : bool

Gets the selected alternate interface of the specified interface.

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.

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

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

GetLangIDs ( short &langIDs ) : bool

Asking for the zero'th index is special - it returns a string descriptor that contains all the language IDs supported by the device. Typically there aren't many - often only one. The language IDs are 16 bit numbers, and they start at the third byte in the descriptor. See USB 2.0 specification, section 9.6.7, for more information on this.

GetString ( string &stringData, short langId, byte stringIndex ) : bool

Gets a DescriptorType.String descriptor from the device.

Open ( ) : bool

Opens the USB device handle.

OpenEndpointReader ( ReadEndpointID readEndpointID ) : UsbEndpointReader

Opens a EndpointType.Bulk endpoint for reading

OpenEndpointReader ( ReadEndpointID readEndpointID, int readBufferSize ) : UsbEndpointReader

Opens a EndpointType.Bulk endpoint for reading

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

Opens an endpoint for reading

OpenEndpointWriter ( WriteEndpointID writeEndpointID ) : UsbEndpointWriter

Opens a EndpointType.Bulk endpoint for writing

OpenEndpointWriter ( WriteEndpointID writeEndpointID, EndpointType endpointType ) : UsbEndpointWriter

Opens an endpoint for writing

OpenUsbDevice ( Predicate findDevicePredicate ) : UsbDevice

Opens the usb device that matches the find predicate.

OpenUsbDevice ( UsbDeviceFinder usbDeviceFinder ) : UsbDevice

Opens the usb device that matches the UsbDeviceFinder.

OpenUsbDevice ( System.Guid &devInterfaceGuid, UsbDevice &usbDevice ) : bool

Opens a WinUsb device by its DeviceInterfaceGUID.

This is the Microsoft-recommended way for opening a WinUsb device. LibUsb device can be opened in this way as well. In order to open LibUsb devices in this manner, an entry must be added to the driver inf file:

[Install.HW]

Addreg=Add_LibUsb_Guid_Reg

[Add_LibUsb_Guid_Reg]

HKR,,LibUsbInterfaceGUIDs,0x10000,"{Your-Unique-Guid-String}"

비공개 메소드들

메소드 설명
FireUsbError ( object sender, UsbError usbError ) : void
GetDeviceConfigs ( UsbDevice usbDevice ) : List
UsbDevice ( UsbApiBase usbApi, SafeHandle usbHandle ) : System

메소드 상세

Close() 공개 추상적인 메소드

Closes the UsbDevice and disposes any ActiveEndpoints.
public abstract Close ( ) : bool
리턴 bool

ControlTransfer() 공개 메소드

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).
리턴 bool

ControlTransfer() 공개 메소드

Transmits control data over a default control endpoint.
public ControlTransfer ( UsbSetupPacket &setupPacket, object 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 object 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).
리턴 bool

Exit() 공개 정적인 메소드

De-initializes the USB driver.
If this method is not called before the application exits, it can cause it to hang indefinitely.

Calling this method multiple times will have no effect.

public static Exit ( ) : void
리턴 void

GetAltInterfaceSetting() 공개 메소드

Gets the selected alternate interface of the specified interface.
public GetAltInterfaceSetting ( byte interfaceID, byte &selectedAltInterfaceID ) : bool
interfaceID byte The interface settings number (index) to retrieve the selected alternate interface setting for.
selectedAltInterfaceID byte The alternate interface setting selected for use with the specified interface.
리턴 bool

GetConfiguration() 공개 메소드

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.
리턴 bool

GetDescriptor() 공개 메소드

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.
리턴 bool

GetDescriptor() 공개 메소드

Gets a descriptor from the device. See DescriptorType for more information.
public GetDescriptor ( byte descriptorType, byte index, short langId, object 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 object 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.
리턴 bool

GetLangIDs() 공개 메소드

Asking for the zero'th index is special - it returns a string descriptor that contains all the language IDs supported by the device. Typically there aren't many - often only one. The language IDs are 16 bit numbers, and they start at the third byte in the descriptor. See USB 2.0 specification, section 9.6.7, for more information on this.
public GetLangIDs ( short &langIDs ) : bool
langIDs short
리턴 bool

GetString() 공개 메소드

Gets a DescriptorType.String descriptor from the device.
public GetString ( string &stringData, short langId, byte stringIndex ) : bool
stringData string Buffer to store the returned string in upon success.
langId short The language ID to retrieve the string in. (0x409 for english).
stringIndex byte The string index to retrieve.
리턴 bool

Open() 공개 추상적인 메소드

Opens the USB device handle.
public abstract Open ( ) : bool
리턴 bool

OpenEndpointReader() 공개 메소드

Opens a EndpointType.Bulk endpoint for reading
public OpenEndpointReader ( ReadEndpointID readEndpointID ) : UsbEndpointReader
readEndpointID ReadEndpointID Endpoint number for read operations.
리턴 UsbEndpointReader

OpenEndpointReader() 공개 메소드

Opens a EndpointType.Bulk endpoint for reading
public OpenEndpointReader ( ReadEndpointID readEndpointID, int readBufferSize ) : UsbEndpointReader
readEndpointID ReadEndpointID Endpoint number for read operations.
readBufferSize int Size of the read buffer allocated for the event.
리턴 UsbEndpointReader

OpenEndpointReader() 공개 메소드

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.
리턴 UsbEndpointReader

OpenEndpointWriter() 공개 메소드

Opens a EndpointType.Bulk endpoint for writing
public OpenEndpointWriter ( WriteEndpointID writeEndpointID ) : UsbEndpointWriter
writeEndpointID WriteEndpointID Endpoint number for read operations.
리턴 UsbEndpointWriter

OpenEndpointWriter() 공개 메소드

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.
리턴 UsbEndpointWriter

OpenUsbDevice() 공개 정적인 메소드

Opens the usb device that matches the find predicate.
public static OpenUsbDevice ( Predicate findDevicePredicate ) : UsbDevice
findDevicePredicate Predicate The predicate function used to find the usb device.
리턴 UsbDevice

OpenUsbDevice() 공개 정적인 메소드

Opens the usb device that matches the UsbDeviceFinder.
public static OpenUsbDevice ( UsbDeviceFinder usbDeviceFinder ) : UsbDevice
usbDeviceFinder LibUsbDotNet.Main.UsbDeviceFinder The class used to find the usb device.
리턴 UsbDevice

OpenUsbDevice() 공개 정적인 메소드

Opens a WinUsb device by its DeviceInterfaceGUID.
This is the Microsoft-recommended way for opening a WinUsb device. LibUsb device can be opened in this way as well. In order to open LibUsb devices in this manner, an entry must be added to the driver inf file:

[Install.HW]

Addreg=Add_LibUsb_Guid_Reg

[Add_LibUsb_Guid_Reg]

HKR,,LibUsbInterfaceGUIDs,0x10000,"{Your-Unique-Guid-String}"

public static OpenUsbDevice ( System.Guid &devInterfaceGuid, UsbDevice &usbDevice ) : bool
devInterfaceGuid System.Guid Device Interface GUID of the usb device to open.
usbDevice UsbDevice On success, a new instance.
리턴 bool

프로퍼티 상세

ForceLibUsbWinBack 공개적으로 정적으로 프로퍼티

Setting this field to will force LibUsbDotNet to use the Libusb-1.0 Windows-backend driver. For platforms other than windows, this setting has no effect.
If this is , AllDevices will return only MonoUsbDevices in the list.
public static bool ForceLibUsbWinBack
리턴 bool