usb 2.16.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 +14 -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/endpoint.js +1 -1
- package/dist/usb/endpoint.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/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 +5 -2
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.clang-tidy +36 -0
- package/libusb/.private/ci-build.sh +5 -1
- package/libusb/AUTHORS +21 -0
- package/libusb/ChangeLog +29 -2
- package/libusb/KEYS +123 -0
- package/libusb/README +8 -9
- package/libusb/Xcode/common.xcconfig +20 -0
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +16 -12
- package/libusb/android/examples/unrooted_android.c +1 -0
- package/libusb/configure.ac +12 -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/hotplugtest.c +19 -11
- package/libusb/examples/listdevs.c +41 -3
- package/libusb/examples/testlibusb.c +1 -0
- package/libusb/examples/xusb.c +142 -77
- package/libusb/libusb/Makefile.am +4 -0
- package/libusb/libusb/core.c +183 -24
- package/libusb/libusb/descriptor.c +404 -96
- package/libusb/libusb/hotplug.c +27 -8
- package/libusb/libusb/io.c +10 -5
- package/libusb/libusb/libusb-1.0.def +14 -0
- package/libusb/libusb/libusb.h +179 -19
- package/libusb/libusb/libusbi.h +101 -25
- package/libusb/libusb/os/darwin_usb.c +216 -90
- package/libusb/libusb/os/darwin_usb.h +10 -8
- package/libusb/libusb/os/emscripten_webusb.cpp +38 -12
- package/libusb/libusb/os/events_posix.c +4 -4
- package/libusb/libusb/os/haiku_usb_raw.cpp +4 -0
- package/libusb/libusb/os/linux_usbfs.c +92 -33
- package/libusb/libusb/os/linux_usbfs.h +13 -3
- package/libusb/libusb/os/netbsd_usb.c +6 -4
- package/libusb/libusb/os/openbsd_usb.c +4 -2
- package/libusb/libusb/os/sunos_usb.c +7 -5
- package/libusb/libusb/os/threads_posix.c +20 -19
- package/libusb/libusb/os/threads_posix.h +9 -3
- package/libusb/libusb/os/threads_windows.h +4 -3
- 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 +788 -56
- package/libusb/libusb/os/windows_winusb.h +11 -6
- package/libusb/libusb/sync.c +8 -5
- 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/macos.c +2 -2
- package/libusb/tests/stress_mt.c +6 -3
- package/libusb/tests/webusb-test-shim/index.js +6 -5
- package/libusb.gypi +5 -0
- package/package.json +3 -3
- 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/libusb/libusb/core.c
CHANGED
|
@@ -92,7 +92,7 @@ struct list_head active_contexts_list;
|
|
|
92
92
|
*
|
|
93
93
|
* \section gettingstarted Getting Started
|
|
94
94
|
*
|
|
95
|
-
* To begin reading the API documentation, start with the
|
|
95
|
+
* To begin reading the API documentation, start with the Topics page which
|
|
96
96
|
* links to the different categories of libusb's functionality.
|
|
97
97
|
*
|
|
98
98
|
* One decision you will have to make is whether to use the synchronous
|
|
@@ -382,6 +382,8 @@ if (cfg != desired)
|
|
|
382
382
|
* - libusb_detach_kernel_driver()
|
|
383
383
|
* - libusb_dev_mem_alloc()
|
|
384
384
|
* - libusb_dev_mem_free()
|
|
385
|
+
* - libusb_endpoint_set_raw_io()
|
|
386
|
+
* - libusb_endpoint_supports_raw_io()
|
|
385
387
|
* - libusb_error_name()
|
|
386
388
|
* - libusb_event_handler_active()
|
|
387
389
|
* - libusb_event_handling_ok()
|
|
@@ -404,6 +406,7 @@ if (cfg != desired)
|
|
|
404
406
|
* - libusb_free_usb_2_0_extension_descriptor()
|
|
405
407
|
* - libusb_get_active_config_descriptor()
|
|
406
408
|
* - libusb_get_bos_descriptor()
|
|
409
|
+
* - libusb_get_session_data()
|
|
407
410
|
* - libusb_get_bus_number()
|
|
408
411
|
* - libusb_get_config_descriptor()
|
|
409
412
|
* - libusb_get_config_descriptor_by_value()
|
|
@@ -415,10 +418,12 @@ if (cfg != desired)
|
|
|
415
418
|
* - libusb_get_device_descriptor()
|
|
416
419
|
* - libusb_get_device_list()
|
|
417
420
|
* - libusb_get_device_speed()
|
|
421
|
+
* - libusb_get_device_string()
|
|
418
422
|
* - libusb_get_iso_packet_buffer()
|
|
419
423
|
* - libusb_get_iso_packet_buffer_simple()
|
|
420
424
|
* - libusb_get_max_alt_packet_size()
|
|
421
425
|
* - libusb_get_max_iso_packet_size()
|
|
426
|
+
* - libusb_get_max_raw_io_transfer_size()
|
|
422
427
|
* - libusb_get_max_packet_size()
|
|
423
428
|
* - libusb_get_next_timeout()
|
|
424
429
|
* - libusb_get_parent()
|
|
@@ -499,6 +504,7 @@ if (cfg != desired)
|
|
|
499
504
|
* - \ref libusb_capability
|
|
500
505
|
* - \ref libusb_class_code
|
|
501
506
|
* - \ref libusb_descriptor_type
|
|
507
|
+
* - \ref libusb_device_string_type
|
|
502
508
|
* - \ref libusb_endpoint_direction
|
|
503
509
|
* - \ref libusb_endpoint_transfer_type
|
|
504
510
|
* - \ref libusb_error
|
|
@@ -722,26 +728,33 @@ struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
|
|
|
722
728
|
dev->session_data = session_id;
|
|
723
729
|
dev->speed = LIBUSB_SPEED_UNKNOWN;
|
|
724
730
|
|
|
725
|
-
|
|
726
|
-
|
|
731
|
+
/* Note: the device is NOT added to ctx->usb_devs here. The caller
|
|
732
|
+
* (backend) must call usbi_connect_device() after fully initializing
|
|
733
|
+
* the device's private data. This prevents a concurrent
|
|
734
|
+
* usbi_get_device_by_session_id() from finding a half-initialized
|
|
735
|
+
* device. */
|
|
727
736
|
|
|
728
737
|
return dev;
|
|
729
738
|
}
|
|
730
739
|
|
|
731
|
-
void
|
|
740
|
+
void usbi_attach_device(struct libusb_device *dev)
|
|
732
741
|
{
|
|
733
742
|
struct libusb_context *ctx = DEVICE_CTX(dev);
|
|
734
743
|
|
|
735
744
|
usbi_atomic_store(&dev->attached, 1);
|
|
736
745
|
|
|
737
|
-
usbi_mutex_lock(&
|
|
738
|
-
list_add(&dev->list, &
|
|
739
|
-
usbi_mutex_unlock(&
|
|
746
|
+
usbi_mutex_lock(&ctx->usb_devs_lock);
|
|
747
|
+
list_add(&dev->list, &ctx->usb_devs);
|
|
748
|
+
usbi_mutex_unlock(&ctx->usb_devs_lock);
|
|
749
|
+
}
|
|
740
750
|
|
|
741
|
-
|
|
751
|
+
void usbi_connect_device(struct libusb_device *dev)
|
|
752
|
+
{
|
|
753
|
+
usbi_attach_device(dev);
|
|
754
|
+
usbi_hotplug_notification(DEVICE_CTX(dev), dev, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED);
|
|
742
755
|
}
|
|
743
756
|
|
|
744
|
-
void
|
|
757
|
+
void usbi_detach_device(struct libusb_device *dev)
|
|
745
758
|
{
|
|
746
759
|
struct libusb_context *ctx = DEVICE_CTX(dev);
|
|
747
760
|
|
|
@@ -750,8 +763,12 @@ void usbi_disconnect_device(struct libusb_device *dev)
|
|
|
750
763
|
usbi_mutex_lock(&ctx->usb_devs_lock);
|
|
751
764
|
list_del(&dev->list);
|
|
752
765
|
usbi_mutex_unlock(&ctx->usb_devs_lock);
|
|
766
|
+
}
|
|
753
767
|
|
|
754
|
-
|
|
768
|
+
void usbi_disconnect_device(struct libusb_device *dev)
|
|
769
|
+
{
|
|
770
|
+
usbi_detach_device(dev);
|
|
771
|
+
usbi_hotplug_notification(DEVICE_CTX(dev), dev, LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT);
|
|
755
772
|
}
|
|
756
773
|
|
|
757
774
|
/* Perform some final sanity checks on a newly discovered device. If this
|
|
@@ -905,6 +922,26 @@ void API_EXPORTED libusb_free_device_list(libusb_device **list,
|
|
|
905
922
|
free(list);
|
|
906
923
|
}
|
|
907
924
|
|
|
925
|
+
/** \ingroup libusb_dev
|
|
926
|
+
* Returns the backend-specific identifier of the underlying system device tree
|
|
927
|
+
* node. Can be used to find the corresponding system device and directly query
|
|
928
|
+
* it (or access it otherwise) when and if necessary.
|
|
929
|
+
*
|
|
930
|
+
* Relevant backends:
|
|
931
|
+
* - Darwin: IOKit `sessionID`
|
|
932
|
+
* - Windows WinUSB: `DEVINST`
|
|
933
|
+
* - Linux, BSD: `busnum << 8 | devnum`
|
|
934
|
+
*
|
|
935
|
+
* Since version 1.0.30, \ref LIBUSB_API_VERSION >= 0x0100010C
|
|
936
|
+
*
|
|
937
|
+
* \param dev a device (must not be null)
|
|
938
|
+
* \returns the backend-specific device identifier
|
|
939
|
+
*/
|
|
940
|
+
unsigned long API_EXPORTED libusb_get_session_data(libusb_device *dev)
|
|
941
|
+
{
|
|
942
|
+
return dev->session_data;
|
|
943
|
+
}
|
|
944
|
+
|
|
908
945
|
/** \ingroup libusb_dev
|
|
909
946
|
* Get the number of the bus that a device is connected to.
|
|
910
947
|
* \param dev a device
|
|
@@ -954,7 +991,7 @@ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
|
|
|
954
991
|
if (port_numbers_len <= 0)
|
|
955
992
|
return LIBUSB_ERROR_INVALID_PARAM;
|
|
956
993
|
|
|
957
|
-
|
|
994
|
+
/* HCDs can be listed as devices with port #0 */
|
|
958
995
|
while((dev) && (dev->port_number != 0)) {
|
|
959
996
|
if (--i < 0) {
|
|
960
997
|
usbi_warn(ctx, "port numbers array is too small");
|
|
@@ -964,7 +1001,7 @@ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
|
|
|
964
1001
|
dev = dev->parent_dev;
|
|
965
1002
|
}
|
|
966
1003
|
if (i < port_numbers_len)
|
|
967
|
-
memmove(port_numbers, &port_numbers[i], port_numbers_len - i);
|
|
1004
|
+
memmove(port_numbers, &port_numbers[i], (size_t)(port_numbers_len - i));
|
|
968
1005
|
return port_numbers_len - i;
|
|
969
1006
|
}
|
|
970
1007
|
|
|
@@ -1014,7 +1051,7 @@ uint8_t API_EXPORTED libusb_get_device_address(libusb_device *dev)
|
|
|
1014
1051
|
*/
|
|
1015
1052
|
int API_EXPORTED libusb_get_device_speed(libusb_device *dev)
|
|
1016
1053
|
{
|
|
1017
|
-
return dev->speed;
|
|
1054
|
+
return (int)(dev->speed);
|
|
1018
1055
|
}
|
|
1019
1056
|
|
|
1020
1057
|
static const struct libusb_endpoint_descriptor *find_endpoint(
|
|
@@ -1276,6 +1313,7 @@ libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev)
|
|
|
1276
1313
|
|
|
1277
1314
|
refcnt = usbi_atomic_inc(&dev->refcnt);
|
|
1278
1315
|
assert(refcnt >= 2);
|
|
1316
|
+
UNUSED(refcnt);
|
|
1279
1317
|
|
|
1280
1318
|
return dev;
|
|
1281
1319
|
}
|
|
@@ -1292,8 +1330,27 @@ void API_EXPORTED libusb_unref_device(libusb_device *dev)
|
|
|
1292
1330
|
if (!dev)
|
|
1293
1331
|
return;
|
|
1294
1332
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1333
|
+
if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
|
|
1334
|
+
/* Non-hotplug path: the decrement and conditional list removal
|
|
1335
|
+
* must be atomic with respect to usbi_get_device_by_session_id(),
|
|
1336
|
+
* which searches the list and refs the device under the same lock.
|
|
1337
|
+
* Without this, a concurrent search could find a device whose
|
|
1338
|
+
* refcnt has already reached zero and hit the assert in
|
|
1339
|
+
* libusb_ref_device(). */
|
|
1340
|
+
struct libusb_context *ctx = DEVICE_CTX(dev);
|
|
1341
|
+
|
|
1342
|
+
usbi_mutex_lock(&ctx->usb_devs_lock);
|
|
1343
|
+
refcnt = usbi_atomic_dec(&dev->refcnt);
|
|
1344
|
+
assert(refcnt >= 0);
|
|
1345
|
+
if (refcnt == 0 && usbi_atomic_load(&dev->attached)) {
|
|
1346
|
+
list_del(&dev->list);
|
|
1347
|
+
usbi_atomic_store(&dev->attached, 0);
|
|
1348
|
+
}
|
|
1349
|
+
usbi_mutex_unlock(&ctx->usb_devs_lock);
|
|
1350
|
+
} else {
|
|
1351
|
+
refcnt = usbi_atomic_dec(&dev->refcnt);
|
|
1352
|
+
assert(refcnt >= 0);
|
|
1353
|
+
}
|
|
1297
1354
|
|
|
1298
1355
|
if (refcnt == 0) {
|
|
1299
1356
|
usbi_dbg(DEVICE_CTX(dev), "destroy device %d.%d", dev->bus_number, dev->device_address);
|
|
@@ -1303,9 +1360,8 @@ void API_EXPORTED libusb_unref_device(libusb_device *dev)
|
|
|
1303
1360
|
if (usbi_backend.destroy_device)
|
|
1304
1361
|
usbi_backend.destroy_device(dev);
|
|
1305
1362
|
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
usbi_disconnect_device(dev);
|
|
1363
|
+
for (int idx = 0; idx < LIBUSB_DEVICE_STRING_COUNT; ++idx) {
|
|
1364
|
+
free(dev->device_strings_utf8[idx]);
|
|
1309
1365
|
}
|
|
1310
1366
|
|
|
1311
1367
|
free(dev);
|
|
@@ -2204,6 +2260,111 @@ int API_EXPORTED libusb_set_auto_detach_kernel_driver(
|
|
|
2204
2260
|
return LIBUSB_SUCCESS;
|
|
2205
2261
|
}
|
|
2206
2262
|
|
|
2263
|
+
/** \ingroup libusb_dev
|
|
2264
|
+
* Check if the endpoint supports RAW_IO.
|
|
2265
|
+
* \param dev_handle a device handle
|
|
2266
|
+
* \param endpoint the endpoint to check
|
|
2267
|
+
*
|
|
2268
|
+
* \returns 1 if the endpoint supports RAW_IO
|
|
2269
|
+
* \returns 0 if the endpoint does not support RAW_IO
|
|
2270
|
+
* \returns a LIBUSB_ERROR code on failure
|
|
2271
|
+
*
|
|
2272
|
+
* Only endpoints using the WinUSB driver support RAW_IO,
|
|
2273
|
+
* for all other backends/drivers this function will return 0.
|
|
2274
|
+
*
|
|
2275
|
+
* Fails if the interface the endpoint belongs to isn't claimed,
|
|
2276
|
+
* \see libusb_claim_interface().
|
|
2277
|
+
*
|
|
2278
|
+
* \see libusb_endpoint_set_raw_io()
|
|
2279
|
+
*
|
|
2280
|
+
* Since version 1.0.30, \ref LIBUSB_API_VERSION >= 0x0100010C
|
|
2281
|
+
*/
|
|
2282
|
+
int API_EXPORTED libusb_endpoint_supports_raw_io(libusb_device_handle* dev_handle,
|
|
2283
|
+
uint8_t endpoint)
|
|
2284
|
+
{
|
|
2285
|
+
if (usbi_backend.endpoint_supports_raw_io == NULL)
|
|
2286
|
+
{
|
|
2287
|
+
return 0;
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
// If the `endpoint_supports_raw_io` function is present, these two should be too:
|
|
2291
|
+
assert(usbi_backend.endpoint_set_raw_io != NULL);
|
|
2292
|
+
assert(usbi_backend.get_max_raw_io_transfer_size != NULL);
|
|
2293
|
+
|
|
2294
|
+
return usbi_backend.endpoint_supports_raw_io(dev_handle, endpoint);
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
/** \ingroup libusb_dev
|
|
2298
|
+
* Enable/disable RAW_IO for an endpoint on an open device.
|
|
2299
|
+
*
|
|
2300
|
+
* Only endpoints using the WinUSB driver support RAW_IO,
|
|
2301
|
+
* for all other backends/drivers this function will return an error code.
|
|
2302
|
+
*
|
|
2303
|
+
* Using RAW_IO can greatly improve USB throughput by directly passing
|
|
2304
|
+
* transfer requests to the underlying USB driver instead of queuing them
|
|
2305
|
+
* in WinUSB. This can be particularly useful for high-throughput devices
|
|
2306
|
+
* like cameras or oscilloscopes.
|
|
2307
|
+
*
|
|
2308
|
+
* Transfers submitted to the endpoint while RAW_IO is enabled will fail unless
|
|
2309
|
+
* they adhere to the following rules :
|
|
2310
|
+
* - The buffer length must be a multiple of the maximum endpoint packet size
|
|
2311
|
+
* \see libusb_get_max_packet_size.
|
|
2312
|
+
* - The buffer length must be less than or equal to the value returned by
|
|
2313
|
+
* \ref libusb_get_max_raw_io_transfer_size.
|
|
2314
|
+
*
|
|
2315
|
+
* This option should not be changed when any transfer is in progress on
|
|
2316
|
+
* the specified endpoint.
|
|
2317
|
+
*
|
|
2318
|
+
* Fails if the interface the endpoint belongs to isn't claimed,
|
|
2319
|
+
* \see libusb_claim_interface().
|
|
2320
|
+
*
|
|
2321
|
+
* \param dev_handle a device handle
|
|
2322
|
+
* \param endpoint the endpoint to set RAW_IO for
|
|
2323
|
+
* \param enable 1 to enable RAW_IO, 0 to disable it
|
|
2324
|
+
*
|
|
2325
|
+
* \returns \ref LIBUSB_SUCCESS on success
|
|
2326
|
+
* \returns \ref LIBUSB_ERROR_NOT_SUPPORTED if the backend does not support RAW_IO.
|
|
2327
|
+
* \returns another LIBUSB_ERROR code on other failure
|
|
2328
|
+
*
|
|
2329
|
+
* \see libusb_endpoint_supports_raw_io()
|
|
2330
|
+
* \see https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb-functions-for-pipe-policy-modification
|
|
2331
|
+
*
|
|
2332
|
+
* Since version 1.0.30, \ref LIBUSB_API_VERSION >= 0x0100010C
|
|
2333
|
+
*/
|
|
2334
|
+
int API_EXPORTED libusb_endpoint_set_raw_io(libusb_device_handle* dev_handle,
|
|
2335
|
+
uint8_t endpoint, int enable)
|
|
2336
|
+
{
|
|
2337
|
+
if (!usbi_backend.endpoint_set_raw_io)
|
|
2338
|
+
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
2339
|
+
|
|
2340
|
+
return usbi_backend.endpoint_set_raw_io(dev_handle, endpoint, enable);
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
/** \ingroup libusb_dev
|
|
2344
|
+
* Retrieve the maximum transfer size in bytes supported for WinUSB RAW_IO
|
|
2345
|
+
* for an inbound bulk or interrupt endpoint on an open device.
|
|
2346
|
+
*
|
|
2347
|
+
* Returns a maximum transfer size in bytes, or a negative error code.
|
|
2348
|
+
* If the backend does not support WinUSB RAW_IO, returns
|
|
2349
|
+
* \ref LIBUSB_ERROR_NOT_SUPPORTED.
|
|
2350
|
+
*
|
|
2351
|
+
* Fails if the interface the endpoint belongs to isn't claimed,
|
|
2352
|
+
* \see libusb_claim_interface().
|
|
2353
|
+
*
|
|
2354
|
+
* \see libusb_endpoint_set_raw_io()
|
|
2355
|
+
*
|
|
2356
|
+
* Since version 1.0.30, \ref LIBUSB_API_VERSION >= 0x0100010C
|
|
2357
|
+
*/
|
|
2358
|
+
int API_EXPORTED libusb_get_max_raw_io_transfer_size(
|
|
2359
|
+
libusb_device_handle *dev_handle, uint8_t endpoint)
|
|
2360
|
+
{
|
|
2361
|
+
if (!usbi_backend.get_max_raw_io_transfer_size)
|
|
2362
|
+
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
2363
|
+
|
|
2364
|
+
return usbi_backend.get_max_raw_io_transfer_size(
|
|
2365
|
+
dev_handle, endpoint);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2207
2368
|
/** \ingroup libusb_lib
|
|
2208
2369
|
* Deprecated. Use libusb_set_option() or libusb_init_context() instead,
|
|
2209
2370
|
* with the \ref LIBUSB_OPTION_LOG_LEVEL option.
|
|
@@ -2380,14 +2541,12 @@ int API_EXPORTEDV libusb_set_option(libusb_context *ctx,
|
|
|
2380
2541
|
*/
|
|
2381
2542
|
static enum libusb_log_level get_env_debug_level(void)
|
|
2382
2543
|
{
|
|
2544
|
+
enum libusb_log_level level = LIBUSB_LOG_LEVEL_NONE;
|
|
2383
2545
|
const char *dbg = getenv("LIBUSB_DEBUG");
|
|
2384
|
-
enum libusb_log_level level;
|
|
2385
2546
|
if (dbg) {
|
|
2386
|
-
|
|
2547
|
+
long dbg_level = strtol(dbg, NULL, 10);
|
|
2387
2548
|
dbg_level = CLAMP(dbg_level, LIBUSB_LOG_LEVEL_NONE, LIBUSB_LOG_LEVEL_DEBUG);
|
|
2388
2549
|
level = (enum libusb_log_level)dbg_level;
|
|
2389
|
-
} else {
|
|
2390
|
-
level = LIBUSB_LOG_LEVEL_NONE;
|
|
2391
2550
|
}
|
|
2392
2551
|
return level;
|
|
2393
2552
|
}
|
|
@@ -2456,7 +2615,7 @@ int API_EXPORTED libusb_init_context(libusb_context **ctx, const struct libusb_i
|
|
|
2456
2615
|
_ctx->debug = get_env_debug_level();
|
|
2457
2616
|
_ctx->debug_fixed = 1;
|
|
2458
2617
|
} else if (default_context_options[LIBUSB_OPTION_LOG_LEVEL].is_set) {
|
|
2459
|
-
_ctx->debug = default_context_options[LIBUSB_OPTION_LOG_LEVEL].arg.ival;
|
|
2618
|
+
_ctx->debug = (enum libusb_log_level)default_context_options[LIBUSB_OPTION_LOG_LEVEL].arg.ival;
|
|
2460
2619
|
}
|
|
2461
2620
|
#endif
|
|
2462
2621
|
|
|
@@ -2809,7 +2968,7 @@ static void log_v(struct libusb_context *ctx, enum libusb_log_level level,
|
|
|
2809
2968
|
TIMESPEC_SUB(×tamp, ×tamp_origin, ×tamp);
|
|
2810
2969
|
|
|
2811
2970
|
header_len = snprintf(buf, sizeof(buf),
|
|
2812
|
-
"[%2ld.%06ld] [%
|
|
2971
|
+
"[%2ld.%06ld] [%08lx] libusb: %s [%s] ",
|
|
2813
2972
|
(long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000L), usbi_get_tid(), prefix, function);
|
|
2814
2973
|
} else {
|
|
2815
2974
|
header_len = snprintf(buf, sizeof(buf),
|