usb 2.0.0-alpha.2 → 2.0.1
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/.gitmodules +1 -1
- package/CHANGELOG.md +81 -0
- package/README.md +570 -0
- package/binding.gyp +2 -2
- package/dist/usb/bindings.d.ts +13 -0
- package/dist/usb/bindings.js +2 -1
- package/dist/usb/bindings.js.map +1 -1
- package/dist/usb/index.js +86 -2
- package/dist/usb/index.js.map +1 -1
- package/dist/usb/interface.js.map +1 -1
- package/dist/webusb/index.d.ts +28 -19
- package/dist/webusb/index.js +152 -66
- package/dist/webusb/index.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +1 -1
- package/dist/webusb/webusb-device.js +9 -4
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.private/pre-commit.sh +7 -1
- package/libusb/.travis.yml +49 -0
- package/libusb/AUTHORS +44 -3
- package/libusb/Brewfile +4 -0
- package/libusb/ChangeLog +74 -2
- package/libusb/README.md +32 -0
- package/libusb/TODO +1 -1
- package/libusb/Xcode/common.xcconfig +12 -0
- package/libusb/Xcode/config.h +25 -0
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +959 -1
- package/libusb/android/README +4 -2
- package/libusb/android/config.h +75 -0
- package/libusb/appveyor.yml +41 -0
- package/libusb/appveyor_cygwin.bat +11 -0
- package/libusb/appveyor_minGW.bat +19 -0
- package/libusb/autogen.sh +1 -1
- package/libusb/bootstrap.sh +3 -16
- package/libusb/configure.ac +108 -80
- package/libusb/doc/doxygen.cfg.in +1785 -739
- package/libusb/examples/Makefile.am +1 -1
- package/libusb/examples/dpfp.c +3 -1
- package/libusb/examples/dpfp_threaded.c +23 -10
- package/libusb/examples/ezusb.c +3 -3
- package/libusb/examples/ezusb.h +2 -2
- package/libusb/examples/fxload.c +31 -9
- package/libusb/examples/hotplugtest.c +35 -7
- package/libusb/examples/listdevs.c +3 -1
- package/libusb/examples/sam3u_benchmark.c +3 -3
- package/libusb/examples/testlibusb.c +277 -0
- package/libusb/examples/xusb.c +40 -34
- package/libusb/libusb/Makefile.am +49 -23
- package/libusb/libusb/core.c +855 -457
- package/libusb/libusb/descriptor.c +72 -78
- package/libusb/libusb/hotplug.c +122 -76
- package/libusb/libusb/hotplug.h +42 -25
- package/libusb/libusb/io.c +625 -390
- package/libusb/libusb/libusb-1.0.def +12 -0
- package/libusb/libusb/libusb.h +218 -150
- package/libusb/libusb/libusbi.h +346 -176
- package/libusb/libusb/os/darwin_usb.c +604 -319
- package/libusb/libusb/os/darwin_usb.h +61 -20
- package/libusb/libusb/os/haiku_pollfs.cpp +367 -0
- package/libusb/libusb/os/haiku_usb.h +113 -0
- package/libusb/libusb/os/haiku_usb_backend.cpp +533 -0
- package/libusb/libusb/os/haiku_usb_raw.cpp +267 -0
- package/libusb/libusb/os/haiku_usb_raw.h +188 -0
- package/libusb/libusb/os/linux_netlink.c +186 -146
- package/libusb/libusb/os/linux_udev.c +36 -14
- package/libusb/libusb/os/linux_usbfs.c +426 -225
- package/libusb/libusb/os/linux_usbfs.h +5 -3
- package/libusb/libusb/os/netbsd_usb.c +21 -77
- package/libusb/libusb/os/openbsd_usb.c +32 -115
- package/libusb/libusb/os/poll_posix.c +38 -5
- package/libusb/libusb/os/poll_posix.h +3 -0
- package/libusb/libusb/os/poll_windows.c +277 -626
- package/libusb/libusb/os/poll_windows.h +11 -44
- package/libusb/libusb/os/sunos_usb.c +1695 -0
- package/libusb/libusb/os/sunos_usb.h +80 -0
- package/libusb/libusb/os/threads_posix.c +24 -26
- package/libusb/libusb/os/threads_posix.h +73 -21
- package/libusb/libusb/os/threads_windows.c +71 -157
- package/libusb/libusb/os/threads_windows.h +68 -44
- package/libusb/libusb/os/wince_usb.c +276 -420
- package/libusb/libusb/os/wince_usb.h +23 -28
- package/libusb/libusb/os/windows_common.h +78 -58
- package/libusb/libusb/os/windows_nt_common.c +1010 -0
- package/libusb/libusb/os/windows_nt_common.h +110 -0
- package/libusb/libusb/os/windows_nt_shared_types.h +147 -0
- package/libusb/libusb/os/windows_usbdk.c +830 -0
- package/libusb/libusb/os/windows_usbdk.h +103 -0
- package/libusb/libusb/os/windows_winusb.c +4391 -0
- package/libusb/libusb/os/windows_winusb.h +783 -0
- package/libusb/libusb/strerror.c +41 -7
- package/libusb/libusb/sync.c +41 -13
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/libusb-1.0.pc.in +1 -1
- package/libusb/msvc/appveyor.bat +27 -0
- package/libusb/msvc/config.h +5 -4
- package/libusb/msvc/ddk_build.cmd +87 -43
- package/libusb/msvc/fxload_2010.vcxproj +24 -104
- package/libusb/msvc/fxload_2012.vcxproj +24 -107
- package/libusb/msvc/fxload_2013.vcxproj +24 -107
- package/libusb/msvc/fxload_2015.vcxproj +91 -0
- package/libusb/msvc/fxload_2017.vcxproj +114 -0
- package/libusb/msvc/fxload_sources +1 -1
- package/libusb/msvc/getopt_2010.vcxproj +16 -75
- package/libusb/msvc/getopt_2012.vcxproj +16 -79
- package/libusb/msvc/getopt_2013.vcxproj +16 -79
- package/libusb/msvc/getopt_2015.vcxproj +73 -0
- package/libusb/msvc/getopt_2017.vcxproj +98 -0
- package/libusb/msvc/getopt_sources +6 -2
- package/libusb/msvc/hotplugtest_2010.vcxproj +18 -99
- package/libusb/msvc/hotplugtest_2012.vcxproj +18 -102
- package/libusb/msvc/hotplugtest_2013.vcxproj +18 -102
- package/libusb/msvc/hotplugtest_2015.vcxproj +83 -0
- package/libusb/msvc/hotplugtest_2017.vcxproj +106 -0
- package/libusb/msvc/hotplugtest_sources +1 -1
- package/libusb/msvc/libusb_2005.sln +20 -20
- package/libusb/msvc/libusb_2010.sln +57 -46
- package/libusb/msvc/libusb_2012.sln +57 -46
- package/libusb/msvc/libusb_2013.sln +57 -50
- package/libusb/msvc/libusb_2015.sln +59 -52
- package/libusb/msvc/libusb_2017.sln +186 -0
- package/libusb/msvc/libusb_dll.dsp +2 -2
- package/libusb/msvc/libusb_dll_2005.vcproj +30 -2
- package/libusb/msvc/libusb_dll_2010.vcxproj +26 -90
- package/libusb/msvc/libusb_dll_2012.vcxproj +28 -96
- package/libusb/msvc/libusb_dll_2013.vcxproj +28 -96
- package/libusb/msvc/libusb_dll_2015.vcxproj +107 -0
- package/libusb/msvc/libusb_dll_2017.vcxproj +134 -0
- package/libusb/msvc/libusb_dll_wince.vcproj +9 -1
- package/libusb/msvc/libusb_sources +10 -5
- package/libusb/msvc/libusb_static.dsp +2 -2
- package/libusb/msvc/libusb_static_2005.vcproj +32 -4
- package/libusb/msvc/libusb_static_2010.vcxproj +24 -83
- package/libusb/msvc/libusb_static_2012.vcxproj +25 -87
- package/libusb/msvc/libusb_static_2013.vcxproj +25 -87
- package/libusb/msvc/libusb_static_2015.vcxproj +98 -0
- package/libusb/msvc/libusb_static_2017.vcxproj +117 -0
- package/libusb/msvc/libusb_static_wince.vcproj +20 -26
- package/libusb/msvc/libusb_wince.sln +88 -88
- package/libusb/msvc/listdevs_2010.vcxproj +16 -99
- package/libusb/msvc/listdevs_2012.vcxproj +16 -102
- package/libusb/msvc/listdevs_2013.vcxproj +16 -102
- package/libusb/msvc/listdevs_2015.vcxproj +83 -0
- package/libusb/msvc/listdevs_2017.vcxproj +106 -0
- package/libusb/msvc/listdevs_sources +2 -1
- package/libusb/msvc/stress_2010.vcxproj +20 -101
- package/libusb/msvc/stress_2012.vcxproj +20 -104
- package/libusb/msvc/stress_2013.vcxproj +20 -104
- package/libusb/msvc/stress_2015.vcxproj +87 -0
- package/libusb/msvc/stress_2017.vcxproj +110 -0
- package/libusb/msvc/stress_sources +21 -0
- package/libusb/msvc/testlibusb_2010.vcxproj +82 -0
- package/libusb/msvc/testlibusb_2012.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2013.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2015.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2017.vcxproj +106 -0
- package/libusb/msvc/testlibusb_sources +20 -0
- package/libusb/msvc/xusb_2010.vcxproj +17 -98
- package/libusb/msvc/xusb_2012.vcxproj +17 -101
- package/libusb/msvc/xusb_2013.vcxproj +17 -101
- package/libusb/msvc/xusb_2015.vcxproj +83 -0
- package/libusb/msvc/xusb_2017.vcxproj +106 -0
- package/libusb/msvc/xusb_sources +1 -1
- package/libusb/tests/stress.c +2 -2
- package/libusb/tests/testlib.c +0 -4
- package/libusb/travis-autogen.sh +39 -0
- package/libusb.gypi +13 -2
- package/package.json +23 -13
- 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 +7 -7
- package/src/node_usb.cc +43 -1
- package/src/uv_async_queue.h +33 -25
- package/test/usb.coffee +6 -0
- package/tsc/index.ts +1 -1
- package/tsc/usb/bindings.ts +19 -1
- package/tsc/usb/index.ts +67 -19
- package/tsc/usb/interface.ts +2 -2
- package/tsc/webusb/index.ts +187 -75
- package/tsc/webusb/webusb-device.ts +19 -15
- package/.github/workflows/prebuild.yml +0 -48
- package/Readme.md +0 -339
- package/dist/webusb/typed-event-target.d.ts +0 -11
- package/dist/webusb/typed-event-target.js +0 -21
- package/dist/webusb/typed-event-target.js.map +0 -1
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/usb_bindings.device.html +0 -1338
- package/docs/classes/usb_bindings.libusbexception.html +0 -234
- package/docs/classes/usb_bindings.transfer.html +0 -344
- package/docs/classes/usb_capability.capability.html +0 -297
- package/docs/classes/usb_device.extendeddevice.html +0 -766
- package/docs/classes/usb_endpoint.endpoint.html +0 -472
- package/docs/classes/usb_endpoint.inendpoint.html +0 -766
- package/docs/classes/usb_endpoint.outendpoint.html +0 -582
- package/docs/classes/usb_interface.interface.html +0 -648
- package/docs/classes/webusb.webusb-1.html +0 -615
- package/docs/classes/webusb_mutex.mutex.html +0 -270
- package/docs/classes/webusb_typed_event_target.typedeventtarget.html +0 -443
- package/docs/classes/webusb_webusb_device.webusbdevice.html +0 -904
- package/docs/index.html +0 -500
- package/docs/interfaces/usb.deviceevents.html +0 -242
- package/docs/interfaces/usb_descriptors.bosdescriptor.html +0 -293
- package/docs/interfaces/usb_descriptors.capabilitydescriptor.html +0 -274
- package/docs/interfaces/usb_descriptors.configdescriptor.html +0 -388
- package/docs/interfaces/usb_descriptors.devicedescriptor.html +0 -464
- package/docs/interfaces/usb_descriptors.endpointdescriptor.html +0 -370
- package/docs/interfaces/usb_descriptors.interfacedescriptor.html +0 -407
- package/docs/interfaces/webusb.usboptions.html +0 -226
- package/docs/modules/index.html +0 -304
- package/docs/modules/usb.html +0 -173
- package/docs/modules/usb_bindings.html +0 -2248
- package/docs/modules/usb_capability.html +0 -156
- package/docs/modules/usb_descriptors.html +0 -176
- package/docs/modules/usb_device.html +0 -156
- package/docs/modules/usb_endpoint.html +0 -164
- package/docs/modules/usb_interface.html +0 -156
- package/docs/modules/webusb.html +0 -165
- package/docs/modules/webusb_mutex.html +0 -156
- package/docs/modules/webusb_typed_event_target.html +0 -156
- package/docs/modules/webusb_webusb_device.html +0 -156
- package/docs/modules.html +0 -156
- package/libusb/INSTALL +0 -234
- package/libusb/README +0 -28
- package/libusb/libusb/os/windows_usb.c +0 -5347
- package/libusb/libusb/os/windows_usb.h +0 -971
- package/libusb/msvc/fxload_2010.vcxproj.filters +0 -25
- package/libusb/msvc/fxload_2012.vcxproj.filters +0 -25
- package/libusb/msvc/getopt_2010.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2012.vcxproj.filters +0 -26
- package/libusb/msvc/hotplugtest_2010.vcxproj.filters +0 -14
- package/libusb/msvc/hotplugtest_2012.vcxproj.filters +0 -14
- package/libusb/msvc/libusb_dll_2010.vcxproj.filters +0 -81
- package/libusb/msvc/libusb_dll_2012.vcxproj.filters +0 -84
- package/libusb/msvc/libusb_static_2010.vcxproj.filters +0 -74
- package/libusb/msvc/libusb_static_2012.vcxproj.filters +0 -74
- package/libusb/msvc/listdevs_2010.vcxproj.filters +0 -14
- package/libusb/msvc/listdevs_2012.vcxproj.filters +0 -14
- package/libusb/msvc/stress_2010.vcxproj.filters +0 -25
- package/libusb/msvc/stress_2012.vcxproj.filters +0 -25
- package/libusb/msvc/xusb_2010.vcxproj.filters +0 -14
- package/libusb/msvc/xusb_2012.vcxproj.filters +0 -14
- package/tsc/webusb/typed-event-target.ts +0 -23
package/.gitmodules
CHANGED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.0.1] - 2021-12-11
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Added new WebUSB API - [`443`](https://github.com/node-usb/node-usb/pull/443) ([Rob Moran](https://github.com/thegecko))
|
|
7
|
+
- Switched to TypeScript
|
|
8
|
+
- Switched to yarn instead of npm
|
|
9
|
+
- Added docs using Typedoc
|
|
10
|
+
|
|
11
|
+
## [1.9.2] - 2021-12-05
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Fixed exit delay and hang by moving queue start/stop to device open/close - [`460`](https://github.com/node-usb/node-usb/pull/460) ([MikeColeGuru](https://github.com/MikeColeGuru))
|
|
15
|
+
|
|
16
|
+
## [1.9.1] - 2021-11-14
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- Reverted fix for exit delay fixing a segfault issue it introduced - [`456`](https://github.com/node-usb/node-usb/pull/456) ([Rob Moran](https://github.com/thegecko))
|
|
20
|
+
|
|
21
|
+
## [1.9.0] - 2021-11-08
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Changed libusb dependency to upstream v1.0.23 - [`453`](https://github.com/node-usb/node-usb/pull/453) ([Rob Moran](https://github.com/thegecko))
|
|
25
|
+
|
|
26
|
+
## [1.8.1] - 2021-11-08
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- Added functionality to ref/unref the hotplug events - [`455`](https://github.com/node-usb/node-usb/pull/455) ([Guilherme Francescon](https://github.com/gfcittolin))
|
|
30
|
+
- Added CHANGELOG - [`454`](https://github.com/node-usb/node-usb/pull/454) ([Rob Moran](https://github.com/thegecko))
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
- Fixed delay when exiting program - [`455`](https://github.com/node-usb/node-usb/pull/455) ([Rob Moran](https://github.com/thegecko))
|
|
34
|
+
|
|
35
|
+
## [1.8.0] - 2021-10-14
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
- Added prebuildify and GitHub action for native binaries - [`450`](https://github.com/node-usb/node-usb/pull/450) ([Rob Moran](https://github.com/thegecko))
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- Fixed crash after wake on Windows when using Electron - [`451`](https://github.com/node-usb/node-usb/pull/451) ([Rob Moran](https://github.com/thegecko))
|
|
42
|
+
- Fixed invalid initial refs - [`445`](https://github.com/node-usb/node-usb/pull/445) ([Alba Mendez](https://github.com/mildsunrise))
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- Changed GitHub organisation to [node-usb](https://github.com/node-usb) - [`447`](https://github.com/node-usb/node-usb/pull/447) ([Rob Moran](https://github.com/thegecko))
|
|
46
|
+
|
|
47
|
+
## [1.7.2] - 2021-08-30
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
- Fixed crash when exiting on MacOS with Electron 9 - [`440`](https://github.com/node-usb/node-usb/pull/440) ([Daniel Main](https://github.com/danielmain))
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
- **Breaking:** Changed minimum Node.js version to `10` - [`428`](https://github.com/node-usb/node-usb/pull/428) ([Rob Moran](https://github.com/thegecko))
|
|
54
|
+
|
|
55
|
+
## [1.7.1] - 2021-05-08
|
|
56
|
+
|
|
57
|
+
### Fixed
|
|
58
|
+
- Fixed compiler warnings - [`419`](https://github.com/node-usb/node-usb/pull/419) ([Joel Purra](https://github.com/joelpurra))
|
|
59
|
+
|
|
60
|
+
## [1.7.0] - 2021-04-10
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
- Changed native support to use Node Addon API - [`399`](https://github.com/node-usb/node-usb/pull/399) ([Georg Vienna](https://github.com/geovie))
|
|
64
|
+
|
|
65
|
+
## [1.6.5] - 2021-02-14
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
- Changed prebuild for Electron 12 beta to nightly - [`410`](https://github.com/node-usb/node-usb/pull/410) ([Piotr Rogowski](https://github.com/karniv00l))
|
|
69
|
+
|
|
70
|
+
### Removed
|
|
71
|
+
- Removed `portNumbers` test on arm64 - [`408`](https://github.com/node-usb/node-usb/pull/408) ([Rob Moran](https://github.com/thegecko))
|
|
72
|
+
|
|
73
|
+
## [1.6.4] - 2021-01-30
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
- Added prebuild for Electron 10 and 12 beta - [`407`](https://github.com/node-usb/node-usb/pull/407) ([Rob Moran](https://github.com/thegecko))
|
|
77
|
+
- Added prebuild for Electron 9 - [`362`](https://github.com/node-usb/node-usb/pull/362) (Luke Whyte)
|
|
78
|
+
|
|
79
|
+
### Changed
|
|
80
|
+
- Changed to GitHub Actions for prebuild workflow - [`404`](https://github.com/node-usb/node-usb/pull/404) ([Rob Moran](https://github.com/thegecko))
|
|
81
|
+
- Changed Node.js 13 prebuild target to Node.js 14 - [`374`](https://github.com/node-usb/node-usb/pull/374) ([Micah Zoltu](https://github.com/MicahZoltu))
|
package/README.md
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
# USB Library for Node.JS
|
|
2
|
+
|
|
3
|
+
[](https://github.com/node-usb/node-usb/actions)
|
|
4
|
+
[](https://www.npmjs.com/package/usb)
|
|
5
|
+
[](http://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Node.JS library for communicating with USB devices.
|
|
8
|
+
|
|
9
|
+
This is a refactoring / rewrite of Christopher Klein's [node-usb](https://github.com/schakko/node-usb).
|
|
10
|
+
|
|
11
|
+
# Prerequisites
|
|
12
|
+
|
|
13
|
+
[Node.js >= v10.16.0](https://nodejs.org), which includes `npm`.
|
|
14
|
+
|
|
15
|
+
On Windows, use [Zadig](http://zadig.akeo.ie/) to install the WinUSB driver for your USB device. Otherwise you will get `LIBUSB_ERROR_NOT_SUPPORTED` when attempting to open devices.
|
|
16
|
+
|
|
17
|
+
# Installation
|
|
18
|
+
|
|
19
|
+
Native modules are bundled using `prebuildify`, so installation should be as simple as installing the package.
|
|
20
|
+
|
|
21
|
+
With `npm`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install usb
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
With `yarn`:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add usb
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
__Note:__ the library is now written in `TypeScript`, so a separate types file is not longer required to be installed.
|
|
34
|
+
|
|
35
|
+
# License
|
|
36
|
+
[MIT](LICENSE.md)
|
|
37
|
+
|
|
38
|
+
Note that the compiled Node extension includes [libusb](https://github.com/libusb/libusb), and is thus subject to the [LGPL](https://github.com/libusb/libusb/blob/master/COPYING).
|
|
39
|
+
|
|
40
|
+
# Limitations
|
|
41
|
+
Does not support:
|
|
42
|
+
|
|
43
|
+
- Configurations other than the default one
|
|
44
|
+
- Isochronous transfers
|
|
45
|
+
|
|
46
|
+
# Getting Started
|
|
47
|
+
Use the following examples to kickstart your development. Once you have a desired device, use the APIs below to interact with it.
|
|
48
|
+
|
|
49
|
+
## Migrating to `v2.0.0`
|
|
50
|
+
The legacy API exists on an object called `usb` on the main import and the convenience functions exist as top level objects.
|
|
51
|
+
|
|
52
|
+
To use `v2.0.0` simply update your import statements and the function calls;
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// import * as usb from 'usb';
|
|
56
|
+
// const devices: usb.Device[] = usb.getDeviceList();
|
|
57
|
+
|
|
58
|
+
import { usb, getDeviceList } from 'usb';
|
|
59
|
+
const devices: usb.Device[] = getDeviceList();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## List all legacy devices
|
|
63
|
+
```typescript
|
|
64
|
+
import { getDeviceList } from 'usb';
|
|
65
|
+
|
|
66
|
+
const devices = getDeviceList();
|
|
67
|
+
|
|
68
|
+
for (const device of devices) {
|
|
69
|
+
console.log(device); // Legacy device
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Find legacy device by vid/pid
|
|
74
|
+
```typescript
|
|
75
|
+
import { findByIds } from 'usb';
|
|
76
|
+
|
|
77
|
+
const device = findByIds(0x59e3, 0x0a23);
|
|
78
|
+
|
|
79
|
+
if (device) {
|
|
80
|
+
console.log(device); // Legacy device
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Find legacy device by SerialNumber
|
|
85
|
+
```typescript
|
|
86
|
+
import { findBySerialNumber } from 'usb';
|
|
87
|
+
|
|
88
|
+
(async () => {
|
|
89
|
+
// Uses a blocking call, so is async
|
|
90
|
+
const device = await findBySerialNumber('TEST_DEVICE');
|
|
91
|
+
|
|
92
|
+
if (device) {
|
|
93
|
+
console.log(device); // Legacy device
|
|
94
|
+
}
|
|
95
|
+
})();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Turn legacy Device into WebUSB compatible device
|
|
99
|
+
```typescript
|
|
100
|
+
import { findBySerialNumber, WebUSBDevice } from 'usb';
|
|
101
|
+
|
|
102
|
+
(async () => {
|
|
103
|
+
// Uses a blocking call, so is async
|
|
104
|
+
const device = await findBySerialNumber('TEST_DEVICE');
|
|
105
|
+
|
|
106
|
+
// Uses blocking calls, so is async
|
|
107
|
+
const webDevice = await WebUSBDevice.createInstance(device);
|
|
108
|
+
|
|
109
|
+
if (webDevice) {
|
|
110
|
+
console.log(webDevice); // WebUSB device
|
|
111
|
+
}
|
|
112
|
+
})();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Use WebUSB approach to find a device
|
|
116
|
+
```typescript
|
|
117
|
+
import { webusb } from 'usb';
|
|
118
|
+
|
|
119
|
+
(async () => {
|
|
120
|
+
// Returns first matching device
|
|
121
|
+
const device = await webusb.requestDevice({
|
|
122
|
+
filters: [{}]
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
if (device) {
|
|
126
|
+
console.log(device); // WebUSB device
|
|
127
|
+
}
|
|
128
|
+
})();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Use WebUSB approach to find a device with custom selection method
|
|
132
|
+
```typescript
|
|
133
|
+
import { WebUSB } from 'usb';
|
|
134
|
+
|
|
135
|
+
(async () => {
|
|
136
|
+
const customWebUSB = new WebUSB({
|
|
137
|
+
// This function can return a promise which allows a UI to be displayed if required
|
|
138
|
+
devicesFound: devices => devices.find(device => device.serialNumber === 'TEST_DEVICE')
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Returns device based on injected 'devicesFound' function
|
|
142
|
+
const device = await customWebUSB.requestDevice({
|
|
143
|
+
filters: [{}]
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
if (device) {
|
|
147
|
+
console.log(device); // WebUSB device
|
|
148
|
+
}
|
|
149
|
+
})();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Use WebUSB approach to list authorised devices
|
|
153
|
+
```typescript
|
|
154
|
+
import { webusb } from 'usb';
|
|
155
|
+
|
|
156
|
+
(async () => {
|
|
157
|
+
// The default webusb instance follows the WebUSB spec and only returns authorised devices
|
|
158
|
+
const devices = await webusb.getDevices();
|
|
159
|
+
|
|
160
|
+
for (const device of devices) {
|
|
161
|
+
console.log(device); // WebUSB device
|
|
162
|
+
}
|
|
163
|
+
})();
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Use WebUSB approach to list all devices
|
|
167
|
+
```typescript
|
|
168
|
+
import { WebUSB } from 'usb';
|
|
169
|
+
|
|
170
|
+
(async () => {
|
|
171
|
+
const customWebUSB = new WebUSB({
|
|
172
|
+
// Bypass cheking for authorised devices
|
|
173
|
+
allowAllDevices: true
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Uses blocking calls, so is async
|
|
177
|
+
const devices = await customWebUSB.getDevices();
|
|
178
|
+
|
|
179
|
+
for (const device of devices) {
|
|
180
|
+
console.log(device); // WebUSB device
|
|
181
|
+
}
|
|
182
|
+
})();
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Electron
|
|
186
|
+
Please refer to the maintained example for using `node-usb` in electron:
|
|
187
|
+
|
|
188
|
+
https://github.com/node-usb/node-usb-example-electron
|
|
189
|
+
|
|
190
|
+
# APIs
|
|
191
|
+
Since `v2.0.0`, the `node-usb` library supports two APIs:
|
|
192
|
+
|
|
193
|
+
- `WebUSB` which follows the [WebUSB Specification](https://wicg.github.io/webusb/) (recommended)
|
|
194
|
+
- `Legacy API` which retains the previous 'non-blocking' API
|
|
195
|
+
|
|
196
|
+
Convenience methods also exist to easily list or find devices as well as convert between a legacy usb.Device device and WebUSB device.
|
|
197
|
+
|
|
198
|
+
Full auto-generated API documentation can be seen here:
|
|
199
|
+
|
|
200
|
+
https://node-usb.github.io/node-usb/
|
|
201
|
+
|
|
202
|
+
## Convenience Functions
|
|
203
|
+
|
|
204
|
+
### getDeviceList()
|
|
205
|
+
Return a list of legacy `Device` objects for the USB devices attached to the system.
|
|
206
|
+
|
|
207
|
+
### findByIds(vid, pid)
|
|
208
|
+
Convenience method to get the first legacy device with the specified VID and PID, or `undefined` if no such device is present.
|
|
209
|
+
|
|
210
|
+
### findBySerialNumber(serialNumber)
|
|
211
|
+
Convenience method to get a promise of the legacy device with the specified serial number, or `undefined` if no such device is present.
|
|
212
|
+
|
|
213
|
+
### WebUSBDevice
|
|
214
|
+
WebUSB Device class for wrapping a legacy Device into a WebUSB device
|
|
215
|
+
|
|
216
|
+
#### WebUSBDevice.createInstance(device)
|
|
217
|
+
Convenience method to return a promise of a WebUSB device based on a legacy device
|
|
218
|
+
|
|
219
|
+
## WebUSB
|
|
220
|
+
|
|
221
|
+
Please refer to the WebUSB specification which be found here:
|
|
222
|
+
|
|
223
|
+
https://wicg.github.io/webusb/
|
|
224
|
+
|
|
225
|
+
### Implementation Status
|
|
226
|
+
|
|
227
|
+
#### USB
|
|
228
|
+
|
|
229
|
+
- [x] getDevices()
|
|
230
|
+
- [x] requestDevice()
|
|
231
|
+
|
|
232
|
+
#### USBDevice
|
|
233
|
+
|
|
234
|
+
- [x] usbVersionMajor
|
|
235
|
+
- [x] usbVersionMinor
|
|
236
|
+
- [x] usbVersionSubminor
|
|
237
|
+
- [x] deviceClass
|
|
238
|
+
- [x] deviceSubclass
|
|
239
|
+
- [x] deviceProtocol
|
|
240
|
+
- [x] vendorId
|
|
241
|
+
- [x] productId
|
|
242
|
+
- [x] deviceVersionMajor
|
|
243
|
+
- [x] deviceVersionMinor
|
|
244
|
+
- [x] deviceVersionSubminor
|
|
245
|
+
- [x] manufacturerName
|
|
246
|
+
- [x] productName
|
|
247
|
+
- [x] serialNumber
|
|
248
|
+
- [x] configuration
|
|
249
|
+
- [x] configurations
|
|
250
|
+
- [x] opened
|
|
251
|
+
- [x] open()
|
|
252
|
+
- [x] close()
|
|
253
|
+
- [x] selectConfiguration()
|
|
254
|
+
- [x] claimInterface()
|
|
255
|
+
- [x] releaseInterface()
|
|
256
|
+
- [x] selectAlternateInterface()
|
|
257
|
+
- [x] controlTransferIn()
|
|
258
|
+
- [x] controlTransferOut() - `bytesWritten` always equals the initial buffer length
|
|
259
|
+
- [x] transferIn()
|
|
260
|
+
- [x] transferOut() - `bytesWritten` always equals the initial buffer length
|
|
261
|
+
- [x] clearHalt()
|
|
262
|
+
- [x] reset()
|
|
263
|
+
- [ ] isochronousTransferIn()
|
|
264
|
+
- [ ] isochronousTransferOut()
|
|
265
|
+
|
|
266
|
+
#### Events
|
|
267
|
+
|
|
268
|
+
- [x] connect
|
|
269
|
+
- [x] disconnect
|
|
270
|
+
|
|
271
|
+
## Legacy API
|
|
272
|
+
|
|
273
|
+
### usb
|
|
274
|
+
Legacy usb object.
|
|
275
|
+
|
|
276
|
+
#### usb.LIBUSB_*
|
|
277
|
+
Constant properties from libusb
|
|
278
|
+
|
|
279
|
+
#### usb.setDebugLevel(level : int)
|
|
280
|
+
Set the libusb debug level (between 0 and 4)
|
|
281
|
+
|
|
282
|
+
### Device
|
|
283
|
+
Represents a USB device.
|
|
284
|
+
|
|
285
|
+
#### .busNumber
|
|
286
|
+
Integer USB device number
|
|
287
|
+
|
|
288
|
+
#### .deviceAddress
|
|
289
|
+
Integer USB device address
|
|
290
|
+
|
|
291
|
+
#### .portNumbers
|
|
292
|
+
Array containing the USB device port numbers, or `undefined` if not supported on this platform.
|
|
293
|
+
|
|
294
|
+
#### .deviceDescriptor
|
|
295
|
+
Object with properties for the fields of the device descriptor:
|
|
296
|
+
|
|
297
|
+
- bLength
|
|
298
|
+
- bDescriptorType
|
|
299
|
+
- bcdUSB
|
|
300
|
+
- bDeviceClass
|
|
301
|
+
- bDeviceSubClass
|
|
302
|
+
- bDeviceProtocol
|
|
303
|
+
- bMaxPacketSize0
|
|
304
|
+
- idVendor
|
|
305
|
+
- idProduct
|
|
306
|
+
- bcdDevice
|
|
307
|
+
- iManufacturer
|
|
308
|
+
- iProduct
|
|
309
|
+
- iSerialNumber
|
|
310
|
+
- bNumConfigurations
|
|
311
|
+
|
|
312
|
+
#### .configDescriptor
|
|
313
|
+
Object with properties for the fields of the configuration descriptor:
|
|
314
|
+
|
|
315
|
+
- bLength
|
|
316
|
+
- bDescriptorType
|
|
317
|
+
- wTotalLength
|
|
318
|
+
- bNumInterfaces
|
|
319
|
+
- bConfigurationValue
|
|
320
|
+
- iConfiguration
|
|
321
|
+
- bmAttributes
|
|
322
|
+
- bMaxPower
|
|
323
|
+
- extra (Buffer containing any extra data or additional descriptors)
|
|
324
|
+
|
|
325
|
+
#### .allConfigDescriptors
|
|
326
|
+
Contains all config descriptors of the device (same structure as .configDescriptor above)
|
|
327
|
+
|
|
328
|
+
#### .parent
|
|
329
|
+
Contains the parent of the device, such as a hub. If there is no parent this property is set to `null`.
|
|
330
|
+
|
|
331
|
+
#### .open()
|
|
332
|
+
Open the device. All methods below require the device to be open before use.
|
|
333
|
+
|
|
334
|
+
#### .close()
|
|
335
|
+
Close the device.
|
|
336
|
+
|
|
337
|
+
#### .controlTransfer(bmRequestType, bRequest, wValue, wIndex, data_or_length, callback(error, data))
|
|
338
|
+
Perform a control transfer with `libusb_control_transfer`.
|
|
339
|
+
|
|
340
|
+
Parameter `data_or_length` can be a integer length for an IN transfer, or a Buffer for an out transfer. The type must match the direction specified in the MSB of bmRequestType.
|
|
341
|
+
|
|
342
|
+
The `data` parameter of the callback is always undefined for OUT transfers, or will be passed a Buffer for IN transfers.
|
|
343
|
+
|
|
344
|
+
A [package is available to calculate bmRequestType](https://www.npmjs.com/package/bmrequesttype) if needed.
|
|
345
|
+
|
|
346
|
+
#### .setConfiguration(id, callback(error))
|
|
347
|
+
Set the device configuration to something other than the default (0). To use this, first call `.open(false)` (which tells it not to auto configure), then before claiming an interface, call this method.
|
|
348
|
+
|
|
349
|
+
#### .getStringDescriptor(index, callback(error, data))
|
|
350
|
+
Perform a control transfer to retrieve a string descriptor
|
|
351
|
+
|
|
352
|
+
#### .getBosDescriptor(callback(error, bosDescriptor))
|
|
353
|
+
Perform a control transfer to retrieve an object with properties for the fields of the Binary Object Store descriptor:
|
|
354
|
+
|
|
355
|
+
- bLength
|
|
356
|
+
- bDescriptorType
|
|
357
|
+
- wTotalLength
|
|
358
|
+
- bNumDeviceCaps
|
|
359
|
+
|
|
360
|
+
#### .getCapabilities(callback(error, capabilities))
|
|
361
|
+
Retrieve a list of Capability objects for the Binary Object Store capabilities of the device.
|
|
362
|
+
|
|
363
|
+
#### .interface(interface)
|
|
364
|
+
Return the interface with the specified interface number.
|
|
365
|
+
|
|
366
|
+
#### .interfaces
|
|
367
|
+
List of Interface objects for the interfaces of the default configuration of the device.
|
|
368
|
+
|
|
369
|
+
#### .timeout
|
|
370
|
+
Timeout in milliseconds to use for control transfers.
|
|
371
|
+
|
|
372
|
+
#### .reset(callback(error))
|
|
373
|
+
Performs a reset of the device. Callback is called when complete.
|
|
374
|
+
|
|
375
|
+
### Interface
|
|
376
|
+
|
|
377
|
+
#### .endpoint(address)
|
|
378
|
+
Return the InEndpoint or OutEndpoint with the specified address.
|
|
379
|
+
|
|
380
|
+
#### .endpoints
|
|
381
|
+
List of endpoints on this interface: InEndpoint and OutEndpoint objects.
|
|
382
|
+
|
|
383
|
+
#### .interface
|
|
384
|
+
Integer interface number.
|
|
385
|
+
|
|
386
|
+
#### .altSetting
|
|
387
|
+
Integer alternate setting number.
|
|
388
|
+
|
|
389
|
+
#### .setAltSetting(altSetting, callback(error))
|
|
390
|
+
Sets the alternate setting. It updates the `interface.endpoints` array to reflect the endpoints found in the alternate setting.
|
|
391
|
+
|
|
392
|
+
#### .claim()
|
|
393
|
+
Claims the interface. This method must be called before using any endpoints of this interface.
|
|
394
|
+
|
|
395
|
+
#### .release([closeEndpoints], callback(error))
|
|
396
|
+
Releases the interface and resets the alternate setting. Calls callback when complete.
|
|
397
|
+
|
|
398
|
+
It is an error to release an interface with pending transfers. If the optional closeEndpoints parameter is true, any active endpoint streams are stopped (see `Endpoint.stopStream`), and the interface is released after the stream transfers are cancelled. Transfers submitted individually with `Endpoint.transfer` are not affected by this parameter.
|
|
399
|
+
|
|
400
|
+
#### .isKernelDriverActive()
|
|
401
|
+
Returns `false` if a kernel driver is not active; `true` if active.
|
|
402
|
+
|
|
403
|
+
#### .detachKernelDriver()
|
|
404
|
+
Detaches the kernel driver from the interface.
|
|
405
|
+
|
|
406
|
+
#### .attachKernelDriver()
|
|
407
|
+
Re-attaches the kernel driver for the interface.
|
|
408
|
+
|
|
409
|
+
#### .descriptor
|
|
410
|
+
Object with fields from the interface descriptor -- see libusb documentation or USB spec.
|
|
411
|
+
|
|
412
|
+
- bLength
|
|
413
|
+
- bDescriptorType
|
|
414
|
+
- bInterfaceNumber
|
|
415
|
+
- bAlternateSetting
|
|
416
|
+
- bNumEndpoints
|
|
417
|
+
- bInterfaceClass
|
|
418
|
+
- bInterfaceSubClass
|
|
419
|
+
- bInterfaceProtocol
|
|
420
|
+
- iInterface
|
|
421
|
+
- extra (Buffer containing any extra data or additional descriptors)
|
|
422
|
+
|
|
423
|
+
### Capability
|
|
424
|
+
|
|
425
|
+
#### .type
|
|
426
|
+
Integer capability type.
|
|
427
|
+
|
|
428
|
+
#### .data
|
|
429
|
+
Buffer capability data.
|
|
430
|
+
|
|
431
|
+
#### .descriptor
|
|
432
|
+
Object with fields from the capability descriptor -- see libusb documentation or USB spec.
|
|
433
|
+
|
|
434
|
+
- bLength
|
|
435
|
+
- bDescriptorType
|
|
436
|
+
- bDevCapabilityType
|
|
437
|
+
|
|
438
|
+
### Endpoint
|
|
439
|
+
Common base for InEndpoint and OutEndpoint, see below.
|
|
440
|
+
|
|
441
|
+
#### .direction
|
|
442
|
+
Endpoint direction: `"in"` or `"out"`.
|
|
443
|
+
|
|
444
|
+
#### .transferType
|
|
445
|
+
Endpoint type: `usb.LIBUSB_TRANSFER_TYPE_BULK`, `usb.LIBUSB_TRANSFER_TYPE_INTERRUPT`, or `usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS`.
|
|
446
|
+
|
|
447
|
+
#### .descriptor
|
|
448
|
+
Object with fields from the endpoint descriptor -- see libusb documentation or USB spec.
|
|
449
|
+
|
|
450
|
+
- bLength
|
|
451
|
+
- bDescriptorType
|
|
452
|
+
- bEndpointAddress
|
|
453
|
+
- bmAttributes
|
|
454
|
+
- wMaxPacketSize
|
|
455
|
+
- bInterval
|
|
456
|
+
- bRefresh
|
|
457
|
+
- bSynchAddress
|
|
458
|
+
- extra (Buffer containing any extra data or additional descriptors)
|
|
459
|
+
|
|
460
|
+
#### .timeout
|
|
461
|
+
Sets the timeout in milliseconds for transfers on this endpoint. The default, `0`, is infinite timeout.
|
|
462
|
+
|
|
463
|
+
#### .clearHalt(callback(error))
|
|
464
|
+
Clear the halt/stall condition for this endpoint.
|
|
465
|
+
|
|
466
|
+
### InEndpoint
|
|
467
|
+
Endpoints in the IN direction (device->PC) have this type.
|
|
468
|
+
|
|
469
|
+
#### .transfer(length, callback(error, data))
|
|
470
|
+
Perform a transfer to read data from the endpoint.
|
|
471
|
+
|
|
472
|
+
If length is greater than maxPacketSize, libusb will automatically split the transfer in multiple packets, and you will receive one callback with all data once all packets are complete.
|
|
473
|
+
|
|
474
|
+
`this` in the callback is the InEndpoint object.
|
|
475
|
+
|
|
476
|
+
#### .startPoll(nTransfers=3, transferSize=maxPacketSize)
|
|
477
|
+
Start polling the endpoint.
|
|
478
|
+
|
|
479
|
+
The library will keep `nTransfers` transfers of size `transferSize` pending in
|
|
480
|
+
the kernel at all times to ensure continuous data flow. This is handled by the
|
|
481
|
+
libusb event thread, so it continues even if the Node v8 thread is busy. The
|
|
482
|
+
`data` and `error` events are emitted as transfers complete.
|
|
483
|
+
|
|
484
|
+
#### .stopPoll(cb)
|
|
485
|
+
Stop polling.
|
|
486
|
+
|
|
487
|
+
Further data may still be received. The `end` event is emitted and the callback
|
|
488
|
+
is called once all transfers have completed or canceled.
|
|
489
|
+
|
|
490
|
+
#### Event: data(data : Buffer)
|
|
491
|
+
Emitted with data received by the polling transfers
|
|
492
|
+
|
|
493
|
+
#### Event: error(error)
|
|
494
|
+
Emitted when polling encounters an error. All in flight transfers will be automatically canceled and no further polling will be done. You have to wait for the `end` event before you can start polling again.
|
|
495
|
+
|
|
496
|
+
#### Event: end
|
|
497
|
+
Emitted when polling has been canceled
|
|
498
|
+
|
|
499
|
+
### OutEndpoint
|
|
500
|
+
Endpoints in the OUT direction (PC->device) have this type.
|
|
501
|
+
|
|
502
|
+
#### .transfer(data, callback(error))
|
|
503
|
+
Perform a transfer to write `data` to the endpoint.
|
|
504
|
+
|
|
505
|
+
If length is greater than maxPacketSize, libusb will automatically split the transfer in multiple packets, and you will receive one callback once all packets are complete.
|
|
506
|
+
|
|
507
|
+
`this` in the callback is the OutEndpoint object.
|
|
508
|
+
|
|
509
|
+
#### Event: error(error)
|
|
510
|
+
Emitted when the stream encounters an error.
|
|
511
|
+
|
|
512
|
+
#### Event: end
|
|
513
|
+
Emitted when the stream has been stopped and all pending requests have been completed.
|
|
514
|
+
|
|
515
|
+
### UsbDetection
|
|
516
|
+
|
|
517
|
+
#### usb.on('attach', function(device) { ... });
|
|
518
|
+
Attaches a callback to plugging in a `device`.
|
|
519
|
+
|
|
520
|
+
#### usb.on('detach', function(device) { ... });
|
|
521
|
+
Attaches a callback to unplugging a `device`.
|
|
522
|
+
|
|
523
|
+
#### usb.refHotplugEvents();
|
|
524
|
+
Restore (re-reference) the hotplug events unreferenced by `unrefHotplugEvents()`
|
|
525
|
+
|
|
526
|
+
#### usb.unrefHotplugEvents();
|
|
527
|
+
Listening to events will prevent the process to exit. By calling this function, hotplug events will be unreferenced by the event loop, allowing the process to exit even when listening for the `attach` and `detach` events.
|
|
528
|
+
|
|
529
|
+
# Development
|
|
530
|
+
The library is based on native bindings wrapping the [libusb](https://github.com/libusb/libusb) library.
|
|
531
|
+
|
|
532
|
+
## Setup
|
|
533
|
+
Libusb is included as a submodule, clone this repository and then the submodule as follows:
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
git clone https://github.com/node-usb/node-usb
|
|
537
|
+
cd node-usb
|
|
538
|
+
git submodule update --init
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
## Building
|
|
542
|
+
The package uses `yarn` for the typescript code and `prebuildify` to generate the native binaries. These can be executed as follows:
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
yarn
|
|
546
|
+
yarn prebuild
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
__Note:__ On Linux, you'll need libudev to build libusb. On Ubuntu/Debian:
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
sudo apt-get install build-essential libudev-dev
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
## Testing
|
|
556
|
+
To execute the unit tests, Run:
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
yarn test
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
Some tests require an [attached STM32F103 Microprocessor USB device with specific firmware](https://github.com/node-usb/node-usb-test-firmware).
|
|
563
|
+
|
|
564
|
+
```bash
|
|
565
|
+
yarn full-test
|
|
566
|
+
yarn valgrind
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
## Releasing
|
|
570
|
+
Please refer to the [Wiki](https://github.com/node-usb/node-usb/wiki/Release-Process) for release instructions.
|
package/binding.gyp
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
'cflags_cc!': [ '-fno-exceptions' ],
|
|
11
11
|
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
|
12
12
|
'CLANG_CXX_LIBRARY': 'libc++',
|
|
13
|
-
'MACOSX_DEPLOYMENT_TARGET': '10.
|
|
13
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.11',
|
|
14
14
|
},
|
|
15
15
|
'msvs_settings': {
|
|
16
16
|
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
'OTHER_CFLAGS': [ '-std=c++1y', '-stdlib=libc++' ],
|
|
53
53
|
'OTHER_LDFLAGS': [ '-framework', 'CoreFoundation', '-framework', 'IOKit' ],
|
|
54
54
|
'SDKROOT': 'macosx',
|
|
55
|
-
'MACOSX_DEPLOYMENT_TARGET': '10.
|
|
55
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.11',
|
|
56
56
|
},
|
|
57
57
|
}],
|
|
58
58
|
['OS=="win"', {
|
package/dist/usb/bindings.d.ts
CHANGED
|
@@ -15,6 +15,15 @@ export declare class LibUSBException extends Error {
|
|
|
15
15
|
export declare function setDebugLevel(level: number): void;
|
|
16
16
|
export declare function _enableHotplugEvents(): void;
|
|
17
17
|
export declare function _disableHotplugEvents(): void;
|
|
18
|
+
export declare function _getLibusbCapability(capability: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Restore (re-reference) the hotplug events unreferenced by `unrefHotplugEvents()`
|
|
21
|
+
*/
|
|
22
|
+
export declare function refHotplugEvents(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Unreference the hotplug events from the event loop, allowing the process to exit even when listening for the `attach` and `detach` events
|
|
25
|
+
*/
|
|
26
|
+
export declare function unrefHotplugEvents(): void;
|
|
18
27
|
/** Represents a USB transfer */
|
|
19
28
|
export declare class Transfer {
|
|
20
29
|
constructor(device: Device, endpointAddr: number, type: number, timeout: number, callback: (error: LibUSBException, buf: Buffer, actual: number) => void);
|
|
@@ -212,6 +221,10 @@ export declare const LIBUSB_RECIPIENT_ENDPOINT: number;
|
|
|
212
221
|
export declare const LIBUSB_RECIPIENT_OTHER: number;
|
|
213
222
|
export declare const LIBUSB_CONTROL_SETUP_SIZE: number;
|
|
214
223
|
export declare const LIBUSB_DT_BOS_SIZE: number;
|
|
224
|
+
export declare const LIBUSB_CAP_HAS_CAPABILITY: number;
|
|
225
|
+
export declare const LIBUSB_CAP_HAS_HOTPLUG: number;
|
|
226
|
+
export declare const LIBUSB_CAP_HAS_HID_ACCESS: number;
|
|
227
|
+
export declare const LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER: number;
|
|
215
228
|
/** Input/output error */
|
|
216
229
|
export declare const LIBUSB_ERROR_IO: number;
|
|
217
230
|
/** Invalid parameter */
|