Click or drag to resize

USBDeviceBeginControlTransfer Method (Byte, Byte, Int32, Int32, Byte, Int32, AsyncCallback, Object)

Initiates an asynchronous control transfer over the default control endpoint. This method allows both IN and OUT direction transfers, depending on the highest bit of the requestType parameter. Alternatively, BeginControlIn(Byte, Byte, Int32, Int32, Byte, Int32, AsyncCallback, Object) and BeginControlIn(Byte, Byte, Int32, Int32, Byte, Int32, AsyncCallback, Object) can be used for asynchronous control transfers in a specific direction, which is the recommended way because it prevents using the wrong direction accidentally. Use the BeginControlTransfer method when the direction is not known at compile time.

Namespace:  MadWizard.WinUSBNet
Assembly:  WinUSBNet (in WinUSBNet.dll) Version: 2.0.0.0 (2.0.0.0)
Syntax
public IAsyncResult BeginControlTransfer(
	byte requestType,
	byte request,
	int value,
	int index,
	byte[] buffer,
	int length,
	AsyncCallback userCallback,
	Object stateObject
)

Parameters

requestType
Type: SystemByte
The setup packet request type.
request
Type: SystemByte
The setup packet device request.
value
Type: SystemInt32
The value member in the setup packet. Its meaning depends on the request. Value should be between zero and 65535 (0xFFFF).
index
Type: SystemInt32
The index member in the setup packet. Its meaning depends on the request. Index should be between zero and 65535 (0xFFFF).
buffer
Type: SystemByte
The data to transfer in the data stage of the control. When the transfer is in the IN direction the data received will be written to this buffer. For an OUT direction transfer the contents of the buffer are written sent through the pipe. Note: This buffer is not allowed to change for the duration of the asynchronous operation.
length
Type: SystemInt32
Length of the data to transfer. Must be equal to or less than the length of buffer. The setup packet's length member will be set to this length.
userCallback
Type: SystemAsyncCallback
An optional asynchronous callback, to be called when the control transfer is complete. Can be null if no callback is required.
stateObject
Type: SystemObject
A user-provided object that distinguishes this particular asynchronous operation. Can be null if not required.

Return Value

Type: IAsyncResult
An IAsyncResult object representing the asynchronous control transfer, which could still be pending.
Remarks
This method always completes immediately even if the operation is still pending. The IAsyncResult object returned represents the operation and must be passed to EndControlTransfer(IAsyncResult) to retrieve the result of the operation. For every call to this method a matching call to EndControlTransfer(IAsyncResult) must be made. When userCallback specifies a callback function, this function will be called when the operation is completed. The optional stateObject parameter can be used to pass user-defined information to this callback or the IAsyncResult. The IAsyncResult also provides an event handle (AsyncWaitHandle) that will be triggered when the operation is complete as well.
See Also