Commit Graph

25 Commits

Author SHA1 Message Date
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
b50bc8761f First version of streaming transfers. 2017-04-23 10:45:04 +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
188fd8382d more comments 2017-04-09 20:27:37 +02:00
Sebastian Zagrodzki
87c7a873e9 Go naming for error codes. Export USBError type. 2017-04-09 19:27:33 +02:00
Sebastian Zagrodzki
e0f30623b3 Modify EndpointInfo to provide meaningful data rather than raw USB
descriptor values. E.g. for the user, the distinction between
MaxIsoPkt and MaxPktSize is irrelevant, only the calculated max packet
size matters.
2017-04-08 23:49:10 +02:00
Sebastian Zagrodzki
36241e869e more constants 2017-03-27 22:29:24 +02:00
Sebastian Zagrodzki
8addfb562f updated submit interface and added data() method. 2017-02-26 21:13:31 +01:00
Sebastian Zagrodzki
81e9253f49 no more C in transfer.go 2017-02-23 10:46:04 +01:00
Sebastian Zagrodzki
bf3b23ccd2 move all transfer C parts to libusb.go to alloc() 2017-02-23 10:45:35 +01:00
Sebastian Zagrodzki
82184ea552 make libusbDevHandle part of alloc() 2017-02-23 10:29:24 +01:00
Sebastian Zagrodzki
cc135fe616 move all libusb wrappers to libusb.go. 2017-02-23 10:25:02 +01:00
Sebastian Zagrodzki
360740e76c Cast libusb_transfer explicitly, to make Go 1.8 happy. 2017-02-18 18:13:22 +01:00
Sebastian Zagrodzki
99ec211c43 Improve tests - use offsetof to find the position of the iso packet
descriptor in the transfer struct.
2017-02-16 12:04:10 +01:00
Sebastian Zagrodzki
ef932806ed more comments about transfer protocol. 2017-02-15 18:20:32 +01:00
Sebastian Zagrodzki
0ba09a9942 Move device handle to newUSBTransfer args, remove separate attach() 2017-02-14 01:24:20 +01:00
Sebastian Zagrodzki
16f99ed0b0 Merge remote-tracking branch 'origin/master' into async_transfers_everywhere 2017-02-14 01:12:35 +01:00
Sebastian Zagrodzki
931a15849b set the same channel in t.xfer.user_data as in t.done. 2017-02-13 03:14:38 +01:00
Sebastian Zagrodzki
4a64c18350 move newUSBTransfer as a vanilla function to transfer.go.
Initialize all static params at new.
2017-02-13 03:01:30 +01:00
Sebastian Zagrodzki
a47809fda8 Simplify the C part even more - the buffer that xfer uses for
transferring data is the same as the one that was created in
newUSBTransfer.
2017-02-13 02:50:47 +01:00
Sebastian Zagrodzki
83a4778988 wait() does not need the buffer passed explicitly, it's already stored
in t.buf.
2017-02-10 22:32:16 +01:00
Sebastian Zagrodzki
31b3ac1c67 move iso.c to transfer.c, as it's used for all transfers.
move transfer callback to transfer.go.
2017-02-10 22:11:54 +01:00
Sebastian Zagrodzki
9e50cd8c1c Rename extract_data to extract_iso_data, add extract_data for use by
other transfer types.
2017-02-10 21:45:26 +01:00
Sebastian Zagrodzki
de92c7047b make methods of usbTransfer private 2017-02-09 22:38:16 +01:00
Sebastian Zagrodzki
80b2741a2c Rename Transfer to usbTransfer, it's internal to gousb.
Move usbTransfer and it's methods to transfer.go, it's not only used by
iso transfers.
2017-02-09 22:36:51 +01:00