usb 2.17.0 → 3.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/LICENSE +18 -4
  2. package/README.md +25 -516
  3. package/dist/index.d.ts +67 -13
  4. package/dist/index.js +333 -64
  5. package/index.d.ts +89 -0
  6. package/index.js +583 -0
  7. package/package.json +53 -33
  8. package/CHANGELOG.md +0 -294
  9. package/binding.gyp +0 -128
  10. package/dist/index.js.map +0 -1
  11. package/dist/usb/bindings.d.ts +0 -266
  12. package/dist/usb/bindings.js +0 -10
  13. package/dist/usb/bindings.js.map +0 -1
  14. package/dist/usb/capability.d.ts +0 -13
  15. package/dist/usb/capability.js +0 -17
  16. package/dist/usb/capability.js.map +0 -1
  17. package/dist/usb/descriptors.d.ts +0 -128
  18. package/dist/usb/descriptors.js +0 -3
  19. package/dist/usb/descriptors.js.map +0 -1
  20. package/dist/usb/device.d.ts +0 -100
  21. package/dist/usb/device.js +0 -297
  22. package/dist/usb/device.js.map +0 -1
  23. package/dist/usb/endpoint.d.ts +0 -94
  24. package/dist/usb/endpoint.js +0 -219
  25. package/dist/usb/endpoint.js.map +0 -1
  26. package/dist/usb/index.d.ts +0 -31
  27. package/dist/usb/index.js +0 -116
  28. package/dist/usb/index.js.map +0 -1
  29. package/dist/usb/interface.d.ts +0 -80
  30. package/dist/usb/interface.js +0 -133
  31. package/dist/usb/interface.js.map +0 -1
  32. package/dist/webusb/index.d.ts +0 -64
  33. package/dist/webusb/index.js +0 -295
  34. package/dist/webusb/index.js.map +0 -1
  35. package/dist/webusb/webusb-device.d.ts +0 -54
  36. package/dist/webusb/webusb-device.js +0 -434
  37. package/dist/webusb/webusb-device.js.map +0 -1
  38. package/libusb/.clang-tidy +0 -34
  39. package/libusb/.codespellrc +0 -3
  40. package/libusb/.private/README.txt +0 -5
  41. package/libusb/.private/appveyor_build.sh +0 -26
  42. package/libusb/.private/bm.sh +0 -54
  43. package/libusb/.private/ci-build.sh +0 -92
  44. package/libusb/.private/ci-container-build.sh +0 -67
  45. package/libusb/.private/post-rewrite.sh +0 -32
  46. package/libusb/.private/pre-commit.sh +0 -52
  47. package/libusb/.private/wbs.txt +0 -43
  48. package/libusb/.travis.yml +0 -58
  49. package/libusb/AUTHORS +0 -231
  50. package/libusb/COPYING +0 -504
  51. package/libusb/ChangeLog +0 -365
  52. package/libusb/HACKING +0 -25
  53. package/libusb/INSTALL_WIN.txt +0 -52
  54. package/libusb/KEYS +0 -123
  55. package/libusb/Makefile.am +0 -50
  56. package/libusb/NEWS +0 -2
  57. package/libusb/PORTING +0 -94
  58. package/libusb/README +0 -29
  59. package/libusb/README.git +0 -41
  60. package/libusb/TODO +0 -2
  61. package/libusb/Xcode/common.xcconfig +0 -92
  62. package/libusb/Xcode/config.h +0 -31
  63. package/libusb/Xcode/debug.xcconfig +0 -32
  64. package/libusb/Xcode/libusb.xcconfig +0 -21
  65. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +0 -1391
  66. package/libusb/Xcode/libusb_debug.xcconfig +0 -21
  67. package/libusb/Xcode/libusb_release.xcconfig +0 -21
  68. package/libusb/Xcode/release.xcconfig +0 -30
  69. package/libusb/android/README +0 -152
  70. package/libusb/android/config.h +0 -55
  71. package/libusb/android/examples/unrooted_android.c +0 -301
  72. package/libusb/android/examples/unrooted_android.h +0 -36
  73. package/libusb/android/jni/Android.mk +0 -23
  74. package/libusb/android/jni/Application.mk +0 -40
  75. package/libusb/android/jni/examples.mk +0 -168
  76. package/libusb/android/jni/libusb.mk +0 -60
  77. package/libusb/android/jni/tests.mk +0 -45
  78. package/libusb/appveyor.yml +0 -108
  79. package/libusb/autogen.sh +0 -10
  80. package/libusb/bootstrap.sh +0 -10
  81. package/libusb/configure.ac +0 -450
  82. package/libusb/doc/Makefile.in +0 -22
  83. package/libusb/doc/doxygen.cfg.in +0 -2571
  84. package/libusb/doc/libusb.png +0 -0
  85. package/libusb/examples/Makefile.am +0 -12
  86. package/libusb/examples/dpfp.c +0 -711
  87. package/libusb/examples/ezusb.c +0 -846
  88. package/libusb/examples/ezusb.h +0 -109
  89. package/libusb/examples/fxload.c +0 -310
  90. package/libusb/examples/hotplugtest.c +0 -147
  91. package/libusb/examples/listdevs.c +0 -73
  92. package/libusb/examples/sam3u_benchmark.c +0 -228
  93. package/libusb/examples/testlibusb.c +0 -312
  94. package/libusb/examples/xusb.c +0 -1254
  95. package/libusb/libusb/Makefile.am +0 -98
  96. package/libusb/libusb/Makefile.am.extra +0 -26
  97. package/libusb/libusb/core.c +0 -2925
  98. package/libusb/libusb/descriptor.c +0 -1558
  99. package/libusb/libusb/hotplug.c +0 -489
  100. package/libusb/libusb/io.c +0 -2865
  101. package/libusb/libusb/libusb-1.0.def +0 -199
  102. package/libusb/libusb/libusb-1.0.rc +0 -53
  103. package/libusb/libusb/libusb.h +0 -2421
  104. package/libusb/libusb/libusbi.h +0 -1535
  105. package/libusb/libusb/os/darwin_usb.c +0 -2977
  106. package/libusb/libusb/os/darwin_usb.h +0 -156
  107. package/libusb/libusb/os/emscripten_webusb.cpp +0 -875
  108. package/libusb/libusb/os/events_posix.c +0 -340
  109. package/libusb/libusb/os/events_posix.h +0 -62
  110. package/libusb/libusb/os/events_windows.c +0 -214
  111. package/libusb/libusb/os/events_windows.h +0 -46
  112. package/libusb/libusb/os/haiku_pollfs.cpp +0 -372
  113. package/libusb/libusb/os/haiku_usb.h +0 -113
  114. package/libusb/libusb/os/haiku_usb_backend.cpp +0 -532
  115. package/libusb/libusb/os/haiku_usb_raw.cpp +0 -231
  116. package/libusb/libusb/os/haiku_usb_raw.h +0 -188
  117. package/libusb/libusb/os/linux_netlink.c +0 -401
  118. package/libusb/libusb/os/linux_udev.c +0 -321
  119. package/libusb/libusb/os/linux_usbfs.c +0 -2829
  120. package/libusb/libusb/os/linux_usbfs.h +0 -221
  121. package/libusb/libusb/os/netbsd_usb.c +0 -617
  122. package/libusb/libusb/os/null_usb.c +0 -111
  123. package/libusb/libusb/os/openbsd_usb.c +0 -700
  124. package/libusb/libusb/os/sunos_usb.c +0 -1619
  125. package/libusb/libusb/os/sunos_usb.h +0 -79
  126. package/libusb/libusb/os/threads_posix.c +0 -126
  127. package/libusb/libusb/os/threads_posix.h +0 -98
  128. package/libusb/libusb/os/threads_windows.c +0 -40
  129. package/libusb/libusb/os/threads_windows.h +0 -113
  130. package/libusb/libusb/os/windows_common.c +0 -923
  131. package/libusb/libusb/os/windows_common.h +0 -424
  132. package/libusb/libusb/os/windows_usbdk.c +0 -724
  133. package/libusb/libusb/os/windows_usbdk.h +0 -106
  134. package/libusb/libusb/os/windows_winusb.c +0 -4766
  135. package/libusb/libusb/os/windows_winusb.h +0 -787
  136. package/libusb/libusb/strerror.c +0 -223
  137. package/libusb/libusb/sync.c +0 -342
  138. package/libusb/libusb/version.h +0 -18
  139. package/libusb/libusb/version_nano.h +0 -1
  140. package/libusb/libusb-1.0.pc.in +0 -11
  141. package/libusb/msvc/Base.props +0 -60
  142. package/libusb/msvc/Configuration.Application.props +0 -7
  143. package/libusb/msvc/Configuration.Base.props +0 -47
  144. package/libusb/msvc/Configuration.DynamicLibrary.props +0 -21
  145. package/libusb/msvc/Configuration.StaticLibrary.props +0 -7
  146. package/libusb/msvc/ProjectConfigurations.Base.props +0 -69
  147. package/libusb/msvc/build_all.ps1 +0 -17
  148. package/libusb/msvc/config.h +0 -58
  149. package/libusb/msvc/dpfp.vcxproj +0 -33
  150. package/libusb/msvc/dpfp_threaded.vcxproj +0 -38
  151. package/libusb/msvc/fxload.vcxproj +0 -46
  152. package/libusb/msvc/getopt/getopt.c +0 -1060
  153. package/libusb/msvc/getopt/getopt.h +0 -180
  154. package/libusb/msvc/getopt/getopt1.c +0 -188
  155. package/libusb/msvc/getopt.vcxproj +0 -33
  156. package/libusb/msvc/hotplugtest.vcxproj +0 -32
  157. package/libusb/msvc/init_context.vcxproj +0 -35
  158. package/libusb/msvc/libusb.sln +0 -542
  159. package/libusb/msvc/libusb_dll.vcxproj +0 -61
  160. package/libusb/msvc/libusb_static.vcxproj +0 -49
  161. package/libusb/msvc/listdevs.vcxproj +0 -32
  162. package/libusb/msvc/sam3u_benchmark.vcxproj +0 -33
  163. package/libusb/msvc/set_option.vcxproj +0 -35
  164. package/libusb/msvc/stress.vcxproj +0 -35
  165. package/libusb/msvc/stress_mt.vcxproj +0 -33
  166. package/libusb/msvc/testlibusb.vcxproj +0 -32
  167. package/libusb/msvc/xusb.vcxproj +0 -38
  168. package/libusb/tests/Makefile.am +0 -40
  169. package/libusb/tests/init_context.c +0 -153
  170. package/libusb/tests/libusb_testlib.h +0 -76
  171. package/libusb/tests/macos.c +0 -130
  172. package/libusb/tests/set_option.c +0 -253
  173. package/libusb/tests/stress.c +0 -172
  174. package/libusb/tests/stress_mt.c +0 -267
  175. package/libusb/tests/testlib.c +0 -184
  176. package/libusb/tests/umockdev.c +0 -1175
  177. package/libusb/tests/webusb-test-shim/index.js +0 -12
  178. package/libusb/tests/webusb-test-shim/package-lock.json +0 -50
  179. package/libusb/tests/webusb-test-shim/package.json +0 -10
  180. package/libusb.gypi +0 -154
  181. package/libusb_config/config.h +0 -1
  182. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  183. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  184. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  185. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  186. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  187. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  188. package/prebuilds/linux-ia32/node.napi.node +0 -0
  189. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  190. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  191. package/prebuilds/win32-arm64/node.napi.node +0 -0
  192. package/prebuilds/win32-ia32/node.napi.node +0 -0
  193. package/prebuilds/win32-x64/node.napi.node +0 -0
  194. package/src/device.cc +0 -439
  195. package/src/helpers.h +0 -64
  196. package/src/hotplug/hotplug.h +0 -22
  197. package/src/hotplug/libusb.cc +0 -90
  198. package/src/hotplug/windows.cc +0 -168
  199. package/src/node_usb.cc +0 -314
  200. package/src/node_usb.h +0 -131
  201. package/src/thread_name.cc +0 -79
  202. package/src/thread_name.h +0 -11
  203. package/src/transfer.cc +0 -143
  204. package/src/uv_async_queue.h +0 -41
  205. package/test/usb.coffee +0 -250
  206. package/test/webusb.coffee +0 -227
  207. package/test/worker.cjs +0 -13
@@ -1,223 +0,0 @@
1
- /*
2
- * libusb strerror code
3
- * Copyright © 2013 Hans de Goede <hdegoede@redhat.com>
4
- *
5
- * This library is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU Lesser General Public
7
- * License as published by the Free Software Foundation; either
8
- * version 2.1 of the License, or (at your option) any later version.
9
- *
10
- * This library is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * Lesser General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- */
19
-
20
- #include "libusbi.h"
21
-
22
- #include <ctype.h>
23
- #include <string.h>
24
-
25
- /** \ingroup libusb_misc
26
- * How to add a new \ref libusb_strerror() translation:
27
- * <ol>
28
- * <li> Download the latest \c strerror.c from:<br>
29
- * https://raw.github.com/libusb/libusb/master/libusb/strerror.c </li>
30
- * <li> Open the file in an UTF-8 capable editor </li>
31
- * <li> Add the 2 letter <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 639-1</a>
32
- * code for your locale at the end of \c usbi_locale_supported[]<br>
33
- * Eg. for Chinese, you would add "zh" so that:
34
- * \code... usbi_locale_supported[] = { "en", "nl", "fr" };\endcode
35
- * becomes:
36
- * \code... usbi_locale_supported[] = { "en", "nl", "fr", "zh" };\endcode </li>
37
- * <li> Copy the <tt>{ / * English (en) * / ... }</tt> section and add it at the end of \c usbi_localized_errors<br>
38
- * Eg. for Chinese, the last section of \c usbi_localized_errors could look like:
39
- * \code
40
- * }, { / * Chinese (zh) * /
41
- * "Success",
42
- * ...
43
- * "Other error",
44
- * },
45
- * };\endcode </li>
46
- * <li> Translate each of the English messages from the section you copied into your language </li>
47
- * <li> Save the file (in UTF-8 format) and send it to \c libusb-devel\@lists.sourceforge.net </li>
48
- * </ol>
49
- */
50
-
51
- static const char * const usbi_locale_supported[] = { "en", "nl", "fr", "ru", "de", "hu" };
52
- static const char * const usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUSB_ERROR_COUNT] = {
53
- { /* English (en) */
54
- "Success",
55
- "Input/Output Error",
56
- "Invalid parameter",
57
- "Access denied (insufficient permissions)",
58
- "No such device (it may have been disconnected)",
59
- "Entity not found",
60
- "Resource busy",
61
- "Operation timed out",
62
- "Overflow",
63
- "Pipe error",
64
- "System call interrupted (perhaps due to signal)",
65
- "Insufficient memory",
66
- "Operation not supported or unimplemented on this platform",
67
- "Other error",
68
- }, { /* Dutch (nl) */
69
- "Gelukt",
70
- "Invoer-/uitvoerfout",
71
- "Ongeldig argument",
72
- "Toegang geweigerd (onvoldoende toegangsrechten)",
73
- "Apparaat bestaat niet (verbinding met apparaat verbroken?)",
74
- "Niet gevonden",
75
- "Apparaat of hulpbron is bezig",
76
- "Bewerking verlopen",
77
- "Waarde is te groot",
78
- "Gebroken pijp",
79
- "Onderbroken systeemaanroep",
80
- "Onvoldoende geheugen beschikbaar",
81
- "Bewerking wordt niet ondersteund",
82
- "Andere fout",
83
- }, { /* French (fr) */
84
- "Succès",
85
- "Erreur d'entrée/sortie",
86
- "Paramètre invalide",
87
- "Accès refusé (permissions insuffisantes)",
88
- "Périphérique introuvable (peut-être déconnecté)",
89
- "Elément introuvable",
90
- "Resource déjà occupée",
91
- "Operation expirée",
92
- "Débordement",
93
- "Erreur de pipe",
94
- "Appel système abandonné (peut-être à cause d’un signal)",
95
- "Mémoire insuffisante",
96
- "Opération non supportée or non implémentée sur cette plateforme",
97
- "Autre erreur",
98
- }, { /* Russian (ru) */
99
- "Успех",
100
- "Ошибка ввода/вывода",
101
- "Неверный параметр",
102
- "Доступ запрещён (не хватает прав)",
103
- "Устройство отсутствует (возможно, оно было отсоединено)",
104
- "Элемент не найден",
105
- "Ресурс занят",
106
- "Истекло время ожидания операции",
107
- "Переполнение",
108
- "Ошибка канала",
109
- "Системный вызов прерван (возможно, сигналом)",
110
- "Память исчерпана",
111
- "Операция не поддерживается данной платформой",
112
- "Неизвестная ошибка"
113
- }, { /* German (de) */
114
- "Erfolgreich",
115
- "Eingabe-/Ausgabefehler",
116
- "Ungültiger Parameter",
117
- "Keine Berechtigung (Zugriffsrechte fehlen)",
118
- "Kein passendes Gerät gefunden (es könnte entfernt worden sein)",
119
- "Entität nicht gefunden",
120
- "Die Ressource ist belegt",
121
- "Die Wartezeit für die Operation ist abgelaufen",
122
- "Mehr Daten empfangen als erwartet",
123
- "Datenübergabe unterbrochen (broken pipe)",
124
- "Unterbrechung während des Betriebssystemaufrufs",
125
- "Nicht genügend Hauptspeicher verfügbar",
126
- "Die Operation wird nicht unterstützt oder ist auf dieser Platform nicht implementiert",
127
- "Allgemeiner Fehler",
128
- }, { /* Hungarian (hu) */
129
- "Sikeres",
130
- "Be-/kimeneti hiba",
131
- "Érvénytelen paraméter",
132
- "Hozzáférés megtagadva",
133
- "Az eszköz nem található (eltávolították?)",
134
- "Nem található",
135
- "Az erőforrás foglalt",
136
- "Időtúllépés",
137
- "Túlcsordulás",
138
- "Törött adatcsatorna",
139
- "Rendszerhívás megszakítva",
140
- "Nincs elég memória",
141
- "A művelet nem támogatott ezen a rendszeren",
142
- "Általános hiba",
143
- },
144
- };
145
-
146
- static const char * const (*usbi_error_strings)[LIBUSB_ERROR_COUNT] = &usbi_localized_errors[0];
147
-
148
- /** \ingroup libusb_misc
149
- * Set the language, and only the language, not the encoding! used for
150
- * translatable libusb messages.
151
- *
152
- * This takes a locale string in the default setlocale format: lang[-region]
153
- * or lang[_country_region][.codeset]. Only the lang part of the string is
154
- * used, and only 2 letter ISO 639-1 codes are accepted for it, such as "de".
155
- * The optional region, country_region or codeset parts are ignored. This
156
- * means that functions which return translatable strings will NOT honor the
157
- * specified encoding.
158
- * All strings returned are encoded as UTF-8 strings.
159
- *
160
- * If libusb_setlocale() is not called, all messages will be in English.
161
- *
162
- * The following functions return translatable strings: libusb_strerror().
163
- * Note that the libusb log messages controlled through LIBUSB_OPTION_LOG_LEVEL
164
- * are not translated, they are always in English.
165
- *
166
- * For POSIX UTF-8 environments if you want libusb to follow the standard
167
- * locale settings, call libusb_setlocale(setlocale(LC_MESSAGES, NULL)),
168
- * after your app has done its locale setup.
169
- *
170
- * \param locale locale-string in the form of lang[_country_region][.codeset]
171
- * or lang[-region], where lang is a 2 letter ISO 639-1 code
172
- * \returns \ref LIBUSB_SUCCESS on success
173
- * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the locale doesn't meet the requirements
174
- * \returns \ref LIBUSB_ERROR_NOT_FOUND if the requested language is not supported
175
- * \returns a LIBUSB_ERROR code on other errors
176
- */
177
-
178
- int API_EXPORTED libusb_setlocale(const char *locale)
179
- {
180
- size_t i;
181
-
182
- if (!locale || strlen(locale) < 2
183
- || (locale[2] != '\0' && locale[2] != '-' && locale[2] != '_' && locale[2] != '.'))
184
- return LIBUSB_ERROR_INVALID_PARAM;
185
-
186
- for (i = 0; i < ARRAYSIZE(usbi_locale_supported); i++) {
187
- if (usbi_locale_supported[i][0] == tolower((unsigned char)locale[0])
188
- && usbi_locale_supported[i][1] == tolower((unsigned char)locale[1]))
189
- break;
190
- }
191
-
192
- if (i == ARRAYSIZE(usbi_locale_supported))
193
- return LIBUSB_ERROR_NOT_FOUND;
194
-
195
- usbi_error_strings = &usbi_localized_errors[i];
196
-
197
- return LIBUSB_SUCCESS;
198
- }
199
-
200
- /** \ingroup libusb_misc
201
- * Returns a constant string with a short description of the given error code,
202
- * this description is intended for displaying to the end user and will be in
203
- * the language set by libusb_setlocale().
204
- *
205
- * The returned string is encoded in UTF-8.
206
- *
207
- * The messages always start with a capital letter and end without any dot.
208
- * The caller must not free() the returned string.
209
- *
210
- * \param errcode the error code whose description is desired
211
- * \returns a short description of the error code in UTF-8 encoding
212
- */
213
- DEFAULT_VISIBILITY const char * LIBUSB_CALL libusb_strerror(int errcode)
214
- {
215
- int errcode_index = -errcode;
216
-
217
- if (errcode_index < 0 || errcode_index >= LIBUSB_ERROR_COUNT) {
218
- /* "Other Error", which should always be our last message, is returned */
219
- errcode_index = LIBUSB_ERROR_COUNT - 1;
220
- }
221
-
222
- return (*usbi_error_strings)[errcode_index];
223
- }
@@ -1,342 +0,0 @@
1
- /* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
2
- /*
3
- * Synchronous I/O functions for libusb
4
- * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
5
- * Copyright © 2019 Nathan Hjelm <hjelmn@cs.unm.edu>
6
- * Copyright © 2019 Google LLC. All rights reserved.
7
- *
8
- * This library is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU Lesser General Public
10
- * License as published by the Free Software Foundation; either
11
- * version 2.1 of the License, or (at your option) any later version.
12
- *
13
- * This library is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * Lesser General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU Lesser General Public
19
- * License along with this library; if not, write to the Free Software
20
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
- */
22
-
23
- #include "libusbi.h"
24
-
25
- #include <assert.h>
26
- #include <string.h>
27
-
28
- /**
29
- * @defgroup libusb_syncio Synchronous device I/O
30
- *
31
- * This page documents libusb's synchronous (blocking) API for USB device I/O.
32
- * This interface is easy to use but has some limitations. More advanced users
33
- * may wish to consider using the \ref libusb_asyncio "asynchronous I/O API" instead.
34
- */
35
-
36
- static void LIBUSB_CALL sync_transfer_cb(struct libusb_transfer *transfer)
37
- {
38
- usbi_dbg(TRANSFER_CTX(transfer), "actual_length=%d", transfer->actual_length);
39
-
40
- int *completed = transfer->user_data;
41
- *completed = 1;
42
- /*
43
- * Right after setting 'completed', another thread might free the transfer, so don't
44
- * access it beyond this point. The instantiating thread (not necessarily the
45
- * current one) interprets the result and frees the transfer.
46
- */
47
- }
48
-
49
- static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer)
50
- {
51
- int r, *completed = transfer->user_data;
52
- struct libusb_context *ctx = HANDLE_CTX(transfer->dev_handle);
53
-
54
- while (!*completed) {
55
- r = libusb_handle_events_completed(ctx, completed);
56
- if (r < 0) {
57
- if (r == LIBUSB_ERROR_INTERRUPTED)
58
- continue;
59
- usbi_err(ctx, "libusb_handle_events failed: %s, cancelling transfer and retrying",
60
- libusb_error_name(r));
61
- libusb_cancel_transfer(transfer);
62
- continue;
63
- }
64
- if (NULL == transfer->dev_handle) {
65
- /* transfer completion after libusb_close() */
66
- transfer->status = LIBUSB_TRANSFER_NO_DEVICE;
67
- *completed = 1;
68
- }
69
- }
70
- }
71
-
72
- /** \ingroup libusb_syncio
73
- * Perform a USB control transfer.
74
- *
75
- * The direction of the transfer is inferred from the bmRequestType field of
76
- * the setup packet.
77
- *
78
- * The wValue, wIndex and wLength fields values should be given in host-endian
79
- * byte order.
80
- *
81
- * \param dev_handle a handle for the device to communicate with
82
- * \param bmRequestType the request type field for the setup packet
83
- * \param bRequest the request field for the setup packet
84
- * \param wValue the value field for the setup packet
85
- * \param wIndex the index field for the setup packet
86
- * \param data a suitably-sized data buffer for either input or output
87
- * (depending on direction bits within bmRequestType)
88
- * \param wLength the length field for the setup packet. The data buffer should
89
- * be at least this size.
90
- * \param timeout timeout (in milliseconds) that this function should wait
91
- * before giving up due to no response being received. For an unlimited
92
- * timeout, use value 0.
93
- * \returns on success, the number of bytes actually transferred
94
- * \returns \ref LIBUSB_ERROR_TIMEOUT if the transfer timed out
95
- * \returns \ref LIBUSB_ERROR_PIPE if the control request was not supported by the
96
- * device
97
- * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
98
- * \returns \ref LIBUSB_ERROR_BUSY if called from event handling context
99
- * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
100
- * the operating system and/or hardware can support (see \ref asynclimits)
101
- * \returns another LIBUSB_ERROR code on other failures
102
- */
103
- int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
104
- uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
105
- unsigned char *data, uint16_t wLength, unsigned int timeout)
106
- {
107
- struct libusb_transfer *transfer;
108
- unsigned char *buffer;
109
- int completed = 0;
110
- int r;
111
-
112
- if (usbi_handling_events(HANDLE_CTX(dev_handle)))
113
- return LIBUSB_ERROR_BUSY;
114
-
115
- transfer = libusb_alloc_transfer(0);
116
- if (!transfer)
117
- return LIBUSB_ERROR_NO_MEM;
118
-
119
- buffer = malloc(LIBUSB_CONTROL_SETUP_SIZE + wLength);
120
- if (!buffer) {
121
- libusb_free_transfer(transfer);
122
- return LIBUSB_ERROR_NO_MEM;
123
- }
124
-
125
- libusb_fill_control_setup(buffer, bmRequestType, bRequest, wValue, wIndex,
126
- wLength);
127
- if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT)
128
- memcpy(buffer + LIBUSB_CONTROL_SETUP_SIZE, data, wLength);
129
-
130
- libusb_fill_control_transfer(transfer, dev_handle, buffer,
131
- sync_transfer_cb, &completed, timeout);
132
- transfer->flags = LIBUSB_TRANSFER_FREE_BUFFER;
133
- r = libusb_submit_transfer(transfer);
134
- if (r < 0) {
135
- libusb_free_transfer(transfer);
136
- return r;
137
- }
138
-
139
- sync_transfer_wait_for_completion(transfer);
140
-
141
- if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
142
- memcpy(data, libusb_control_transfer_get_data(transfer),
143
- (size_t)transfer->actual_length);
144
-
145
- switch (transfer->status) {
146
- case LIBUSB_TRANSFER_COMPLETED:
147
- r = transfer->actual_length;
148
- break;
149
- case LIBUSB_TRANSFER_TIMED_OUT:
150
- r = LIBUSB_ERROR_TIMEOUT;
151
- break;
152
- case LIBUSB_TRANSFER_STALL:
153
- r = LIBUSB_ERROR_PIPE;
154
- break;
155
- case LIBUSB_TRANSFER_NO_DEVICE:
156
- r = LIBUSB_ERROR_NO_DEVICE;
157
- break;
158
- case LIBUSB_TRANSFER_OVERFLOW:
159
- r = LIBUSB_ERROR_OVERFLOW;
160
- break;
161
- case LIBUSB_TRANSFER_ERROR:
162
- case LIBUSB_TRANSFER_CANCELLED:
163
- r = LIBUSB_ERROR_IO;
164
- break;
165
- default:
166
- usbi_warn(HANDLE_CTX(dev_handle),
167
- "unrecognised status code %d", transfer->status);
168
- r = LIBUSB_ERROR_OTHER;
169
- }
170
-
171
- libusb_free_transfer(transfer);
172
- return r;
173
- }
174
-
175
- static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
176
- unsigned char endpoint, unsigned char *buffer, int length,
177
- int *transferred, unsigned int timeout, unsigned char type)
178
- {
179
- struct libusb_transfer *transfer;
180
- int completed = 0;
181
- int r;
182
-
183
- if (usbi_handling_events(HANDLE_CTX(dev_handle)))
184
- return LIBUSB_ERROR_BUSY;
185
-
186
- transfer = libusb_alloc_transfer(0);
187
- if (!transfer)
188
- return LIBUSB_ERROR_NO_MEM;
189
-
190
- libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer, length,
191
- sync_transfer_cb, &completed, timeout);
192
- transfer->type = type;
193
-
194
- r = libusb_submit_transfer(transfer);
195
- if (r < 0) {
196
- libusb_free_transfer(transfer);
197
- return r;
198
- }
199
-
200
- sync_transfer_wait_for_completion(transfer);
201
-
202
- if (transferred) {
203
- assert(transfer->actual_length >= 0);
204
- *transferred = transfer->actual_length;
205
- }
206
-
207
- switch (transfer->status) {
208
- case LIBUSB_TRANSFER_COMPLETED:
209
- r = 0;
210
- break;
211
- case LIBUSB_TRANSFER_TIMED_OUT:
212
- r = LIBUSB_ERROR_TIMEOUT;
213
- break;
214
- case LIBUSB_TRANSFER_STALL:
215
- r = LIBUSB_ERROR_PIPE;
216
- break;
217
- case LIBUSB_TRANSFER_OVERFLOW:
218
- r = LIBUSB_ERROR_OVERFLOW;
219
- break;
220
- case LIBUSB_TRANSFER_NO_DEVICE:
221
- r = LIBUSB_ERROR_NO_DEVICE;
222
- break;
223
- case LIBUSB_TRANSFER_ERROR:
224
- case LIBUSB_TRANSFER_CANCELLED:
225
- r = LIBUSB_ERROR_IO;
226
- break;
227
- default:
228
- usbi_warn(HANDLE_CTX(dev_handle),
229
- "unrecognised status code %d", transfer->status);
230
- r = LIBUSB_ERROR_OTHER;
231
- }
232
-
233
- libusb_free_transfer(transfer);
234
- return r;
235
- }
236
-
237
- /** \ingroup libusb_syncio
238
- * Perform a USB bulk transfer. The direction of the transfer is inferred from
239
- * the direction bits of the endpoint address.
240
- *
241
- * For bulk reads, the <tt>length</tt> field indicates the maximum length of
242
- * data you are expecting to receive. If less data arrives than expected,
243
- * this function will return that data, so be sure to check the
244
- * <tt>transferred</tt> output parameter.
245
- *
246
- * You should also check the <tt>transferred</tt> parameter for bulk writes.
247
- * Not all of the data may have been written.
248
- *
249
- * Also check <tt>transferred</tt> when dealing with a timeout error code.
250
- * libusb may have to split your transfer into a number of chunks to satisfy
251
- * underlying O/S requirements, meaning that the timeout may expire after
252
- * the first few chunks have completed. libusb is careful not to lose any data
253
- * that may have been transferred; do not assume that timeout conditions
254
- * indicate a complete lack of I/O. See \ref asynctimeout for more details.
255
- *
256
- * \param dev_handle a handle for the device to communicate with
257
- * \param endpoint the address of a valid endpoint to communicate with
258
- * \param data a suitably-sized data buffer for either input or output
259
- * (depending on endpoint)
260
- * \param length for bulk writes, the number of bytes from data to be sent. for
261
- * bulk reads, the maximum number of bytes to receive into the data buffer.
262
- * \param transferred output location for the number of bytes actually
263
- * transferred. Since version 1.0.21 (\ref LIBUSB_API_VERSION >= 0x01000105),
264
- * it is legal to pass a NULL pointer if you do not wish to receive this
265
- * information.
266
- * \param timeout timeout (in milliseconds) that this function should wait
267
- * before giving up due to no response being received. For an unlimited
268
- * timeout, use value 0.
269
- *
270
- * \returns 0 on success (and populates <tt>transferred</tt>)
271
- * \returns \ref LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates
272
- * <tt>transferred</tt>)
273
- * \returns \ref LIBUSB_ERROR_PIPE if the endpoint halted
274
- * \returns \ref LIBUSB_ERROR_OVERFLOW if the device offered more data, see
275
- * \ref libusb_packetoverflow
276
- * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
277
- * \returns \ref LIBUSB_ERROR_BUSY if called from event handling context
278
- * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
279
- * the operating system and/or hardware can support (see \ref asynclimits)
280
- * \returns another LIBUSB_ERROR code on other failures
281
- */
282
- int API_EXPORTED libusb_bulk_transfer(libusb_device_handle *dev_handle,
283
- unsigned char endpoint, unsigned char *data, int length,
284
- int *transferred, unsigned int timeout)
285
- {
286
- return do_sync_bulk_transfer(dev_handle, endpoint, data, length,
287
- transferred, timeout, LIBUSB_TRANSFER_TYPE_BULK);
288
- }
289
-
290
- /** \ingroup libusb_syncio
291
- * Perform a USB interrupt transfer. The direction of the transfer is inferred
292
- * from the direction bits of the endpoint address.
293
- *
294
- * For interrupt reads, the <tt>length</tt> field indicates the maximum length
295
- * of data you are expecting to receive. If less data arrives than expected,
296
- * this function will return that data, so be sure to check the
297
- * <tt>transferred</tt> output parameter.
298
- *
299
- * You should also check the <tt>transferred</tt> parameter for interrupt
300
- * writes. Not all of the data may have been written.
301
- *
302
- * Also check <tt>transferred</tt> when dealing with a timeout error code.
303
- * libusb may have to split your transfer into a number of chunks to satisfy
304
- * underlying O/S requirements, meaning that the timeout may expire after
305
- * the first few chunks have completed. libusb is careful not to lose any data
306
- * that may have been transferred; do not assume that timeout conditions
307
- * indicate a complete lack of I/O. See \ref asynctimeout for more details.
308
- *
309
- * The default endpoint bInterval value is used as the polling interval.
310
- *
311
- * \param dev_handle a handle for the device to communicate with
312
- * \param endpoint the address of a valid endpoint to communicate with
313
- * \param data a suitably-sized data buffer for either input or output
314
- * (depending on endpoint)
315
- * \param length for bulk writes, the number of bytes from data to be sent. for
316
- * bulk reads, the maximum number of bytes to receive into the data buffer.
317
- * \param transferred output location for the number of bytes actually
318
- * transferred. Will never be negative. Since version 1.0.21
319
- * (\ref LIBUSB_API_VERSION >= 0x01000105), it is legal to pass a NULL
320
- * pointer if you do not wish to receive this information.
321
- * \param timeout timeout (in milliseconds) that this function should wait
322
- * before giving up due to no response being received. For an unlimited
323
- * timeout, use value 0.
324
- *
325
- * \returns 0 on success (and populates <tt>transferred</tt>)
326
- * \returns \ref LIBUSB_ERROR_TIMEOUT if the transfer timed out
327
- * \returns \ref LIBUSB_ERROR_PIPE if the endpoint halted
328
- * \returns \ref LIBUSB_ERROR_OVERFLOW if the device offered more data, see
329
- * \ref libusb_packetoverflow
330
- * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
331
- * \returns \ref LIBUSB_ERROR_BUSY if called from event handling context
332
- * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
333
- * the operating system and/or hardware can support (see \ref asynclimits)
334
- * \returns another LIBUSB_ERROR code on other error
335
- */
336
- int API_EXPORTED libusb_interrupt_transfer(libusb_device_handle *dev_handle,
337
- unsigned char endpoint, unsigned char *data, int length,
338
- int *transferred, unsigned int timeout)
339
- {
340
- return do_sync_bulk_transfer(dev_handle, endpoint, data, length,
341
- transferred, timeout, LIBUSB_TRANSFER_TYPE_INTERRUPT);
342
- }
@@ -1,18 +0,0 @@
1
- /* This file is parsed by m4 and windres and RC.EXE so please keep it simple. */
2
- #include "version_nano.h"
3
- #ifndef LIBUSB_MAJOR
4
- #define LIBUSB_MAJOR 1
5
- #endif
6
- #ifndef LIBUSB_MINOR
7
- #define LIBUSB_MINOR 0
8
- #endif
9
- #ifndef LIBUSB_MICRO
10
- #define LIBUSB_MICRO 29
11
- #endif
12
- #ifndef LIBUSB_NANO
13
- #define LIBUSB_NANO 0
14
- #endif
15
- /* LIBUSB_RC is the release candidate suffix. Should normally be empty. */
16
- #ifndef LIBUSB_RC
17
- #define LIBUSB_RC ""
18
- #endif
@@ -1 +0,0 @@
1
- #define LIBUSB_NANO 11953
@@ -1,11 +0,0 @@
1
- prefix=@prefix@
2
- exec_prefix=@exec_prefix@
3
- libdir=@libdir@
4
- includedir=@includedir@
5
-
6
- Name: libusb-1.0
7
- Description: C API for USB device access from Linux, Mac OS X, Windows, OpenBSD/NetBSD and Solaris userspace
8
- Version: @VERSION@
9
- Libs: -L${libdir} -lusb-1.0
10
- Libs.private: @LIBS@
11
- Cflags: -I${includedir}/libusb-1.0
@@ -1,60 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <PropertyGroup>
4
- <LibusbRootDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..'))\</LibusbRootDir>
5
- <IntDir>$(LibusbRootDir)build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
6
- <OutDir>$(IntDir)..\</OutDir>
7
- </PropertyGroup>
8
- <ItemDefinitionGroup>
9
- <!--ClCompile Base-->
10
- <ClCompile>
11
- <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
12
- <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
13
- <WarningLevel>Level4</WarningLevel>
14
- <TreatWarningAsError>true</TreatWarningAsError>
15
- <IntrinsicFunctions>true</IntrinsicFunctions>
16
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
17
- <!--Treat sources as utf-8-->
18
- <AdditionalOptions Condition="'$(PlatformToolsetVersion)'&gt;'120'">/utf-8 %(AdditionalOptions)</AdditionalOptions>
19
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
20
- <DiagnosticsFormat>Caret</DiagnosticsFormat>
21
- </ClCompile>
22
- <!--ClCompile Debug*-->
23
- <ClCompile Condition="$(Configuration.StartsWith('Debug'))">
24
- <Optimization>Disabled</Optimization>
25
- </ClCompile>
26
- <ClCompile Condition="$(Configuration.StartsWith('Debug')) And '$(EnableASAN)'=='true'">
27
- <BasicRuntimeChecks>Default</BasicRuntimeChecks>
28
- </ClCompile>
29
- <!--ClCompile Release*-->
30
- <ClCompile Condition="$(Configuration.StartsWith('Release'))">
31
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
32
- <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
33
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
34
- <OmitFramePointers>true</OmitFramePointers>
35
- <StringPooling>true</StringPooling>
36
- <AdditionalOptions>/Gw %(AdditionalOptions)</AdditionalOptions>
37
- <WholeProgramOptimization>true</WholeProgramOptimization>
38
- </ClCompile>
39
- <!--Link Base-->
40
- <Link>
41
- <GenerateDebugInformation>true</GenerateDebugInformation>
42
- <TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
43
- </Link>
44
- <!--Link Release*-->
45
- <Link Condition="$(Configuration.StartsWith('Release'))">
46
- <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
47
- <OptimizeReferences>true</OptimizeReferences>
48
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
49
- <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
50
- </Link>
51
- <!--Link Base:Application-->
52
- <Link Condition="'$(ConfigurationType)'=='Application'">
53
- <SubSystem>Console</SubSystem>
54
- </Link>
55
- <Lib>
56
- <TreatLibWarningAsErrors>true</TreatLibWarningAsErrors>
57
- <LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
58
- </Lib>
59
- </ItemDefinitionGroup>
60
- </Project>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <Import Project="Configuration.Base.props" />
4
- <PropertyGroup Label="Configuration">
5
- <ConfigurationType>Application</ConfigurationType>
6
- </PropertyGroup>
7
- </Project>