usb 2.15.0 → 2.17.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 +13 -0
- package/README.md +1 -1
- package/dist/usb/endpoint.js +1 -1
- package/dist/usb/endpoint.js.map +1 -1
- package/dist/webusb/index.d.ts +1 -1
- package/dist/webusb/index.js +1 -1
- package/dist/webusb/index.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +4 -4
- package/dist/webusb/webusb-device.js +8 -3
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.clang-tidy +34 -0
- package/libusb/AUTHORS +7 -0
- package/libusb/ChangeLog +14 -0
- package/libusb/KEYS +123 -0
- package/libusb/README +0 -4
- package/libusb/Xcode/common.xcconfig +20 -0
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +12 -12
- package/libusb/android/examples/unrooted_android.c +1 -0
- package/libusb/configure.ac +2 -2
- package/libusb/examples/dpfp.c +1 -1
- package/libusb/examples/ezusb.c +6 -1
- package/libusb/examples/fxload.c +7 -5
- package/libusb/examples/testlibusb.c +1 -0
- package/libusb/examples/xusb.c +136 -76
- package/libusb/libusb/core.c +8 -10
- package/libusb/libusb/descriptor.c +253 -94
- package/libusb/libusb/hotplug.c +27 -8
- package/libusb/libusb/io.c +3 -2
- package/libusb/libusb/libusb-1.0.def +4 -0
- package/libusb/libusb/libusb.h +121 -11
- package/libusb/libusb/libusbi.h +12 -0
- package/libusb/libusb/os/darwin_usb.c +93 -47
- package/libusb/libusb/os/emscripten_webusb.cpp +7 -2
- package/libusb/libusb/os/events_posix.c +4 -4
- package/libusb/libusb/os/linux_usbfs.c +20 -9
- package/libusb/libusb/os/linux_usbfs.h +13 -3
- package/libusb/libusb/os/netbsd_usb.c +4 -4
- package/libusb/libusb/os/openbsd_usb.c +2 -2
- package/libusb/libusb/os/sunos_usb.c +5 -5
- package/libusb/libusb/os/threads_posix.c +17 -16
- package/libusb/libusb/os/threads_posix.h +1 -1
- package/libusb/libusb/os/threads_windows.h +2 -2
- package/libusb/libusb/os/windows_winusb.c +35 -15
- package/libusb/libusb/sync.c +8 -5
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/tests/macos.c +2 -2
- package/libusb/tests/stress_mt.c +4 -2
- package/package.json +4 -4
- 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/test/webusb.coffee +2 -2
|
@@ -182,7 +182,7 @@ static int dev_has_config0(struct libusb_device *dev)
|
|
|
182
182
|
return 0;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
static int get_usbfs_fd(struct libusb_device *dev,
|
|
185
|
+
static int get_usbfs_fd(struct libusb_device *dev, int access_mode, int silent)
|
|
186
186
|
{
|
|
187
187
|
struct libusb_context *ctx = DEVICE_CTX(dev);
|
|
188
188
|
char path[24];
|
|
@@ -195,7 +195,7 @@ static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
|
|
|
195
195
|
snprintf(path, sizeof(path), USB_DEVTMPFS_PATH "/%03u/%03u",
|
|
196
196
|
dev->bus_number, dev->device_address);
|
|
197
197
|
|
|
198
|
-
fd = open(path,
|
|
198
|
+
fd = open(path, access_mode | O_CLOEXEC);
|
|
199
199
|
if (fd != -1)
|
|
200
200
|
return fd; /* Success */
|
|
201
201
|
|
|
@@ -209,14 +209,14 @@ static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
|
|
|
209
209
|
/* Wait 10ms for USB device path creation.*/
|
|
210
210
|
nanosleep(&delay_ts, NULL);
|
|
211
211
|
|
|
212
|
-
fd = open(path,
|
|
212
|
+
fd = open(path, access_mode | O_CLOEXEC);
|
|
213
213
|
if (fd != -1)
|
|
214
214
|
return fd; /* Success */
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
if (!silent) {
|
|
218
218
|
usbi_err(ctx, "libusb couldn't open USB device %s, errno=%d", path, errno);
|
|
219
|
-
if (errno == EACCES &&
|
|
219
|
+
if (errno == EACCES && access_mode == O_RDWR)
|
|
220
220
|
usbi_err(ctx, "libusb requires write access to USB device nodes");
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -541,7 +541,7 @@ static int read_sysfs_attr(struct libusb_context *ctx,
|
|
|
541
541
|
|
|
542
542
|
errno = 0;
|
|
543
543
|
value = strtol(buf, &endptr, 10);
|
|
544
|
-
if (value < 0 || value > (long)max_value || errno) {
|
|
544
|
+
if (buf == endptr || value < 0 || value > (long)max_value || errno) {
|
|
545
545
|
usbi_err(ctx, "attribute %s contains an invalid value: '%s'", attr, buf);
|
|
546
546
|
return LIBUSB_ERROR_INVALID_PARAM;
|
|
547
547
|
} else if (*endptr != '\0') {
|
|
@@ -933,6 +933,7 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
|
|
|
933
933
|
case 480: dev->speed = LIBUSB_SPEED_HIGH; break;
|
|
934
934
|
case 5000: dev->speed = LIBUSB_SPEED_SUPER; break;
|
|
935
935
|
case 10000: dev->speed = LIBUSB_SPEED_SUPER_PLUS; break;
|
|
936
|
+
case 20000: dev->speed = LIBUSB_SPEED_SUPER_PLUS_X2; break;
|
|
936
937
|
default:
|
|
937
938
|
usbi_warn(ctx, "unknown device speed: %d Mbps", speed);
|
|
938
939
|
}
|
|
@@ -1032,7 +1033,7 @@ static int linux_get_parent_info(struct libusb_device *dev, const char *sysfs_di
|
|
|
1032
1033
|
{
|
|
1033
1034
|
struct libusb_context *ctx = DEVICE_CTX(dev);
|
|
1034
1035
|
struct libusb_device *it;
|
|
1035
|
-
char *parent_sysfs_dir, *tmp;
|
|
1036
|
+
char *parent_sysfs_dir, *tmp, *end;
|
|
1036
1037
|
int ret, add_parent = 1;
|
|
1037
1038
|
|
|
1038
1039
|
/* XXX -- can we figure out the topology when using usbfs? */
|
|
@@ -1047,7 +1048,16 @@ static int linux_get_parent_info(struct libusb_device *dev, const char *sysfs_di
|
|
|
1047
1048
|
|
|
1048
1049
|
if ((tmp = strrchr(parent_sysfs_dir, '.')) ||
|
|
1049
1050
|
(tmp = strrchr(parent_sysfs_dir, '-'))) {
|
|
1050
|
-
|
|
1051
|
+
const char *start = tmp + 1;
|
|
1052
|
+
long port_number = strtol(start, &end, 10);
|
|
1053
|
+
if (port_number < 0 || port_number > INT_MAX || start == end || '\0' != *end) {
|
|
1054
|
+
usbi_warn(ctx, "Can not parse sysfs_dir: %s, unexpected parent info",
|
|
1055
|
+
parent_sysfs_dir);
|
|
1056
|
+
free(parent_sysfs_dir);
|
|
1057
|
+
return LIBUSB_ERROR_OTHER;
|
|
1058
|
+
} else {
|
|
1059
|
+
dev->port_number = (int)port_number;
|
|
1060
|
+
}
|
|
1051
1061
|
*tmp = '\0';
|
|
1052
1062
|
} else {
|
|
1053
1063
|
usbi_warn(ctx, "Can not parse sysfs_dir: %s, no parent info",
|
|
@@ -1627,8 +1637,9 @@ out:
|
|
|
1627
1637
|
return ret;
|
|
1628
1638
|
}
|
|
1629
1639
|
|
|
1630
|
-
static int do_streams_ioctl(struct libusb_device_handle *handle,
|
|
1631
|
-
uint32_t num_streams, unsigned char *endpoints,
|
|
1640
|
+
static int do_streams_ioctl(struct libusb_device_handle *handle,
|
|
1641
|
+
unsigned long req, uint32_t num_streams, unsigned char *endpoints,
|
|
1642
|
+
int num_endpoints)
|
|
1632
1643
|
{
|
|
1633
1644
|
struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
|
|
1634
1645
|
int r, fd = hpriv->fd;
|
|
@@ -174,7 +174,17 @@ static inline int linux_start_event_monitor(void)
|
|
|
174
174
|
{
|
|
175
175
|
#if defined(HAVE_LIBUDEV)
|
|
176
176
|
return linux_udev_start_event_monitor();
|
|
177
|
-
|
|
177
|
+
/*
|
|
178
|
+
* __ANDROID__: preprocessor macro defined automatically by GCC for all Android
|
|
179
|
+
* targets (i.e. both Android native applications, and Android OS-level
|
|
180
|
+
* services)
|
|
181
|
+
*
|
|
182
|
+
* ANDROID_OS: compilation flag that should be set for using libusb from programs
|
|
183
|
+
* running on Android at OS level (e.g. Android platform services).
|
|
184
|
+
* The programs using libusb built with the ANDROID_OS flag must have
|
|
185
|
+
* permission to access netlink sockets.
|
|
186
|
+
*/
|
|
187
|
+
#elif !defined(__ANDROID__) || defined(ANDROID_OS)
|
|
178
188
|
return linux_netlink_start_event_monitor();
|
|
179
189
|
#else
|
|
180
190
|
return LIBUSB_SUCCESS;
|
|
@@ -185,7 +195,7 @@ static inline void linux_stop_event_monitor(void)
|
|
|
185
195
|
{
|
|
186
196
|
#if defined(HAVE_LIBUDEV)
|
|
187
197
|
linux_udev_stop_event_monitor();
|
|
188
|
-
#elif !defined(__ANDROID__)
|
|
198
|
+
#elif !defined(__ANDROID__) || defined(ANDROID_OS)
|
|
189
199
|
linux_netlink_stop_event_monitor();
|
|
190
200
|
#endif
|
|
191
201
|
}
|
|
@@ -194,7 +204,7 @@ static inline void linux_hotplug_poll(void)
|
|
|
194
204
|
{
|
|
195
205
|
#if defined(HAVE_LIBUDEV)
|
|
196
206
|
linux_udev_hotplug_poll();
|
|
197
|
-
#elif !defined(__ANDROID__)
|
|
207
|
+
#elif !defined(__ANDROID__) || defined(ANDROID_OS)
|
|
198
208
|
linux_netlink_hotplug_poll();
|
|
199
209
|
#endif
|
|
200
210
|
}
|
|
@@ -444,6 +444,8 @@ netbsd_handle_transfer_completion(struct usbi_transfer *itransfer)
|
|
|
444
444
|
int
|
|
445
445
|
_errno_to_libusb(int err)
|
|
446
446
|
{
|
|
447
|
+
usbi_dbg(NULL, "error: %s (%d)", strerror(err), err);
|
|
448
|
+
|
|
447
449
|
switch (err) {
|
|
448
450
|
case EIO:
|
|
449
451
|
return LIBUSB_ERROR_IO;
|
|
@@ -456,11 +458,9 @@ _errno_to_libusb(int err)
|
|
|
456
458
|
case EWOULDBLOCK:
|
|
457
459
|
case ETIMEDOUT:
|
|
458
460
|
return LIBUSB_ERROR_TIMEOUT;
|
|
461
|
+
default:
|
|
462
|
+
return LIBUSB_ERROR_OTHER;
|
|
459
463
|
}
|
|
460
|
-
|
|
461
|
-
usbi_dbg(NULL, "error: %s (%d)", strerror(err), err);
|
|
462
|
-
|
|
463
|
-
return LIBUSB_ERROR_OTHER;
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
int
|
|
@@ -86,7 +86,7 @@ static int sunos_get_link(di_devlink_t devlink, void *arg)
|
|
|
86
86
|
const char *p;
|
|
87
87
|
const char *q;
|
|
88
88
|
|
|
89
|
-
if (
|
|
89
|
+
if (link_arg->path) {
|
|
90
90
|
char *content = (char *)di_devlink_content(devlink);
|
|
91
91
|
char *start = strstr(content, "/devices/");
|
|
92
92
|
start += strlen("/devices");
|
|
@@ -94,8 +94,8 @@ static int sunos_get_link(di_devlink_t devlink, void *arg)
|
|
|
94
94
|
|
|
95
95
|
/* line content must have minor node */
|
|
96
96
|
if (start == NULL ||
|
|
97
|
-
strncmp(start,
|
|
98
|
-
start[
|
|
97
|
+
strncmp(start, link_arg->path, link_arg->len) != 0 ||
|
|
98
|
+
start[link_arg->len] != ':')
|
|
99
99
|
return (DI_WALK_CONTINUE);
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -103,7 +103,7 @@ static int sunos_get_link(di_devlink_t devlink, void *arg)
|
|
|
103
103
|
q = strrchr(p, '/');
|
|
104
104
|
usbi_dbg(NULL, "%s", q);
|
|
105
105
|
|
|
106
|
-
*(
|
|
106
|
+
*(link_arg->linkpp) = strndup(p, strlen(p) - strlen(q));
|
|
107
107
|
|
|
108
108
|
return (DI_WALK_TERMINATE);
|
|
109
109
|
}
|
|
@@ -171,7 +171,7 @@ sunos_usb_ioctl(struct libusb_device *dev, int cmd)
|
|
|
171
171
|
|
|
172
172
|
nvlist_alloc(&nvlist, NV_UNIQUE_NAME_TYPE, KM_NOSLEEP);
|
|
173
173
|
nvlist_add_int32(nvlist, "port", dev->port_number);
|
|
174
|
-
|
|
174
|
+
/* find the hub path */
|
|
175
175
|
snprintf(path_arg, sizeof(path_arg), "/devices%s:hubd", hubpath);
|
|
176
176
|
usbi_dbg(DEVICE_CTX(dev), "ioctl hub path: %s", path_arg);
|
|
177
177
|
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
#include "libusbi.h"
|
|
23
23
|
|
|
24
24
|
#include <errno.h>
|
|
25
|
+
#include <limits.h>
|
|
25
26
|
#if defined(__ANDROID__)
|
|
26
27
|
# include <unistd.h>
|
|
27
28
|
#elif defined(__HAIKU__)
|
|
@@ -79,47 +80,47 @@ int usbi_cond_timedwait(pthread_cond_t *cond,
|
|
|
79
80
|
return LIBUSB_ERROR_OTHER;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
unsigned
|
|
83
|
+
unsigned long usbi_get_tid(void)
|
|
83
84
|
{
|
|
84
|
-
static _Thread_local unsigned
|
|
85
|
-
|
|
85
|
+
static _Thread_local unsigned long tl_tid;
|
|
86
|
+
unsigned long tid;
|
|
86
87
|
|
|
87
88
|
if (tl_tid)
|
|
88
89
|
return tl_tid;
|
|
89
90
|
|
|
90
91
|
#if defined(__ANDROID__)
|
|
91
|
-
tid = gettid();
|
|
92
|
+
tid = (unsigned long)gettid();
|
|
92
93
|
#elif defined(__APPLE__)
|
|
93
94
|
#ifdef HAVE_PTHREAD_THREADID_NP
|
|
94
95
|
uint64_t thread_id;
|
|
95
96
|
|
|
96
97
|
if (pthread_threadid_np(NULL, &thread_id) == 0)
|
|
97
|
-
tid = (
|
|
98
|
+
tid = (unsigned long)thread_id;
|
|
98
99
|
else
|
|
99
|
-
tid =
|
|
100
|
+
tid = ULONG_MAX;
|
|
100
101
|
#else
|
|
101
|
-
tid = (
|
|
102
|
+
tid = (unsigned long)pthread_mach_thread_np(pthread_self());
|
|
102
103
|
#endif
|
|
103
104
|
#elif defined(__HAIKU__)
|
|
104
|
-
tid = get_pthread_thread_id(pthread_self());
|
|
105
|
+
tid = (unsigned long)get_pthread_thread_id(pthread_self());
|
|
105
106
|
#elif defined(__linux__)
|
|
106
|
-
tid = (
|
|
107
|
+
tid = (unsigned long)syscall(SYS_gettid);
|
|
107
108
|
#elif defined(__NetBSD__)
|
|
108
|
-
tid = _lwp_self();
|
|
109
|
+
tid = (unsigned long)_lwp_self();
|
|
109
110
|
#elif defined(__OpenBSD__)
|
|
110
|
-
tid = getthrid();
|
|
111
|
+
tid = (unsigned long)getthrid();
|
|
111
112
|
#elif defined(__sun__)
|
|
112
|
-
tid = _lwp_self();
|
|
113
|
+
tid = (unsigned long)_lwp_self();
|
|
113
114
|
#else
|
|
114
|
-
tid =
|
|
115
|
+
tid = ULONG_MAX;
|
|
115
116
|
#endif
|
|
116
117
|
|
|
117
|
-
if (tid ==
|
|
118
|
+
if (tid == ULONG_MAX) {
|
|
118
119
|
/* If we don't have a thread ID, at least return a unique
|
|
119
120
|
* value that can be used to distinguish individual
|
|
120
121
|
* threads. */
|
|
121
|
-
tid = (
|
|
122
|
+
tid = (unsigned long)(uintptr_t)pthread_self();
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
return tl_tid =
|
|
125
|
+
return tl_tid = tid;
|
|
125
126
|
}
|
|
@@ -105,9 +105,9 @@ static inline void usbi_tls_key_delete(usbi_tls_key_t key)
|
|
|
105
105
|
WINAPI_CHECK(TlsFree(key));
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
static inline unsigned
|
|
108
|
+
static inline unsigned long usbi_get_tid(void)
|
|
109
109
|
{
|
|
110
|
-
return (unsigned
|
|
110
|
+
return (unsigned long)GetCurrentThreadId();
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
#endif /* LIBUSB_THREADS_WINDOWS_H */
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
#include <setupapi.h>
|
|
30
30
|
#include <ctype.h>
|
|
31
31
|
#include <stdio.h>
|
|
32
|
+
#include <stdlib.h>
|
|
32
33
|
|
|
33
34
|
#include "libusbi.h"
|
|
34
35
|
#include "windows_winusb.h"
|
|
@@ -1229,6 +1230,9 @@ static bool get_dev_port_number(HDEVINFO dev_info, SP_DEVINFO_DATA *dev_info_dat
|
|
|
1229
1230
|
{
|
|
1230
1231
|
char buffer[MAX_KEY_LENGTH];
|
|
1231
1232
|
DWORD size;
|
|
1233
|
+
const char *start = NULL;
|
|
1234
|
+
char *end = NULL;
|
|
1235
|
+
long long port;
|
|
1232
1236
|
|
|
1233
1237
|
// First try SPDRP_LOCATION_INFORMATION, which returns a REG_SZ. The string *may* have a format
|
|
1234
1238
|
// similar to "Port_#0002.Hub_#000D", in which case we can extract the port number. However, we
|
|
@@ -1237,7 +1241,15 @@ static bool get_dev_port_number(HDEVINFO dev_info, SP_DEVINFO_DATA *dev_info_dat
|
|
|
1237
1241
|
NULL, (PBYTE)buffer, sizeof(buffer), NULL)) {
|
|
1238
1242
|
// Check for the required format.
|
|
1239
1243
|
if (strncmp(buffer, "Port_#", 6) == 0) {
|
|
1240
|
-
|
|
1244
|
+
start = buffer + 6;
|
|
1245
|
+
// Note that 0 is both strtoll's sentinel return value to indicate failure, as well
|
|
1246
|
+
// as (obviously) the return value for the literal "0". Fortunately we can always treat
|
|
1247
|
+
// 0 as a failure, since Windows USB port numbers are numbered 1..n.
|
|
1248
|
+
port = strtoll(start, &end, 10);
|
|
1249
|
+
if (port <= 0 || port >= ULONG_MAX || end == start || (*end != '.' && *end != '\0')) {
|
|
1250
|
+
return false;
|
|
1251
|
+
}
|
|
1252
|
+
*port_nr = (DWORD)port;
|
|
1241
1253
|
return true;
|
|
1242
1254
|
}
|
|
1243
1255
|
}
|
|
@@ -1251,7 +1263,12 @@ static bool get_dev_port_number(HDEVINFO dev_info, SP_DEVINFO_DATA *dev_info_dat
|
|
|
1251
1263
|
// Find the last "#USB(x)" substring
|
|
1252
1264
|
for (char *token = strrchr(buffer, '#'); token != NULL; token = strrchr(buffer, '#')) {
|
|
1253
1265
|
if (strncmp(token, "#USB(", 5) == 0) {
|
|
1254
|
-
|
|
1266
|
+
start = token + 5;
|
|
1267
|
+
port = strtoll(start, &end, 10);
|
|
1268
|
+
if (port <= 0 || port >= ULONG_MAX || end == start || (*end != ')' && *end != '\0')) {
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
*port_nr = (DWORD)port;
|
|
1255
1272
|
return true;
|
|
1256
1273
|
}
|
|
1257
1274
|
// Shorten the string and try again.
|
|
@@ -1492,7 +1509,7 @@ static int get_guid(struct libusb_context *ctx, char *dev_id, HDEVINFO *dev_info
|
|
|
1492
1509
|
// The GUID was read successfully
|
|
1493
1510
|
break;
|
|
1494
1511
|
} else if (s == ERROR_FILE_NOT_FOUND) {
|
|
1495
|
-
|
|
1512
|
+
usbi_dbg(ctx, "no DeviceInterfaceGUID registered for '%s'", dev_id);
|
|
1496
1513
|
err = LIBUSB_ERROR_ACCESS;
|
|
1497
1514
|
goto exit;
|
|
1498
1515
|
} else if (s == ERROR_MORE_DATA) {
|
|
@@ -1572,7 +1589,6 @@ static int get_guid(struct libusb_context *ctx, char *dev_id, HDEVINFO *dev_info
|
|
|
1572
1589
|
usbi_warn(ctx, "device '%s' has malformed DeviceInterfaceGUID string '%s', skipping", dev_id, guid);
|
|
1573
1590
|
free(*if_guid);
|
|
1574
1591
|
*if_guid = NULL;
|
|
1575
|
-
err = LIBUSB_ERROR_NO_MEM;
|
|
1576
1592
|
goto exit;
|
|
1577
1593
|
}
|
|
1578
1594
|
|
|
@@ -1767,7 +1783,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
|
|
|
1767
1783
|
}
|
|
1768
1784
|
// ...and to add the additional device interface GUIDs
|
|
1769
1785
|
r = get_guid(ctx, dev_id, dev_info, &dev_info_data, 0, &if_guid);
|
|
1770
|
-
if (r == LIBUSB_SUCCESS) {
|
|
1786
|
+
if (r == LIBUSB_SUCCESS && if_guid != NULL) {
|
|
1771
1787
|
// Check if we've already seen this GUID
|
|
1772
1788
|
for (j = EXT_PASS; j < nb_guids; j++) {
|
|
1773
1789
|
if (memcmp(guid_list[j], if_guid, sizeof(*if_guid)) == 0)
|
|
@@ -1796,7 +1812,9 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
|
|
|
1796
1812
|
} else if (r == LIBUSB_ERROR_NO_MEM) {
|
|
1797
1813
|
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
|
|
1798
1814
|
} else {
|
|
1799
|
-
|
|
1815
|
+
if (r != LIBUSB_SUCCESS) {
|
|
1816
|
+
usbi_warn(ctx, "unexpected error during getting DeviceInterfaceGUID for '%s'", dev_id);
|
|
1817
|
+
}
|
|
1800
1818
|
}
|
|
1801
1819
|
break;
|
|
1802
1820
|
case HID_PASS:
|
|
@@ -3498,24 +3516,26 @@ static int _hid_wcslen(WCHAR *str)
|
|
|
3498
3516
|
return i;
|
|
3499
3517
|
}
|
|
3500
3518
|
|
|
3501
|
-
static int _hid_get_device_descriptor(struct hid_device_priv *hid_priv, void *data, size_t *size)
|
|
3519
|
+
static int _hid_get_device_descriptor(struct libusb_device *dev, struct hid_device_priv *hid_priv, void *data, size_t *size)
|
|
3502
3520
|
{
|
|
3503
3521
|
struct libusb_device_descriptor d;
|
|
3504
3522
|
|
|
3523
|
+
/* Copy some values from the cached device descriptor
|
|
3524
|
+
* because we cannot get them through HID */
|
|
3505
3525
|
d.bLength = LIBUSB_DT_DEVICE_SIZE;
|
|
3506
3526
|
d.bDescriptorType = LIBUSB_DT_DEVICE;
|
|
3507
|
-
d.bcdUSB =
|
|
3508
|
-
d.bDeviceClass =
|
|
3509
|
-
d.bDeviceSubClass =
|
|
3510
|
-
d.bDeviceProtocol =
|
|
3511
|
-
d.bMaxPacketSize0 =
|
|
3527
|
+
d.bcdUSB = dev->device_descriptor.bcdUSB;
|
|
3528
|
+
d.bDeviceClass = dev->device_descriptor.bDeviceClass;
|
|
3529
|
+
d.bDeviceSubClass = dev->device_descriptor.bDeviceSubClass;
|
|
3530
|
+
d.bDeviceProtocol = dev->device_descriptor.bDeviceProtocol;
|
|
3531
|
+
d.bMaxPacketSize0 = dev->device_descriptor.bMaxPacketSize0;
|
|
3512
3532
|
d.idVendor = (uint16_t)hid_priv->vid;
|
|
3513
3533
|
d.idProduct = (uint16_t)hid_priv->pid;
|
|
3514
|
-
d.bcdDevice =
|
|
3534
|
+
d.bcdDevice = dev->device_descriptor.bcdDevice;
|
|
3515
3535
|
d.iManufacturer = hid_priv->string_index[0];
|
|
3516
3536
|
d.iProduct = hid_priv->string_index[1];
|
|
3517
3537
|
d.iSerialNumber = hid_priv->string_index[2];
|
|
3518
|
-
d.bNumConfigurations =
|
|
3538
|
+
d.bNumConfigurations = dev->device_descriptor.bNumConfigurations;
|
|
3519
3539
|
|
|
3520
3540
|
if (*size > LIBUSB_DT_DEVICE_SIZE)
|
|
3521
3541
|
*size = LIBUSB_DT_DEVICE_SIZE;
|
|
@@ -3743,7 +3763,7 @@ static int _hid_get_descriptor(struct libusb_device *dev, HANDLE hid_handle, int
|
|
|
3743
3763
|
switch (type) {
|
|
3744
3764
|
case LIBUSB_DT_DEVICE:
|
|
3745
3765
|
usbi_dbg(DEVICE_CTX(dev), "LIBUSB_DT_DEVICE");
|
|
3746
|
-
return _hid_get_device_descriptor(priv->hid, data, size);
|
|
3766
|
+
return _hid_get_device_descriptor(dev, priv->hid, data, size);
|
|
3747
3767
|
case LIBUSB_DT_CONFIG:
|
|
3748
3768
|
usbi_dbg(DEVICE_CTX(dev), "LIBUSB_DT_CONFIG");
|
|
3749
3769
|
if (!_index)
|
package/libusb/libusb/sync.c
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
#include "libusbi.h"
|
|
24
24
|
|
|
25
|
+
#include <assert.h>
|
|
25
26
|
#include <string.h>
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -139,7 +140,7 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
|
|
|
139
140
|
|
|
140
141
|
if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
|
|
141
142
|
memcpy(data, libusb_control_transfer_get_data(transfer),
|
|
142
|
-
transfer->actual_length);
|
|
143
|
+
(size_t)transfer->actual_length);
|
|
143
144
|
|
|
144
145
|
switch (transfer->status) {
|
|
145
146
|
case LIBUSB_TRANSFER_COMPLETED:
|
|
@@ -198,8 +199,10 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
|
|
|
198
199
|
|
|
199
200
|
sync_transfer_wait_for_completion(transfer);
|
|
200
201
|
|
|
201
|
-
if (transferred)
|
|
202
|
+
if (transferred) {
|
|
203
|
+
assert(transfer->actual_length >= 0);
|
|
202
204
|
*transferred = transfer->actual_length;
|
|
205
|
+
}
|
|
203
206
|
|
|
204
207
|
switch (transfer->status) {
|
|
205
208
|
case LIBUSB_TRANSFER_COMPLETED:
|
|
@@ -312,9 +315,9 @@ int API_EXPORTED libusb_bulk_transfer(libusb_device_handle *dev_handle,
|
|
|
312
315
|
* \param length for bulk writes, the number of bytes from data to be sent. for
|
|
313
316
|
* bulk reads, the maximum number of bytes to receive into the data buffer.
|
|
314
317
|
* \param transferred output location for the number of bytes actually
|
|
315
|
-
* transferred. Since version 1.0.21
|
|
316
|
-
* it is legal to pass a NULL
|
|
317
|
-
* information.
|
|
318
|
+
* transferred. Will never be negative. Since version 1.0.21
|
|
319
|
+
* (\ref LIBUSB_API_VERSION >= 0x01000105), it is legal to pass a NULL
|
|
320
|
+
* pointer if you do not wish to receive this information.
|
|
318
321
|
* \param timeout timeout (in milliseconds) that this function should wait
|
|
319
322
|
* before giving up due to no response being received. For an unlimited
|
|
320
323
|
* timeout, use value 0.
|
package/libusb/libusb/version.h
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#define LIBUSB_NANO
|
|
1
|
+
#define LIBUSB_NANO 11953
|
package/libusb/tests/macos.c
CHANGED
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
extern uint32_t libusb_testonly_fake_running_version;
|
|
74
|
-
extern
|
|
75
|
-
extern
|
|
74
|
+
extern uint32_t libusb_testonly_using_running_interface_version;
|
|
75
|
+
extern uint32_t libusb_testonly_using_running_device_version;
|
|
76
76
|
extern bool libusb_testonly_clear_running_version_cache;
|
|
77
77
|
|
|
78
78
|
static libusb_testlib_result test_macos_version_fallback(void) {
|
package/libusb/tests/stress_mt.c
CHANGED
|
@@ -114,7 +114,8 @@ static thread_return_t THREAD_CALL_TYPE init_and_exit(void * arg)
|
|
|
114
114
|
for (ti->iteration = 0; ti->iteration < ITERS && !ti->err; ti->iteration++) {
|
|
115
115
|
libusb_context *ctx = NULL;
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
ti->err = libusb_init_context(&ctx, /*options=*/NULL, /*num_options=*/0);
|
|
118
|
+
if (ti->err != 0) {
|
|
118
119
|
break;
|
|
119
120
|
}
|
|
120
121
|
if (ti->enumerate) {
|
|
@@ -127,7 +128,8 @@ static thread_return_t THREAD_CALL_TYPE init_and_exit(void * arg)
|
|
|
127
128
|
for (int i = 0; i < ti->devcount && ti->err == 0; i++) {
|
|
128
129
|
libusb_device *dev = devs[i];
|
|
129
130
|
struct libusb_device_descriptor desc;
|
|
130
|
-
|
|
131
|
+
ti->err = libusb_get_device_descriptor(dev, &desc);
|
|
132
|
+
if (ti->err != 0) {
|
|
131
133
|
break;
|
|
132
134
|
}
|
|
133
135
|
if (no_access[i]) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "usb",
|
|
3
3
|
"description": "Library to access USB devices",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.17.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=12.22.0 <13.0 || >=14.17.0"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"node-gyp-build": "^4.5.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/node": "^
|
|
60
|
+
"@types/node": "^25.0.3",
|
|
61
61
|
"@typescript-eslint/eslint-plugin": "^5.45.1",
|
|
62
62
|
"@typescript-eslint/parser": "^5.45.1",
|
|
63
63
|
"coffeescript": "^2.7.0",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"prebuildify": "^6.0.1",
|
|
68
68
|
"prebuildify-ci": "^1.0.5",
|
|
69
69
|
"prebuildify-cross": "^5.1.1",
|
|
70
|
-
"typedoc": "^0.
|
|
71
|
-
"typescript": "^5.
|
|
70
|
+
"typedoc": "^0.28.0",
|
|
71
|
+
"typescript": "^5.9.3"
|
|
72
72
|
},
|
|
73
73
|
"binary": {
|
|
74
74
|
"napi_versions": [
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/webusb.coffee
CHANGED
|
@@ -192,7 +192,7 @@ describe 'Transfers', ->
|
|
|
192
192
|
it 'should control transfer OUT', ->
|
|
193
193
|
transferResult = await device.controlTransferOut({
|
|
194
194
|
requestType: 'device',
|
|
195
|
-
recipient: 'vendor'
|
|
195
|
+
recipient: 'vendor',
|
|
196
196
|
request: 0x81,
|
|
197
197
|
value: 0,
|
|
198
198
|
index: 0
|
|
@@ -204,7 +204,7 @@ describe 'Transfers', ->
|
|
|
204
204
|
it 'should control transfer IN', ->
|
|
205
205
|
transferResult = await device.controlTransferIn({
|
|
206
206
|
requestType: 'device',
|
|
207
|
-
recipient: 'vendor'
|
|
207
|
+
recipient: 'vendor',
|
|
208
208
|
request: 0x81,
|
|
209
209
|
value: 0,
|
|
210
210
|
index: 0
|