393 Commits

Author SHA1 Message Date
Sebastian Zagrodzki
d5a8179068 Exit libusb context when done. 2017-04-27 03:12:47 +02:00
Sebastian Zagrodzki
462651f20f use the new fakeTransferPointer function to allocate a fake transfer
struct.
2017-04-27 03:12:25 +02:00
Sebastian Zagrodzki
b9dabf4da9 Add a method to return a fake allocated transfer. 2017-04-27 03:12:06 +02:00
Sebastian Zagrodzki
76df46148e Fix typo in log args. 2017-04-27 03:11:36 +02:00
Sebastian Zagrodzki
7ee11b48c5 Close the Context 2017-04-27 03:01:35 +02:00
Sebastian Zagrodzki
60ee821dd6 Close the Context 2017-04-27 03:01:20 +02:00
Sebastian Zagrodzki
2bcc25f8d0 Close the Context 2017-04-27 03:01:10 +02:00
Sebastian Zagrodzki
a1b915080e Close returns error, to satisfy the io.Closer interface. 2017-04-27 02:48:43 +02:00
Sebastian Zagrodzki
76f4548b85 Add info about concurrency safety for stream. 2017-04-26 22:49:37 +02:00
Sebastian Zagrodzki
6c9e76f578 s/USB involving/USB transfers involving/ 2017-04-26 22:27:46 +02:00
Sebastian Zagrodzki
93355e7490 replace uint32 in MaxPacketSize with int 2017-04-26 22:27:12 +02:00
Sebastian Zagrodzki
22ff844a3d s/DeviceSpeed/Speed/ 2017-04-26 22:24:46 +02:00
Sebastian Zagrodzki
6c60468e06 Update to use ints instead of uint8s 2017-04-26 22:23:58 +02:00
Sebastian Zagrodzki
83276566fc Replace uint8 with Go-idiomatic int, where it makes sense. 2017-04-26 22:22:07 +02:00
Sebastian Zagrodzki
a55abe9076 Disable Write streams for now. 2017-04-26 21:51:00 +02:00
Sebastian Zagrodzki
cdd4223813 Handle a case where transfers channel was not closed properly. 2017-04-26 21:50:10 +02:00
Sebastian Zagrodzki
ae8627a890 update tests with the new "transfer done" logic. 2017-04-26 21:40:51 +02:00
Sebastian Zagrodzki
fbd26497e6 NewStream takes int now. 2017-04-26 21:36:14 +02:00
Sebastian Zagrodzki
eed8b77a16 NewStream takes int now. 2017-04-26 21:35:50 +02:00
Sebastian Zagrodzki
eed6d08423 Re-use the same done channel for every callback of a single transfer. 2017-04-26 21:35:26 +02:00
Sebastian Zagrodzki
c1009ed25d Call back to Go function directly, it will know how to deal with an xfer
pointer.
2017-04-26 21:33:45 +02:00
Sebastian Zagrodzki
550fe8d1f2 Introduce xferMap, avoid passing Go pointer into the C code.
Weirdness with memory barriers.
2017-04-26 21:32:49 +02:00
Sebastian Zagrodzki
dacae32d83 Tests for read transfers, starting on write transfers. 2017-04-23 22:58:30 +02:00
Sebastian Zagrodzki
b50bc8761f First version of streaming transfers. 2017-04-23 10:45:04 +02:00
Sebastian Zagrodzki
d92ea14c33 Add a test to catch invalud endpoint info. 2017-04-10 03:25:32 +02:00
Sebastian Zagrodzki
9cecdec977 Fix a bug where EndpointInfo would always be picked from the last
alternative setting.

When looking up matching EndpointInfo and InterfaceSetting for
an endpoint, a reference to range variable is stored. If range is
allowed to continue, the value of this variable will be updated.
It's a trick to allow use of "nil" pointer as a "found" variable, but it
requires a careful management of the range iterations.
2017-04-10 03:16:59 +02:00
Sebastian Zagrodzki
b0d5519c67 Change the iso packet size if the buffer is very small.
Previously number of iso packets could have amounted to a transfer
buffer larger than passed buffer, which could lead to overflow.

Now the number of bytes requested from device is always smaller or equal
to the buffer size.

In theory, it could lead to inefficiencies in transfer: if max packet
size is 1024 and user request 2046 bytes of data, transfer will return at most
1024 bytes, while it could use a more efficient 2 packets of 1023 bytes.
But at least it's correct now. It seems that for efficiency the user would
always use the reported max packet size anyway.

The device could still send more data than requested, but libusb takes
care of it.
2017-04-10 02:45:16 +02:00
Sebastian Zagrodzki
961f271746 rename setup to alternate, print endpoint description first. 2017-04-10 02:44:23 +02:00
Sebastian Zagrodzki
5efb68e45e iota used on the second line of const block starts from 1, not from 0... 2017-04-10 01:41:36 +02:00
Sebastian Zagrodzki
5150242633 Set slice length, since we don't use append. 2017-04-10 01:41:12 +02:00
Sebastian Zagrodzki
453e3832b2 Add tests for failed open. Add tests for OutEndpoint.Write 2017-04-10 01:28:21 +02:00
Sebastian Zagrodzki
b6794b7d45 Add a test for InEndpoint.Read. Use ID for vid/pid in OpenDevice... 2017-04-10 01:25:51 +02:00
Sebastian Zagrodzki
b1dcaa1195 Add Device.OutEndpoint, simplify endpoint test. 2017-04-10 01:11:38 +02:00
Sebastian Zagrodzki
57b10f0dd3 Remove OpenEndpoint, add InEndpoint for Read transfers. 2017-04-10 01:00:53 +02:00
Sebastian Zagrodzki
dd405348e9 move tests around 2017-04-09 20:55:37 +02:00
Sebastian Zagrodzki
128c206986 Move EndpointInfo to endpoint.go 2017-04-09 20:51:47 +02:00
Sebastian Zagrodzki
b7b8fbb50a references to gousb2.0-dev... 2017-04-09 20:48:07 +02:00
Sebastian Zagrodzki
aaef575b06 rename Setups to AltSettings 2017-04-09 20:45:35 +02:00
Sebastian Zagrodzki
8364724ca4 lint fixes. 2017-04-09 20:28:26 +02:00
Sebastian Zagrodzki
188fd8382d more comments 2017-04-09 20:27:37 +02:00
Sebastian Zagrodzki
56162d0105 Remove BCD.Int, add BCD.Major/Minor. Remove USB spec versions
- I don't expect them to get much use, and reuse of BCD for USB spec
version and device revision makes it somewhat confusing.
2017-04-09 20:25:16 +02:00
Sebastian Zagrodzki
a5c4de3a29 more comments. Rename USBError to just Error. 2017-04-09 19:41:44 +02:00
Sebastian Zagrodzki
87c7a873e9 Go naming for error codes. Export USBError type. 2017-04-09 19:27:33 +02:00
Sebastian Zagrodzki
54aed557d8 more comments 2017-04-09 19:18:11 +02:00
Sebastian Zagrodzki
b09de1cf09 more comments 2017-04-09 19:17:13 +02:00
Sebastian Zagrodzki
f668df87df OpenEndpoint for now takes an address - a device can have two endpoints
with the same number...
2017-04-09 19:08:42 +02:00
Sebastian Zagrodzki
c44b5b7307 OpenEndpoint now uses endpoint number, not endpoint address. 2017-04-09 18:57:43 +02:00
Sebastian Zagrodzki
f58798160d make addr() part of EndpointInfo 2017-04-09 18:55:41 +02:00
Sebastian Zagrodzki
13f4e95f2f Unexport bitmasks, they are only used internally. All values present
in exported structs are meaningful and the users should not need to use
bitmasks.
2017-04-09 18:53:49 +02:00
Sebastian Zagrodzki
3d62929e05 Replace EndpointDirection with a bool 2017-04-09 18:51:51 +02:00