Revision ad55e25a host/lib/transport/libusb1_base.hpp
| b/host/lib/transport/libusb1_base.hpp | ||
|---|---|---|
| 25 | 25 |
namespace uhd { namespace transport {
|
| 26 | 26 |
|
| 27 | 27 |
namespace libusb {
|
| 28 |
/* |
|
| 29 |
* Initialize libusb and set debug level |
|
| 30 |
* Takes a pointer to context pointer because that's |
|
| 31 |
* how libusb rolls. Debug levels. |
|
| 32 |
* |
|
| 33 |
* Level 0: no messages ever printed by the library (default) |
|
| 34 |
* Level 1: error messages are printed to stderr |
|
| 35 |
* Level 2: warning and error messages are printed to stderr |
|
| 36 |
* Level 3: informational messages are printed to stdout, warning |
|
| 37 |
* and error messages are printed to stderr |
|
| 38 |
* |
|
| 39 |
* \param ctx pointer to context pointer |
|
| 40 |
* \param debug_level |
|
| 41 |
*/ |
|
| 28 | 42 |
void init(libusb_context **ctx, int debug_level); |
| 29 | 43 |
|
| 44 |
/* |
|
| 45 |
* Get a list of Free Software Foundation devices (Vendor ID 0xfffe) |
|
| 46 |
* As opposed to the public USB device handle interface, which returns |
|
| 47 |
* generic identifiers, this call returns device pointers speficic |
|
| 48 |
* to libusb. |
|
| 49 |
* \param ctx the libusb context used for init |
|
| 50 |
* \return a vector of libusb devices |
|
| 51 |
*/ |
|
| 30 | 52 |
std::vector<libusb_device *> get_fsf_device_list(libusb_context *ctx); |
| 31 | 53 |
|
| 54 |
/* |
|
| 55 |
* Open the device specified by a generic handle |
|
| 56 |
* Find the libusb_device cooresponding to the generic handle |
|
| 57 |
* and open it for I/O, which returns a libusb_device_handle |
|
| 58 |
* ready for an interface |
|
| 59 |
* \param ctx the libusb context used for init |
|
| 60 |
* \return a libusb_device_handle ready for action |
|
| 61 |
*/ |
|
| 32 | 62 |
libusb_device_handle *open_device(libusb_context *ctx, |
| 33 | 63 |
usb_device_handle::sptr handle); |
| 34 | 64 |
|
| 65 |
/* |
|
| 66 |
* Compare a libusb device with a generic handle |
|
| 67 |
* Check the descriptors and open the device to check the |
|
| 68 |
* serial number string. Compare values against the given |
|
| 69 |
* handle. The libusb context is already implied in the |
|
| 70 |
* libusb_device. |
|
| 71 |
* \param dev a libusb_device pointer |
|
| 72 |
* \param handle a generic handle specifier |
|
| 73 |
* \return true if handle and device match, false otherwise |
|
| 74 |
*/ |
|
| 35 | 75 |
bool compare_device(libusb_device *dev, usb_device_handle::sptr handle); |
| 36 | 76 |
|
| 77 |
/* |
|
| 78 |
* Open an interface to the device |
|
| 79 |
* This is a logical operation for operating system housekeeping as |
|
| 80 |
* nothing is sent over the bus. The interface much correspond |
|
| 81 |
* to the USB device descriptors. |
|
| 82 |
* \param dev_handle libusb handle to an opened device |
|
| 83 |
* \param interface integer of the interface to use |
|
| 84 |
* \return true on success, false on error |
|
| 85 |
*/ |
|
| 37 | 86 |
bool open_interface(libusb_device_handle *dev_handle, int interface); |
| 38 | 87 |
|
| 88 |
/* |
|
| 89 |
* Get serial number |
|
| 90 |
* The standard USB device descriptor contains an index to an |
|
| 91 |
* actual serial number string descriptor. The index is readily |
|
| 92 |
* readble, but the string descriptor requires probing the device. |
|
| 93 |
* Because this call attempts to open the device, it may not |
|
| 94 |
* succeed because not all USB devices are readily opened. |
|
| 95 |
* The default language is used for the request (English). |
|
| 96 |
* \param dev a libusb_device pointer |
|
| 97 |
* \return string serial number or 0 on error or unavailablity |
|
| 98 |
*/ |
|
| 39 | 99 |
std::string get_serial(libusb_device *dev); |
| 40 | 100 |
} |
| 41 | 101 |
|
Also available in: Unified diff