node-raspberrypi-usbboot
Advanced tools
Comparing version 1.0.2 to 1.0.3-update-usb-6480c9bcce0458099770bb336b12e62c04a398ef
@@ -9,3 +9,4 @@ "use strict"; | ||
// tslint:disable:no-bitwise | ||
const usb = require("usb"); | ||
const usb_1 = require("usb"); | ||
const endpoint_1 = require("usb/dist/usb/endpoint"); | ||
const _debug = require("debug"); | ||
@@ -184,2 +185,3 @@ const events_1 = require("events"); | ||
const initializeDevice = (device) => { | ||
var _a; | ||
// interface is a reserved keyword in TypeScript so we use iface | ||
@@ -191,3 +193,3 @@ device.open(); | ||
let endpointNumber; | ||
if (device.configDescriptor.bNumInterfaces === | ||
if (((_a = device.configDescriptor) === null || _a === void 0 ? void 0 : _a.bNumInterfaces) === | ||
USB_ENDPOINT_INTERFACES_SOC_BCM2835) { | ||
@@ -204,3 +206,3 @@ interfaceNumber = 0; | ||
const endpoint = iface.endpoint(endpointNumber); | ||
if (!(endpoint instanceof usb.OutEndpoint)) { | ||
if (!(endpoint instanceof endpoint_1.OutEndpoint)) { | ||
throw new Error('endpoint is not an usb.OutEndpoint'); | ||
@@ -212,3 +214,3 @@ } | ||
const sendSize = async (device, size) => { | ||
await performControlTransfer(device, usb.LIBUSB_REQUEST_TYPE_VENDOR, USB_REQUEST_CODE_GET_STATUS, size & USBBOOT_MESSAGE_MAX_BUFFER_LENGTH, size >> CONTROL_TRANSFER_INDEX_RIGHT_BIT_SHIFT, NULL_BUFFER); | ||
await performControlTransfer(device, usb_1.usb.LIBUSB_REQUEST_TYPE_VENDOR, USB_REQUEST_CODE_GET_STATUS, size & USBBOOT_MESSAGE_MAX_BUFFER_LENGTH, size >> CONTROL_TRANSFER_INDEX_RIGHT_BIT_SHIFT, NULL_BUFFER); | ||
}; | ||
@@ -233,3 +235,3 @@ function* chunks(buffer, size) { | ||
catch (error) { | ||
if (error.errno === usb.LIBUSB_TRANSFER_STALL) { | ||
if (error.errno === usb_1.usb.LIBUSB_TRANSFER_STALL) { | ||
continue; | ||
@@ -252,3 +254,3 @@ } | ||
const epRead = async (device, bytesToRead) => { | ||
return await performControlTransfer(device, usb.LIBUSB_REQUEST_TYPE_VENDOR | usb.LIBUSB_ENDPOINT_IN, USB_REQUEST_CODE_GET_STATUS, bytesToRead & USBBOOT_MESSAGE_MAX_BUFFER_LENGTH, bytesToRead >> CONTROL_TRANSFER_INDEX_RIGHT_BIT_SHIFT, bytesToRead); | ||
return await performControlTransfer(device, usb_1.usb.LIBUSB_REQUEST_TYPE_VENDOR | usb_1.usb.LIBUSB_ENDPOINT_IN, USB_REQUEST_CODE_GET_STATUS, bytesToRead & USBBOOT_MESSAGE_MAX_BUFFER_LENGTH, bytesToRead >> CONTROL_TRANSFER_INDEX_RIGHT_BIT_SHIFT, bytesToRead); | ||
}; | ||
@@ -378,3 +380,3 @@ const getDeviceId = (device) => { | ||
// Prepare already connected devices | ||
usb.getDeviceList().map(this.boundAttachDevice); | ||
usb_1.usb.getDeviceList().map(this.boundAttachDevice); | ||
// At this point all devices from `usg.getDeviceList()` above | ||
@@ -384,5 +386,5 @@ // have had an 'attach' event emitted if they were raspberry pis. | ||
// Watch for new devices being plugged in and prepare them | ||
usb.on('attach', this.boundAttachDevice); | ||
usb_1.usb.on('attach', this.boundAttachDevice); | ||
// Watch for devices detaching | ||
usb.on('detach', this.boundDetachDevice); | ||
usb_1.usb.on('detach', this.boundDetachDevice); | ||
// ts-ignore because of a confusion between NodeJS.Timer and number | ||
@@ -395,4 +397,4 @@ // @ts-ignore | ||
stop() { | ||
usb.removeListener('attach', this.boundAttachDevice); | ||
usb.removeListener('detach', this.boundDetachDevice); | ||
usb_1.usb.removeListener('attach', this.boundAttachDevice); | ||
usb_1.usb.removeListener('detach', this.boundDetachDevice); | ||
clearInterval(this.interval); | ||
@@ -399,0 +401,0 @@ this.usbbootDevices.clear(); |
@@ -7,4 +7,9 @@ # Change Log | ||
# v1.0.3 | ||
## (2022-04-20) | ||
* update usb [Zane Hitchcox] | ||
# v1.0.2 | ||
## (2021-12-18) | ||
## (2021-12-06) | ||
@@ -11,0 +16,0 @@ * blobs/raspberrypi: Update start_cd.elf to latest patched revision [Alexandru Costache] |
{ | ||
"name": "node-raspberrypi-usbboot", | ||
"version": "1.0.2", | ||
"version": "1.0.3-update-usb-6480c9bcce0458099770bb336b12e62c04a398ef", | ||
"description": "Transforms Raspberry Pi Compute Modules and Zeros to mass storage devices.", | ||
@@ -29,3 +29,3 @@ "main": "build/index.js", | ||
"debug": "^4.1.1", | ||
"usb": "^1.7.2" | ||
"usb": "^2.3.1" | ||
}, | ||
@@ -36,3 +36,2 @@ "devDependencies": { | ||
"@types/node": "^8.10.61", | ||
"@types/usb": "^1.5.1", | ||
"rimraf": "^3.0.2", | ||
@@ -43,4 +42,4 @@ "ts-node": "^8.10.2", | ||
"versionist": { | ||
"publishedAt": "2021-12-18T15:54:30.963Z" | ||
"publishedAt": "2022-04-20T12:52:42.214Z" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6
28129866
2093
2
+ Added@types/w3c-web-usb@1.0.10(transitive)
+ Addednode-addon-api@8.3.0(transitive)
+ Addedusb@2.14.0(transitive)
- Removednode-addon-api@4.3.0(transitive)
- Removedusb@1.9.2(transitive)
Updatedusb@^2.3.1