Do not assume interface numbers follow the slice indices.
This is a continuation of
9ad54830f4
which tried to solve the problem of non-contiguous interface indices;
this commit modifies another code path that had the same assumption.
Adds a new way to initialize the context, `ContextOptions`, and a new way to open devices, `OpenDeviceWithFileDescriptor`.
Combined they can be used to support Android devices, where device enumeration is not supported (can be now disabled through `ContextOptions`) and where USB devices can be opened in the Android SDK and passed over to gousb through a file descriptor.
Co-authored-by: Juan <994594+juaoose@users.noreply.github.com>
Co-authored-by: Kuba Raczkowski <kuba.raczkowski@spectricity.com>
This will avoid listing this version in "go list -m -versions", which
is used by GitHub's dependabot. The "go list" is expected to list
versions oldest to newest, but it doesn't exclude the "+incompatible"
versions and treats v2.1.0 as the newest. We don't want that, 1.1 is the
latest at the moment.
./fakelibusb_test.go:101:87: libusbContext can't be allocated in Go; it is incomplete (or unallocatable)
./fakelibusb_test.go:131:10: libusbDevHandle can't be allocated in Go; it is incomplete (or unallocatable)
Use CGo malloc to obtain unique pointers.
* Add an invalid interface descriptor to one of the test devices.
* Add a test for getting that interface description.
* Handle the malformed interface/alternate setting descriptors, where
interface/alt numbers don't follow the spec (not 0-based, not contiguous
etc.)
Addresses issue #65.
Don't skip empty transfers.
Update the fake libusb to honor the endpoint max packet sizes.
Update tests that were taking advantage of the fact that libusb
allowed unlimited amount of data in any transfer packet.
Adds ReadContext/WriteContext methods to endpoints and to streams. Update rawread example tool to use ReadContext for implementation of "timeout" flag.
* fix mispell
* update golint path in travis
* Golint requires Go 1.9 or later
* install golint only if go >=1.9
* exclude go 1.7 and go 1.8 for golint
* add build on go 1.10.x
* One more place that should call gousb_set_debug instead of
libusb_set_debug.
* Better comment to explain what sort of benchmarking this is needed for.
* Support libusb_set_option in additon to libusb_set_debug.
The latter is deprecated in libusb 1.0.22 and later.
* Move the "debug level constants" todo to the right place. Add a comment
about libusb 1.0.22 exported API version.
Defines a WriteStream structure for buffering writes, similar to the existing ReadStream. WriteStreams can be created on OutEndpoints by using ep.NewStream().
* Store a reference to libusb implementation in the context, transfers
and some more places. Remove the global libusb variable.
* Parallelize tests.
* Fix the link in README.
* Add APIs for config and interface descriptors. Split out the common
parts of selecting a config descriptor from device desc and
selecting a setting descriptor from a config desc.
* Parallelize the few tests that actually can be parallelized safely.
Add comments where they can't. Note to self: it would be beneficial
to restructure the fakelibusb to index all properties of the lib
with the used context. That way a libusb implementation wouldn't need
to be referred via a shared variable.
In free(), remove Go references to the C memory before the C memory
itself is released. That ensures that a concurrent alloc()
will not try to insert the same pointer into the map that was not
yet removed.
* add alloc/free_transfer_and_buffer. Manages the buffer memory on the C
side.
* switch libusb.go to use the new alloc/free_transfer_and_buffer. Add
a new buffer() call to get access to the allocated buffer as a Go slice.
* Fake USB transfer uses the new alloc/free/buffer interface.
* Switch to the new libusb.alloc signature, where libusb owns the buffer.
* newUSBTransfer now allocates a separate buffer, do a copy on
endpoint.transfer.
* newUSBTransfer will now allocate it's own buffer.
* Enable autodetach in rawread.