Improve documentation
dvc94ch opened this issue · 9 comments
read_bulk, write_bulk doesn't say anything about buffer size. it seems like the maximum that can be received in one read_bulk is 0xffff.
another gotcha seems to be when using set_active_configuration
with the already active configuration a -E_SHUTDOWN
is returned. docs should probably mention not to do that.
read_bulk, write_bulk doesn't say anything about buffer size. it seems like the maximum that can be received in one read_bulk is 0xffff.
It is not true.
another gotcha seems to be when using set_active_configuration with the already active configuration a -E_SHUTDOWN is returned. docs should probably mention not to do that.
This is no error E_SHUTDOWN.
What OS you are using?
It is not true.
sorry meant 16384, converted it to hex wrong 🤦 apparently that's some kind of limitation due to usbfs (found a comment in some usb code).
This is no error E_SHUTDOWN.
according to [0] it is indeed an error code (not a libusb one). the os error code is visible when enabling logging.
What OS you are using?
linux
sorry meant 16384, converted it to hex wrong 🤦 apparently that's some kind of limitation due to usbfs (found a comment in some usb code).
In linux I can read large then 16384 and 65535 bytes. I can read about 4MB with one read_bulk call.
I think about errors better use libusb documentation.
https://libusb.sourceforge.io/api-1.0/group__libusb__dev.html#ga785ddea63a2b9bcb879a614ca4867bed
And also according libusb documentation not limitation about size https://libusb.sourceforge.io/api-1.0/group__libusb__syncio.html#ga2f90957ccc1285475ae96ad2ceb1f58c
In linux I can read large then 16384 and 65535 bytes. I can read about 4MB with one read_bulk call.
that is interesting. so actually over the wire it's packets of 512 bytes grouped in a transfer? so it will return up to 4MB of data from a transfer? wondering why I've seen code artificially limit the data per transfer to 16384 bytes.
the libusb error I got was LIBUSB_ERROR_NO_DEVICE when setting the active configuration to the existing active configuration when interfacing an android device via usb. now I just skip the set_active_config
when it's already activated.
For example. You can look at this commit(this from usb PTP library) a1ien/libptp@28d31ae
Before this change, I could sometimes read giant buffers of 12 megabytes or more. But sometimes the reads failed and and I started using chunk with 1MB and after that I have no problem.
so actually over the wire it's packets of 512 bytes grouped in a transfer? so it will return up to 4MB of data from a transfer?
Yes.
wondering why I've seen code artificially limit the data per transfer to 16384 bytes.
To be honest I don't know :)
it does seem to have some significance. in the libusb code it's called the MAX_BULK_BUFFER_LENGTH [0]
anyway, overall it was quite neat working with rusb, so thank you. still don't quite understand the NO_DEVICE error after changing the active configuration [0] to the already active one, but it works well enough now.