Brian Silverman | 395d625 | 2013-09-13 20:58:14 -0700 | [diff] [blame] | 1 | // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 | // |
Brian Silverman | 14a7b1a | 2013-10-11 21:34:03 -0700 | [diff] [blame] | 3 | // Modified by FRC Team 971. |
| 4 | // |
Brian Silverman | 395d625 | 2013-09-13 20:58:14 -0700 | [diff] [blame] | 5 | // Alternative libusb call to do transfers that quits when |
| 6 | // a notification is notified. |
| 7 | |
| 8 | #ifndef _GLIBUSB_GLIBUSB_TRANSFER_H_ |
| 9 | #define _GLIBUSB_GLIBUSB_TRANSFER_H_ |
| 10 | |
| 11 | extern "C" { |
| 12 | struct libusb_context; |
| 13 | struct libusb_device_handle; |
| 14 | } |
| 15 | |
| 16 | class Notification; |
| 17 | |
| 18 | namespace glibusb { |
| 19 | |
Brian Silverman | 14a7b1a | 2013-10-11 21:34:03 -0700 | [diff] [blame] | 20 | // Transfer code cribbed from libusb1/sync.c and modified. |
| 21 | // It supports bulk, isochronous, and interrupt transfers. |
Brian Silverman | 395d625 | 2013-09-13 20:58:14 -0700 | [diff] [blame] | 22 | // The difference between this and the original code is that the |
| 23 | // transfer now accepts a notification to poll for the quit message. |
| 24 | // When it receives a quit message on the notification, it cancels the transfer. |
| 25 | // The provided API's don't support better reuse of the existing code from what |
Brian Silverman | 14a7b1a | 2013-10-11 21:34:03 -0700 | [diff] [blame] | 26 | // I can tell. It has also been modified to support isochronous transfers. |
| 27 | int do_sync_transfer( |
Brian Silverman | 395d625 | 2013-09-13 20:58:14 -0700 | [diff] [blame] | 28 | struct libusb_context *context, |
| 29 | struct libusb_device_handle *dev_handle, |
| 30 | unsigned char endpoint, unsigned char *buffer, int length, |
| 31 | int *transferred, unsigned int timeout, unsigned char type, |
| 32 | Notification *quit); |
| 33 | |
| 34 | } // namespace glibusb |
| 35 | |
| 36 | #endif // _GLIBUSB_GLIBUSB_TRANSFER_H_ |