User55412
User55412

Reputation: 940

Maximum length of libusb bulk transfer

Is there a maximum length of bulk transfers when using libusb in Linux?

For example can you pass any positive value as the length parameter of the function libusb_fill_bulk_transfer?

Upvotes: 0

Views: 3165

Answers (1)

HighExodus
HighExodus

Reputation: 104

In theory it is the max positive value of an int on the target system. The length parameter is ultimately used to initialize the length member of the transfer structure (see libusb.h, relative and abbreviated code pasted below).

In reality, I imagine the exact number is device dependent and/or application specific. I have seen discussions that claim to have issues with larger packet sizes (for example: LibUSB driver issues: timeout).

libusb_fill_bulk_transfer:

static inline void libusb_fill_bulk_transfer(
    struct libusb_transfer *transfer,
    libusb_device_handle *dev_handle, 
    unsigned char endpoint,
    unsigned char *buffer, 
    int length, libusb_transfer_cb_fn callback,
    void *user_data, 
    unsigned int timeout)
{
            /* NOTE: Only relevant code is pasted here.  For complete code see official libusb.h file included with your distribution.  */
    transfer->length = length;
}

libusb_transfer:

struct libusb_transfer 
{
    /* NOTE: Only relevant code is pasted here.  For complete code see official libusb.h file included with your distribution.  */

    /** Length of the data buffer */
    int length;
};

Upvotes: 1

Related Questions