UsbControlRequest Procedure

Version 7

 

Sends and receives control setup packet to the specified USB device.

Syntax

[ lStatus = ] UsbControlRequest ( hDevice, ucBmRequestType, ucRequest, wValue, wIndex, wLength, pSendData, pReceiveData, lEndpointAddress )

The UsbControlRequest procedure syntax has the following parts:

 

Name

Type

Description

lStatus

Long

Status: -1 for error, >=0 indicates # bytes sent or received

hDevice

Val AHandle

Handle to the USB device

ucBmRequestType

Val Byte

Characteristics of the request (i.e Direction, Type, and Recipient)

ucRequest

Val Byte

Specific request

wValue

Val Word

Varies according to request. typically used for data.

wIndex

Val Word

Varies according to request; typically used to pass an index or offset.

wLength

Val Word

Number of bytes to send or receive if there is a Data stage

pSendData

[Val] Any

Send Data Buffer

pReceiveData

[Var] Any

Receive Data Buffer

lEndpointAddress

[Val] Long

Optional Endpoint address, default=0

Remarks

Sends control request to a USB control pipe. The request and its parameters are sent to the device in the Setup packet. Please see USB 2.0 specifications section 9.3 "USB Device Request" for more details. (see http://www.usb.org/developers/devclass_docs#approved).

If the endpoint address of the control pipe is not specified, default control pipe with address 0 will be used.

Example

The following example sends a request to retrieve the configuration descriptor of a USB device:

! aucConfigDesc : Byte[1000]

UsbControlRequest(hDevice, 0x80, 0x06, 0x0200, 0, 1000, , aucConfigDesc)

See Also

UsbStandardControlRequest