Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-raspberrypi-usbboot

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-raspberrypi-usbboot - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1-usbboot-stalls-9d6be4db6e4279e9df9e3bfc8385ab7ebb5edd82

39

build/index.js

@@ -85,4 +85,7 @@ "use strict";

*/
// In node-usb, 0 means "infinite" timeout
const USB_CONTROL_TRANSFER_TIMEOUT_MS = 0;
const USB_CONTROL_TRANSFER_TIMEOUT_MS = 10000;
/**
* @summary The timeout for USB bulk transfers, in milliseconds
*/
const USB_BULK_TRANSFER_TIMEOUT_MS = 10000;
const USB_ENDPOINT_INTERFACES_SOC_BCM2835 = 1;

@@ -99,2 +102,4 @@ const USB_VENDOR_ID_BROADCOM_CORPORATION = 0x0a5c;

const READ_ERROR_DELAY = 100;
// Transfer delay
const TRANSFER_DELAY_MS = 1000;
var FileMessageCommand;

@@ -195,9 +200,29 @@ (function (FileMessageCommand) {

}
const transfer = (endpoint, chunk, times = 3) => __awaiter(this, void 0, void 0, function* () {
if (times === 0) {
throw new Error('USB bulk transfer stall');
}
try {
yield bluebird_1.fromCallback(callback => {
endpoint.timeout = USB_BULK_TRANSFER_TIMEOUT_MS;
endpoint.transfer(chunk, callback);
});
}
catch (error) {
if (error.errno === usb.LIBUSB_TRANSFER_STALL) {
debug('Transfer stall, retrying');
yield transfer(endpoint, chunk, times - 1);
}
throw error;
}
});
const epWrite = (buffer, device, endpoint) => __awaiter(this, void 0, void 0, function* () {
debug('Sending buffer size', buffer.length);
yield sendSize(device, buffer.length);
yield bluebird_1.delay(TRANSFER_DELAY_MS);
if (buffer.length > 0) {
for (const chunk of chunks(buffer, TRANSFER_BLOCK_SIZE)) {
yield bluebird_1.fromCallback(callback => {
endpoint.transfer(chunk, callback);
});
debug('Sending chunk of size', chunk.length);
yield transfer(endpoint, chunk);
yield bluebird_1.delay(TRANSFER_DELAY_MS);
}

@@ -304,2 +329,6 @@ }

this.boundDetachDevice = this.detachDevice.bind(this);
// This is an undocumented property
if (usb.INIT_ERROR) {
throw new Error('USB failed to initialize');
}
}

@@ -306,0 +335,0 @@ start() {

@@ -7,2 +7,6 @@ # Change Log

## 0.2.1 - 2019-03-18
* Improve USB boot stability [Juan Cruz Viotti]
## 0.2.0 - 2019-03-18

@@ -9,0 +13,0 @@

2

package.json
{
"name": "node-raspberrypi-usbboot",
"version": "0.2.0",
"version": "0.2.1-usbboot-stalls-9d6be4db6e4279e9df9e3bfc8385ab7ebb5edd82",
"description": "Transforms Raspberry Pi Compute Modules and Zeros to mass storage devices.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc