Comparing version 1.8.1 to 1.9.0
# Changelog | ||
## [1.9.0] - 2021-11-08 | ||
### Changed | ||
- Changed libusb dependency to upstream v1.0.23 - [`453`](https://github.com/node-usb/node-usb/pull/453) ([Rob Moran](https://github.com/thegecko)) | ||
## [1.8.1] - 2021-11-08 | ||
@@ -4,0 +9,0 @@ |
{ | ||
"name": "usb", | ||
"description": "Library to access USB devices", | ||
"version": "1.8.1", | ||
"version": "1.9.0", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=10.16.0" |
55
usb.js
var usb = exports = module.exports = require('node-gyp-build')(__dirname); | ||
var events = require('events') | ||
var util = require('util') | ||
var events = require('events'); | ||
var util = require('util'); | ||
@@ -513,2 +513,41 @@ var isBuffer = function(obj) { | ||
// Polling mechanism for discovering device changes until this is fixed: | ||
// https://github.com/libusb/libusb/issues/86 | ||
exports._pollTimeout = 500; | ||
var hotplugSupported = usb._getLibusbCapability(usb.LIBUSB_CAP_HAS_HOTPLUG) > 0; | ||
var pollingHotplug = false; | ||
var pollDevices = []; | ||
function pollHotplug(start) { | ||
if (start) { | ||
pollingHotplug = true; | ||
} else if (!pollingHotplug) { | ||
return; | ||
} | ||
var devices = usb.getDeviceList(); | ||
if (!start) { | ||
// Find attached devices | ||
for (var device of devices) { | ||
var found = pollDevices.find(item => item.deviceAddress === device.deviceAddress); | ||
if (!found) { | ||
usb.emit('attach', device); | ||
} | ||
} | ||
// Find detached devices | ||
for (var device of pollDevices) { | ||
var found = devices.find(item => item.deviceAddress === device.deviceAddress); | ||
if (!found) { | ||
usb.emit('detach', device); | ||
} | ||
} | ||
} | ||
pollDevices = devices; | ||
setTimeout(() => { | ||
pollHotplug(); | ||
}, exports._pollTimeout); | ||
} | ||
var hotplugListeners = 0; | ||
@@ -518,3 +557,7 @@ exports.on('newListener', function(name) { | ||
if (++hotplugListeners === 1) { | ||
usb._enableHotplugEvents(); | ||
if (hotplugSupported) { | ||
usb._enableHotplugEvents(); | ||
} else { | ||
pollHotplug(true); | ||
} | ||
} | ||
@@ -526,4 +569,8 @@ }); | ||
if (--hotplugListeners === 0) { | ||
usb._disableHotplugEvents(); | ||
if (hotplugSupported) { | ||
usb._disableHotplugEvents(); | ||
} else { | ||
pollingHotplug = false; | ||
} | ||
} | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
5073463
223
492
9
60