ISoftUSBEndpointEvents::OnWriteTransfer Method

The OnWriteTransfer event is fired when an OUT transaction is received from the host. The caller must copy or otherwise consume the data.

Syntax

HRESULT OnWriteTransfer(
  [in]   BYTE DataToggle,
  [in]   BYTE *pbDataBuffer,
  [in]   ULONG cbDataBuffer,
  [out]  BYTE *pbStatus
);

Parameters

  • DataToggle [in]
    The data toggle value for the transaction.

  • pbDataBuffer [in]
    A pointer to the data buffer that contains the data for the transaction.

  • cbDataBuffer [in]
    The size of the data buffer that *pbDataBuffer specifies.

  • pbStatus [out]
    The USB status to return to the host controller for the transaction.

Return Value

OnWriteTransfer returns an HRESULT value.

Remarks

The following C++ code example shows how to handle write transfer request from the host contoller.

STDMETHODIMP CLoopBackDevice::OnWriteTransfer(BYTE DataToggle, BYTE *pbDataBuffer,
                               ULONG cbDataBuffer, BYTE *pbStatus)
{
    HRESULT hr        = S_OK;
    BYTE    bINStatus = USB_ACK;

    // Check that the IN endpoint is valid
    if (NULL == m_piINEndpoint)
    {
        hr = E_UNEXPECTED;
        goto Exit;
    }

    if(NULL == pbStatus)
    {
          hr = E_POINTER; 
          goto Exit;
    }

    // Send the data to the IN Endpoint
    hr = m_piINEndpoint->QueueINData(pbDataBuffer,
                                           cbDataBuffer,
                                           bINStatus,
                                           SOFTUSB_FOREVER));
     if(FAILED(hr))
          goto Exit;

// ACK the status because the data was successfully sent to the IN endpoint
*pbStatus = USB_ACK;

Exit:
    if (FAILED(hr))
    {
        *pbStatus = USB_STALL;
    }
    return hr;
}

Requirements

Header

SoftUSBif.h

See Also

ISoftUSBEndpointEvents

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010