ISoftUSBEndpoint::QueueDeviceRequestResponse Method

The QueueDeviceRequestResponse method enables the device simulator to queue data and status for responses to subsequent device requests, for control endpoints.

Syntax

HRESULT QueueDeviceRequestResponse(
  [in]  USBSETUPREQUEST *pRequest,
  [in]  RequestMatchOpts MatchOpt,
  [in]  BYTE *pbResponseData,
  [in]  ULONG cbResponseData,
  [in]  BYTE FinalRequestStatus,
  [in]  ULONG ulTimeToLive
);

Parameters

  • pRequest [in]
    A pointer to the request that data is being queued for.

  • MatchOpt [in]
    A RequestMatchOpts enumeration value that specifies how closely the request length should match. A value of MatchExactLength indicates that the length needs to be the same, and a value of MatchAnyLength indicates that the length will match any request of this type.

  • pbResponseData [in]
    A pointer to a buffer that contains any data that needs to be sent in response to this request.

  • cbResponseData [in]
    The size of the response data buffer that *pbResponseData specifies.

  • FinalRequestStatus [in]
    The final status to send as a response to this device request.

  • ulTimeToLive [in]
    The time, in milliseconds, that this data should remain in the endpoint queue if it is never transferred to the controller. You should specify SOFTUSB_FOREVER for ulTimeToLive if the data should remain in the queue until the controller consumes it.

Return Value

QueueDeviceRequestResponse returns S_OK if the operation succeeds.

Remarks

The endpoint copies the queued data and keeps it in the queue until the host controller requests the data or the time that the ulTimeToLive parameter specifies, in milliseconds, passes.

The following C++ code example shows how device request data can be added to the data queue so that they can be used later to respond to device requests from the host controller.

HRESULT  CSoftLoopbackDevice::QueueGetConfigRequest()
{
 ISoftUSBEndpoint  *piEndpoint = NULL;
    HRESULT           hr = S_OK;
    BYTE              bDataBuffer[8];
    BYTE              bmRequest = 128;
    BYTE              bRequest = GET_DESCRIPTOR;
    SHORT             sIndex = 0;
    SHORT             sValue = DEVICE_DESCRIPTION_TYPE;
    SHORT             sLength = 8; 
    USBCONFIGDESC ConfigData; ::ZeroMemory(&ConfigData, sizeof(ConfigData));

 ZeroMemory(bDescriptionData, sizeof(bDescriptionData));
 
 hr = m_piSoftUSBDevice->get_Endpoint0(&piSoftUSBEndpoint);
 if(FAILED(hr))
 goto Exit;

 hr =  piEndpoint>put_HandleStdDeviceRequests(VARIANT_FALSE);
 if(FAILED(hr))
 goto Exit;

    // Queue the configuration data
 ConfigData.bAttributes = 9;
 ConfigData.bDescriptorType = 6;
 ConfigData.bMaxPower = 56;

 bRequest = GET_CONFIGURATION;
 ZeroMemory(bDataBuffer, sizeof(bDataBuffer));
 CreateTransferBuffer(bDataBuffer, bmRequest, bRequest, sValue, sIndex, sLength);

    // Send the configuration data
 hr = piEndpoint->QueueDeviceRequestResponse((USBSETUPREQUEST*)bDataBuffer, 
 MatchAnyLength,
 reinterpret_cast<BYTE*>(&ConfigData),
 sizeof(ConfigData), 
                                                USB_ACK,
                                                SOFTUSB_FOREVER);
 if(FAILED(hr))
 goto Exit;

Exit:
 RELEASE(piEndpoint);
 return hr;
}

Requirements

Header

Headers:SoftUSBif.h

See Also

ISoftUSBEndpoint

RequestMatchOpts

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010