openusb_xfer_wait, openusb_xfer_aio

OpenUSB Developers Guide
Prev |  | Next

# `openusb_xfer_wait, openusb_xfer_aio`

## Name

`openusb_xfer_wait, openusb_xfer_aio` -- Issue synchronous I/O request, Issue asynchronous I/O request

## Synopsis

``int32_t openusb_xfer_wait`(openusb_request_handle_t handle);`

``int32_topenusb_xfer_aio`(openusb_request_handle_t handle);`

## Parameters

`handle` - Pointer to request handle.

Elements in openusb_request_handle structure:

        	   openusb_dev_handle_t     dev; /* device handle */
        	   uint8_t                 interface;      /* ignored for ep0 */
        	   uint8_t                 endpoint;
        	   openusb_transfer_type_t  type; /* transfer type */

        	   union openusb_request {
        	       openusb_ctrl_request_t   *ctrl;
        	       openusb_intr_request_t   *intr;
        	       openusb_bulk_request_t   *bulk;
        	       openusb_isoc_request_t   *isoc;
        	   } req;

        	   int32_t (*cb)(struct openusb_request_handle *handle); /* callback of this request */
        	   void    *arg;   /* additional arg for callback */

## Description

`openusb_xfer_wait()` can be called by application to do synchronous USB transfers. Alternately, application can call `openusb_xfer_aio()` to do asynchronous USB transfer.

For both functions, application should allocate a request handle and fill required parameters in it. When application calls `openusb_xfer_wait()`, they don't have to set request callback. For `openusb_xfer_aio()`, if application wants to use `openusb_wait()` or `openusb_poll()` to get completed request, it must not set callback `cb` in the request handle. (In implementation of OpenUSB, if `cb` is not NULL, it will be called immediately after this request is accomplished. Otherwise, the completed request is put on a list for application to retrieve by using `openusb_wait/openusb_poll` )

## Return Value

`openusb_xfer_wait`(), `openusb_xfer_aio`() returns 0 on success. Otherwise, a openusb error is returned. NOTE, when an error happens, it just means submission of this request fails. The data status should be checked in `result` of individual request type.

OPENUSB_SUCCESS - No errors.

OPENUSB_BADARG - `handle` or elements in `handle` is not valid.

OPENUSB_UNKNOWN_DEVICE - Device handle `dev` is not valid.

OPENUSB_PLATFORM_FAILURE - Unspecified kernel/driver failure.

OPENUSB_NO_RESOURCES - Memory allocation failure.

OPENUSB_IO_* - USB host controller errors.

## See Also

`openusb_wait, openusb_poll`

Prev | Home | Next
USB Data Transfer | Up | `openusb_ctrl_xfer, openusb_intr_xfer, openusb_bulk_xfer, openusb_isoc_xfer`