Language

UsbDeviceConnection.BulkTransferAsync Method

Definition

Overloads

Name Description
BulkTransferAsync(UsbEndpoint, Byte[], Int32, Int32)

Runs a bulk transfer on the given endpoint in a task.

BulkTransferAsync(UsbEndpoint, Byte[], Int32, Int32, Int32)

Runs a bulk transfer from the given buffer offset in a task.

BulkTransferAsync(UsbEndpoint, Byte[], Int32, Int32)

Runs a bulk transfer on the given endpoint in a task.

public System.Threading.Tasks.Task<int> BulkTransferAsync(Android.Hardware.Usb.UsbEndpoint? endpoint, byte[]? buffer, int length, int timeout);
member this.BulkTransferAsync : Android.Hardware.Usb.UsbEndpoint * byte[] * int * int -> System.Threading.Tasks.Task<int>

Parameters

endpoint
UsbEndpoint

The endpoint that determines the transfer direction.

buffer
Byte[]

The buffer for data to send or receive, starting at index zero. If null, length must be zero.

length
Int32

The number of bytes to send or receive. Must be nonnegative and no greater than the buffer length. See the remarks for the 16384-byte compatibility limit.

timeout
Int32

The transfer timeout in milliseconds; zero waits indefinitely.

Returns

A task whose result is the number of bytes transferred, including zero, on success, or a negative value on failure.

Remarks

This .NET method uses Run<TResult>(Func<TResult>) to call BulkTransfer(UsbEndpoint, Byte[], Int32, Int32). Keep the connection open and do not read or change the buffer until the task completes.

Before Android 9 (API level 28), transfer lengths greater than 16384 bytes are reduced to 16384. On Android 9 and later, this limit still applies to applications that target an API level below 28. Buffer bounds are checked before this reduction.

Implementation sources: .NET task wrapper generator and Android USB connection implementation.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BulkTransferAsync(UsbEndpoint, Byte[], Int32, Int32, Int32)

Runs a bulk transfer from the given buffer offset in a task.

public System.Threading.Tasks.Task<int> BulkTransferAsync(Android.Hardware.Usb.UsbEndpoint? endpoint, byte[]? buffer, int offset, int length, int timeout);
member this.BulkTransferAsync : Android.Hardware.Usb.UsbEndpoint * byte[] * int * int * int -> System.Threading.Tasks.Task<int>

Parameters

endpoint
UsbEndpoint

The endpoint that determines the transfer direction.

buffer
Byte[]

The buffer for data to send or receive. If null, offset and length must both be zero.

offset
Int32

The nonnegative index of the first byte to send or receive in buffer.

length
Int32

The number of bytes to send or receive. Must be nonnegative, and the range starting at offset must fit within the buffer. See the remarks for the 16384-byte compatibility limit.

timeout
Int32

The transfer timeout in milliseconds; zero waits indefinitely.

Returns

A task whose result is the number of bytes transferred, including zero, on success, or a negative value on failure.

Remarks

This .NET method uses Run<TResult>(Func<TResult>) to call BulkTransfer(UsbEndpoint, Byte[], Int32, Int32, Int32). Keep the connection open and do not read or change the buffer until the task completes.

Before Android 9 (API level 28), transfer lengths greater than 16384 bytes are reduced to 16384. On Android 9 and later, this limit still applies to applications that target an API level below 28. Buffer bounds are checked before this reduction.

Implementation sources: .NET task wrapper generator and Android USB connection implementation.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to