usb 2.17.0 → 2.18.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 +6 -0
- package/README.md +14 -0
- package/binding.gyp +2 -9
- package/dist/usb/bindings.d.ts +27 -2
- package/dist/usb/bindings.js.map +1 -1
- package/dist/usb/index.d.ts +0 -29
- package/dist/usb/index.js +4 -18
- package/dist/usb/index.js.map +1 -1
- package/libusb/.clang-tidy +5 -3
- package/libusb/.private/ci-build.sh +5 -1
- package/libusb/AUTHORS +14 -0
- package/libusb/ChangeLog +15 -2
- package/libusb/README +8 -5
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +4 -0
- package/libusb/configure.ac +12 -2
- package/libusb/examples/hotplugtest.c +19 -11
- package/libusb/examples/listdevs.c +41 -3
- package/libusb/examples/xusb.c +6 -1
- package/libusb/libusb/Makefile.am +4 -0
- package/libusb/libusb/core.c +175 -14
- package/libusb/libusb/descriptor.c +163 -14
- package/libusb/libusb/io.c +7 -3
- package/libusb/libusb/libusb-1.0.def +10 -0
- package/libusb/libusb/libusb.h +59 -9
- package/libusb/libusb/libusbi.h +89 -25
- package/libusb/libusb/os/darwin_usb.c +126 -46
- package/libusb/libusb/os/darwin_usb.h +10 -8
- package/libusb/libusb/os/emscripten_webusb.cpp +31 -10
- package/libusb/libusb/os/haiku_usb_raw.cpp +4 -0
- package/libusb/libusb/os/linux_usbfs.c +73 -25
- package/libusb/libusb/os/netbsd_usb.c +2 -0
- package/libusb/libusb/os/openbsd_usb.c +2 -0
- package/libusb/libusb/os/sunos_usb.c +2 -0
- package/libusb/libusb/os/threads_posix.c +3 -3
- package/libusb/libusb/os/threads_posix.h +8 -2
- package/libusb/libusb/os/threads_windows.h +2 -1
- package/libusb/libusb/os/windows_common.c +86 -1
- package/libusb/libusb/os/windows_common.h +20 -1
- package/libusb/libusb/os/windows_hotplug.c +321 -0
- package/libusb/libusb/os/windows_hotplug.h +28 -0
- package/libusb/libusb/os/windows_usbdk.c +16 -8
- package/libusb/libusb/os/windows_winusb.c +753 -41
- package/libusb/libusb/os/windows_winusb.h +11 -6
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/msvc/Base.props +1 -1
- package/libusb/msvc/Configuration.Base.props +2 -1
- package/libusb/msvc/Configuration.DynamicLibrary.props +12 -0
- package/libusb/msvc/ProjectConfigurations.Base.props +69 -16
- package/libusb/msvc/build_all.ps1 +2 -2
- package/libusb/msvc/config.h +4 -0
- package/libusb/msvc/getopt/bits/getopt_core.h +96 -0
- package/libusb/msvc/getopt/bits/getopt_ext.h +77 -0
- package/libusb/msvc/getopt/features.h +21 -0
- package/libusb/msvc/getopt/getopt.c +456 -705
- package/libusb/msvc/getopt/getopt.h +16 -158
- package/libusb/msvc/getopt/getopt1.c +40 -69
- package/libusb/msvc/getopt/getopt_int.h +118 -0
- package/libusb/msvc/getopt/gettext.h +7 -0
- package/libusb/msvc/getopt/unistd.h +5 -0
- package/libusb/msvc/getopt.vcxproj +11 -4
- package/libusb/msvc/libusb.sln +515 -268
- package/libusb/msvc/libusb_dll.vcxproj +2 -0
- package/libusb/msvc/libusb_static.vcxproj +2 -0
- package/libusb/msvc/xusb.vcxproj +1 -1
- package/libusb/tests/Makefile.am +10 -1
- package/libusb/tests/fuzz/corpus/bos/min.bos +0 -0
- package/libusb/tests/fuzz/corpus/descriptor_parsers/min_valid_config.bin +0 -0
- package/libusb/tests/fuzz/corpus/descriptor_parsers/regression_bug_a_endpoint_null.bin +0 -0
- package/libusb/tests/fuzz/corpus/descriptor_parsers/regression_bug_b_iad_oob.bin +0 -0
- package/libusb/tests/fuzz/fuzz_bos_descriptor.c +49 -0
- package/libusb/tests/fuzz/fuzz_descriptor_parsers.c +83 -0
- package/libusb/tests/stress_mt.c +2 -1
- package/libusb/tests/webusb-test-shim/index.js +6 -5
- package/libusb.gypi +5 -0
- package/package.json +1 -1
- 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-arm64/node.napi.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/{hotplug/libusb.cc → hotplug.cc} +2 -3
- package/src/{hotplug/hotplug.h → hotplug.h} +2 -6
- package/src/node_usb.cc +3 -3
- package/test/usb.coffee +4 -4
- package/test/webusb.coffee +22 -12
- package/src/hotplug/windows.cc +0 -168
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.18.0] - 2026-06-06
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Updated libusb to v1.0.30 - [`950`](https://github.com/node-usb/node-usb/pull/950) ([Rob Moran](https://github.com/thegecko))
|
|
7
|
+
- Switched to using libusb hotplug support for Windows - [`953`](https://github.com/node-usb/node-usb/pull/953) ([Rob Moran](https://github.com/thegecko))
|
|
8
|
+
|
|
3
9
|
## [2.17.0] - 2026-01-18
|
|
4
10
|
|
|
5
11
|
### Changed
|
package/README.md
CHANGED
|
@@ -606,6 +606,20 @@ There is no direct equivalent to this. Instead you can listen to both `attach` a
|
|
|
606
606
|
# Development
|
|
607
607
|
The library is based on native bindings wrapping the [libusb](https://github.com/libusb/libusb) library.
|
|
608
608
|
|
|
609
|
+
## Prerequisites
|
|
610
|
+
|
|
611
|
+
A valid node-gyp build system
|
|
612
|
+
|
|
613
|
+
### Windows
|
|
614
|
+
|
|
615
|
+
- [chocolatey](https://chocolatey.org/)
|
|
616
|
+
|
|
617
|
+
```bash
|
|
618
|
+
choco install python visualstudio2019-workload-vctools -y
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
If the automatic installation of VS Tools fails or pauses, open the installer GUI to resume installation.
|
|
622
|
+
|
|
609
623
|
## Setup
|
|
610
624
|
Libusb is included as a submodule, clone this repository and then the submodule as follows:
|
|
611
625
|
|
package/binding.gyp
CHANGED
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
'src/node_usb.cc',
|
|
30
30
|
'src/device.cc',
|
|
31
31
|
'src/transfer.cc',
|
|
32
|
-
'src/thread_name.cc'
|
|
32
|
+
'src/thread_name.cc',
|
|
33
|
+
'src/hotplug.cc'
|
|
33
34
|
],
|
|
34
35
|
'cflags_cc': [
|
|
35
36
|
'-std=c++14'
|
|
@@ -76,15 +77,7 @@
|
|
|
76
77
|
'MACOSX_DEPLOYMENT_TARGET': '10.7'
|
|
77
78
|
}
|
|
78
79
|
}],
|
|
79
|
-
['OS!="win"', {
|
|
80
|
-
'sources': [
|
|
81
|
-
'src/hotplug/libusb.cc'
|
|
82
|
-
],
|
|
83
|
-
}],
|
|
84
80
|
['OS=="win"', {
|
|
85
|
-
'sources': [
|
|
86
|
-
'src/hotplug/windows.cc'
|
|
87
|
-
],
|
|
88
81
|
'defines':[
|
|
89
82
|
'WIN32_LEAN_AND_MEAN'
|
|
90
83
|
],
|
package/dist/usb/bindings.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DeviceDescriptor, ConfigDescriptor, BosDescriptor } from './descriptors';
|
|
2
|
+
import type { ExtendedDevice } from './device';
|
|
2
3
|
/**
|
|
3
4
|
* Return a list of `Device` objects for the USB devices attached to the system.
|
|
4
5
|
*/
|
|
@@ -24,7 +25,7 @@ export declare function setDebugLevel(level: number): void;
|
|
|
24
25
|
* Use USBDK Backend (Windows only)
|
|
25
26
|
*/
|
|
26
27
|
export declare function useUsbDkBackend(): void;
|
|
27
|
-
export declare function _supportedHotplugEvents():
|
|
28
|
+
export declare function _supportedHotplugEvents(): boolean;
|
|
28
29
|
export declare function _enableHotplugEvents(): void;
|
|
29
30
|
export declare function _disableHotplugEvents(): void;
|
|
30
31
|
export declare function _getLibusbCapability(capability: number): number;
|
|
@@ -53,7 +54,7 @@ export declare class Transfer {
|
|
|
53
54
|
cancel(): boolean;
|
|
54
55
|
}
|
|
55
56
|
/** Represents a USB device. */
|
|
56
|
-
export declare class Device {
|
|
57
|
+
export declare class Device extends ExtendedDevice {
|
|
57
58
|
/** Integer USB device number */
|
|
58
59
|
busNumber: number;
|
|
59
60
|
/** Integer USB device address */
|
|
@@ -264,3 +265,27 @@ export declare const LIBUSB_ERROR_NO_MEM: number;
|
|
|
264
265
|
export declare const LIBUSB_ERROR_NOT_SUPPORTED: number;
|
|
265
266
|
/** Other error */
|
|
266
267
|
export declare const LIBUSB_ERROR_OTHER: number;
|
|
268
|
+
export declare interface EventListeners<T> {
|
|
269
|
+
newListener: keyof T;
|
|
270
|
+
removeListener: keyof T;
|
|
271
|
+
}
|
|
272
|
+
export declare interface DeviceIds {
|
|
273
|
+
idVendor: number;
|
|
274
|
+
idProduct: number;
|
|
275
|
+
}
|
|
276
|
+
export declare interface DeviceEvents extends EventListeners<DeviceEvents> {
|
|
277
|
+
attach: Device;
|
|
278
|
+
detach: Device;
|
|
279
|
+
attachIds: DeviceIds;
|
|
280
|
+
detachIds: DeviceIds;
|
|
281
|
+
}
|
|
282
|
+
export declare function addListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
283
|
+
export declare function removeListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
284
|
+
export declare function on<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
285
|
+
export declare function off<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
286
|
+
export declare function once<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
287
|
+
export declare function listeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
|
288
|
+
export declare function rawListeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
|
289
|
+
export declare function removeAllListeners<K extends keyof DeviceEvents>(event?: K): void;
|
|
290
|
+
export declare function emit<K extends keyof DeviceEvents>(event: K, arg: DeviceEvents[K]): boolean;
|
|
291
|
+
export declare function listenerCount<K extends keyof DeviceEvents>(event: K): number;
|
package/dist/usb/bindings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../tsc/usb/bindings.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,mDAAmD;AACnD,2CAA2C;;AAE3C,+BAA4B;
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../tsc/usb/bindings.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,mDAAmD;AACnD,2CAA2C;;AAE3C,+BAA4B;AAI5B,uDAAuD;AACvD,MAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAChG,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC"}
|
package/dist/usb/index.d.ts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
import { ExtendedDevice } from './device';
|
|
2
1
|
import * as usb from './bindings';
|
|
3
|
-
interface EventListeners<T> {
|
|
4
|
-
newListener: keyof T;
|
|
5
|
-
removeListener: keyof T;
|
|
6
|
-
}
|
|
7
|
-
interface DeviceIds {
|
|
8
|
-
idVendor: number;
|
|
9
|
-
idProduct: number;
|
|
10
|
-
}
|
|
11
|
-
declare module './bindings' {
|
|
12
|
-
interface Device extends ExtendedDevice {
|
|
13
|
-
}
|
|
14
|
-
interface DeviceEvents extends EventListeners<DeviceEvents> {
|
|
15
|
-
attach: Device;
|
|
16
|
-
detach: Device;
|
|
17
|
-
attachIds: DeviceIds;
|
|
18
|
-
detachIds: DeviceIds;
|
|
19
|
-
}
|
|
20
|
-
function addListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
21
|
-
function removeListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
22
|
-
function on<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
23
|
-
function off<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
24
|
-
function once<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
25
|
-
function listeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
|
26
|
-
function rawListeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
|
27
|
-
function removeAllListeners<K extends keyof DeviceEvents>(event?: K): void;
|
|
28
|
-
function emit<K extends keyof DeviceEvents>(event: K, arg: DeviceEvents[K]): boolean;
|
|
29
|
-
function listenerCount<K extends keyof DeviceEvents>(event: K): number;
|
|
30
|
-
}
|
|
31
2
|
export = usb;
|
package/dist/usb/index.js
CHANGED
|
@@ -55,26 +55,17 @@ const pollHotplug = (start = false) => {
|
|
|
55
55
|
}
|
|
56
56
|
setTimeout(() => pollHotplug(), usb.pollHotplugDelay);
|
|
57
57
|
};
|
|
58
|
-
// Devices changed event handler
|
|
59
|
-
const devicesChanged = () => setTimeout(() => emitHotplugEvents(), usb.pollHotplugDelay);
|
|
60
58
|
// Hotplug control
|
|
61
|
-
let hotplugSupported =
|
|
59
|
+
let hotplugSupported = false;
|
|
62
60
|
const startHotplug = () => {
|
|
63
|
-
hotplugSupported = usb.pollHotplug ?
|
|
64
|
-
if (hotplugSupported !== 1) {
|
|
65
|
-
// Collect initial devices when not using libusb
|
|
66
|
-
hotPlugDevices = new Set(usb.getDeviceList());
|
|
67
|
-
}
|
|
61
|
+
hotplugSupported = usb.pollHotplug ? false : usb._supportedHotplugEvents();
|
|
68
62
|
if (hotplugSupported) {
|
|
69
63
|
// Use hotplug event emitters
|
|
70
64
|
usb._enableHotplugEvents();
|
|
71
|
-
if (hotplugSupported === 2) {
|
|
72
|
-
// Use hotplug ID events to trigger a change check
|
|
73
|
-
usb.on('attachIds', devicesChanged);
|
|
74
|
-
usb.on('detachIds', devicesChanged);
|
|
75
|
-
}
|
|
76
65
|
}
|
|
77
66
|
else {
|
|
67
|
+
// Collect initial devices
|
|
68
|
+
hotPlugDevices = new Set(usb.getDeviceList());
|
|
78
69
|
// Fallback to using polling to check for changes
|
|
79
70
|
pollHotplug(true);
|
|
80
71
|
}
|
|
@@ -83,11 +74,6 @@ const stopHotplug = () => {
|
|
|
83
74
|
if (hotplugSupported) {
|
|
84
75
|
// Disable hotplug events
|
|
85
76
|
usb._disableHotplugEvents();
|
|
86
|
-
if (hotplugSupported === 2) {
|
|
87
|
-
// Remove hotplug ID event listeners
|
|
88
|
-
usb.off('attachIds', devicesChanged);
|
|
89
|
-
usb.off('detachIds', devicesChanged);
|
|
90
|
-
}
|
|
91
77
|
}
|
|
92
78
|
else {
|
|
93
79
|
// Stop polling
|
package/dist/usb/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/usb/index.ts"],"names":[],"mappings":";AAAA,mCAAsC;AACtC,qCAA0C;AAC1C,kCAAkC;AAElC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;IACjB,+BAA+B;IAC/B,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC;A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AC;AACL,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,CAAC,EAAE;IAC7B,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO;IACX,CAAC;IACD,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChF,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACtB,WAAW,EAAE,CAAC;IAClB,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,iBAAS,GAAG,CAAC"}
|
package/libusb/.clang-tidy
CHANGED
|
@@ -6,6 +6,8 @@ bugprone-*,\
|
|
|
6
6
|
-bugprone-narrowing-conversions,\
|
|
7
7
|
-bugprone-signed-char-misuse,\
|
|
8
8
|
-bugprone-switch-missing-default-case,\
|
|
9
|
+
-bugprone-multi-level-implicit-pointer-conversion,\
|
|
10
|
+
-bugprone-branch-clone,\
|
|
9
11
|
clang-analyzer-*,\
|
|
10
12
|
-clang-analyzer-core.NullDereference,\
|
|
11
13
|
-clang-analyzer-deadcode.DeadStores,\
|
|
@@ -16,11 +18,11 @@ clang-analyzer-*,\
|
|
|
16
18
|
misc-*,\
|
|
17
19
|
-misc-no-recursion,\
|
|
18
20
|
-misc-include-cleaner,\
|
|
21
|
+
-misc-unused-parameters,\
|
|
19
22
|
modernize-*,\
|
|
20
23
|
-modernize-macro-to-enum,\
|
|
21
24
|
performance-*,\
|
|
22
25
|
-performance-no-int-to-ptr,\
|
|
23
|
-
-performance-type-promotion-in-math-fn,\
|
|
24
26
|
portability-*,\
|
|
25
27
|
readability-*,\
|
|
26
28
|
-readability-braces-around-statements,\
|
|
@@ -29,6 +31,6 @@ readability-*,\
|
|
|
29
31
|
-readability-function-cognitive-complexity,\
|
|
30
32
|
-readability-isolate-declaration,\
|
|
31
33
|
-readability-magic-numbers,\
|
|
34
|
+
-readability-non-const-parameter,\
|
|
35
|
+
-readability-use-concise-preprocessor-directives,\
|
|
32
36
|
"
|
|
33
|
-
#WarningsAsErrors: "*"
|
|
34
|
-
...
|
|
@@ -30,6 +30,10 @@ while [ $# -gt 0 ]; do
|
|
|
30
30
|
asan=no
|
|
31
31
|
shift
|
|
32
32
|
;;
|
|
33
|
+
--werror)
|
|
34
|
+
cflags+=" -Werror"
|
|
35
|
+
shift
|
|
36
|
+
;;
|
|
33
37
|
--)
|
|
34
38
|
shift
|
|
35
39
|
break;
|
|
@@ -53,7 +57,7 @@ fi
|
|
|
53
57
|
mkdir "${builddir}"
|
|
54
58
|
cd "${builddir}"
|
|
55
59
|
|
|
56
|
-
cflags
|
|
60
|
+
cflags+=" -O2"
|
|
57
61
|
|
|
58
62
|
# enable extra warnings
|
|
59
63
|
cflags+=" -Winline"
|
package/libusb/AUTHORS
CHANGED
|
@@ -15,6 +15,7 @@ Aaron Luft
|
|
|
15
15
|
Adam Korcz
|
|
16
16
|
Addison Crump
|
|
17
17
|
Adrian Bunk
|
|
18
|
+
Adrien Bertrand
|
|
18
19
|
Adrien Destugues
|
|
19
20
|
Akshay Jaggi
|
|
20
21
|
Alan Ott
|
|
@@ -24,6 +25,7 @@ Alexander Mot
|
|
|
24
25
|
Alexander Pyhalov
|
|
25
26
|
Alexander Schlarb
|
|
26
27
|
Alexander Stein
|
|
28
|
+
Alex Birkett
|
|
27
29
|
Alex Feinman
|
|
28
30
|
Alex Vatchenko
|
|
29
31
|
Andrew Aldridge
|
|
@@ -35,6 +37,7 @@ Angus Gratton
|
|
|
35
37
|
Anil Nair
|
|
36
38
|
Ankur Verma
|
|
37
39
|
Anthony Clay
|
|
40
|
+
Antoine Moreau
|
|
38
41
|
Antonio Ospite
|
|
39
42
|
Artem Egorkine
|
|
40
43
|
Aurelien Jarno
|
|
@@ -84,8 +87,10 @@ Graeme Gill
|
|
|
84
87
|
Greg Kroah-Hartman
|
|
85
88
|
Gustavo Zacarias
|
|
86
89
|
Haidong Zheng
|
|
90
|
+
Hannes Franke
|
|
87
91
|
Hans Ulrich Niedermann
|
|
88
92
|
Harry Mallon
|
|
93
|
+
Hartwig Wiesmann
|
|
89
94
|
Hector Martin
|
|
90
95
|
Hoi-Ho Chan
|
|
91
96
|
Ido Yariv
|
|
@@ -124,20 +129,24 @@ Lars Wirzenius
|
|
|
124
129
|
Lei Chen
|
|
125
130
|
Léo Lam
|
|
126
131
|
Liang Yunwang
|
|
132
|
+
Logan Gallois
|
|
127
133
|
Lonnie Abelbeck
|
|
128
134
|
Luca Longinotti
|
|
129
135
|
Luz Paz
|
|
136
|
+
Łukasz Bartosik
|
|
130
137
|
Mac Wang
|
|
131
138
|
Marco Trevisan (Treviño)
|
|
132
139
|
Marcus Meissner
|
|
133
140
|
Mario Kleiner
|
|
134
141
|
Mark Kuo
|
|
142
|
+
Mark Lee
|
|
135
143
|
Markus Heidelberg
|
|
136
144
|
Martin Ettl
|
|
137
145
|
Martin Koegler
|
|
138
146
|
Martin Ling
|
|
139
147
|
Martin Thierer
|
|
140
148
|
Mathias Hjärtström
|
|
149
|
+
Matt Liberty
|
|
141
150
|
Matthew Stapleton
|
|
142
151
|
Matthias Bolte
|
|
143
152
|
Matthijs Lavrijsen
|
|
@@ -151,7 +160,9 @@ Moritz Fischer
|
|
|
151
160
|
Nancy Li
|
|
152
161
|
Nia Alarie
|
|
153
162
|
Nicholas Corgan
|
|
163
|
+
Nicolas Bats
|
|
154
164
|
Niklas Gürtler
|
|
165
|
+
Ole André Vadla Ravnås
|
|
155
166
|
Oleksand Radovenchyk
|
|
156
167
|
Omri Iluz
|
|
157
168
|
Orhan aib Kavrakoglu
|
|
@@ -191,6 +202,7 @@ Steinar H. Gunderson
|
|
|
191
202
|
Stephen Groat
|
|
192
203
|
Sylvain Fasel
|
|
193
204
|
Theo Buehler
|
|
205
|
+
Theodor Engøy
|
|
194
206
|
Thomas Röfer
|
|
195
207
|
Tim Hutt
|
|
196
208
|
Tim Roberts
|
|
@@ -200,6 +212,7 @@ Tormod Volden
|
|
|
200
212
|
Trygve Laugstøl
|
|
201
213
|
Uri Lublin
|
|
202
214
|
Uwe Bonnes
|
|
215
|
+
Vadim Mikhailov
|
|
203
216
|
Vasily Khoruzhick
|
|
204
217
|
Vegard Storheil Eriksen
|
|
205
218
|
Venkatesh Shukla
|
|
@@ -208,6 +221,7 @@ Victor Toso
|
|
|
208
221
|
Vinicius Tinti
|
|
209
222
|
Vitali Lovich
|
|
210
223
|
Vladimir Beloborodov
|
|
224
|
+
Vladimir Gladkov
|
|
211
225
|
William Orr
|
|
212
226
|
William Skellenger
|
|
213
227
|
Xiaofan Chen
|
package/libusb/ChangeLog
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
For detailed information about the changes below, please see the git log
|
|
2
|
-
|
|
1
|
+
For detailed information about the changes below, please see the git log.
|
|
2
|
+
|
|
3
|
+
2026-05-17: v1.0.30
|
|
4
|
+
* Add hotplug support on Microsoft Windows
|
|
5
|
+
* Add RAW_IO support in WinUSB backend
|
|
6
|
+
* Work around a macOS 26 Tahoe compatibility breakage due to Apple changing kUSBHostPortPropertyPortNumber
|
|
7
|
+
* Add new API libusb_get_device_string() to access device strings without opening the device
|
|
8
|
+
* Add new API libusb_get_session_data() which returns the OS-specific handle
|
|
9
|
+
* Fix device removal races on non-hotplug builds
|
|
10
|
+
* Improve descriptor parsing memory safety
|
|
11
|
+
* On Darwin, fix concurrency issues
|
|
12
|
+
* On Android, fix intermittent failures in get_usbfs_fd()
|
|
13
|
+
* On Windows, fix bus number assignment for root hub device, preventing duplicate bus number assignments
|
|
14
|
+
* Fix compilation with Microsoft Visual Studio 2026
|
|
15
|
+
* Fix various compiler warnings, improved tests and examples
|
|
3
16
|
|
|
4
17
|
2025-06-01: v1.0.29
|
|
5
18
|
* Fix regression on macOS leading to timeouts in enumeration
|
package/libusb/README
CHANGED
|
@@ -20,10 +20,13 @@ http://api.libusb.info
|
|
|
20
20
|
Use the mailing list for questions, comments, etc:
|
|
21
21
|
http://mailing-list.libusb.info
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
- Nathan Hjelm
|
|
27
|
-
-
|
|
23
|
+
- Tormod Volden
|
|
24
|
+
- Sylvain Fasel
|
|
25
|
+
- Sean McBride
|
|
26
|
+
- Nathan Hjelm
|
|
27
|
+
- Xiaofan Chen
|
|
28
|
+
- Hans de Goede
|
|
29
|
+
- Ludovic Rousseau
|
|
30
|
+
- Chris Dickens
|
|
28
31
|
|
|
29
32
|
(Please use the mailing list rather than mailing developers directly)
|
|
@@ -272,6 +272,8 @@
|
|
|
272
272
|
1443EE8716417E63007E0579 /* libusb.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = libusb.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
|
|
273
273
|
1443EE8816417E63007E0579 /* release.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = release.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
|
|
274
274
|
1443EE8916417EA6007E0579 /* libusb_release.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = libusb_release.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
|
|
275
|
+
145F5D8D2E60B46B004ABA5D /* windows_hotplug.h */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = windows_hotplug.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
|
|
276
|
+
145F5D8E2E60B46B004ABA5D /* windows_hotplug.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = windows_hotplug.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
|
|
275
277
|
14EC13E12B3D5BA600CF9AD0 /* emscripten_webusb.cpp */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = emscripten_webusb.cpp; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
|
|
276
278
|
14EC13E22B3D5BBE00CF9AD0 /* sunos_usb.h */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = sunos_usb.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
|
|
277
279
|
14EC13E32B3D5BBE00CF9AD0 /* openbsd_usb.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = openbsd_usb.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
|
|
@@ -493,6 +495,8 @@
|
|
|
493
495
|
14EC13F72B3D5BC800CF9AD0 /* threads_windows.h */,
|
|
494
496
|
14EC13F52B3D5BC800CF9AD0 /* windows_common.c */,
|
|
495
497
|
14EC13F22B3D5BC800CF9AD0 /* windows_common.h */,
|
|
498
|
+
145F5D8D2E60B46B004ABA5D /* windows_hotplug.h */,
|
|
499
|
+
145F5D8E2E60B46B004ABA5D /* windows_hotplug.c */,
|
|
496
500
|
14EC13F92B3D5BC800CF9AD0 /* windows_usbdk.c */,
|
|
497
501
|
14EC13F82B3D5BC800CF9AD0 /* windows_usbdk.h */,
|
|
498
502
|
14EC13F42B3D5BC800CF9AD0 /* windows_winusb.c */,
|
package/libusb/configure.ac
CHANGED
|
@@ -31,9 +31,9 @@ dnl Library versioning
|
|
|
31
31
|
dnl These numbers should be tweaked on every release. Read carefully:
|
|
32
32
|
dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
|
33
33
|
dnl http://sourceware.org/autobook/autobook/autobook_91.html
|
|
34
|
-
lt_current=
|
|
34
|
+
lt_current=6
|
|
35
35
|
lt_revision=0
|
|
36
|
-
lt_age=
|
|
36
|
+
lt_age=6
|
|
37
37
|
LT_LDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age} -no-undefined"
|
|
38
38
|
|
|
39
39
|
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
|
@@ -397,10 +397,20 @@ AM_CONDITIONAL([OS_EMSCRIPTEN], [test "x$backend" = xemscripten])
|
|
|
397
397
|
AM_CONDITIONAL([PLATFORM_POSIX], [test "x$platform" = xposix])
|
|
398
398
|
AM_CONDITIONAL([PLATFORM_WINDOWS], [test "x$platform" = xwindows])
|
|
399
399
|
AM_CONDITIONAL([USE_UDEV], [test "x$use_udev" = xyes])
|
|
400
|
+
AM_CONDITIONAL([LIBUSB_WINDOWS_HOTPLUG], [test "x$enable_windows_hotplug" = xyes])
|
|
400
401
|
|
|
401
402
|
dnl The -Wcast-function-type warning causes a flurry of warnings when compiling
|
|
402
403
|
dnl Windows with GCC 8 or later because of dynamically loaded functions
|
|
403
404
|
if test "x$backend" = xwindows; then
|
|
405
|
+
AC_ARG_ENABLE([windows-hotplug],
|
|
406
|
+
AS_HELP_STRING([--enable-windows-hotplug], [Enable Windows hotplug support]),
|
|
407
|
+
[enable_windows_hotplug="$enableval"],
|
|
408
|
+
[enable_windows_hotplug=no])
|
|
409
|
+
|
|
410
|
+
if test "x$enable_windows_hotplug" = "xyes"; then
|
|
411
|
+
AC_DEFINE([LIBUSB_WINDOWS_HOTPLUG], [1], [Define to enable Windows hotplug support])
|
|
412
|
+
fi
|
|
413
|
+
|
|
404
414
|
saved_CFLAGS="${CFLAGS}"
|
|
405
415
|
CFLAGS="-Werror -Wcast-function-type"
|
|
406
416
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
|
|
@@ -23,12 +23,14 @@
|
|
|
23
23
|
|
|
24
24
|
#include "libusb.h"
|
|
25
25
|
|
|
26
|
-
int
|
|
26
|
+
int done_attach = 0;
|
|
27
|
+
int done_detach = 0;
|
|
27
28
|
libusb_device_handle *handle = NULL;
|
|
28
29
|
|
|
29
30
|
static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *user_data)
|
|
30
31
|
{
|
|
31
32
|
struct libusb_device_descriptor desc;
|
|
33
|
+
libusb_device_handle *new_handle;
|
|
32
34
|
int rc;
|
|
33
35
|
|
|
34
36
|
(void)ctx;
|
|
@@ -45,18 +47,23 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
|
|
|
45
47
|
libusb_strerror((enum libusb_error)rc));
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
handle
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
50
|
+
rc = libusb_open (dev, &new_handle);
|
|
51
|
+
if (LIBUSB_SUCCESS == rc) {
|
|
52
|
+
if (handle) {
|
|
53
|
+
libusb_close (handle);
|
|
54
|
+
}
|
|
55
|
+
handle = new_handle;
|
|
56
|
+
} else if (LIBUSB_ERROR_ACCESS != rc
|
|
57
|
+
#if defined(PLATFORM_WINDOWS)
|
|
58
|
+
&& LIBUSB_ERROR_NOT_SUPPORTED != rc
|
|
59
|
+
&& LIBUSB_ERROR_NOT_FOUND != rc
|
|
60
|
+
#endif
|
|
61
|
+
) {
|
|
55
62
|
fprintf (stderr, "No access to device: %s\n",
|
|
56
63
|
libusb_strerror((enum libusb_error)rc));
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
done_attach++;
|
|
60
67
|
|
|
61
68
|
return 0;
|
|
62
69
|
}
|
|
@@ -85,7 +92,7 @@ static int LIBUSB_CALL hotplug_callback_detach(libusb_context *ctx, libusb_devic
|
|
|
85
92
|
handle = NULL;
|
|
86
93
|
}
|
|
87
94
|
|
|
88
|
-
|
|
95
|
+
done_detach++;
|
|
89
96
|
|
|
90
97
|
return 0;
|
|
91
98
|
}
|
|
@@ -130,7 +137,7 @@ int main(int argc, char *argv[])
|
|
|
130
137
|
return EXIT_FAILURE;
|
|
131
138
|
}
|
|
132
139
|
|
|
133
|
-
while (
|
|
140
|
+
while (done_detach < done_attach || done_attach == 0) {
|
|
134
141
|
rc = libusb_handle_events (NULL);
|
|
135
142
|
if (LIBUSB_SUCCESS != rc)
|
|
136
143
|
printf ("libusb_handle_events() failed: %s\n",
|
|
@@ -138,6 +145,7 @@ int main(int argc, char *argv[])
|
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
if (handle) {
|
|
148
|
+
printf ("Warning: Closing left-over open handle\n");
|
|
141
149
|
libusb_close (handle);
|
|
142
150
|
}
|
|
143
151
|
|
|
@@ -18,14 +18,16 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
#include <stdio.h>
|
|
21
|
+
#include <string.h>
|
|
21
22
|
|
|
22
23
|
#include "libusb.h"
|
|
23
24
|
|
|
24
|
-
static void print_devs(libusb_device **devs)
|
|
25
|
+
static void print_devs(libusb_device **devs, int verbose)
|
|
25
26
|
{
|
|
26
27
|
libusb_device *dev;
|
|
27
28
|
int i = 0, j = 0;
|
|
28
29
|
uint8_t path[8];
|
|
30
|
+
char string_buffer[LIBUSB_DEVICE_STRING_BYTES_MAX];
|
|
29
31
|
|
|
30
32
|
while ((dev = devs[i++]) != NULL) {
|
|
31
33
|
struct libusb_device_descriptor desc;
|
|
@@ -45,16 +47,52 @@ static void print_devs(libusb_device **devs)
|
|
|
45
47
|
for (j = 1; j < r; j++)
|
|
46
48
|
printf(".%d", path[j]);
|
|
47
49
|
}
|
|
50
|
+
|
|
51
|
+
if (verbose) {
|
|
52
|
+
r = libusb_get_device_string(dev, LIBUSB_DEVICE_STRING_MANUFACTURER,
|
|
53
|
+
string_buffer, sizeof(string_buffer));
|
|
54
|
+
if (r >= 0) {
|
|
55
|
+
printf("\n manufacturer = %s", string_buffer);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
r = libusb_get_device_string(dev, LIBUSB_DEVICE_STRING_PRODUCT,
|
|
59
|
+
string_buffer, sizeof(string_buffer));
|
|
60
|
+
if (r >= 0) {
|
|
61
|
+
printf("\n product = %s", string_buffer);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
r = libusb_get_device_string(dev, LIBUSB_DEVICE_STRING_SERIAL_NUMBER,
|
|
65
|
+
string_buffer, sizeof(string_buffer));
|
|
66
|
+
if (r >= 0) {
|
|
67
|
+
printf("\n serial_number = %s", string_buffer);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
48
70
|
printf("\n");
|
|
49
71
|
}
|
|
50
72
|
}
|
|
51
73
|
|
|
52
|
-
int
|
|
74
|
+
static int usage(void) {
|
|
75
|
+
printf("usage: listdevs [--verbose]\n");
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
int main(int argc, char *argv[])
|
|
53
80
|
{
|
|
81
|
+
int verbose = 0;
|
|
54
82
|
libusb_device **devs;
|
|
55
83
|
int r;
|
|
56
84
|
ssize_t cnt;
|
|
57
85
|
|
|
86
|
+
--argc; ++argv; /* consume argument */
|
|
87
|
+
while (argc) {
|
|
88
|
+
if ((0 == strcmp("-v", argv[0])) || (0 == strcmp("--verbose", argv[0]))) {
|
|
89
|
+
++verbose;
|
|
90
|
+
--argc; ++argv; /* consume argument */
|
|
91
|
+
} else {
|
|
92
|
+
return usage();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
58
96
|
r = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
|
|
59
97
|
if (r < 0)
|
|
60
98
|
return r;
|
|
@@ -65,7 +103,7 @@ int main(void)
|
|
|
65
103
|
return (int) cnt;
|
|
66
104
|
}
|
|
67
105
|
|
|
68
|
-
print_devs(devs);
|
|
106
|
+
print_devs(devs, verbose);
|
|
69
107
|
libusb_free_device_list(devs, 1);
|
|
70
108
|
|
|
71
109
|
libusb_exit(NULL);
|
package/libusb/examples/xusb.c
CHANGED
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
#if defined(_MSC_VER)
|
|
32
32
|
#define snprintf _snprintf
|
|
33
33
|
#define putenv _putenv
|
|
34
|
+
/* Disable: warning C5287: operands are different enum types */
|
|
35
|
+
#if (_MSC_VER > 1800)
|
|
36
|
+
/* Disable: warning C5287: operands are different enum types, supported after Visual Studio 2013 */
|
|
37
|
+
#pragma warning(disable:5287)
|
|
38
|
+
#endif
|
|
34
39
|
#endif
|
|
35
40
|
|
|
36
41
|
// Future versions of libusb will use usb_interface instead of interface
|
|
@@ -498,7 +503,7 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in,
|
|
|
498
503
|
for (i=0; i<8; i++) {
|
|
499
504
|
vid[i] = buffer[8+i];
|
|
500
505
|
pid[i] = buffer[16+i];
|
|
501
|
-
rev[i/2] = buffer[32+i/2]; // instead of another loop
|
|
506
|
+
rev[i/2] = buffer[32+(i/2)]; // instead of another loop
|
|
502
507
|
}
|
|
503
508
|
vid[8] = 0;
|
|
504
509
|
pid[8] = 0;
|
|
@@ -30,6 +30,10 @@ OS_WINDOWS_SRC = libusb-1.0.def libusb-1.0.rc \
|
|
|
30
30
|
os/windows_usbdk.h os/windows_usbdk.c \
|
|
31
31
|
os/windows_winusb.h os/windows_winusb.c
|
|
32
32
|
|
|
33
|
+
if LIBUSB_WINDOWS_HOTPLUG
|
|
34
|
+
OS_WINDOWS_SRC += os/windows_hotplug.h os/windows_hotplug.c
|
|
35
|
+
endif
|
|
36
|
+
|
|
33
37
|
if OS_DARWIN
|
|
34
38
|
OS_SRC = $(OS_DARWIN_SRC)
|
|
35
39
|
endif
|