usb 1.7.2-prebuild

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 (183) hide show
  1. package/.github/workflows/prebuild.yml +62 -0
  2. package/.gitmodules +3 -0
  3. package/LICENSE +7 -0
  4. package/Readme.md +339 -0
  5. package/binding.gyp +90 -0
  6. package/libusb/.gitattributes +11 -0
  7. package/libusb/.private/README.txt +5 -0
  8. package/libusb/.private/bd.cmd +89 -0
  9. package/libusb/.private/bm.sh +54 -0
  10. package/libusb/.private/bwince.cmd +57 -0
  11. package/libusb/.private/post-rewrite.sh +28 -0
  12. package/libusb/.private/pre-commit.sh +42 -0
  13. package/libusb/.private/wbs.txt +61 -0
  14. package/libusb/.private/wbs_wince.txt +42 -0
  15. package/libusb/AUTHORS +78 -0
  16. package/libusb/COPYING +504 -0
  17. package/libusb/ChangeLog +211 -0
  18. package/libusb/INSTALL +234 -0
  19. package/libusb/INSTALL_WIN.txt +73 -0
  20. package/libusb/Makefile.am +28 -0
  21. package/libusb/NEWS +2 -0
  22. package/libusb/PORTING +94 -0
  23. package/libusb/README +28 -0
  24. package/libusb/README.git +41 -0
  25. package/libusb/TODO +2 -0
  26. package/libusb/Xcode/common.xcconfig +49 -0
  27. package/libusb/Xcode/debug.xcconfig +29 -0
  28. package/libusb/Xcode/libusb.xcconfig +21 -0
  29. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +1 -0
  30. package/libusb/Xcode/libusb_debug.xcconfig +21 -0
  31. package/libusb/Xcode/libusb_release.xcconfig +21 -0
  32. package/libusb/Xcode/release.xcconfig +30 -0
  33. package/libusb/android/README +114 -0
  34. package/libusb/android/jni/Android.mk +23 -0
  35. package/libusb/android/jni/Application.mk +24 -0
  36. package/libusb/android/jni/examples.mk +134 -0
  37. package/libusb/android/jni/libusb.mk +54 -0
  38. package/libusb/android/jni/tests.mk +56 -0
  39. package/libusb/autogen.sh +8 -0
  40. package/libusb/bootstrap.sh +19 -0
  41. package/libusb/configure.ac +304 -0
  42. package/libusb/doc/Makefile.am +9 -0
  43. package/libusb/doc/doxygen.cfg.in +1288 -0
  44. package/libusb/doc/libusb.png +0 -0
  45. package/libusb/examples/Makefile.am +19 -0
  46. package/libusb/examples/dpfp.c +506 -0
  47. package/libusb/examples/dpfp_threaded.c +544 -0
  48. package/libusb/examples/ezusb.c +831 -0
  49. package/libusb/examples/ezusb.h +120 -0
  50. package/libusb/examples/fxload.c +287 -0
  51. package/libusb/examples/getopt/getopt.c +1060 -0
  52. package/libusb/examples/getopt/getopt.h +180 -0
  53. package/libusb/examples/getopt/getopt1.c +188 -0
  54. package/libusb/examples/hotplugtest.c +104 -0
  55. package/libusb/examples/listdevs.c +71 -0
  56. package/libusb/examples/sam3u_benchmark.c +193 -0
  57. package/libusb/examples/xusb.c +1129 -0
  58. package/libusb/libusb/Makefile.am +75 -0
  59. package/libusb/libusb/core.c +2342 -0
  60. package/libusb/libusb/descriptor.c +1199 -0
  61. package/libusb/libusb/hotplug.c +327 -0
  62. package/libusb/libusb/hotplug.h +82 -0
  63. package/libusb/libusb/io.c +2631 -0
  64. package/libusb/libusb/libusb-1.0.def +166 -0
  65. package/libusb/libusb/libusb-1.0.rc +61 -0
  66. package/libusb/libusb/libusb.h +1998 -0
  67. package/libusb/libusb/libusbi.h +1040 -0
  68. package/libusb/libusb/os/darwin_usb.c +2009 -0
  69. package/libusb/libusb/os/darwin_usb.h +162 -0
  70. package/libusb/libusb/os/linux_netlink.c +369 -0
  71. package/libusb/libusb/os/linux_udev.c +307 -0
  72. package/libusb/libusb/os/linux_usbfs.c +2695 -0
  73. package/libusb/libusb/os/linux_usbfs.h +192 -0
  74. package/libusb/libusb/os/netbsd_usb.c +738 -0
  75. package/libusb/libusb/os/openbsd_usb.c +832 -0
  76. package/libusb/libusb/os/poll_posix.c +51 -0
  77. package/libusb/libusb/os/poll_posix.h +11 -0
  78. package/libusb/libusb/os/poll_windows.c +796 -0
  79. package/libusb/libusb/os/poll_windows.h +131 -0
  80. package/libusb/libusb/os/threads_posix.c +82 -0
  81. package/libusb/libusb/os/threads_posix.h +50 -0
  82. package/libusb/libusb/os/threads_windows.c +212 -0
  83. package/libusb/libusb/os/threads_windows.h +87 -0
  84. package/libusb/libusb/os/wince_usb.c +1032 -0
  85. package/libusb/libusb/os/wince_usb.h +131 -0
  86. package/libusb/libusb/os/windows_common.h +108 -0
  87. package/libusb/libusb/os/windows_usb.c +5347 -0
  88. package/libusb/libusb/os/windows_usb.h +971 -0
  89. package/libusb/libusb/strerror.c +199 -0
  90. package/libusb/libusb/sync.c +307 -0
  91. package/libusb/libusb/version.h +18 -0
  92. package/libusb/libusb/version_nano.h +1 -0
  93. package/libusb/libusb-1.0.pc.in +11 -0
  94. package/libusb/msvc/config.h +50 -0
  95. package/libusb/msvc/ddk_build.cmd +175 -0
  96. package/libusb/msvc/errno.h +102 -0
  97. package/libusb/msvc/fxload_2010.vcxproj +170 -0
  98. package/libusb/msvc/fxload_2010.vcxproj.filters +25 -0
  99. package/libusb/msvc/fxload_2012.vcxproj +174 -0
  100. package/libusb/msvc/fxload_2012.vcxproj.filters +25 -0
  101. package/libusb/msvc/fxload_2013.vcxproj +174 -0
  102. package/libusb/msvc/fxload_sources +23 -0
  103. package/libusb/msvc/getopt_2005.vcproj +288 -0
  104. package/libusb/msvc/getopt_2010.vcxproj +131 -0
  105. package/libusb/msvc/getopt_2010.vcxproj.filters +26 -0
  106. package/libusb/msvc/getopt_2012.vcxproj +136 -0
  107. package/libusb/msvc/getopt_2012.vcxproj.filters +26 -0
  108. package/libusb/msvc/getopt_2013.vcxproj +136 -0
  109. package/libusb/msvc/getopt_sources +20 -0
  110. package/libusb/msvc/hotplugtest_2010.vcxproj +163 -0
  111. package/libusb/msvc/hotplugtest_2010.vcxproj.filters +14 -0
  112. package/libusb/msvc/hotplugtest_2012.vcxproj +167 -0
  113. package/libusb/msvc/hotplugtest_2012.vcxproj.filters +14 -0
  114. package/libusb/msvc/hotplugtest_2013.vcxproj +167 -0
  115. package/libusb/msvc/hotplugtest_sources +20 -0
  116. package/libusb/msvc/inttypes.h +295 -0
  117. package/libusb/msvc/libusb.dsw +71 -0
  118. package/libusb/msvc/libusb_2005.sln +95 -0
  119. package/libusb/msvc/libusb_2010.sln +94 -0
  120. package/libusb/msvc/libusb_2012.sln +94 -0
  121. package/libusb/msvc/libusb_2013.sln +100 -0
  122. package/libusb/msvc/libusb_2015.sln +100 -0
  123. package/libusb/msvc/libusb_dll.dsp +194 -0
  124. package/libusb/msvc/libusb_dll_2005.vcproj +436 -0
  125. package/libusb/msvc/libusb_dll_2010.vcxproj +170 -0
  126. package/libusb/msvc/libusb_dll_2010.vcxproj.filters +81 -0
  127. package/libusb/msvc/libusb_dll_2012.vcxproj +175 -0
  128. package/libusb/msvc/libusb_dll_2012.vcxproj.filters +84 -0
  129. package/libusb/msvc/libusb_dll_2013.vcxproj +175 -0
  130. package/libusb/msvc/libusb_dll_wince.vcproj +1243 -0
  131. package/libusb/msvc/libusb_sources +38 -0
  132. package/libusb/msvc/libusb_static.dsp +174 -0
  133. package/libusb/msvc/libusb_static_2005.vcproj +362 -0
  134. package/libusb/msvc/libusb_static_2010.vcxproj +156 -0
  135. package/libusb/msvc/libusb_static_2010.vcxproj.filters +74 -0
  136. package/libusb/msvc/libusb_static_2012.vcxproj +160 -0
  137. package/libusb/msvc/libusb_static_2012.vcxproj.filters +74 -0
  138. package/libusb/msvc/libusb_static_2013.vcxproj +160 -0
  139. package/libusb/msvc/libusb_static_wince.vcproj +1185 -0
  140. package/libusb/msvc/libusb_wince.sln +246 -0
  141. package/libusb/msvc/listdevs.dsp +103 -0
  142. package/libusb/msvc/listdevs_2005.vcproj +360 -0
  143. package/libusb/msvc/listdevs_2010.vcxproj +165 -0
  144. package/libusb/msvc/listdevs_2010.vcxproj.filters +14 -0
  145. package/libusb/msvc/listdevs_2012.vcxproj +169 -0
  146. package/libusb/msvc/listdevs_2012.vcxproj.filters +14 -0
  147. package/libusb/msvc/listdevs_2013.vcxproj +169 -0
  148. package/libusb/msvc/listdevs_sources +19 -0
  149. package/libusb/msvc/listdevs_wince.vcproj +1120 -0
  150. package/libusb/msvc/missing.c +80 -0
  151. package/libusb/msvc/missing.h +32 -0
  152. package/libusb/msvc/stdint.h +256 -0
  153. package/libusb/msvc/stress_2005.vcproj +390 -0
  154. package/libusb/msvc/stress_2010.vcxproj +167 -0
  155. package/libusb/msvc/stress_2010.vcxproj.filters +25 -0
  156. package/libusb/msvc/stress_2012.vcxproj +171 -0
  157. package/libusb/msvc/stress_2012.vcxproj.filters +25 -0
  158. package/libusb/msvc/stress_2013.vcxproj +171 -0
  159. package/libusb/msvc/stress_wince.vcproj +1128 -0
  160. package/libusb/msvc/xusb.dsp +102 -0
  161. package/libusb/msvc/xusb_2005.vcproj +344 -0
  162. package/libusb/msvc/xusb_2010.vcxproj +163 -0
  163. package/libusb/msvc/xusb_2010.vcxproj.filters +14 -0
  164. package/libusb/msvc/xusb_2012.vcxproj +167 -0
  165. package/libusb/msvc/xusb_2012.vcxproj.filters +14 -0
  166. package/libusb/msvc/xusb_2013.vcxproj +167 -0
  167. package/libusb/msvc/xusb_sources +20 -0
  168. package/libusb/msvc/xusb_wince.vcproj +1120 -0
  169. package/libusb/tests/Makefile.am +6 -0
  170. package/libusb/tests/libusb_testlib.h +107 -0
  171. package/libusb/tests/stress.c +160 -0
  172. package/libusb/tests/testlib.c +281 -0
  173. package/libusb.gypi +136 -0
  174. package/libusb_config/config.h +1 -0
  175. package/package.json +69 -0
  176. package/src/device.cc +412 -0
  177. package/src/helpers.h +64 -0
  178. package/src/node_usb.cc +319 -0
  179. package/src/node_usb.h +120 -0
  180. package/src/transfer.cc +148 -0
  181. package/src/uv_async_queue.h +33 -0
  182. package/test/usb.coffee +191 -0
  183. package/usb.js +524 -0
@@ -0,0 +1,62 @@
1
+ name: prebuild
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ tags:
8
+ - '*'
9
+ pull_request:
10
+ branches:
11
+ - master
12
+ workflow_dispatch:
13
+
14
+ jobs:
15
+ prebuild:
16
+ strategy:
17
+ matrix:
18
+ config:
19
+ - { name: darwin, os: macos-11, arch: x64 }
20
+ - { name: win32-x86, os: windows-latest, arch: x86 }
21
+ - { name: win32-x64, os: windows-latest, arch: x64 }
22
+ - { name: linux-x64, os: ubuntu-latest, arch: x64 }
23
+ - { name: linux-arm, os: ubuntu-latest, arch: x64 }
24
+ - { name: android-arm, os: ubuntu-latest, arch: x64 }
25
+ name: Build ${{ matrix.config.name }}
26
+ runs-on: ${{ matrix.config.os }}
27
+ steps:
28
+ - if: matrix.config.os == 'ubuntu-latest'
29
+ run: |
30
+ sudo apt-get update
31
+ sudo apt-get install libudev-dev
32
+ - uses: actions/setup-node@v2
33
+ with:
34
+ node-version: 14.x
35
+ architecture: ${{ matrix.config.arch }}
36
+ - uses: actions/checkout@v2
37
+ with:
38
+ submodules: recursive
39
+ - run: npm install --ignore-scripts
40
+ - run: npm run prebuild-${{ matrix.config.name }}
41
+ - run: tar -zcvf ${{ matrix.config.name }}.tar.gz -C prebuilds .
42
+ - uses: actions/upload-artifact@v2
43
+ with:
44
+ name: ${{ matrix.config.name }}
45
+ path: ${{ matrix.config.name }}.tar.gz
46
+ retention-days: 1
47
+ release:
48
+ needs: prebuild
49
+ name: Release
50
+ runs-on: ubuntu-latest
51
+ if: startsWith(github.ref, 'refs/tags/')
52
+ steps:
53
+ - uses: actions/checkout@v2
54
+ - uses: actions/download-artifact@v2
55
+ with:
56
+ path: artifacts
57
+ - uses: docker://antonyurchenko/git-release:v4
58
+ env:
59
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60
+ CHANGELOG_FILE: none
61
+ with:
62
+ args: artifacts/*/*.tar.gz
package/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "libusb"]
2
+ path = libusb
3
+ url = https://github.com/node-usb/libusb.git
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012 Nonolith Labs, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/Readme.md ADDED
@@ -0,0 +1,339 @@
1
+ USB Library for Node.JS
2
+ ===============================
3
+
4
+ [![Build Status](https://github.com/tessel/node-usb/workflows/prebuild/badge.svg)](https://github.com/tessel/node-usb/actions)
5
+
6
+ Node.JS library for communicating with USB devices in JavaScript / CoffeeScript.
7
+
8
+ This is a refactoring / rewrite of Christopher Klein's [node-usb](https://github.com/schakko/node-usb). The API is not compatible (hopefully you find it an improvement).
9
+
10
+ It's based entirely on libusb's asynchronous API for better efficiency, and provides a stream API for continuously streaming data or events.
11
+
12
+ Installation
13
+ ============
14
+
15
+ Libusb is included as a submodule. On Linux, you'll need libudev to build libusb. On Ubuntu/Debian: `sudo apt-get install build-essential libudev-dev`
16
+
17
+ Then, just run
18
+
19
+ npm install usb
20
+
21
+ to install from npm. See the bottom of this page for instructions for building from a git checkout.
22
+
23
+ ### Windows
24
+ 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.
25
+
26
+
27
+ API
28
+ ===
29
+
30
+ var usb = require('usb')
31
+
32
+ usb
33
+ ---
34
+
35
+ Top-level object.
36
+
37
+ ### usb.getDeviceList()
38
+ Return a list of `Device` objects for the USB devices attached to the system.
39
+
40
+ ### usb.findByIds(vid, pid)
41
+ Convenience method to get the first device with the specified VID and PID, or `undefined` if no such device is present.
42
+
43
+ ### usb.LIBUSB_*
44
+ Constant properties from libusb
45
+
46
+ ### usb.setDebugLevel(level : int)
47
+ Set the libusb debug level (between 0 and 4)
48
+
49
+ Device
50
+ ------
51
+
52
+ Represents a USB device.
53
+
54
+ ### .busNumber
55
+ Integer USB device number
56
+
57
+ ### .deviceAddress
58
+ Integer USB device address
59
+
60
+ ### .portNumbers
61
+ Array containing the USB device port numbers, or `undefined` if not supported on this platform.
62
+
63
+ ### .deviceDescriptor
64
+ Object with properties for the fields of the device descriptor:
65
+
66
+ - bLength
67
+ - bDescriptorType
68
+ - bcdUSB
69
+ - bDeviceClass
70
+ - bDeviceSubClass
71
+ - bDeviceProtocol
72
+ - bMaxPacketSize0
73
+ - idVendor
74
+ - idProduct
75
+ - bcdDevice
76
+ - iManufacturer
77
+ - iProduct
78
+ - iSerialNumber
79
+ - bNumConfigurations
80
+
81
+ ### .configDescriptor
82
+ Object with properties for the fields of the configuration descriptor:
83
+
84
+ - bLength
85
+ - bDescriptorType
86
+ - wTotalLength
87
+ - bNumInterfaces
88
+ - bConfigurationValue
89
+ - iConfiguration
90
+ - bmAttributes
91
+ - bMaxPower
92
+ - extra (Buffer containing any extra data or additional descriptors)
93
+
94
+ ### .allConfigDescriptors
95
+ Contains all config descriptors of the device (same structure as .configDescriptor above)
96
+
97
+ ### .parent
98
+ Contains the parent of the device, such as a hub. If there is no parent this property is set to `null`.
99
+
100
+ ### .open()
101
+
102
+ Open the device. All methods below require the device to be open before use.
103
+
104
+ ### .close()
105
+
106
+ Close the device.
107
+
108
+ ### .controlTransfer(bmRequestType, bRequest, wValue, wIndex, data_or_length, callback(error, data))
109
+
110
+ Perform a control transfer with `libusb_control_transfer`.
111
+
112
+ 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.
113
+
114
+ The `data` parameter of the callback is always undefined for OUT transfers, or will be passed a Buffer for IN transfers.
115
+
116
+ A [package is available to calculate bmRequestType](https://www.npmjs.com/package/bmrequesttype) if needed.
117
+
118
+ ### .setConfiguration(id, callback(error))
119
+ 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.
120
+
121
+ ### .getStringDescriptor(index, callback(error, data))
122
+ Perform a control transfer to retrieve a string descriptor
123
+
124
+ ### .getBosDescriptor(callback(error, bosDescriptor))
125
+ Perform a control transfer to retrieve an object with properties for the fields of the Binary Object Store descriptor:
126
+
127
+ - bLength
128
+ - bDescriptorType
129
+ - wTotalLength
130
+ - bNumDeviceCaps
131
+
132
+ ### .getCapabilities(callback(error, capabilities))
133
+ Retrieve a list of Capability objects for the Binary Object Store capabilities of the device.
134
+
135
+ ### .interface(interface)
136
+ Return the interface with the specified interface number.
137
+
138
+ ### .interfaces
139
+ List of Interface objects for the interfaces of the default configuration of the device.
140
+
141
+ ### .timeout
142
+ Timeout in milliseconds to use for control transfers.
143
+
144
+ ### .reset(callback(error))
145
+ Performs a reset of the device. Callback is called when complete.
146
+
147
+
148
+ Interface
149
+ ---------
150
+
151
+ ### .endpoint(address)
152
+ Return the InEndpoint or OutEndpoint with the specified address.
153
+
154
+ ### .endpoints
155
+ List of endpoints on this interface: InEndpoint and OutEndpoint objects.
156
+
157
+ ### .interface
158
+ Integer interface number.
159
+
160
+ ### .altSetting
161
+ Integer alternate setting number.
162
+
163
+ ### .setAltSetting(altSetting, callback(error))
164
+ Sets the alternate setting. It updates the `interface.endpoints` array to reflect the endpoints found in the alternate setting.
165
+
166
+ ### .claim()
167
+ Claims the interface. This method must be called before using any endpoints of this interface.
168
+
169
+ ### .release([closeEndpoints], callback(error))
170
+ Releases the interface and resets the alternate setting. Calls callback when complete.
171
+
172
+ 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.
173
+
174
+ ### .isKernelDriverActive()
175
+ Returns `false` if a kernel driver is not active; `true` if active.
176
+
177
+ ### .detachKernelDriver()
178
+ Detaches the kernel driver from the interface.
179
+
180
+ ### .attachKernelDriver()
181
+ Re-attaches the kernel driver for the interface.
182
+
183
+ ### .descriptor
184
+ Object with fields from the interface descriptor -- see libusb documentation or USB spec.
185
+
186
+ - bLength
187
+ - bDescriptorType
188
+ - bInterfaceNumber
189
+ - bAlternateSetting
190
+ - bNumEndpoints
191
+ - bInterfaceClass
192
+ - bInterfaceSubClass
193
+ - bInterfaceProtocol
194
+ - iInterface
195
+ - extra (Buffer containing any extra data or additional descriptors)
196
+
197
+
198
+ Capability
199
+ ---------
200
+
201
+ ### .type
202
+ Integer capability type.
203
+
204
+ ### .data
205
+ Buffer capability data.
206
+
207
+ ### .descriptor
208
+ Object with fields from the capability descriptor -- see libusb documentation or USB spec.
209
+ - bLength
210
+ - bDescriptorType
211
+ - bDevCapabilityType
212
+
213
+
214
+ Endpoint
215
+ --------
216
+
217
+ Common base for InEndpoint and OutEndpoint, see below.
218
+
219
+ ### .direction
220
+ Endpoint direction: `"in"` or `"out"`.
221
+
222
+ ### .transferType
223
+ Endpoint type: `usb.LIBUSB_TRANSFER_TYPE_BULK`, `usb.LIBUSB_TRANSFER_TYPE_INTERRUPT`, or `usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS`.
224
+
225
+ ### .descriptor
226
+ Object with fields from the endpoint descriptor -- see libusb documentation or USB spec.
227
+
228
+ - bLength
229
+ - bDescriptorType
230
+ - bEndpointAddress
231
+ - bmAttributes
232
+ - wMaxPacketSize
233
+ - bInterval
234
+ - bRefresh
235
+ - bSynchAddress
236
+ - extra (Buffer containing any extra data or additional descriptors)
237
+
238
+ ### .timeout
239
+ Sets the timeout in milliseconds for transfers on this endpoint. The default, `0`, is infinite timeout.
240
+
241
+ ### .clearHalt(callback(error))
242
+ Clear the halt/stall condition for this endpoint.
243
+
244
+ InEndpoint
245
+ ----------
246
+
247
+ Endpoints in the IN direction (device->PC) have this type.
248
+
249
+ ### .transfer(length, callback(error, data))
250
+ Perform a transfer to read data from the endpoint.
251
+
252
+ 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.
253
+
254
+ `this` in the callback is the InEndpoint object.
255
+
256
+ ### .startPoll(nTransfers=3, transferSize=maxPacketSize)
257
+ Start polling the endpoint.
258
+
259
+ The library will keep `nTransfers` transfers of size `transferSize` pending in
260
+ the kernel at all times to ensure continuous data flow. This is handled by the
261
+ libusb event thread, so it continues even if the Node v8 thread is busy. The
262
+ `data` and `error` events are emitted as transfers complete.
263
+
264
+ ### .stopPoll(cb)
265
+ Stop polling.
266
+
267
+ Further data may still be received. The `end` event is emitted and the callback
268
+ is called once all transfers have completed or canceled.
269
+
270
+ ### Event: data(data : Buffer)
271
+ Emitted with data received by the polling transfers
272
+
273
+ ### Event: error(error)
274
+ 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.
275
+
276
+ ### Event: end
277
+ Emitted when polling has been canceled
278
+
279
+ OutEndpoint
280
+ -----------
281
+
282
+ Endpoints in the OUT direction (PC->device) have this type.
283
+
284
+ ### .transfer(data, callback(error))
285
+ Perform a transfer to write `data` to the endpoint.
286
+
287
+ 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.
288
+
289
+ `this` in the callback is the OutEndpoint object.
290
+
291
+ ### Event: error(error)
292
+ Emitted when the stream encounters an error.
293
+
294
+ ### Event: end
295
+ Emitted when the stream has been stopped and all pending requests have been completed.
296
+
297
+
298
+ UsbDetection
299
+ ------------
300
+
301
+ ### usb.on('attach', function(device) { ... });
302
+ Attaches a callback to plugging in a `device`.
303
+
304
+ ### usb.on('detach', function(device) { ... });
305
+ Attaches a callback to unplugging a `device`.
306
+
307
+
308
+ Development and testing
309
+ =======================
310
+
311
+ To build from git:
312
+
313
+ git clone --recursive https://github.com/tessel/node-usb.git
314
+ cd node-usb
315
+ npm install
316
+
317
+ To execute the unit tests, [CoffeeScript](http://coffeescript.org) is required. Run
318
+
319
+ npm test
320
+
321
+ Some tests require an [attached STM32F103 Microprocessor USB device with specific firmware](https://github.com/thegecko/node-usb-test-firmware).
322
+
323
+ npm run --silent full-test
324
+ npm run --silent valgrind
325
+
326
+ Limitations
327
+ ===========
328
+
329
+ Does not support:
330
+
331
+ - Configurations other than the default one
332
+ - Isochronous transfers
333
+
334
+ License
335
+ =======
336
+
337
+ MIT
338
+
339
+ Note that the compiled Node extension includes Libusb, and is thus subject to the LGPL.
package/binding.gyp ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ 'variables': {
3
+ 'use_udev%': 1,
4
+ 'use_system_libusb%': 'false',
5
+ },
6
+ 'targets': [
7
+ {
8
+ 'target_name': 'usb_bindings',
9
+ 'cflags!': [ '-fno-exceptions' ],
10
+ 'cflags_cc!': [ '-fno-exceptions' ],
11
+ 'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
12
+ 'CLANG_CXX_LIBRARY': 'libc++',
13
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7',
14
+ },
15
+ 'msvs_settings': {
16
+ 'VCCLCompilerTool': { 'ExceptionHandling': 1 },
17
+ },
18
+ 'sources': [
19
+ './src/node_usb.cc',
20
+ './src/device.cc',
21
+ './src/transfer.cc',
22
+ ],
23
+ 'cflags_cc': [
24
+ '-std=c++14'
25
+ ],
26
+ 'defines': [
27
+ '_FILE_OFFSET_BITS=64',
28
+ '_LARGEFILE_SOURCE',
29
+ 'NAPI_VERSION=<(napi_build_version)',
30
+ ],
31
+ 'include_dirs+': [
32
+ 'src/',
33
+ "<!@(node -p \"require('node-addon-api').include\")"
34
+ ],
35
+
36
+ 'conditions' : [
37
+ ['use_system_libusb=="false" and OS!="freebsd"', {
38
+ 'dependencies': [
39
+ 'libusb.gypi:libusb',
40
+ ],
41
+ }],
42
+ ['use_system_libusb=="true" or OS=="freebsd"', {
43
+ 'include_dirs+': [
44
+ '<!@(pkg-config libusb-1.0 --cflags-only-I | sed s/-I//g)'
45
+ ],
46
+ 'libraries': [
47
+ '<!@(pkg-config libusb-1.0 --libs)'
48
+ ],
49
+ }],
50
+ ['OS=="mac"', {
51
+ 'xcode_settings': {
52
+ 'OTHER_CFLAGS': [ '-std=c++1y', '-stdlib=libc++' ],
53
+ 'OTHER_LDFLAGS': [ '-framework', 'CoreFoundation', '-framework', 'IOKit' ],
54
+ 'SDKROOT': 'macosx',
55
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7',
56
+ },
57
+ }],
58
+ ['OS=="win"', {
59
+ 'defines':[
60
+ 'WIN32_LEAN_AND_MEAN'
61
+ ],
62
+ 'default_configuration': 'Debug',
63
+ 'configurations': {
64
+ 'Debug': {
65
+ 'defines': [ 'DEBUG', '_DEBUG' ],
66
+ 'msvs_settings': {
67
+ 'VCCLCompilerTool': {
68
+ 'RuntimeLibrary': 1, # static debug
69
+ },
70
+ },
71
+ },
72
+ 'Release': {
73
+ 'defines': [ 'NDEBUG' ],
74
+ 'msvs_settings': {
75
+ 'VCCLCompilerTool': {
76
+ 'RuntimeLibrary': 0, # static release
77
+ },
78
+ },
79
+ }
80
+ },
81
+ 'msvs_settings': {
82
+ 'VCCLCompilerTool': {
83
+ 'AdditionalOptions': [ '/EHsc' ],
84
+ },
85
+ },
86
+ }]
87
+ ]
88
+ },
89
+ ]
90
+ }
@@ -0,0 +1,11 @@
1
+ *.sh eol=lf
2
+ *.ac eol=lf
3
+ *.am eol=lf
4
+ *.dsw eol=crlf
5
+ *.dsp eol=crlf whitespace=space-before-tab
6
+ *.sln eol=crlf
7
+ *.vcproj eol=crlf
8
+ *.vcxproj* eol=crlf
9
+ .gitattributes export-ignore
10
+ .gitignore export-ignore
11
+ INSTALL_WIN.txt eol=crlf
@@ -0,0 +1,5 @@
1
+ This directory contains private internal scripts used by the libusb
2
+ project maintainers.
3
+
4
+ These scripts are not intended for general usage and will not be
5
+ exported when producing release archives.
@@ -0,0 +1,89 @@
1
+ @echo off
2
+ rem produce the DDK binary files for snapshots
3
+ rem !!!THIS SCRIPT IS FOR INTERNAL DEVELOPER USE ONLY!!!
4
+
5
+ if NOT x%DDK_TARGET_OS%==xWinXP goto usage
6
+
7
+ set IWD=%~dp0
8
+ cd ..
9
+ mkdir E:\dailies\%DATE%
10
+ for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A
11
+ for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A\static
12
+ for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A\dll
13
+ for %%A in (source bin32 bin64) do mkdir E:\dailies\%DATE%\examples\%%A
14
+ copy examples\listdevs.c E:\dailies\%DATE%\examples\source
15
+ copy examples\xusb.c E:\dailies\%DATE%\examples\source
16
+ copy examples\ezusb.? E:\dailies\%DATE%\examples\source
17
+ copy examples\fxload.c E:\dailies\%DATE%\examples\source
18
+ copy msvc\stdint.h E:\dailies\%DATE%\examples\source
19
+ copy .private\wbs.txt E:\dailies\%DATE%\README.txt
20
+
21
+ set ORG_BUILD_ALT_DIR=%BUILD_ALT_DIR%
22
+ set ORG_BUILDARCH=%_BUILDARCH%
23
+ set ORG_PATH=%PATH%
24
+ set ORG_BUILD_DEFAULT_TARGETS=%BUILD_DEFAULT_TARGETS%
25
+
26
+ set 386=1
27
+ set AMD64=
28
+ set BUILD_DEFAULT_TARGETS=-386
29
+ set _AMD64bit=
30
+ set _BUILDARCH=x86
31
+ set PATH=%BASEDIR%\bin\x86;%BASEDIR%\bin\x86\x86
32
+
33
+ cd msvc
34
+ call ddk_build
35
+ cd ..
36
+
37
+ @echo off
38
+ copy Win32\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS32\static
39
+ copy Win32\Release\examples\listdevs.exe E:\dailies\%DATE%\examples\bin32
40
+ copy Win32\Release\examples\xusb.exe E:\dailies\%DATE%\examples\bin32
41
+ copy Win32\Release\examples\fxload.exe E:\dailies\%DATE%\examples\bin32
42
+
43
+ cd msvc
44
+ call ddk_build DLL
45
+ cd ..
46
+
47
+ @echo off
48
+ copy Win32\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS32\dll
49
+ copy Win32\Release\dll\libusb-1.0.dll E:\dailies\%DATE%\MS32\dll
50
+ copy Win32\Release\dll\libusb-1.0.pdb E:\dailies\%DATE%\MS32\dll
51
+
52
+ set 386=
53
+ set AMD64=1
54
+ set BUILD_DEFAULT_TARGETS=-amd64
55
+ set _AMD64bit=true
56
+ set _BUILDARCH=AMD64
57
+ set PATH=%BASEDIR%\bin\x86\amd64;%BASEDIR%\bin\x86
58
+
59
+ cd msvc
60
+ call ddk_build
61
+ cd ..
62
+
63
+ @echo off
64
+ copy x64\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS64\static
65
+ copy x64\Release\examples\listdevs.exe E:\dailies\%DATE%\examples\bin64
66
+ copy x64\Release\examples\xusb.exe E:\dailies\%DATE%\examples\bin64
67
+ copy x64\Release\examples\fxload.exe E:\dailies\%DATE%\examples\bin64
68
+
69
+ cd msvc
70
+ call ddk_build DLL
71
+ cd ..
72
+
73
+ @echo off
74
+ copy x64\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS64\dll
75
+ copy x64\Release\dll\libusb-1.0.dll E:\dailies\%DATE%\MS64\dll
76
+ copy x64\Release\dll\libusb-1.0.pdb E:\dailies\%DATE%\MS64\dll
77
+
78
+ set BUILD_ALT_DIR=%ORG_BUILD_ALT_DIR%
79
+ set _BUILDARCH=%ORG_BUILDARCH%
80
+ set PATH=%ORG_PATH%
81
+ set BUILD_DEFAULT_TARGETS=%ORG_BUILD_DEFAULT_TARGETS%
82
+
83
+ goto done
84
+
85
+ :usage
86
+ echo must be run in a WXP build environment!
87
+
88
+ :done
89
+ cd %IWD%
@@ -0,0 +1,54 @@
1
+ #!/bin/sh
2
+ # produce the MinGW binary files for snapshots
3
+ # !!!THIS SCRIPT IS FOR INTERNAL DEVELOPER USE ONLY!!!
4
+
5
+ PWD=`pwd`
6
+ cd ..
7
+ date=`date +%Y.%m.%d`
8
+ target=e:/dailies/$date
9
+ mkdir -p $target/include/libusb-1.0
10
+ cp -v libusb/libusb-1.0.def $target
11
+ cp -v libusb/libusb.h $target/include/libusb-1.0
12
+
13
+ #
14
+ # 32 bit binaries
15
+ #
16
+ target=e:/dailies/$date/MinGW32
17
+ git clean -fdx
18
+ # Not using debug (-g) in CFLAGS DRAMATICALLY reduces the size of the binaries
19
+ export CFLAGS="-O2 -m32"
20
+ export LDFLAGS="-m32"
21
+ export RCFLAGS="--target=pe-i386"
22
+ export DLLTOOLFLAGS="-m i386 -f --32"
23
+ echo `pwd`
24
+ (glibtoolize --version) < /dev/null > /dev/null 2>&1 && LIBTOOLIZE=glibtoolize || LIBTOOLIZE=libtoolize
25
+ $LIBTOOLIZE --copy --force || exit 1
26
+ aclocal || exit 1
27
+ autoheader || exit 1
28
+ autoconf || exit 1
29
+ automake -a -c || exit 1
30
+ ./configure
31
+ make -j2
32
+ mkdir -p $target/static
33
+ mkdir -p $target/dll
34
+ cp -v libusb/.libs/libusb-1.0.a $target/static
35
+ cp -v libusb/.libs/libusb-1.0.dll $target/dll
36
+ cp -v libusb/.libs/libusb-1.0.dll.a $target/dll
37
+ make clean -j2
38
+
39
+ #
40
+ # 64 bit binaries
41
+ #
42
+ target=e:/dailies/$date/MinGW64
43
+ export CFLAGS="-O2"
44
+ export LDFLAGS=""
45
+ export RCFLAGS=""
46
+ export DLLTOOLFLAGS=""
47
+ ./configure
48
+ make -j2
49
+ mkdir -p $target/static
50
+ mkdir -p $target/dll
51
+ cp -v libusb/.libs/libusb-1.0.a $target/static
52
+ cp -v libusb/.libs/libusb-1.0.dll $target/dll
53
+ cp -v libusb/.libs/libusb-1.0.dll.a $target/dll
54
+ cd $PWD