usb 2.1.1 → 2.2.0
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.
- package/CHANGELOG.md +22 -0
- package/README.md +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/usb/bindings.d.ts +4 -0
- package/dist/usb/device.js +5 -0
- package/dist/usb/device.js.map +1 -1
- package/dist/usb/interface.d.ts +1 -1
- package/dist/usb/interface.js +1 -5
- package/dist/usb/interface.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +2 -1
- package/dist/webusb/webusb-device.js +21 -14
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.gitattributes +2 -6
- package/libusb/.private/appveyor_build.sh +22 -0
- package/libusb/.private/bm.sh +1 -1
- package/libusb/.private/ci-build.sh +67 -0
- package/libusb/.private/post-rewrite.sh +5 -1
- package/libusb/.private/pre-commit.sh +5 -1
- package/libusb/.private/wbs.txt +4 -19
- package/libusb/.travis.yml +32 -23
- package/libusb/AUTHORS +76 -3
- package/libusb/ChangeLog +41 -3
- package/libusb/INSTALL_WIN.txt +22 -44
- package/libusb/Makefile.am +32 -10
- package/libusb/{README.md → README} +2 -2
- package/libusb/README.git +3 -3
- package/libusb/Xcode/common.xcconfig +23 -19
- package/libusb/Xcode/config.h +25 -13
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +511 -109
- package/libusb/android/README +90 -54
- package/libusb/android/config.h +23 -43
- package/libusb/android/examples/unrooted_android.c +301 -0
- package/libusb/android/examples/unrooted_android.h +36 -0
- package/libusb/android/jni/Android.mk +1 -1
- package/libusb/android/jni/Application.mk +16 -0
- package/libusb/android/jni/examples.mk +63 -29
- package/libusb/android/jni/libusb.mk +14 -8
- package/libusb/android/jni/tests.mk +13 -24
- package/libusb/appveyor.yml +69 -30
- package/libusb/autogen.sh +5 -3
- package/libusb/bootstrap.sh +6 -2
- package/libusb/configure.ac +302 -228
- package/libusb/doc/Makefile.in +22 -0
- package/libusb/doc/doxygen.cfg.in +460 -223
- package/libusb/examples/Makefile.am +6 -13
- package/libusb/examples/dpfp.c +276 -73
- package/libusb/examples/ezusb.c +18 -8
- package/libusb/examples/ezusb.h +6 -17
- package/libusb/examples/fxload.c +4 -5
- package/libusb/examples/hotplugtest.c +1 -1
- package/libusb/examples/sam3u_benchmark.c +59 -24
- package/libusb/examples/testlibusb.c +138 -104
- package/libusb/examples/xusb.c +26 -22
- package/libusb/libusb/Makefile.am +57 -70
- package/libusb/libusb/Makefile.am.extra +26 -0
- package/libusb/libusb/core.c +420 -423
- package/libusb/libusb/descriptor.c +365 -419
- package/libusb/libusb/hotplug.c +197 -104
- package/libusb/libusb/io.c +491 -528
- package/libusb/libusb/libusb-1.0.def +7 -3
- package/libusb/libusb/libusb-1.0.rc +1 -9
- package/libusb/libusb/libusb.h +295 -226
- package/libusb/libusb/libusbi.h +587 -314
- package/libusb/libusb/os/darwin_usb.c +634 -317
- package/libusb/libusb/os/darwin_usb.h +39 -15
- package/libusb/libusb/os/events_posix.c +300 -0
- package/libusb/libusb/os/events_posix.h +59 -0
- package/libusb/libusb/os/events_windows.c +214 -0
- package/libusb/{msvc/missing.h → libusb/os/events_windows.h} +25 -11
- package/libusb/libusb/os/haiku_pollfs.cpp +14 -9
- package/libusb/libusb/os/haiku_usb.h +12 -12
- package/libusb/libusb/os/haiku_usb_backend.cpp +36 -37
- package/libusb/libusb/os/haiku_usb_raw.cpp +80 -116
- package/libusb/libusb/os/linux_netlink.c +55 -63
- package/libusb/libusb/os/linux_udev.c +61 -69
- package/libusb/libusb/os/linux_usbfs.c +926 -1015
- package/libusb/libusb/os/linux_usbfs.h +74 -57
- package/libusb/libusb/os/netbsd_usb.c +103 -168
- package/libusb/libusb/os/null_usb.c +111 -0
- package/libusb/libusb/os/openbsd_usb.c +71 -120
- package/libusb/libusb/os/sunos_usb.c +289 -375
- package/libusb/libusb/os/sunos_usb.h +0 -1
- package/libusb/libusb/os/threads_posix.c +81 -32
- package/libusb/libusb/os/threads_posix.h +19 -23
- package/libusb/libusb/os/threads_windows.c +9 -95
- package/libusb/libusb/os/threads_windows.h +33 -31
- package/libusb/libusb/os/windows_common.c +904 -0
- package/libusb/libusb/os/windows_common.h +329 -42
- package/libusb/libusb/os/windows_usbdk.c +161 -267
- package/libusb/libusb/os/windows_usbdk.h +5 -2
- package/libusb/libusb/os/windows_winusb.c +1326 -1190
- package/libusb/libusb/os/windows_winusb.h +167 -167
- package/libusb/libusb/strerror.c +20 -30
- package/libusb/libusb/sync.c +20 -21
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/msvc/.gitattributes +3 -0
- package/libusb/msvc/config.h +27 -20
- package/libusb/msvc/{hotplugtest_2012.vcxproj → dpfp_2013.vcxproj} +14 -10
- package/libusb/msvc/dpfp_2013.vcxproj.filters +26 -0
- package/libusb/msvc/{listdevs_2010.vcxproj → dpfp_2015.vcxproj} +14 -9
- package/libusb/msvc/dpfp_2015.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_2017.vcxproj +106 -0
- package/libusb/msvc/dpfp_2017.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_2019.vcxproj +106 -0
- package/libusb/msvc/dpfp_2019.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2013.vcxproj +87 -0
- package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2015.vcxproj +87 -0
- package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2017.vcxproj +106 -0
- package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +26 -0
- package/libusb/msvc/{fxload_2012.vcxproj → dpfp_threaded_2019.vcxproj} +32 -17
- package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +26 -0
- package/libusb/msvc/fxload_2013.vcxproj +6 -3
- package/libusb/msvc/fxload_2013.vcxproj.filters +35 -0
- package/libusb/msvc/fxload_2015.vcxproj +6 -3
- package/libusb/msvc/fxload_2015.vcxproj.filters +35 -0
- package/libusb/msvc/fxload_2017.vcxproj +6 -7
- package/libusb/msvc/fxload_2017.vcxproj.filters +35 -0
- package/libusb/msvc/{fxload_2010.vcxproj → fxload_2019.vcxproj} +29 -6
- package/libusb/msvc/fxload_2019.vcxproj.filters +35 -0
- package/libusb/{examples → msvc}/getopt/getopt.c +0 -0
- package/libusb/{examples → msvc}/getopt/getopt.h +0 -0
- package/libusb/{examples → msvc}/getopt/getopt1.c +0 -0
- package/libusb/msvc/getopt_2013.vcxproj +4 -5
- package/libusb/msvc/getopt_2013.vcxproj.filters +26 -0
- package/libusb/msvc/getopt_2015.vcxproj +4 -4
- package/libusb/msvc/getopt_2015.vcxproj.filters +26 -0
- package/libusb/msvc/getopt_2017.vcxproj +4 -10
- package/libusb/msvc/getopt_2017.vcxproj.filters +26 -0
- package/libusb/msvc/{getopt_2012.vcxproj → getopt_2019.vcxproj} +25 -6
- package/libusb/msvc/getopt_2019.vcxproj.filters +26 -0
- package/libusb/msvc/hotplugtest_2013.vcxproj +6 -3
- package/libusb/msvc/hotplugtest_2013.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2015.vcxproj +6 -3
- package/libusb/msvc/hotplugtest_2015.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2017.vcxproj +6 -7
- package/libusb/msvc/hotplugtest_2017.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2019.vcxproj +105 -0
- package/libusb/msvc/hotplugtest_2019.vcxproj.filters +23 -0
- package/libusb/msvc/libusb_2013.sln +50 -20
- package/libusb/msvc/libusb_2015.sln +51 -21
- package/libusb/msvc/libusb_2017.sln +90 -36
- package/libusb/msvc/libusb_2019.sln +240 -0
- package/libusb/msvc/libusb_dll_2013.vcxproj +6 -9
- package/libusb/msvc/libusb_dll_2013.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_dll_2015.vcxproj +6 -8
- package/libusb/msvc/libusb_dll_2015.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_dll_2017.vcxproj +6 -16
- package/libusb/msvc/libusb_dll_2017.vcxproj.filters +94 -0
- package/libusb/msvc/{libusb_dll_2010.vcxproj → libusb_dll_2019.vcxproj} +27 -9
- package/libusb/msvc/libusb_dll_2019.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_static_2013.vcxproj +5 -9
- package/libusb/msvc/libusb_static_2013.vcxproj.filters +80 -0
- package/libusb/msvc/libusb_static_2015.vcxproj +5 -8
- package/libusb/msvc/libusb_static_2015.vcxproj.filters +80 -0
- package/libusb/msvc/libusb_static_2017.vcxproj +5 -8
- package/libusb/msvc/libusb_static_2017.vcxproj.filters +80 -0
- package/libusb/msvc/{libusb_static_2010.vcxproj → libusb_static_2019.vcxproj} +26 -9
- package/libusb/msvc/libusb_static_2019.vcxproj.filters +80 -0
- package/libusb/msvc/listdevs_2013.vcxproj +6 -3
- package/libusb/msvc/listdevs_2013.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2015.vcxproj +6 -3
- package/libusb/msvc/listdevs_2015.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2017.vcxproj +6 -7
- package/libusb/msvc/listdevs_2017.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2019.vcxproj +105 -0
- package/libusb/msvc/listdevs_2019.vcxproj.filters +23 -0
- package/libusb/msvc/{listdevs_2012.vcxproj → sam3u_benchmark_2013.vcxproj} +13 -9
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +26 -0
- package/libusb/msvc/{hotplugtest_2010.vcxproj → sam3u_benchmark_2015.vcxproj} +13 -8
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +26 -0
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj +106 -0
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +26 -0
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj +106 -0
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +26 -0
- package/libusb/msvc/stress_2013.vcxproj +4 -2
- package/libusb/msvc/stress_2013.vcxproj.filters +32 -0
- package/libusb/msvc/stress_2015.vcxproj +4 -2
- package/libusb/msvc/stress_2015.vcxproj.filters +32 -0
- package/libusb/msvc/stress_2017.vcxproj +4 -6
- package/libusb/msvc/stress_2017.vcxproj.filters +32 -0
- package/libusb/msvc/{stress_2010.vcxproj → stress_2019.vcxproj} +26 -4
- package/libusb/msvc/stress_2019.vcxproj.filters +32 -0
- package/libusb/msvc/testlibusb_2013.vcxproj +6 -3
- package/libusb/msvc/testlibusb_2013.vcxproj.filters +23 -0
- package/libusb/msvc/testlibusb_2015.vcxproj +6 -3
- package/libusb/msvc/testlibusb_2015.vcxproj.filters +23 -0
- package/libusb/msvc/testlibusb_2017.vcxproj +6 -7
- package/libusb/msvc/testlibusb_2017.vcxproj.filters +23 -0
- package/libusb/msvc/{testlibusb_2010.vcxproj → testlibusb_2019.vcxproj} +28 -5
- package/libusb/msvc/testlibusb_2019.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2013.vcxproj +6 -3
- package/libusb/msvc/xusb_2013.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2015.vcxproj +6 -3
- package/libusb/msvc/xusb_2015.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2017.vcxproj +6 -7
- package/libusb/msvc/xusb_2017.vcxproj.filters +23 -0
- package/libusb/msvc/{xusb_2010.vcxproj → xusb_2019.vcxproj} +28 -5
- package/libusb/msvc/xusb_2019.vcxproj.filters +23 -0
- package/libusb/tests/Makefile.am +1 -0
- package/libusb/tests/libusb_testlib.h +12 -43
- package/libusb/tests/stress.c +59 -50
- package/libusb/tests/testlib.c +78 -171
- package/libusb.gypi +10 -11
- package/package.json +2 -2
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/device.cc +12 -7
- package/src/node_usb.cc +10 -0
- package/test/usb.coffee +6 -0
- package/tsc/index.ts +2 -0
- package/tsc/usb/bindings.ts +5 -0
- package/tsc/usb/device.ts +6 -0
- package/tsc/usb/interface.ts +2 -7
- package/tsc/webusb/webusb-device.ts +12 -8
- package/libusb/.private/bd.cmd +0 -89
- package/libusb/.private/bwince.cmd +0 -57
- package/libusb/.private/wbs_wince.txt +0 -42
- package/libusb/Brewfile +0 -4
- package/libusb/appveyor_cygwin.bat +0 -11
- package/libusb/appveyor_minGW.bat +0 -19
- package/libusb/doc/Makefile.am +0 -9
- package/libusb/examples/dpfp_threaded.c +0 -557
- package/libusb/libusb/hotplug.h +0 -99
- package/libusb/libusb/os/poll_posix.c +0 -84
- package/libusb/libusb/os/poll_posix.h +0 -14
- package/libusb/libusb/os/poll_windows.c +0 -447
- package/libusb/libusb/os/poll_windows.h +0 -98
- package/libusb/libusb/os/wince_usb.c +0 -888
- package/libusb/libusb/os/wince_usb.h +0 -126
- package/libusb/libusb/os/windows_nt_common.c +0 -1010
- package/libusb/libusb/os/windows_nt_common.h +0 -110
- package/libusb/libusb/os/windows_nt_shared_types.h +0 -147
- package/libusb/msvc/appveyor.bat +0 -27
- package/libusb/msvc/ddk_build.cmd +0 -219
- package/libusb/msvc/errno.h +0 -102
- package/libusb/msvc/fxload_sources +0 -23
- package/libusb/msvc/getopt_2005.vcproj +0 -288
- package/libusb/msvc/getopt_2010.vcxproj +0 -72
- package/libusb/msvc/getopt_sources +0 -24
- package/libusb/msvc/hotplugtest_sources +0 -20
- package/libusb/msvc/inttypes.h +0 -295
- package/libusb/msvc/libusb.dsw +0 -71
- package/libusb/msvc/libusb_2005.sln +0 -95
- package/libusb/msvc/libusb_2010.sln +0 -105
- package/libusb/msvc/libusb_2012.sln +0 -105
- package/libusb/msvc/libusb_dll.dsp +0 -194
- package/libusb/msvc/libusb_dll_2005.vcproj +0 -464
- package/libusb/msvc/libusb_dll_2012.vcxproj +0 -107
- package/libusb/msvc/libusb_dll_wince.vcproj +0 -1251
- package/libusb/msvc/libusb_sources +0 -43
- package/libusb/msvc/libusb_static.dsp +0 -174
- package/libusb/msvc/libusb_static_2005.vcproj +0 -390
- package/libusb/msvc/libusb_static_2012.vcxproj +0 -98
- package/libusb/msvc/libusb_static_wince.vcproj +0 -1179
- package/libusb/msvc/libusb_wince.sln +0 -246
- package/libusb/msvc/listdevs.dsp +0 -103
- package/libusb/msvc/listdevs_2005.vcproj +0 -360
- package/libusb/msvc/listdevs_sources +0 -20
- package/libusb/msvc/listdevs_wince.vcproj +0 -1120
- package/libusb/msvc/missing.c +0 -80
- package/libusb/msvc/stdint.h +0 -256
- package/libusb/msvc/stress_2005.vcproj +0 -390
- package/libusb/msvc/stress_2012.vcxproj +0 -87
- package/libusb/msvc/stress_sources +0 -21
- package/libusb/msvc/stress_wince.vcproj +0 -1128
- package/libusb/msvc/testlibusb_2012.vcxproj +0 -83
- package/libusb/msvc/testlibusb_sources +0 -20
- package/libusb/msvc/xusb.dsp +0 -102
- package/libusb/msvc/xusb_2005.vcproj +0 -344
- package/libusb/msvc/xusb_2012.vcxproj +0 -83
- package/libusb/msvc/xusb_sources +0 -20
- package/libusb/msvc/xusb_wince.vcproj +0 -1120
- package/libusb/travis-autogen.sh +0 -39
package/libusb/examples/ezusb.h
CHANGED
|
@@ -20,23 +20,10 @@
|
|
|
20
20
|
* along with this program; if not, write to the Free Software
|
|
21
21
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
#include <config.h>
|
|
25
|
+
|
|
24
26
|
#include <stdbool.h>
|
|
25
|
-
#else
|
|
26
|
-
#define __attribute__(x)
|
|
27
|
-
#if !defined(bool)
|
|
28
|
-
#define bool int
|
|
29
|
-
#endif
|
|
30
|
-
#if !defined(true)
|
|
31
|
-
#define true (1 == 1)
|
|
32
|
-
#endif
|
|
33
|
-
#if !defined(false)
|
|
34
|
-
#define false (!true)
|
|
35
|
-
#endif
|
|
36
|
-
#if defined(_PREFAST_)
|
|
37
|
-
#pragma warning(disable:28193)
|
|
38
|
-
#endif
|
|
39
|
-
#endif
|
|
40
27
|
|
|
41
28
|
#define FX_TYPE_UNDEFINED -1
|
|
42
29
|
#define FX_TYPE_AN21 0 /* Original AnchorChips parts */
|
|
@@ -59,7 +46,7 @@
|
|
|
59
46
|
extern "C" {
|
|
60
47
|
#endif
|
|
61
48
|
|
|
62
|
-
/*
|
|
49
|
+
/*
|
|
63
50
|
* Automatically identified devices (VID, PID, type, designation).
|
|
64
51
|
* TODO: Could use some validation. Also where's the FX2?
|
|
65
52
|
*/
|
|
@@ -113,6 +100,8 @@ extern int ezusb_load_eeprom(libusb_device_handle *device,
|
|
|
113
100
|
/* Verbosity level (default 1). Can be increased or decreased with options v/q */
|
|
114
101
|
extern int verbose;
|
|
115
102
|
|
|
103
|
+
extern void logerror(const char *format, ...) PRINTF_FORMAT(1, 2);
|
|
104
|
+
|
|
116
105
|
#ifdef __cplusplus
|
|
117
106
|
}
|
|
118
107
|
#endif
|
package/libusb/examples/fxload.c
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
#include <config.h>
|
|
25
|
+
|
|
24
26
|
#include <stdlib.h>
|
|
25
27
|
#include <stdio.h>
|
|
26
28
|
#include <string.h>
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
#include "libusb.h"
|
|
33
35
|
#include "ezusb.h"
|
|
34
36
|
|
|
35
|
-
#if !defined(_WIN32) || defined(__CYGWIN__
|
|
37
|
+
#if !defined(_WIN32) || defined(__CYGWIN__)
|
|
36
38
|
#include <syslog.h>
|
|
37
39
|
static bool dosyslog = false;
|
|
38
40
|
#include <strings.h>
|
|
@@ -47,15 +49,12 @@ static bool dosyslog = false;
|
|
|
47
49
|
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
|
48
50
|
#endif
|
|
49
51
|
|
|
50
|
-
void logerror(const char *format, ...)
|
|
51
|
-
__attribute__ ((format (__printf__, 1, 2)));
|
|
52
|
-
|
|
53
52
|
void logerror(const char *format, ...)
|
|
54
53
|
{
|
|
55
54
|
va_list ap;
|
|
56
55
|
va_start(ap, format);
|
|
57
56
|
|
|
58
|
-
#if !defined(_WIN32) || defined(__CYGWIN__
|
|
57
|
+
#if !defined(_WIN32) || defined(__CYGWIN__)
|
|
59
58
|
if (dosyslog)
|
|
60
59
|
vsyslog(LOG_ERR, format, ap);
|
|
61
60
|
else
|
|
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
if (!libusb_has_capability (LIBUSB_CAP_HAS_HOTPLUG)) {
|
|
98
|
-
printf ("Hotplug
|
|
98
|
+
printf ("Hotplug capabilities are not supported on this platform\n");
|
|
99
99
|
libusb_exit (NULL);
|
|
100
100
|
return EXIT_FAILURE;
|
|
101
101
|
}
|
|
@@ -22,24 +22,54 @@
|
|
|
22
22
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
#include <
|
|
26
|
-
|
|
27
|
-
#include <stdio.h>
|
|
25
|
+
#include <config.h>
|
|
26
|
+
|
|
28
27
|
#include <errno.h>
|
|
29
28
|
#include <signal.h>
|
|
29
|
+
#include <stdio.h>
|
|
30
|
+
#include <stdlib.h>
|
|
31
|
+
#ifdef HAVE_SYS_TIME_H
|
|
32
|
+
#include <sys/time.h>
|
|
33
|
+
#endif
|
|
34
|
+
#include <time.h>
|
|
30
35
|
|
|
31
|
-
#include
|
|
32
|
-
|
|
36
|
+
#include "libusb.h"
|
|
33
37
|
|
|
34
38
|
#define EP_DATA_IN 0x82
|
|
35
39
|
#define EP_ISO_IN 0x86
|
|
36
40
|
|
|
37
|
-
static
|
|
41
|
+
static volatile sig_atomic_t do_exit = 0;
|
|
38
42
|
static struct libusb_device_handle *devh = NULL;
|
|
39
43
|
|
|
40
44
|
static unsigned long num_bytes = 0, num_xfer = 0;
|
|
41
45
|
static struct timeval tv_start;
|
|
42
46
|
|
|
47
|
+
static void get_timestamp(struct timeval *tv)
|
|
48
|
+
{
|
|
49
|
+
#if defined(PLATFORM_WINDOWS)
|
|
50
|
+
static LARGE_INTEGER frequency;
|
|
51
|
+
LARGE_INTEGER counter;
|
|
52
|
+
|
|
53
|
+
if (!frequency.QuadPart)
|
|
54
|
+
QueryPerformanceFrequency(&frequency);
|
|
55
|
+
|
|
56
|
+
QueryPerformanceCounter(&counter);
|
|
57
|
+
counter.QuadPart *= 1000000;
|
|
58
|
+
counter.QuadPart /= frequency.QuadPart;
|
|
59
|
+
|
|
60
|
+
tv->tv_sec = (long)(counter.QuadPart / 1000000ULL);
|
|
61
|
+
tv->tv_usec = (long)(counter.QuadPart % 1000000ULL);
|
|
62
|
+
#elif defined(HAVE_CLOCK_GETTIME)
|
|
63
|
+
struct timespec ts;
|
|
64
|
+
|
|
65
|
+
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
66
|
+
tv->tv_sec = ts.tv_sec;
|
|
67
|
+
tv->tv_usec = (int)(ts.tv_nsec / 1000L);
|
|
68
|
+
#else
|
|
69
|
+
gettimeofday(tv, NULL);
|
|
70
|
+
#endif
|
|
71
|
+
}
|
|
72
|
+
|
|
43
73
|
static void LIBUSB_CALL cb_xfr(struct libusb_transfer *xfr)
|
|
44
74
|
{
|
|
45
75
|
int i;
|
|
@@ -92,8 +122,10 @@ static int benchmark_in(uint8_t ep)
|
|
|
92
122
|
num_iso_pack = 16;
|
|
93
123
|
|
|
94
124
|
xfr = libusb_alloc_transfer(num_iso_pack);
|
|
95
|
-
if (!xfr)
|
|
96
|
-
|
|
125
|
+
if (!xfr) {
|
|
126
|
+
errno = ENOMEM;
|
|
127
|
+
return -1;
|
|
128
|
+
}
|
|
97
129
|
|
|
98
130
|
if (ep == EP_ISO_IN) {
|
|
99
131
|
libusb_fill_iso_transfer(xfr, devh, ep, buf,
|
|
@@ -103,7 +135,7 @@ static int benchmark_in(uint8_t ep)
|
|
|
103
135
|
libusb_fill_bulk_transfer(xfr, devh, ep, buf,
|
|
104
136
|
sizeof(buf), cb_xfr, NULL, 0);
|
|
105
137
|
|
|
106
|
-
|
|
138
|
+
get_timestamp(&tv_start);
|
|
107
139
|
|
|
108
140
|
/* NOTE: To reach maximum possible performance the program must
|
|
109
141
|
* submit *multiple* transfers here, not just one.
|
|
@@ -125,36 +157,39 @@ static int benchmark_in(uint8_t ep)
|
|
|
125
157
|
static void measure(void)
|
|
126
158
|
{
|
|
127
159
|
struct timeval tv_stop;
|
|
128
|
-
unsigned
|
|
160
|
+
unsigned long diff_msec;
|
|
129
161
|
|
|
130
|
-
|
|
162
|
+
get_timestamp(&tv_stop);
|
|
131
163
|
|
|
132
|
-
diff_msec = (tv_stop.tv_sec - tv_start.tv_sec)*
|
|
133
|
-
diff_msec += (tv_stop.tv_usec - tv_start.tv_usec)/
|
|
164
|
+
diff_msec = (tv_stop.tv_sec - tv_start.tv_sec) * 1000L;
|
|
165
|
+
diff_msec += (tv_stop.tv_usec - tv_start.tv_usec) / 1000L;
|
|
134
166
|
|
|
135
|
-
printf("%lu transfers (total %lu bytes) in %
|
|
136
|
-
num_xfer, num_bytes, diff_msec, (num_bytes*
|
|
167
|
+
printf("%lu transfers (total %lu bytes) in %lu milliseconds => %lu bytes/sec\n",
|
|
168
|
+
num_xfer, num_bytes, diff_msec, (num_bytes * 1000L) / diff_msec);
|
|
137
169
|
}
|
|
138
170
|
|
|
139
171
|
static void sig_hdlr(int signum)
|
|
140
172
|
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
173
|
+
(void)signum;
|
|
174
|
+
|
|
175
|
+
measure();
|
|
176
|
+
do_exit = 1;
|
|
147
177
|
}
|
|
148
178
|
|
|
149
|
-
int main(
|
|
179
|
+
int main(void)
|
|
150
180
|
{
|
|
151
181
|
int rc;
|
|
182
|
+
|
|
183
|
+
#if defined(PLATFORM_POSIX)
|
|
152
184
|
struct sigaction sigact;
|
|
153
185
|
|
|
154
186
|
sigact.sa_handler = sig_hdlr;
|
|
155
187
|
sigemptyset(&sigact.sa_mask);
|
|
156
188
|
sigact.sa_flags = 0;
|
|
157
|
-
sigaction(SIGINT, &sigact, NULL);
|
|
189
|
+
(void)sigaction(SIGINT, &sigact, NULL);
|
|
190
|
+
#else
|
|
191
|
+
(void)signal(SIGINT, sig_hdlr);
|
|
192
|
+
#endif
|
|
158
193
|
|
|
159
194
|
rc = libusb_init(NULL);
|
|
160
195
|
if (rc < 0) {
|
|
@@ -184,7 +219,7 @@ int main(int argc, char **argv)
|
|
|
184
219
|
|
|
185
220
|
/* Measurement has already been done by the signal handler. */
|
|
186
221
|
|
|
187
|
-
libusb_release_interface(devh,
|
|
222
|
+
libusb_release_interface(devh, 2);
|
|
188
223
|
out:
|
|
189
224
|
if (devh)
|
|
190
225
|
libusb_close(devh);
|
|
@@ -21,18 +21,14 @@
|
|
|
21
21
|
#include <string.h>
|
|
22
22
|
#include "libusb.h"
|
|
23
23
|
|
|
24
|
-
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
|
25
|
-
#define snprintf _snprintf
|
|
26
|
-
#endif
|
|
27
|
-
|
|
28
24
|
int verbose = 0;
|
|
29
25
|
|
|
30
26
|
static void print_endpoint_comp(const struct libusb_ss_endpoint_companion_descriptor *ep_comp)
|
|
31
27
|
{
|
|
32
28
|
printf(" USB 3.0 Endpoint Companion:\n");
|
|
33
|
-
printf(" bMaxBurst:
|
|
34
|
-
printf(" bmAttributes:
|
|
35
|
-
printf(" wBytesPerInterval:
|
|
29
|
+
printf(" bMaxBurst: %u\n", ep_comp->bMaxBurst);
|
|
30
|
+
printf(" bmAttributes: %02xh\n", ep_comp->bmAttributes);
|
|
31
|
+
printf(" wBytesPerInterval: %u\n", ep_comp->wBytesPerInterval);
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint)
|
|
@@ -40,21 +36,20 @@ static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint)
|
|
|
40
36
|
int i, ret;
|
|
41
37
|
|
|
42
38
|
printf(" Endpoint:\n");
|
|
43
|
-
printf(" bEndpointAddress:
|
|
44
|
-
printf(" bmAttributes:
|
|
45
|
-
printf(" wMaxPacketSize:
|
|
46
|
-
printf(" bInterval:
|
|
47
|
-
printf(" bRefresh:
|
|
48
|
-
printf(" bSynchAddress:
|
|
39
|
+
printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
|
|
40
|
+
printf(" bmAttributes: %02xh\n", endpoint->bmAttributes);
|
|
41
|
+
printf(" wMaxPacketSize: %u\n", endpoint->wMaxPacketSize);
|
|
42
|
+
printf(" bInterval: %u\n", endpoint->bInterval);
|
|
43
|
+
printf(" bRefresh: %u\n", endpoint->bRefresh);
|
|
44
|
+
printf(" bSynchAddress: %u\n", endpoint->bSynchAddress);
|
|
49
45
|
|
|
50
46
|
for (i = 0; i < endpoint->extra_length;) {
|
|
51
47
|
if (LIBUSB_DT_SS_ENDPOINT_COMPANION == endpoint->extra[i + 1]) {
|
|
52
48
|
struct libusb_ss_endpoint_companion_descriptor *ep_comp;
|
|
53
49
|
|
|
54
50
|
ret = libusb_get_ss_endpoint_companion_descriptor(NULL, endpoint, &ep_comp);
|
|
55
|
-
if (LIBUSB_SUCCESS != ret)
|
|
51
|
+
if (LIBUSB_SUCCESS != ret)
|
|
56
52
|
continue;
|
|
57
|
-
}
|
|
58
53
|
|
|
59
54
|
print_endpoint_comp(ep_comp);
|
|
60
55
|
|
|
@@ -70,13 +65,13 @@ static void print_altsetting(const struct libusb_interface_descriptor *interface
|
|
|
70
65
|
uint8_t i;
|
|
71
66
|
|
|
72
67
|
printf(" Interface:\n");
|
|
73
|
-
printf(" bInterfaceNumber:
|
|
74
|
-
printf(" bAlternateSetting:
|
|
75
|
-
printf(" bNumEndpoints:
|
|
76
|
-
printf(" bInterfaceClass:
|
|
77
|
-
printf(" bInterfaceSubClass:
|
|
78
|
-
printf(" bInterfaceProtocol:
|
|
79
|
-
printf(" iInterface:
|
|
68
|
+
printf(" bInterfaceNumber: %u\n", interface->bInterfaceNumber);
|
|
69
|
+
printf(" bAlternateSetting: %u\n", interface->bAlternateSetting);
|
|
70
|
+
printf(" bNumEndpoints: %u\n", interface->bNumEndpoints);
|
|
71
|
+
printf(" bInterfaceClass: %u\n", interface->bInterfaceClass);
|
|
72
|
+
printf(" bInterfaceSubClass: %u\n", interface->bInterfaceSubClass);
|
|
73
|
+
printf(" bInterfaceProtocol: %u\n", interface->bInterfaceProtocol);
|
|
74
|
+
printf(" iInterface: %u\n", interface->iInterface);
|
|
80
75
|
|
|
81
76
|
for (i = 0; i < interface->bNumEndpoints; i++)
|
|
82
77
|
print_endpoint(&interface->endpoint[i]);
|
|
@@ -85,58 +80,58 @@ static void print_altsetting(const struct libusb_interface_descriptor *interface
|
|
|
85
80
|
static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor *usb_2_0_ext_cap)
|
|
86
81
|
{
|
|
87
82
|
printf(" USB 2.0 Extension Capabilities:\n");
|
|
88
|
-
printf(" bDevCapabilityType:
|
|
89
|
-
printf(" bmAttributes:
|
|
83
|
+
printf(" bDevCapabilityType: %u\n", usb_2_0_ext_cap->bDevCapabilityType);
|
|
84
|
+
printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes);
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap)
|
|
93
88
|
{
|
|
94
89
|
printf(" USB 3.0 Capabilities:\n");
|
|
95
|
-
printf(" bDevCapabilityType:
|
|
96
|
-
printf(" bmAttributes:
|
|
97
|
-
printf(" wSpeedSupported:
|
|
98
|
-
printf(" bFunctionalitySupport: %
|
|
99
|
-
printf(" bU1devExitLat:
|
|
100
|
-
printf(" bU2devExitLat:
|
|
90
|
+
printf(" bDevCapabilityType: %u\n", ss_usb_cap->bDevCapabilityType);
|
|
91
|
+
printf(" bmAttributes: %02xh\n", ss_usb_cap->bmAttributes);
|
|
92
|
+
printf(" wSpeedSupported: %u\n", ss_usb_cap->wSpeedSupported);
|
|
93
|
+
printf(" bFunctionalitySupport: %u\n", ss_usb_cap->bFunctionalitySupport);
|
|
94
|
+
printf(" bU1devExitLat: %u\n", ss_usb_cap->bU1DevExitLat);
|
|
95
|
+
printf(" bU2devExitLat: %u\n", ss_usb_cap->bU2DevExitLat);
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
static void print_bos(libusb_device_handle *handle)
|
|
104
99
|
{
|
|
105
100
|
struct libusb_bos_descriptor *bos;
|
|
101
|
+
uint8_t i;
|
|
106
102
|
int ret;
|
|
107
103
|
|
|
108
104
|
ret = libusb_get_bos_descriptor(handle, &bos);
|
|
109
|
-
if (
|
|
105
|
+
if (ret < 0)
|
|
110
106
|
return;
|
|
111
|
-
}
|
|
112
107
|
|
|
113
108
|
printf(" Binary Object Store (BOS):\n");
|
|
114
|
-
printf(" wTotalLength:
|
|
115
|
-
printf(" bNumDeviceCaps:
|
|
109
|
+
printf(" wTotalLength: %u\n", bos->wTotalLength);
|
|
110
|
+
printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps);
|
|
116
111
|
|
|
117
|
-
|
|
112
|
+
for (i = 0; i < bos->bNumDeviceCaps; i++) {
|
|
113
|
+
struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i];
|
|
118
114
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (0 > ret) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
115
|
+
if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) {
|
|
116
|
+
struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension;
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
118
|
+
ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap, &usb_2_0_extension);
|
|
119
|
+
if (ret < 0)
|
|
120
|
+
return;
|
|
128
121
|
|
|
129
|
-
|
|
122
|
+
print_2_0_ext_cap(usb_2_0_extension);
|
|
123
|
+
libusb_free_usb_2_0_extension_descriptor(usb_2_0_extension);
|
|
124
|
+
} else if (dev_cap->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) {
|
|
125
|
+
struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap;
|
|
130
126
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
127
|
+
ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap, &ss_dev_cap);
|
|
128
|
+
if (ret < 0)
|
|
129
|
+
return;
|
|
136
130
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
print_ss_usb_cap(ss_dev_cap);
|
|
132
|
+
libusb_free_ss_usb_device_capability_descriptor(ss_dev_cap);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
140
135
|
|
|
141
136
|
libusb_free_bos_descriptor(bos);
|
|
142
137
|
}
|
|
@@ -154,79 +149,71 @@ static void print_configuration(struct libusb_config_descriptor *config)
|
|
|
154
149
|
uint8_t i;
|
|
155
150
|
|
|
156
151
|
printf(" Configuration:\n");
|
|
157
|
-
printf(" wTotalLength:
|
|
158
|
-
printf(" bNumInterfaces:
|
|
159
|
-
printf(" bConfigurationValue:
|
|
160
|
-
printf(" iConfiguration:
|
|
161
|
-
printf(" bmAttributes:
|
|
162
|
-
printf(" MaxPower:
|
|
152
|
+
printf(" wTotalLength: %u\n", config->wTotalLength);
|
|
153
|
+
printf(" bNumInterfaces: %u\n", config->bNumInterfaces);
|
|
154
|
+
printf(" bConfigurationValue: %u\n", config->bConfigurationValue);
|
|
155
|
+
printf(" iConfiguration: %u\n", config->iConfiguration);
|
|
156
|
+
printf(" bmAttributes: %02xh\n", config->bmAttributes);
|
|
157
|
+
printf(" MaxPower: %u\n", config->MaxPower);
|
|
163
158
|
|
|
164
159
|
for (i = 0; i < config->bNumInterfaces; i++)
|
|
165
160
|
print_interface(&config->interface[i]);
|
|
166
161
|
}
|
|
167
162
|
|
|
168
|
-
static
|
|
163
|
+
static void print_device(libusb_device *dev, libusb_device_handle *handle)
|
|
169
164
|
{
|
|
170
165
|
struct libusb_device_descriptor desc;
|
|
171
|
-
|
|
172
|
-
char
|
|
173
|
-
char string[256];
|
|
166
|
+
unsigned char string[256];
|
|
167
|
+
const char *speed;
|
|
174
168
|
int ret;
|
|
175
169
|
uint8_t i;
|
|
176
170
|
|
|
171
|
+
switch (libusb_get_device_speed(dev)) {
|
|
172
|
+
case LIBUSB_SPEED_LOW: speed = "1.5M"; break;
|
|
173
|
+
case LIBUSB_SPEED_FULL: speed = "12M"; break;
|
|
174
|
+
case LIBUSB_SPEED_HIGH: speed = "480M"; break;
|
|
175
|
+
case LIBUSB_SPEED_SUPER: speed = "5G"; break;
|
|
176
|
+
case LIBUSB_SPEED_SUPER_PLUS: speed = "10G"; break;
|
|
177
|
+
default: speed = "Unknown";
|
|
178
|
+
}
|
|
179
|
+
|
|
177
180
|
ret = libusb_get_device_descriptor(dev, &desc);
|
|
178
181
|
if (ret < 0) {
|
|
179
182
|
fprintf(stderr, "failed to get device descriptor");
|
|
180
|
-
return
|
|
183
|
+
return;
|
|
181
184
|
}
|
|
182
185
|
|
|
183
|
-
|
|
184
|
-
|
|
186
|
+
printf("Dev (bus %u, device %u): %04X - %04X speed: %s\n",
|
|
187
|
+
libusb_get_bus_number(dev), libusb_get_device_address(dev),
|
|
188
|
+
desc.idVendor, desc.idProduct, speed);
|
|
189
|
+
|
|
190
|
+
if (!handle)
|
|
191
|
+
libusb_open(dev, &handle);
|
|
192
|
+
|
|
193
|
+
if (handle) {
|
|
185
194
|
if (desc.iManufacturer) {
|
|
186
195
|
ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, sizeof(string));
|
|
187
196
|
if (ret > 0)
|
|
188
|
-
|
|
189
|
-
else
|
|
190
|
-
snprintf(description, sizeof(description), "%04X - ",
|
|
191
|
-
desc.idVendor);
|
|
197
|
+
printf(" Manufacturer: %s\n", (char *)string);
|
|
192
198
|
}
|
|
193
|
-
else
|
|
194
|
-
snprintf(description, sizeof(description), "%04X - ",
|
|
195
|
-
desc.idVendor);
|
|
196
199
|
|
|
197
200
|
if (desc.iProduct) {
|
|
198
201
|
ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string));
|
|
199
202
|
if (ret > 0)
|
|
200
|
-
|
|
201
|
-
strlen(description), "%s", string);
|
|
202
|
-
else
|
|
203
|
-
snprintf(description + strlen(description), sizeof(description) -
|
|
204
|
-
strlen(description), "%04X", desc.idProduct);
|
|
203
|
+
printf(" Product: %s\n", (char *)string);
|
|
205
204
|
}
|
|
206
|
-
else
|
|
207
|
-
snprintf(description + strlen(description), sizeof(description) -
|
|
208
|
-
strlen(description), "%04X", desc.idProduct);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
snprintf(description, sizeof(description), "%04X - %04X",
|
|
212
|
-
desc.idVendor, desc.idProduct);
|
|
213
|
-
}
|
|
214
205
|
|
|
215
|
-
|
|
216
|
-
libusb_get_bus_number(dev), libusb_get_device_address(dev), description);
|
|
217
|
-
|
|
218
|
-
if (handle && verbose) {
|
|
219
|
-
if (desc.iSerialNumber) {
|
|
206
|
+
if (desc.iSerialNumber && verbose) {
|
|
220
207
|
ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string));
|
|
221
208
|
if (ret > 0)
|
|
222
|
-
printf("
|
|
223
|
-
" ", string);
|
|
209
|
+
printf(" Serial Number: %s\n", (char *)string);
|
|
224
210
|
}
|
|
225
211
|
}
|
|
226
212
|
|
|
227
213
|
if (verbose) {
|
|
228
214
|
for (i = 0; i < desc.bNumConfigurations; i++) {
|
|
229
215
|
struct libusb_config_descriptor *config;
|
|
216
|
+
|
|
230
217
|
ret = libusb_get_config_descriptor(dev, i, &config);
|
|
231
218
|
if (LIBUSB_SUCCESS != ret) {
|
|
232
219
|
printf(" Couldn't retrieve descriptors\n");
|
|
@@ -238,40 +225,87 @@ static int print_device(libusb_device *dev, int level)
|
|
|
238
225
|
libusb_free_config_descriptor(config);
|
|
239
226
|
}
|
|
240
227
|
|
|
241
|
-
if (handle && desc.bcdUSB >= 0x0201)
|
|
228
|
+
if (handle && desc.bcdUSB >= 0x0201)
|
|
242
229
|
print_bos(handle);
|
|
243
|
-
}
|
|
244
230
|
}
|
|
245
231
|
|
|
246
232
|
if (handle)
|
|
247
233
|
libusb_close(handle);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
#ifdef __linux__
|
|
237
|
+
#include <errno.h>
|
|
238
|
+
#include <fcntl.h>
|
|
239
|
+
#include <unistd.h>
|
|
240
|
+
|
|
241
|
+
static int test_wrapped_device(const char *device_name)
|
|
242
|
+
{
|
|
243
|
+
libusb_device_handle *handle;
|
|
244
|
+
int r, fd;
|
|
248
245
|
|
|
246
|
+
fd = open(device_name, O_RDWR);
|
|
247
|
+
if (fd < 0) {
|
|
248
|
+
printf("Error could not open %s: %s\n", device_name, strerror(errno));
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
251
|
+
r = libusb_wrap_sys_device(NULL, fd, &handle);
|
|
252
|
+
if (r) {
|
|
253
|
+
printf("Error wrapping device: %s: %s\n", device_name, libusb_strerror(r));
|
|
254
|
+
close(fd);
|
|
255
|
+
return 1;
|
|
256
|
+
}
|
|
257
|
+
print_device(libusb_get_device(handle), handle);
|
|
258
|
+
close(fd);
|
|
249
259
|
return 0;
|
|
250
260
|
}
|
|
261
|
+
#else
|
|
262
|
+
static int test_wrapped_device(const char *device_name)
|
|
263
|
+
{
|
|
264
|
+
(void)device_name;
|
|
265
|
+
printf("Testing wrapped devices is not supported on your platform\n");
|
|
266
|
+
return 1;
|
|
267
|
+
}
|
|
268
|
+
#endif
|
|
251
269
|
|
|
252
270
|
int main(int argc, char *argv[])
|
|
253
271
|
{
|
|
272
|
+
const char *device_name = NULL;
|
|
254
273
|
libusb_device **devs;
|
|
255
274
|
ssize_t cnt;
|
|
256
275
|
int r, i;
|
|
257
276
|
|
|
258
|
-
|
|
259
|
-
|
|
277
|
+
for (i = 1; i < argc; i++) {
|
|
278
|
+
if (!strcmp(argv[i], "-v")) {
|
|
279
|
+
verbose = 1;
|
|
280
|
+
} else if (!strcmp(argv[i], "-d") && (i + 1) < argc) {
|
|
281
|
+
i++;
|
|
282
|
+
device_name = argv[i];
|
|
283
|
+
} else {
|
|
284
|
+
printf("Usage %s [-v] [-d </dev/bus/usb/...>]\n", argv[0]);
|
|
285
|
+
printf("Note use -d to test libusb_wrap_sys_device()\n");
|
|
286
|
+
return 1;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
260
289
|
|
|
261
290
|
r = libusb_init(NULL);
|
|
262
291
|
if (r < 0)
|
|
263
292
|
return r;
|
|
264
293
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
294
|
+
if (device_name) {
|
|
295
|
+
r = test_wrapped_device(device_name);
|
|
296
|
+
} else {
|
|
297
|
+
cnt = libusb_get_device_list(NULL, &devs);
|
|
298
|
+
if (cnt < 0) {
|
|
299
|
+
libusb_exit(NULL);
|
|
300
|
+
return 1;
|
|
301
|
+
}
|
|
268
302
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
303
|
+
for (i = 0; devs[i]; i++)
|
|
304
|
+
print_device(devs[i], NULL);
|
|
272
305
|
|
|
273
|
-
|
|
306
|
+
libusb_free_device_list(devs, 1);
|
|
307
|
+
}
|
|
274
308
|
|
|
275
309
|
libusb_exit(NULL);
|
|
276
|
-
return
|
|
310
|
+
return r;
|
|
277
311
|
}
|