The direction of the transfer is inferred from the direction bits of the endpoint address.

For bulk reads, the length field indicates the maximum length of data you are expecting to receive. If less data arrives than expected, this function will return that data, so be sure to check the transferred output parameter.

You should also check the transferred parameter for bulk writes. Not all of the data may have been written.

Also check transferred when dealing with a timeout error code. libusb may have to split your transfer into a number of chunks to satisfy underlying O/S requirements, meaning that the timeout may expire after the first few chunks have completed. libusb is careful not to lose any data that may have been transferred; do not assume that timeout conditions indicate a complete lack of I/O.

Parameters

dev_handle

a handle for the device to communicate with

endpoint

the address of a valid endpoint to communicate with

data

a suitably-sized data buffer for either input or output (depending on endpoint)

length

for bulk writes, the number of bytes from data to be sent. for bulk reads, the maximum number of bytes to receive into the data buffer.

transferred

output location for the number of bytes actually transferred.

timeout

timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0.

Returns

0 on success (and populates transferred)

LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates transferred)

The direction of the transfer is inferred from the direction bits of the endpoint address.

For interrupt reads, the length field indicates the maximum length of data you are expecting to receive. If less data arrives than expected, this function will return that data, so be sure to check the transferred output parameter.

You should also check the transferred parameter for interrupt writes. Not all of the data may have been written.

Also check transferred when dealing with a timeout error code. libusb may have to split your transfer into a number of chunks to satisfy underlying O/S requirements, meaning that the timeout may expire after the first few chunks have completed. libusb is careful not to lose any data that may have been transferred; do not assume that timeout conditions indicate a complete lack of I/O.

The default endpoint bInterval value is used as the polling interval.

Parameters

dev_handle

a handle for the device to communicate with

endpoint

the address of a valid endpoint to communicate with

data

a suitably-sized data buffer for either input or output (depending on endpoint)

length

for bulk writes, the number of bytes from data to be sent. for bulk reads, the maximum number of bytes to receive into the data buffer.

transferred

output location for the number of bytes actually transferred.

timeout

timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0.