A cross-platform user library to access USB devices
libusb.h
1 /*
2  * Public libusb header file
3  * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
4  * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
5  * Copyright © 2012 Pete Batard <pete@akeo.ie>
6  * Copyright © 2012 Nathan Hjelm <hjelmn@cs.unm.edu>
7  * For more information, please visit: http://libusb.info
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef LIBUSB_H
25 #define LIBUSB_H
26 
27 #ifdef _MSC_VER
28 /* on MS environments, the inline keyword is available in C++ only */
29 #if !defined(__cplusplus)
30 #define inline __inline
31 #endif
32 /* ssize_t is also not available (copy/paste from MinGW) */
33 #ifndef _SSIZE_T_DEFINED
34 #define _SSIZE_T_DEFINED
35 #undef ssize_t
36 #ifdef _WIN64
37  typedef __int64 ssize_t;
38 #else
39  typedef int ssize_t;
40 #endif /* _WIN64 */
41 #endif /* _SSIZE_T_DEFINED */
42 #endif /* _MSC_VER */
43 
44 /* stdint.h is not available on older MSVC */
45 #if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
46 typedef unsigned __int8 uint8_t;
47 typedef unsigned __int16 uint16_t;
48 typedef unsigned __int32 uint32_t;
49 #else
50 #include <stdint.h>
51 #endif
52 
53 #if !defined(_WIN32_WCE)
54 #include <sys/types.h>
55 #endif
56 
57 #if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__HAIKU__)
58 #include <sys/time.h>
59 #endif
60 
61 #include <time.h>
62 #include <limits.h>
63 
64 /* 'interface' might be defined as a macro on Windows, so we need to
65  * undefine it so as not to break the current libusb API, because
66  * libusb_config_descriptor has an 'interface' member
67  * As this can be problematic if you include windows.h after libusb.h
68  * in your sources, we force windows.h to be included first. */
69 #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
70 #include <windows.h>
71 #if defined(interface)
72 #undef interface
73 #endif
74 #if !defined(__CYGWIN__)
75 #include <winsock.h>
76 #endif
77 #endif
78 
79 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
80 #define LIBUSB_DEPRECATED_FOR(f) \
81  __attribute__((deprecated("Use " #f " instead")))
82 #else
83 #define LIBUSB_DEPRECATED_FOR(f)
84 #endif /* __GNUC__ */
85 
111 /* LIBUSB_CALL must be defined on both definition and declaration of libusb
112  * functions. You'd think that declaration would be enough, but cygwin will
113  * complain about conflicting types unless both are marked this way.
114  * The placement of this macro is important too; it must appear after the
115  * return type, before the function name. See internal documentation for
116  * API_EXPORTED.
117  */
118 #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
119 #define LIBUSB_CALL WINAPI
120 #else
121 #define LIBUSB_CALL
122 #endif
123 
144 #define LIBUSB_API_VERSION 0x01000104
145 
146 /* The following is kept for compatibility, but will be deprecated in the future */
147 #define LIBUSBX_API_VERSION LIBUSB_API_VERSION
148 
149 #ifdef __cplusplus
150 extern "C" {
151 #endif
152 
161 static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
162 {
163  union {
164  uint8_t b8[2];
165  uint16_t b16;
166  } _tmp;
167  _tmp.b8[1] = (uint8_t) (x >> 8);
168  _tmp.b8[0] = (uint8_t) (x & 0xff);
169  return _tmp.b16;
170 }
171 
180 #define libusb_le16_to_cpu libusb_cpu_to_le16
181 
182 /* standard USB stuff */
183 
192 
195 
198 
201 
204 
207 
209  LIBUSB_CLASS_PTP = 6, /* legacy name from libusb-0.1 usb.h */
210  LIBUSB_CLASS_IMAGE = 6,
211 
214 
217 
220 
223 
226 
229 
232 
235 
238 
241 
244 };
245 
251 
254 
257 
260 
263 
266 
269 
272 
275 
278 
281 
284 
287 };
288 
289 /* Descriptor sizes per descriptor type */
290 #define LIBUSB_DT_DEVICE_SIZE 18
291 #define LIBUSB_DT_CONFIG_SIZE 9
292 #define LIBUSB_DT_INTERFACE_SIZE 9
293 #define LIBUSB_DT_ENDPOINT_SIZE 7
294 #define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
295 #define LIBUSB_DT_HUB_NONVAR_SIZE 7
296 #define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6
297 #define LIBUSB_DT_BOS_SIZE 5
298 #define LIBUSB_DT_DEVICE_CAPABILITY_SIZE 3
299 
300 /* BOS descriptor sizes */
301 #define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7
302 #define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10
303 #define LIBUSB_BT_CONTAINER_ID_SIZE 20
304 
305 /* We unwrap the BOS => define its max size */
306 #define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) +\
307  (LIBUSB_BT_USB_2_0_EXTENSION_SIZE) +\
308  (LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) +\
309  (LIBUSB_BT_CONTAINER_ID_SIZE))
310 
311 #define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
312 #define LIBUSB_ENDPOINT_DIR_MASK 0x80
313 
321 
324 };
325 
326 #define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
327 
335 
338 
341 
344 
347 };
348 
354 
357 
358  /* 0x02 is reserved */
359 
362 
363  /* 0x04 is reserved */
364 
367 
370 
373 
376 
379 
382 
385 
388 
391 
395 };
396 
404 
407 
410 
413 };
414 
422 
425 
428 
431 };
432 
433 #define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C
434 
443 
446 
449 
452 };
453 
454 #define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
455 
464 
467 
470 };
471 
479  uint8_t bLength;
480 
485 
488  uint16_t bcdUSB;
489 
491  uint8_t bDeviceClass;
492 
496 
500 
503 
505  uint16_t idVendor;
506 
508  uint16_t idProduct;
509 
511  uint16_t bcdDevice;
512 
514  uint8_t iManufacturer;
515 
517  uint8_t iProduct;
518 
520  uint8_t iSerialNumber;
521 
524 };
525 
533  uint8_t bLength;
534 
539 
545 
553  uint8_t bmAttributes;
554 
556  uint16_t wMaxPacketSize;
557 
559  uint8_t bInterval;
560 
563  uint8_t bRefresh;
564 
566  uint8_t bSynchAddress;
567 
570  const unsigned char *extra;
571 
574 };
575 
583  uint8_t bLength;
584 
589 
592 
595 
598  uint8_t bNumEndpoints;
599 
602 
606 
610 
612  uint8_t iInterface;
613 
617 
620  const unsigned char *extra;
621 
624 };
625 
633 
636 };
637 
645  uint8_t bLength;
646 
651 
653  uint16_t wTotalLength;
654 
656  uint8_t bNumInterfaces;
657 
660 
662  uint8_t iConfiguration;
663 
665  uint8_t bmAttributes;
666 
671  uint8_t MaxPower;
672 
676 
679  const unsigned char *extra;
680 
683 };
684 
692 
694  uint8_t bLength;
695 
700 
701 
704  uint8_t bMaxBurst;
705 
710  uint8_t bmAttributes;
711 
715 };
716 
724  uint8_t bLength;
732  uint8_t dev_capability_data
733 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
734  [] /* valid C99 code */
735 #else
736  [0] /* non-standard, but usually working code */
737 #endif
738  ;
739 };
740 
748  uint8_t bLength;
749 
754 
756  uint16_t wTotalLength;
757 
760  uint8_t bNumDeviceCaps;
761 
764 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
765  [] /* valid C99 code */
766 #else
767  [0] /* non-standard, but usually working code */
768 #endif
769  ;
770 };
771 
779  uint8_t bLength;
780 
785 
790 
795  uint32_t bmAttributes;
796 };
797 
805  uint8_t bLength;
806 
811 
816 
821  uint8_t bmAttributes;
822 
825  uint16_t wSpeedSupported;
826 
832 
834  uint8_t bU1DevExitLat;
835 
837  uint16_t bU2DevExitLat;
838 };
839 
847  uint8_t bLength;
848 
853 
858 
860  uint8_t bReserved;
861 
863  uint8_t ContainerID[16];
864 };
865 
874  uint8_t bmRequestType;
875 
881  uint8_t bRequest;
882 
884  uint16_t wValue;
885 
888  uint16_t wIndex;
889 
891  uint16_t wLength;
892 };
893 
894 #define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
895 
896 /* libusb */
897 
898 struct libusb_context;
899 struct libusb_device;
900 struct libusb_device_handle;
901 
907  const uint16_t major;
908 
910  const uint16_t minor;
911 
913  const uint16_t micro;
914 
916  const uint16_t nano;
917 
919  const char *rc;
920 
922  const char* describe;
923 };
924 
943 
960 
961 
971 
978 
981 
984 
987 
990 };
991 
999 
1002 
1005 
1008 };
1009 
1018 };
1019 
1028 };
1029 
1036 
1039 
1042 
1045 };
1046 
1057 
1060 
1063 
1066 
1069 
1072 
1075 
1078 
1081 
1084 
1087 
1090 
1093 
1094  /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
1095  message strings in strerror.c when adding new error codes here. */
1096 
1099 };
1100 
1101 /* Total number of error codes in enum libusb_error */
1102 #define LIBUSB_ERROR_COUNT 14
1103 
1110 
1113 
1116 
1119 
1123 
1126 
1129 
1130  /* NB! Remember to update libusb_error_name()
1131  when adding new status codes here. */
1132 };
1133 
1139 
1142 
1148 
1173 };
1174 
1179  unsigned int length;
1180 
1182  unsigned int actual_length;
1183 
1186 };
1187 
1188 struct libusb_transfer;
1189 
1199 typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
1200 
1210 
1212  uint8_t flags;
1213 
1215  unsigned char endpoint;
1216 
1218  unsigned char type;
1219 
1222  unsigned int timeout;
1223 
1232 
1234  int length;
1235 
1240 
1244 
1246  void *user_data;
1247 
1249  unsigned char *buffer;
1250 
1254 
1257 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1258  [] /* valid C99 code */
1259 #else
1260  [0] /* non-standard, but usually working code */
1261 #endif
1262  ;
1263 };
1264 
1283 };
1284 
1296  LIBUSB_LOG_LEVEL_NONE = 0,
1297  LIBUSB_LOG_LEVEL_ERROR,
1298  LIBUSB_LOG_LEVEL_WARNING,
1299  LIBUSB_LOG_LEVEL_INFO,
1300  LIBUSB_LOG_LEVEL_DEBUG,
1301 };
1302 
1305 void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
1306 const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
1307 int LIBUSB_CALL libusb_has_capability(uint32_t capability);
1308 const char * LIBUSB_CALL libusb_error_name(int errcode);
1309 int LIBUSB_CALL libusb_setlocale(const char *locale);
1310 const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode);
1311 
1313  libusb_device ***list);
1315  int unref_devices);
1318 
1320  int *config);
1322  struct libusb_device_descriptor *desc);
1324  struct libusb_config_descriptor **config);
1326  uint8_t config_index, struct libusb_config_descriptor **config);
1328  uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
1330  struct libusb_config_descriptor *config);
1332  struct libusb_context *ctx,
1333  const struct libusb_endpoint_descriptor *endpoint,
1334  struct libusb_ss_endpoint_companion_descriptor **ep_comp);
1336  struct libusb_ss_endpoint_companion_descriptor *ep_comp);
1338  struct libusb_bos_descriptor **bos);
1341  struct libusb_context *ctx,
1342  struct libusb_bos_dev_capability_descriptor *dev_cap,
1343  struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
1345  struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
1347  struct libusb_context *ctx,
1348  struct libusb_bos_dev_capability_descriptor *dev_cap,
1349  struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
1351  struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
1353  struct libusb_bos_dev_capability_descriptor *dev_cap,
1354  struct libusb_container_id_descriptor **container_id);
1356  struct libusb_container_id_descriptor *container_id);
1359 int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
1360 LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
1361 int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
1366  unsigned char endpoint);
1368  unsigned char endpoint);
1369 
1373 
1375  int configuration);
1377  int interface_number);
1379  int interface_number);
1380 
1382  libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
1383 
1385  int interface_number, int alternate_setting);
1387  unsigned char endpoint);
1389 
1391  uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
1393  unsigned char *endpoints, int num_endpoints);
1394 
1396  int interface_number);
1398  int interface_number);
1400  int interface_number);
1402  libusb_device_handle *dev, int enable);
1403 
1404 /* async I/O */
1405 
1418 static inline unsigned char *libusb_control_transfer_get_data(
1419  struct libusb_transfer *transfer)
1420 {
1421  return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
1422 }
1423 
1437  struct libusb_transfer *transfer)
1438 {
1439  return (struct libusb_control_setup *)(void *) transfer->buffer;
1440 }
1441 
1465 static inline void libusb_fill_control_setup(unsigned char *buffer,
1466  uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
1467  uint16_t wLength)
1468 {
1469  struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
1470  setup->bmRequestType = bmRequestType;
1471  setup->bRequest = bRequest;
1472  setup->wValue = libusb_cpu_to_le16(wValue);
1473  setup->wIndex = libusb_cpu_to_le16(wIndex);
1474  setup->wLength = libusb_cpu_to_le16(wLength);
1475 }
1476 
1477 struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
1478 int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
1479 int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
1480 void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
1482  struct libusb_transfer *transfer, uint32_t stream_id);
1484  struct libusb_transfer *transfer);
1485 
1514 static inline void libusb_fill_control_transfer(
1515  struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1516  unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
1517  unsigned int timeout)
1518 {
1519  struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
1520  transfer->dev_handle = dev_handle;
1521  transfer->endpoint = 0;
1522  transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
1523  transfer->timeout = timeout;
1524  transfer->buffer = buffer;
1525  if (setup)
1526  transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE
1527  + libusb_le16_to_cpu(setup->wLength));
1528  transfer->user_data = user_data;
1529  transfer->callback = callback;
1530 }
1531 
1545 static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
1546  libusb_device_handle *dev_handle, unsigned char endpoint,
1547  unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
1548  void *user_data, unsigned int timeout)
1549 {
1550  transfer->dev_handle = dev_handle;
1551  transfer->endpoint = endpoint;
1552  transfer->type = LIBUSB_TRANSFER_TYPE_BULK;
1553  transfer->timeout = timeout;
1554  transfer->buffer = buffer;
1555  transfer->length = length;
1556  transfer->user_data = user_data;
1557  transfer->callback = callback;
1558 }
1559 
1577  struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1578  unsigned char endpoint, uint32_t stream_id,
1579  unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
1580  void *user_data, unsigned int timeout)
1581 {
1582  libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
1583  length, callback, user_data, timeout);
1585  libusb_transfer_set_stream_id(transfer, stream_id);
1586 }
1587 
1602  struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1603  unsigned char endpoint, unsigned char *buffer, int length,
1604  libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
1605 {
1606  transfer->dev_handle = dev_handle;
1607  transfer->endpoint = endpoint;
1609  transfer->timeout = timeout;
1610  transfer->buffer = buffer;
1611  transfer->length = length;
1612  transfer->user_data = user_data;
1613  transfer->callback = callback;
1614 }
1615 
1630 static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
1631  libusb_device_handle *dev_handle, unsigned char endpoint,
1632  unsigned char *buffer, int length, int num_iso_packets,
1633  libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
1634 {
1635  transfer->dev_handle = dev_handle;
1636  transfer->endpoint = endpoint;
1638  transfer->timeout = timeout;
1639  transfer->buffer = buffer;
1640  transfer->length = length;
1641  transfer->num_iso_packets = num_iso_packets;
1642  transfer->user_data = user_data;
1643  transfer->callback = callback;
1644 }
1645 
1655  struct libusb_transfer *transfer, unsigned int length)
1656 {
1657  int i;
1658  for (i = 0; i < transfer->num_iso_packets; i++)
1659  transfer->iso_packet_desc[i].length = length;
1660 }
1661 
1678 static inline unsigned char *libusb_get_iso_packet_buffer(
1679  struct libusb_transfer *transfer, unsigned int packet)
1680 {
1681  int i;
1682  size_t offset = 0;
1683  int _packet;
1684 
1685  /* oops..slight bug in the API. packet is an unsigned int, but we use
1686  * signed integers almost everywhere else. range-check and convert to
1687  * signed to avoid compiler warnings. FIXME for libusb-2. */
1688  if (packet > INT_MAX)
1689  return NULL;
1690  _packet = (int) packet;
1691 
1692  if (_packet >= transfer->num_iso_packets)
1693  return NULL;
1694 
1695  for (i = 0; i < _packet; i++)
1696  offset += transfer->iso_packet_desc[i].length;
1697 
1698  return transfer->buffer + offset;
1699 }
1700 
1720 static inline unsigned char *libusb_get_iso_packet_buffer_simple(
1721  struct libusb_transfer *transfer, unsigned int packet)
1722 {
1723  int _packet;
1724 
1725  /* oops..slight bug in the API. packet is an unsigned int, but we use
1726  * signed integers almost everywhere else. range-check and convert to
1727  * signed to avoid compiler warnings. FIXME for libusb-2. */
1728  if (packet > INT_MAX)
1729  return NULL;
1730  _packet = (int) packet;
1731 
1732  if (_packet >= transfer->num_iso_packets)
1733  return NULL;
1734 
1735  return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet);
1736 }
1737 
1738 /* sync I/O */
1739 
1741  uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
1742  unsigned char *data, uint16_t wLength, unsigned int timeout);
1743 
1745  unsigned char endpoint, unsigned char *data, int length,
1746  int *actual_length, unsigned int timeout);
1747 
1749  unsigned char endpoint, unsigned char *data, int length,
1750  int *actual_length, unsigned int timeout);
1751 
1765  uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
1766 {
1768  LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index),
1769  0, data, (uint16_t) length, 1000);
1770 }
1771 
1787  uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
1788 {
1790  LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING << 8) | desc_index),
1791  langid, data, (uint16_t) length, 1000);
1792 }
1793 
1795  uint8_t desc_index, unsigned char *data, int length);
1796 
1797 /* polling and timeouts */
1798 
1806 int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
1807 
1809  struct timeval *tv);
1811  struct timeval *tv, int *completed);
1815  struct timeval *tv);
1818  struct timeval *tv);
1819 
1825  int fd;
1826 
1831  short events;
1832 };
1833 
1844 typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
1845  void *user_data);
1846 
1856 typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
1857 
1859  libusb_context *ctx);
1860 void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
1862  libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
1863  void *user_data);
1864 
1878 
1884 typedef enum {
1887 
1891 
1897 typedef enum {
1900 
1906 
1909 #define LIBUSB_HOTPLUG_MATCH_ANY -1
1910 
1934  libusb_device *device,
1935  libusb_hotplug_event event,
1936  void *user_data);
1937 
1973  libusb_hotplug_event events,
1974  libusb_hotplug_flag flags,
1975  int vendor_id, int product_id,
1976  int dev_class,
1978  void *user_data,
1979  libusb_hotplug_callback_handle *handle);
1980 
1993  libusb_hotplug_callback_handle handle);
1994 
1995 #ifdef __cplusplus
1996 }
1997 #endif
1998 
1999 #endif
uint8_t dev_capability_data[0]
Device Capability data (bLength - 3 bytes)
Definition: libusb.h:738
int libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config)
Get a USB configuration descriptor based on its index.
Definition: descriptor.c:625
const char * describe
For ABI compatibility only.
Definition: libusb.h:922
The device is operating at full speed (12MBit/s).
Definition: libusb.h:983
void libusb_free_ss_usb_device_capability_descriptor(struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap)
Free a SuperSpeed USB Device Capability descriptor obtained from libusb_get_ss_usb_device_capability_...
Definition: descriptor.c:1075
int libusb_has_capability(uint32_t capability)
Check at runtime if the loaded library has a given capability.
Definition: core.c:2173
uint16_t bU2DevExitLat
U2 Device Exit Latency.
Definition: libusb.h:837
uint8_t bFunctionalitySupport
The lowest speed at which all the functionality supported by the device is available to the user...
Definition: libusb.h:831
int libusb_get_configuration(libusb_device_handle *dev, int *config)
Determine the bConfigurationValue of the currently active configuration.
Definition: core.c:1465
uint8_t bInterfaceNumber
Number of this interface.
Definition: libusb.h:591
uint8_t bSynchAddress
For audio devices only: the address if the synch endpoint.
Definition: libusb.h:566
libusb_request_type
Request type bits of the bmRequestType field in control transfers.
Definition: libusb.h:401
Return the selected alternate setting for the specified interface.
Definition: libusb.h:381
Smart Card.
Definition: libusb.h:222
void libusb_free_config_descriptor(struct libusb_config_descriptor *config)
Free a configuration descriptor obtained from libusb_get_active_config_descriptor() or libusb_get_con...
Definition: descriptor.c:740
int libusb_open(libusb_device *dev, libusb_device_handle **handle)
Open a device and obtain a device handle.
Definition: core.c:1221
uint8_t bmAttributes
Attributes which apply to the endpoint when it is configured using the bConfigurationValue.
Definition: libusb.h:553
libusb_iso_sync_type
Synchronization type for isochronous endpoints.
Definition: libusb.h:440
A collection of alternate settings for a particular USB interface.
Definition: libusb.h:629
int libusb_set_interface_alt_setting(libusb_device_handle *dev, int interface_number, int alternate_setting)
Activate an alternate setting for an interface.
Definition: core.c:1667
void libusb_free_transfer(struct libusb_transfer *transfer)
Free a transfer structure.
Definition: io.c:1286
Automatically call libusb_free_transfer() after callback returns.
Definition: libusb.h:1147
void libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id)
Set a transfers bulk stream id.
Definition: io.c:1582
uint8_t bReserved
Reserved field.
Definition: libusb.h:860
enum libusb_transfer_status status
Status code for this packet.
Definition: libusb.h:1185
uint8_t bNumConfigurations
Number of possible configurations.
Definition: libusb.h:523
Data endpoint.
Definition: libusb.h:463
int libusb_event_handling_ok(libusb_context *ctx)
Determine if it is still OK for this thread to be doing event handling.
Definition: io.c:1804
uint8_t bRequest
Request.
Definition: libusb.h:881
int libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint)
Calculate the maximum packet size which a specific endpoint is capable is sending or receiving in the...
Definition: core.c:1081
void libusb_free_pollfds(const struct libusb_pollfd **pollfds)
Free a list of libusb_pollfd structures.
Definition: io.c:2699
static void libusb_fill_control_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for a control transfer.
Definition: libusb.h:1514
int libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
Wait for another thread to signal completion of an event.
Definition: io.c:1911
void libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle)
Deregisters a hotplug callback.
Definition: hotplug.c:308
void libusb_exit(libusb_context *ctx)
Deinitialize libusb.
Definition: core.c:2099
Endpoint.
Definition: libusb.h:427
const uint16_t nano
Library nano version.
Definition: libusb.h:916
uint8_t bDevCapabilityType
Capability type.
Definition: libusb.h:857
libusb_request_recipient
Recipient bits of the bmRequestType field in control transfers.
Definition: libusb.h:419
Data class.
Definition: libusb.h:219
SuperSpeed USB device capability.
Definition: libusb.h:1041
struct libusb_context libusb_context
Structure representing a libusb session.
Definition: libusb.h:942
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:724
uint8_t bDeviceSubClass
USB-IF subclass code for the device, qualified by the bDeviceClass value.
Definition: libusb.h:495
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:728
struct libusb_bos_dev_capability_descriptor * dev_capability[0]
bNumDeviceCap Device Capability Descriptors
Definition: libusb.h:763
A structure representing the standard USB configuration descriptor.
Definition: libusb.h:643
A generic representation of a BOS Device Capability descriptor.
Definition: libusb.h:722
uint8_t bInterval
Interval for polling endpoint for data transfers.
Definition: libusb.h:559
Arm the callback and fire it for all matching currently attached devices.
Definition: libusb.h:1889
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:479
#define LIBUSB_CALL
libusb's Windows calling convention.
Definition: libusb.h:121
Device Capability descriptor.
Definition: libusb.h:268
Set device configuration.
Definition: libusb.h:378
String descriptor.
Definition: libusb.h:256
enum libusb_transfer_status status
The status of the transfer.
Definition: libusb.h:1231
Endpoint descriptor.
Definition: libusb.h:262
const char * libusb_strerror(enum libusb_error errcode)
Returns a constant string with a short description of the given error code, this description is inten...
Definition: strerror.c:192
uint8_t bDeviceClass
USB-IF class code for the device.
Definition: libusb.h:491
short events
Event flags to poll for from .
Definition: libusb.h:1831
int libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int num_endpoints)
Free usb bulk streams allocated with libusb_alloc_streams().
Definition: core.c:1793
int libusb_get_active_config_descriptor(libusb_device *dev, struct libusb_config_descriptor **config)
Get the USB configuration descriptor for the currently active configuration.
Definition: descriptor.c:576
int extra_length
Length of the extra descriptors, in bytes.
Definition: libusb.h:573
libusb_speed
Speed codes.
Definition: libusb.h:975
A structure representing the SuperSpeed USB Device Capability descriptor This descriptor is documente...
Definition: libusb.h:803
uint8_t flags
A bitwise OR combination of libusb_transfer_flags.
Definition: libusb.h:1212
int libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle)
Register a hotplug callback function.
Definition: hotplug.c:230
Operation not supported or unimplemented on this platform.
Definition: libusb.h:1092
High speed operation supported (480MBit/s).
Definition: libusb.h:1004
Success (no error)
Definition: libusb.h:1056
int libusb_init(libusb_context **ctx)
Initialize libusb.
Definition: core.c:1985
Class is vendor-specific.
Definition: libusb.h:243
uint8_t bmAttributes
In bulk EP: bits 4:0 represents the maximum number of streams the EP supports.
Definition: libusb.h:710
void libusb_free_ss_endpoint_companion_descriptor(struct libusb_ss_endpoint_companion_descriptor *ep_comp)
Free a superspeed endpoint companion descriptor obtained from libusb_get_ss_endpoint_companion_descri...
Definition: descriptor.c:808
void libusb_set_debug(libusb_context *ctx, int level)
Set log message verbosity.
Definition: core.c:1965
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:538
libusb_hotplug_event
Since version 1.0.16, LIBUSB_API_VERSION >= 0x01000102.
Definition: libusb.h:1897
uint8_t libusb_get_device_address(libusb_device *dev)
Get the address of the device on the bus it is connected to.
Definition: core.c:971
uint8_t iSerialNumber
Index of string descriptor containing device serial number.
Definition: libusb.h:520
int libusb_handle_events_completed(libusb_context *ctx, int *completed)
Handle any pending events in blocking mode.
Definition: io.c:2378
static int libusb_get_string_descriptor(libusb_device_handle *dev, uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
Retrieve a descriptor from a device.
Definition: libusb.h:1786
void libusb_free_device_list(libusb_device **list, int unref_devices)
Frees a list of devices previously discovered using libusb_get_device_list().
Definition: core.c:859
Interrupt endpoint.
Definition: libusb.h:343
Insufficient memory.
Definition: libusb.h:1089
Stream endpoint.
Definition: libusb.h:346
void libusb_unref_device(libusb_device *dev)
Decrement the reference count of a device.
Definition: core.c:1135
const struct libusb_version * libusb_get_version(void)
Returns a pointer to const struct libusb_version with the version (major, minor, micro, nano and rc) of the running library.
Definition: core.c:2452
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:583
struct libusb_device_handle libusb_device_handle
Structure representing a handle on a USB device.
Definition: libusb.h:970
Vendor.
Definition: libusb.h:409
File descriptor for polling.
Definition: libusb.h:1823
#define libusb_le16_to_cpu
Convert a 16-bit value from little-endian to host-endian format.
Definition: libusb.h:180
uint8_t bNumInterfaces
Number of interfaces supported by this configuration.
Definition: libusb.h:656
Low speed operation supported (1.5MBit/s).
Definition: libusb.h:998
void libusb_lock_event_waiters(libusb_context *ctx)
Acquire the event waiters lock.
Definition: io.c:1869
uint8_t bmAttributes
Bitmap encoding of supported device level features.
Definition: libusb.h:821
Superspeed operation supported (5000MBit/s).
Definition: libusb.h:1007
int libusb_interrupt_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)
Perform a USB interrupt transfer.
Definition: sync.c:302
uint16_t bcdDevice
Device release number in binary-coded decimal.
Definition: libusb.h:511
libusb_descriptor_type
Descriptor types as defined by the USB specification.
Definition: libusb.h:248
unsigned char * buffer
Data buffer.
Definition: libusb.h:1249
int libusb_get_ss_endpoint_companion_descriptor(struct libusb_context *ctx, const struct libusb_endpoint_descriptor *endpoint, struct libusb_ss_endpoint_companion_descriptor **ep_comp)
Get an endpoints superspeed endpoint companion descriptor (if any)
Definition: descriptor.c:763
Hub descriptor.
Definition: libusb.h:280
No such device (it may have been disconnected)
Definition: libusb.h:1068
uint8_t bDeviceProtocol
USB-IF protocol code for the device, qualified by the bDeviceClass and bDeviceSubClass values...
Definition: libusb.h:499
Entity not found.
Definition: libusb.h:1071
static unsigned char * libusb_control_transfer_get_data(struct libusb_transfer *transfer)
Get the data section of a control transfer.
Definition: libusb.h:1418
int libusb_setlocale(const char *locale)
Set the language, and only the language, not the encoding! used for translatable libusb messages...
Definition: strerror.c:158
uint16_t wMaxPacketSize
Maximum packet size this endpoint is capable of sending/receiving.
Definition: libusb.h:556
uint8_t bDevCapabilityType
Capability type.
Definition: libusb.h:815
const unsigned char * extra
Extra descriptors.
Definition: libusb.h:570
int libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv)
Determine the next internal timeout that libusb needs to handle.
Definition: io.c:2487
Transfer was cancelled.
Definition: libusb.h:1118
Report short frames as errors.
Definition: libusb.h:1138
int fd
Numeric file descriptor.
Definition: libusb.h:1825
A structure representing the Container ID descriptor.
Definition: libusb.h:845
uint8_t iManufacturer
Index of string descriptor describing manufacturer.
Definition: libusb.h:514
uint8_t iInterface
Index of string descriptor describing this interface.
Definition: libusb.h:612
Set or enable a specific feature.
Definition: libusb.h:361
The generic USB transfer structure.
Definition: libusb.h:1207
Class.
Definition: libusb.h:406
static unsigned char * libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, unsigned int packet)
Convenience function to locate the position of an isochronous packet within the buffer of an isochron...
Definition: libusb.h:1720
int libusb_event_handler_active(libusb_context *ctx)
Determine if an active thread is handling events (i.e.
Definition: io.c:1832
Control endpoint.
Definition: libusb.h:334
Human Interface Device class.
Definition: libusb.h:200
int libusb_detach_kernel_driver(libusb_device_handle *dev, int interface_number)
Detach a kernel driver from an interface.
Definition: core.c:1860
SuperSpeed Endpoint Companion descriptor.
Definition: libusb.h:286
int libusb_handle_events(libusb_context *ctx)
Handle any pending events in blocking mode.
Definition: io.c:2356
BOS descriptor.
Definition: libusb.h:265
Input/output error.
Definition: libusb.h:1059
ssize_t libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
Returns a list of USB devices currently attached to the system.
Definition: core.c:792
int libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv)
Handle any pending events.
Definition: io.c:2336
unsigned int timeout
Timeout for this transfer in millseconds.
Definition: libusb.h:1222
int libusb_submit_transfer(struct libusb_transfer *transfer)
Submit a transfer.
Definition: io.c:1459
uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer)
Get a transfers bulk stream id.
Definition: io.c:1599
Bulk endpoint.
Definition: libusb.h:340
void libusb_free_usb_2_0_extension_descriptor(struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension)
Free a USB 2.0 Extension descriptor obtained from libusb_get_usb_2_0_extension_descriptor().
Definition: descriptor.c:1017
Implicit feedback Data endpoint.
Definition: libusb.h:469
Configuration descriptor.
Definition: libusb.h:253
int libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *path, uint8_t path_length)
Deprecated please use libusb_get_port_numbers instead.
Definition: core.c:941
int(* libusb_hotplug_callback_fn)(libusb_context *ctx, libusb_device *device, libusb_hotplug_event event, void *user_data)
Hotplug callback function type.
Definition: libusb.h:1933
uint8_t bDevCapabilityType
Device Capability type.
Definition: libusb.h:730
libusb_capability
Capabilities supported by an instance of libusb on the current running platform.
Definition: libusb.h:1270
Synchronous.
Definition: libusb.h:451
libusb_transfer_cb_fn callback
Callback function.
Definition: libusb.h:1243
Device.
Definition: libusb.h:421
int libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number)
Re-attach an interface's kernel driver, which was previously detached using libusb_detach_kernel_driv...
Definition: core.c:1894
A structure representing the standard USB interface descriptor.
Definition: libusb.h:581
const uint16_t minor
Library minor version.
Definition: libusb.h:910
const unsigned char * extra
Extra descriptors.
Definition: libusb.h:679
int libusb_control_transfer(libusb_device_handle *dev_handle, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout)
Perform a USB control transfer.
Definition: sync.c:91
A structure representing the standard USB device descriptor.
Definition: libusb.h:477
static int libusb_get_descriptor(libusb_device_handle *dev, uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
Retrieve a descriptor from the default control pipe.
Definition: libusb.h:1764
In the context of a device descriptor, this bDeviceClass value indicates that each interface specifie...
Definition: libusb.h:191
uint8_t bmRequestType
Request type.
Definition: libusb.h:874
Audio class.
Definition: libusb.h:194
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:533
uint8_t bEndpointAddress
The address of the endpoint described by this descriptor.
Definition: libusb.h:544
Standard.
Definition: libusb.h:403
const struct libusb_interface * interface
Array of interfaces supported by this configuration.
Definition: libusb.h:675
Resource busy.
Definition: libusb.h:1074
libusb_endpoint_direction
Endpoint direction.
Definition: libusb.h:318
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:694
uint8_t ContainerID[16]
128 bit UUID
Definition: libusb.h:863
Sets both the U1 and U2 Exit Latency.
Definition: libusb.h:390
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:588
A structure representing the superspeed endpoint companion descriptor.
Definition: libusb.h:691
void(* libusb_transfer_cb_fn)(struct libusb_transfer *transfer)
Asynchronous transfer callback function type.
Definition: libusb.h:1199
void libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
Free a BOS descriptor obtained from libusb_get_bos_descriptor().
Definition: descriptor.c:953
int extra_length
Length of the extra descriptors, in bytes.
Definition: libusb.h:623
const struct libusb_interface_descriptor * altsetting
Array of interface descriptors.
Definition: libusb.h:632
The device is operating at super speed (5000MBit/s).
Definition: libusb.h:989
int libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable)
Enable/disable libusb's automatic kernel driver detachment.
Definition: core.c:1930
Personal Healthcare.
Definition: libusb.h:231
HID report descriptor.
Definition: libusb.h:274
int libusb_get_usb_2_0_extension_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
Get an USB 2.0 Extension descriptor.
Definition: descriptor.c:978
const uint16_t major
Library major version.
Definition: libusb.h:907
uint8_t bU1DevExitLat
U1 Device Exit Latency.
Definition: libusb.h:834
uint8_t libusb_get_port_number(libusb_device *dev)
Get the number of the port that a device is connected to.
Definition: core.c:899
A structure representing the Binary Device Object Store (BOS) descriptor.
Definition: libusb.h:746
Application class.
Definition: libusb.h:240
int libusb_set_configuration(libusb_device_handle *dev, int configuration)
Set the active configuration for a device.
Definition: core.c:1543
static void libusb_fill_interrupt_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for an interrupt transfer.
Definition: libusb.h:1601
Supports Latency Tolerance Messages (LTM)
Definition: libusb.h:1027
Interface.
Definition: libusb.h:424
Transfer timed out.
Definition: libusb.h:1115
Video.
Definition: libusb.h:228
A device has been plugged in and is ready to use.
Definition: libusb.h:1899
Printer class.
Definition: libusb.h:206
libusb_usb_2_0_extension_attributes
Masks for the bits of the bmAttributes field of the USB 2.0 Extension descriptor. ...
Definition: libusb.h:1015
const uint16_t micro
Library micro version.
Definition: libusb.h:913
const char * libusb_error_name(int errcode)
Returns a constant NULL-terminated string with the ASCII name of a libusb error or transfer status co...
Definition: core.c:2397
Wireless class.
Definition: libusb.h:237
unsigned int actual_length
Amount of data that was actually transferred.
Definition: libusb.h:1182
libusb_ss_usb_device_capability_attributes
Masks for the bits of the bmAttributes field field of the SuperSpeed USB Device Capability descriptor...
Definition: libusb.h:1025
Request status of the specific recipient.
Definition: libusb.h:353
int num_altsetting
The number of alternate settings that belong to this interface.
Definition: libusb.h:635
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:779
libusb_hotplug_flag
Since version 1.0.16, LIBUSB_API_VERSION >= 0x01000102.
Definition: libusb.h:1884
Get the current device configuration value.
Definition: libusb.h:375
uint8_t bInterfaceClass
USB-IF class code for this interface.
Definition: libusb.h:601
void libusb_close(libusb_device_handle *dev_handle)
Close a device handle.
Definition: core.c:1387
static void libusb_fill_iso_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, int num_iso_packets, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for an isochronous transfer...
Definition: libusb.h:1630
libusb_transfer_type
Endpoint transfer type.
Definition: libusb.h:332
void libusb_set_pollfd_notifiers(libusb_context *ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data)
Register notification functions for file descriptor additions/removals.
Definition: io.c:2565
Container ID type.
Definition: libusb.h:1044
int libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint)
Clear the halt/stall condition for an endpoint.
Definition: core.c:1707
static struct libusb_control_setup * libusb_control_transfer_get_setup(struct libusb_transfer *transfer)
Get the control setup packet of a control transfer.
Definition: libusb.h:1436
void libusb_unlock_events(libusb_context *ctx)
Release the lock previously acquired with libusb_try_lock_events() or libusb_lock_events().
Definition: io.c:1769
uint16_t wValue
Value.
Definition: libusb.h:884
Asynchronous.
Definition: libusb.h:445
void(* libusb_pollfd_removed_cb)(int fd, void *user_data)
Callback function, invoked when a file descriptor should be removed from the set of file descriptors ...
Definition: libusb.h:1856
SuperSpeed Hub descriptor.
Definition: libusb.h:283
The library can access HID devices without requiring user intervention.
Definition: libusb.h:1279
Overflow.
Definition: libusb.h:1080
Clear or disable a specific feature.
Definition: libusb.h:356
uint8_t bmAttributes
Configuration characteristics.
Definition: libusb.h:665
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:650
int length
Length of the data buffer.
Definition: libusb.h:1234
USB 2.0 extensions.
Definition: libusb.h:1038
int libusb_get_config_descriptor_by_value(libusb_device *dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config)
Get a USB configuration descriptor with a specific bConfigurationValue.
Definition: descriptor.c:709
void * user_data
User context data to pass to the callback function.
Definition: libusb.h:1246
Other.
Definition: libusb.h:430
uint8_t bNumEndpoints
Number of endpoints used by this interface (excluding the control endpoint).
Definition: libusb.h:598
Out: host-to-device.
Definition: libusb.h:323
uint16_t wIndex
Index.
Definition: libusb.h:888
Set then report an endpoint's synchronization frame.
Definition: libusb.h:387
Set device address for all future accesses.
Definition: libusb.h:366
A structure representing the USB 2.0 Extension descriptor This descriptor is documented in section 9...
Definition: libusb.h:777
static void libusb_fill_control_setup(unsigned char *buffer, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength)
Helper function to populate the setup packet (first 8 bytes of the data buffer) for a control transfe...
Definition: libusb.h:1465
uint8_t bDevCapabilityType
Capability type.
Definition: libusb.h:789
Physical descriptor.
Definition: libusb.h:277
void libusb_unlock_event_waiters(libusb_context *ctx)
Release the event waiters lock.
Definition: io.c:1880
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:810
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:748
int libusb_bulk_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)
Perform a USB bulk transfer.
Definition: sync.c:253
Access denied (insufficient permissions)
Definition: libusb.h:1065
libusb_transfer_status
Transfer status codes.
Definition: libusb.h:1106
Setup packet for control transfers.
Definition: libusb.h:868
Get the specified descriptor.
Definition: libusb.h:369
int libusb_claim_interface(libusb_device_handle *dev, int interface_number)
Claim an interface on a given device handle.
Definition: core.c:1578
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:852
libusb_device_handle * dev_handle
Handle of the device that this transfer will be submitted to.
Definition: libusb.h:1209
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:784
uint8_t bNumDeviceCaps
The number of separate device capability descriptors in the BOS.
Definition: libusb.h:760
libusb_transfer_flags
libusb_transfer.flags values
Definition: libusb.h:1136
uint16_t wTotalLength
Total length of data returned for this configuration.
Definition: libusb.h:653
uint16_t idProduct
USB-IF product ID.
Definition: libusb.h:508
uint16_t wTotalLength
Length of this descriptor and all of its sub descriptors.
Definition: libusb.h:756
Device descriptor.
Definition: libusb.h:250
static unsigned char * libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, unsigned int packet)
Convenience function to locate the position of an isochronous packet within the buffer of an isochron...
Definition: libusb.h:1678
int libusb_hotplug_callback_handle
Callback handle.
Definition: libusb.h:1877
Device sent more data than requested.
Definition: libusb.h:1128
int libusb_try_lock_events(libusb_context *ctx)
Attempt to acquire the event handling lock.
Definition: io.c:1712
void libusb_lock_events(libusb_context *ctx)
Acquire the event handling lock, blocking until successful acquisition if it is contended.
Definition: io.c:1754
Communications class.
Definition: libusb.h:197
uint16_t wLength
Number of bytes to transfer.
Definition: libusb.h:891
int libusb_get_device_descriptor(libusb_device *dev, struct libusb_device_descriptor *desc)
Get the USB device descriptor for a given device.
Definition: descriptor.c:553
int libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv)
Handle any pending events by polling file descriptors, without checking if any other threads are alre...
Definition: io.c:2404
uint16_t idVendor
USB-IF vendor ID.
Definition: libusb.h:505
int libusb_kernel_driver_active(libusb_device_handle *dev, int interface_number)
Determine if a kernel driver is active on an interface.
Definition: core.c:1825
uint8_t bInterfaceSubClass
USB-IF subclass code for this interface, qualified by the bInterfaceClass value.
Definition: libusb.h:605
A structure representing the standard USB endpoint descriptor.
Definition: libusb.h:531
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:805
uint8_t bConfigurationValue
Identifier value for this configuration.
Definition: libusb.h:659
libusb_supported_speed
Supported speeds (wSpeedSupported) bitfield.
Definition: libusb.h:996
libusb_bos_type
USB capability types.
Definition: libusb.h:1033
int num_iso_packets
Number of isochronous packets.
Definition: libusb.h:1253
int libusb_handle_events_timeout_completed(libusb_context *ctx, struct timeval *tv, int *completed)
Handle any pending events.
Definition: io.c:2267
libusb_device_handle * libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id, uint16_t product_id)
Convenience function for finding a device with a particular idVendor/idProduct combination.
Definition: core.c:1283
int actual_length
Actual length of data that was transferred.
Definition: libusb.h:1239
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:484
int libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len)
Get the list of all port numbers from root for the specified device.
Definition: core.c:915
Hotplug support is available on this platform.
Definition: libusb.h:1274
The device is operating at low speed (1.5MBit/s).
Definition: libusb.h:980
int libusb_reset_device(libusb_device_handle *dev)
Perform a USB port reset to reinitialize a device.
Definition: core.c:1736
Default value when not using any flags.
Definition: libusb.h:1886
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:645
Transfer completed without error.
Definition: libusb.h:1109
int libusb_get_ss_usb_device_capability_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap)
Get a SuperSpeed USB Device Capability descriptor.
Definition: descriptor.c:1036
uint8_t bMaxPacketSize0
Maximum packet size for endpoint 0.
Definition: libusb.h:502
uint8_t iProduct
Index of string descriptor describing product.
Definition: libusb.h:517
static uint16_t libusb_cpu_to_le16(const uint16_t x)
Convert a 16-bit value from host-endian to little-endian format.
Definition: libusb.h:161
Isochronous endpoint.
Definition: libusb.h:337
int libusb_cancel_transfer(struct libusb_transfer *transfer)
Asynchronously cancel a previously submitted transfer.
Definition: io.c:1536
void libusb_free_container_id_descriptor(struct libusb_container_id_descriptor *container_id)
Free a Container ID descriptor obtained from libusb_get_container_id_descriptor().
Definition: descriptor.c:1132
libusb_device * libusb_ref_device(libusb_device *dev)
Increment the reference count of a device.
Definition: core.c:1122
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:847
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:753
libusb_device * libusb_get_device(libusb_device_handle *dev_handle)
Get the underlying device for a handle.
Definition: core.c:1440
Device was disconnected.
Definition: libusb.h:1125
int extra_length
Length of the extra descriptors, in bytes.
Definition: libusb.h:682
uint32_t bmAttributes
Bitmap encoding of supported device level features.
Definition: libusb.h:795
Transfer failed.
Definition: libusb.h:1112
uint16_t wBytesPerInterval
The total number of bytes this EP will transfer every service interval.
Definition: libusb.h:714
int libusb_get_device_speed(libusb_device *dev)
Get the negotiated connection speed for a device.
Definition: core.c:982
uint8_t iConfiguration
Index of string descriptor describing this configuration.
Definition: libusb.h:662
int libusb_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_t desc_index, unsigned char *data, int length)
Retrieve a string descriptor in C style ASCII.
Definition: descriptor.c:1150
Invalid parameter.
Definition: libusb.h:1062
unsigned int length
Length of data to request in this packet.
Definition: libusb.h:1179
struct libusb_device libusb_device
Structure representing a USB device detected on the system.
Definition: libusb.h:959
const unsigned char * extra
Extra descriptors.
Definition: libusb.h:620
uint8_t bAlternateSetting
Value used to select this alternate setting for this interface.
Definition: libusb.h:594
uint8_t libusb_get_bus_number(libusb_device *dev)
Get the number of the bus that a device is connected to.
Definition: core.c:880
Image class.
Definition: libusb.h:209
The libusb_has_capability() API is available.
Definition: libusb.h:1272
The library supports detaching of the default USB driver, using libusb_detach_kernel_driver(), if one is set by the OS kernel.
Definition: libusb.h:1282
int libusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
Allocate up to num_streams usb bulk streams on the specified endpoints.
Definition: core.c:1766
int libusb_get_container_id_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_container_id_descriptor **container_id)
Get a Container ID descriptor.
Definition: descriptor.c:1094
Physical.
Definition: libusb.h:203
In: device-to-host.
Definition: libusb.h:320
Reserved.
Definition: libusb.h:412
Delay from the time a host transmits a packet to the time it is received by the device.
Definition: libusb.h:394
Other error.
Definition: libusb.h:1098
unsigned char endpoint
Address of the endpoint where this transfer will be sent.
Definition: libusb.h:1215
Diagnostic Device.
Definition: libusb.h:234
const struct libusb_pollfd ** libusb_get_pollfds(libusb_context *ctx)
Retrieve a list of file descriptors that should be polled by your main loop as libusb event sources...
Definition: io.c:2659
Mass storage class.
Definition: libusb.h:213
HID descriptor.
Definition: libusb.h:271
libusb_iso_usage_type
Usage type for isochronous endpoints.
Definition: libusb.h:461
uint8_t bInterfaceProtocol
USB-IF protocol code for this interface, qualified by the bInterfaceClass and bInterfaceSubClass valu...
Definition: libusb.h:609
Terminate transfers that are a multiple of the endpoint's wMaxPacketSize with an extra zero length pa...
Definition: libusb.h:1172
uint16_t bcdUSB
USB specification release number in binary-coded decimal.
Definition: libusb.h:488
static void libusb_fill_bulk_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for a bulk transfer.
Definition: libusb.h:1545
Content Security.
Definition: libusb.h:225
The OS doesn't report or know the device speed.
Definition: libusb.h:977
The device is operating at high speed (480MBit/s).
Definition: libusb.h:986
Operation timed out.
Definition: libusb.h:1077
Feedback endpoint.
Definition: libusb.h:466
static void libusb_fill_bulk_stream_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, uint32_t stream_id, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for a bulk transfer using bulk stream...
Definition: libusb.h:1576
int libusb_release_interface(libusb_device_handle *dev, int interface_number)
Release an interface previously claimed with libusb_claim_interface().
Definition: core.c:1622
Structure providing the version of the libusb runtime.
Definition: libusb.h:905
Wireless USB device capability.
Definition: libusb.h:1035
uint8_t bMaxBurst
The maximum number of packets the endpoint can send or recieve as part of a burst.
Definition: libusb.h:704
uint16_t wSpeedSupported
Bitmap encoding of the speed supported by this device when operating in SuperSpeed mode...
Definition: libusb.h:825
Pipe error.
Definition: libusb.h:1083
int libusb_pollfds_handle_timeouts(libusb_context *ctx)
Determines whether your application must apply special timing considerations when monitoring libusb's...
Definition: io.c:2448
Full speed operation supported (12MBit/s).
Definition: libusb.h:1001
libusb_standard_request
Standard requests, as defined in table 9-5 of the USB 3.0 specifications.
Definition: libusb.h:351
Adaptive.
Definition: libusb.h:448
const struct libusb_endpoint_descriptor * endpoint
Array of endpoint descriptors.
Definition: libusb.h:616
libusb_class_code
Device and/or Interface Class codes.
Definition: libusb.h:186
A device has left and is no longer available.
Definition: libusb.h:1904
void(* libusb_pollfd_added_cb)(int fd, short events, void *user_data)
Callback function, invoked when a new file descriptor should be added to the set of file descriptors ...
Definition: libusb.h:1844
No synchronization.
Definition: libusb.h:442
Isochronous packet descriptor.
Definition: libusb.h:1177
Automatically free() transfer buffer during libusb_free_transfer()
Definition: libusb.h:1141
Interface descriptor.
Definition: libusb.h:259
System call interrupted (perhaps due to signal)
Definition: libusb.h:1086
libusb_device * libusb_get_parent(libusb_device *dev)
Get the the parent from the specified device.
Definition: core.c:961
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:699
const char * rc
Library release candidate suffix string, e.g.
Definition: libusb.h:919
For bulk/interrupt endpoints: halt condition detected (endpoint stalled).
Definition: libusb.h:1122
Supports Link Power Management (LPM)
Definition: libusb.h:1017
int libusb_get_bos_descriptor(libusb_device_handle *handle, struct libusb_bos_descriptor **bos)
Get a Binary Object Store (BOS) descriptor This is a BLOCKING function, which will send requests to t...
Definition: descriptor.c:904
Used to update existing descriptors or add new descriptors.
Definition: libusb.h:372
uint8_t MaxPower
Maximum power consumption of the USB device from this bus in this configuration when the device is fu...
Definition: libusb.h:671
int libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint)
Convenience function to retrieve the wMaxPacketSize value for a particular endpoint in the active dev...
Definition: core.c:1028
unsigned char type
Type of the endpoint from libusb_transfer_type.
Definition: libusb.h:1218
libusb_error
Error codes.
Definition: libusb.h:1054
libusb_log_level
Log message levels.
Definition: libusb.h:1295
struct libusb_transfer * libusb_alloc_transfer(int iso_packets)
Allocate a libusb transfer with a specified number of isochronous packet descriptors.
Definition: io.c:1248
Select an alternate interface for the specified interface.
Definition: libusb.h:384
struct libusb_iso_packet_descriptor iso_packet_desc[0]
Isochronous packet descriptors, for isochronous transfers only.
Definition: libusb.h:1256
uint8_t bRefresh
For audio devices only: the rate at which synchronization feedback is provided.
Definition: libusb.h:563
static void libusb_set_iso_packet_lengths(struct libusb_transfer *transfer, unsigned int length)
Convenience function to set the length of all packets in an isochronous transfer, based on the num_is...
Definition: libusb.h:1654
Hub class.
Definition: libusb.h:216