![]() | UsbDevice Class |
Namespace: WinUsbNet
The UsbDevice type exposes the following members.
Name | Description | |
---|---|---|
![]() | DefaultReadTimeout |
Gets or sets the initial ReadTimeout
value.
|
![]() | DeviceName |
Gets the string generated by Windows that uniquely identifies the USB device.
|
![]() ![]() | GetMyString |
Callback function used to get the string returned by ToString.
|
![]() | IsAttached |
Gets a value indicating if this UsbDevice is valid.
|
![]() | IsOpen |
Gets a value indicating if the UsbDevice is open or closed.
|
![]() | PipeStreams |
Gets the collection of PipeStream objects corresponding to the
USB communication pipes of a USB device.
|
![]() | Tag |
Gets or sets the object that contains data about the UsbDevice.
|
Name | Description | |
---|---|---|
![]() | Close |
Closes the USB device.
|
![]() | ControlRead |
Initiates a USB control transfer that reads data from the USB device.
|
![]() | ControlWrite |
Initiates a USB control transfer with optional data sent to the USB device.
|
![]() | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize |
Destructor.
(Overrides ObjectFinalize.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Open |
Open the USB device for I/O.
|
![]() | ToString |
Returns a string that represents the UsbDevice.
(Overrides ObjectToString.) |
UsbDevice represents a USB device that has been attached and whose WinUSB GUID matches the GUID of the parent WinUsbManager. You do not create a UsbDevice directly. A UsbDevice is automatically placed in the UsbDevices collection for each matching USB device that is attached.
A UsbDevice is valid only as long as the corresponding USB device remains attached to the host. Once it is been detached, the UsbDevice is closed if it was open, the IsAttached property is set to false, and calls to the Open method will throw an exception. Reattaching the USB device will not make the existing UsbDevice valid again. Instead a new UsbDevice is created and added to the UsbDevices collection of the parent WinUsbManager.
To communicate with the USB device, you must first call the Open method. This will populate the PipeStreams collection with PipeStream objects corresponding to the endpoints of the USB device. When you are finished communicating with the USB device, call the Close method, which will set the PipeStreams property to null.
You may open, transfer data, and close the UsbDevice any number of times. This can allow you to share the USB device with multiple applications.
When the UsbDevice is open, you can send and receive USB control transfers using the ControlWrite and ControlRead methods. To transfer data with other endpoints, use the endpoint number as an index into the PipeStreams collection, then use the returned PipeStream to transfer data.
The index of a UsbDevice in the UsbDevices collection of the parent WinUsbManager can change as USB devices are attached and detached. UsbDevice includes a Tag property that can be assigned any generic object to make it easier to track each UsbDevice.