WdfUsbTargetPipeSendUrbSynchronously function (wdfusb.h)

[Applies to KMDF only]

The WdfUsbTargetPipeSendUrbSynchronously method builds an USB request for a specified USB pipe, using request parameters that a specified URB describes.

Syntax

NTSTATUS WdfUsbTargetPipeSendUrbSynchronously(
  [in]           WDFUSBPIPE                Pipe,
  [in, optional] WDFREQUEST                Request,
  [in, optional] PWDF_REQUEST_SEND_OPTIONS RequestOptions,
  [in]           PURB                      Urb
);

Parameters

[in] Pipe

A handle to a framework pipe object that was obtained by calling WdfUsbInterfaceGetConfiguredPipe.

[in, optional] Request

A handle to a framework request object. This parameter is optional and can be NULL. For more information, see the following Remarks section.

[in, optional] RequestOptions

A pointer to a caller-allocated WDF_REQUEST_SEND_OPTIONS structure that specifies options for the request. This pointer is optional and can be NULL. For more information, see the following Remarks section.

[in] Urb

A pointer to a driver-initialized URB structure.

If the driver previously called WdfUsbTargetDeviceCreateWithParameters to create UsbDevice, the driver must use WdfUsbTargetDeviceCreateUrb or WdfUsbTargetDeviceCreateIsochUrb to create this URB.

Return value

WdfUsbTargetPipeSendUrbSynchronously returns the I/O target's completion status value if the operation succeeds. Otherwise, this method might return one of the following values:

Return code Description
STATUS_INFO_LENGTH_MISMATCH
The size of the WDF_REQUEST_SEND_OPTIONS structure that the RequestOptions parameter specified was incorrect.
STATUS_INVALID_PARAMETER
An invalid parameter was detected.
STATUS_INSUFFICIENT_RESOURCES
Insufficient memory was available.
STATUS_INVALID_DEVICE_REQUEST
The caller's IRQL was not PASSIVE_LEVEL, or the specified I/O request was already queued to an I/O target.
STATUS_IO_TIMEOUT
The driver supplied a time-out value and the request did not complete within the allotted time.
STATUS_REQUEST_NOT_ACCEPTED
The I/O request packet (IRP) that the Request parameter represents does not provide enough IO_STACK_LOCATION structures to allow the driver to forward the request.
 

This method also might return other NTSTATUS values.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

Use the WdfUsbTargetPipeSendUrbSynchronously method to send a USB request synchronously. To send such requests asynchronously, use WdfUsbTargetPipeFormatRequestForUrb, followed by WdfRequestSend.

The WdfUsbTargetPipeSendUrbSynchronously method does not return until the request has completed, unless the driver supplies a time-out value in the WDF_REQUEST_SEND_OPTIONS structure that the RequestOptions parameter points to, or unless an error is detected.

The framework does not examine the USB request. If the request changes the state of the USB pipe, the framework will not be aware of the change.

You can forward an I/O request that your driver received in an I/O queue, or you can create and send a new request.

To forward an I/O request that your driver received in an I/O queue, specify the received request's handle for the WdfUsbTargetPipeSendUrbSynchronously method's Request parameter.

To create and send a new request, either supply a NULL request handle for the Request parameter, or create a new request object and supply its handle:

  • If you supply a NULL request handle, the framework uses an internal request object. This technique is simple to use, but the driver cannot cancel the request.
  • If you call WdfRequestCreate to create one or more request objects, you can reuse these request objects by calling WdfRequestReuse. This technique enables your driver's EvtDriverDeviceAdd callback function to preallocate request objects for a device. Additionally, another driver thread can call WdfRequestCancelSentRequest to cancel the request, if necessary.
Your driver can specify a non-NULL RequestOptions parameter, whether the driver provides a non-NULL or a NULL Request parameter. You can, for example, use the RequestOptions parameter to specify a time-out value.

For information about obtaining status information after an I/O request completes, see Obtaining Completion Information.

For more information about the WdfUsbTargetPipeSendUrbSynchronously method and USB I/O targets, see USB I/O Targets.

Examples

The following code example initializes a URB and sends the URB to a USB pipe.

URB  urb;
PURB  pUrb = NULL;
NTSTATUS status;

pUrb = &urb;
pUrb->UrbHeader.Length = (USHORT) sizeof(struct _URB_GET_CURRENT_FRAME_NUMBER);
pUrb->UrbHeader.Function = URB_FUNCTION_GET_CURRENT_FRAME_NUMBER;
pUrb->UrbGetCurrentFrameNumber.FrameNumber = 0; 

status = WdfUsbTargetPipeSendUrbSynchronously(
                                              Pipe,
                                              Request,
                                              NULL,
                                              pUrb
                                              );

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Header wdfusb.h (include Wdfusb.h)
Library Wdf01000.sys (see Framework Library Versioning.)
IRQL PASSIVE_LEVEL
DDI compliance rules DriverCreate(kmdf), IoctlReqs(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), SyncReqSend(kmdf), UsbKmdfIrql(kmdf), UsbKmdfIrql2(kmdf), UsbKmdfIrqlExplicit(kmdf)

See also

WDF_REQUEST_SEND_OPTIONS

WdfRequestCancelSentRequest

WdfUsbInterfaceGetConfiguredPipe