node-raspberrypi-usbboot
Advanced tools
Comparing version 0.0.12 to 0.0.13-update-resin-lint-3ea48ebf27b884436d01ee4339b307e9a83c7053
@@ -92,3 +92,3 @@ "use strict"; | ||
const USB_VENDOR_ID_NETCHIP_TECHNOLOGY = 0x0525; | ||
const USB_PRODUCT_ID_POCKETBOOK_PRO_903 = 0Xa4a5; | ||
const USB_PRODUCT_ID_POCKETBOOK_PRO_903 = 0xa4a5; | ||
// Delay in ms after which we consider that the device was unplugged (not resetted) | ||
@@ -118,3 +118,5 @@ const DEVICE_UNPLUG_TIMEOUT = 5000; | ||
} | ||
return fileMessageBuffer.slice(FILE_MESSAGE_FILE_NAME_OFFSET, end).toString('ascii'); | ||
return fileMessageBuffer | ||
.slice(FILE_MESSAGE_FILE_NAME_OFFSET, end) | ||
.toString('ascii'); | ||
}; | ||
@@ -148,9 +150,9 @@ /** | ||
const isUsbBootCapableUSBDevice = (device) => { | ||
return ((device.deviceDescriptor.idVendor === USB_VENDOR_ID_BROADCOM_CORPORATION) && | ||
((device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2708_BOOT) || | ||
(device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2710_BOOT))); | ||
return (device.deviceDescriptor.idVendor === USB_VENDOR_ID_BROADCOM_CORPORATION && | ||
(device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2708_BOOT || | ||
device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2710_BOOT)); | ||
}; | ||
const isRaspberryPiInMassStorageMode = (device) => { | ||
return ((device.deviceDescriptor.idVendor === USB_VENDOR_ID_NETCHIP_TECHNOLOGY) && | ||
(device.deviceDescriptor.idProduct === USB_PRODUCT_ID_POCKETBOOK_PRO_903)); | ||
return (device.deviceDescriptor.idVendor === USB_VENDOR_ID_NETCHIP_TECHNOLOGY && | ||
device.deviceDescriptor.idProduct === USB_PRODUCT_ID_POCKETBOOK_PRO_903); | ||
}; | ||
@@ -164,3 +166,4 @@ const initializeDevice = (device) => { | ||
let endpointNumber; | ||
if (device._configDescriptor.bNumInterfaces === USB_ENDPOINT_INTERFACES_SOC_BCM2835) { | ||
if (device._configDescriptor.bNumInterfaces === | ||
USB_ENDPOINT_INTERFACES_SOC_BCM2835) { | ||
interfaceNumber = 0; | ||
@@ -191,3 +194,3 @@ endpointNumber = 1; | ||
for (const chunk of chunks(buffer, TRANSFER_BLOCK_SIZE)) { | ||
yield bluebird_1.fromCallback((callback) => { | ||
yield bluebird_1.fromCallback(callback => { | ||
endpoint.transfer(chunk, callback); | ||
@@ -208,4 +211,3 @@ }); | ||
} | ||
catch (e) { | ||
} | ||
catch (e) { } | ||
}); | ||
@@ -345,3 +347,4 @@ const getFileBuffer = (filename) => __awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (isRaspberryPiInMassStorageMode(device) && this.usbbootDevices.has(portId(device))) { | ||
if (isRaspberryPiInMassStorageMode(device) && | ||
this.usbbootDevices.has(portId(device))) { | ||
this.step(device, 41); | ||
@@ -380,3 +383,3 @@ return; | ||
} | ||
const step = (device.deviceDescriptor.iSerialNumber === 0) ? 1 : 40; | ||
const step = device.deviceDescriptor.iSerialNumber === 0 ? 1 : 40; | ||
debug('detach', portId(device), step); | ||
@@ -388,3 +391,3 @@ this.step(device, step); | ||
const usbbootDevice = this.get(device); | ||
if ((usbbootDevice !== undefined) && (usbbootDevice.step === step)) { | ||
if (usbbootDevice !== undefined && usbbootDevice.step === step) { | ||
debug('device', portId(device), 'did not reattached after', DEVICE_UNPLUG_TIMEOUT, 'ms.'); | ||
@@ -405,3 +408,4 @@ this.remove(device); | ||
catch (error) { | ||
if ((error.message === 'LIBUSB_ERROR_NO_DEVICE') || (error.message === 'LIBUSB_ERROR_IO')) { | ||
if (error.message === 'LIBUSB_ERROR_NO_DEVICE' || | ||
error.message === 'LIBUSB_ERROR_IO') { | ||
// Drop out if the device goes away | ||
@@ -415,3 +419,4 @@ break; | ||
debug('Received message', FileMessageCommand[message.command], message.filename, portId(device)); | ||
if ((message.command === FileMessageCommand.GetFileSize) || (message.command === FileMessageCommand.ReadFile)) { | ||
if (message.command === FileMessageCommand.GetFileSize || | ||
message.command === FileMessageCommand.ReadFile) { | ||
const buffer = yield getFileBuffer(message.filename); | ||
@@ -418,0 +423,0 @@ if (buffer === undefined) { |
@@ -7,2 +7,6 @@ # Change Log | ||
## v0.0.13 - 2018-10-21 | ||
* Update resin-lint, run prettier on all ts files [Alexis Svinartchouk] | ||
## v0.0.12 - 2018-10-19 | ||
@@ -9,0 +13,0 @@ |
{ | ||
"name": "node-raspberrypi-usbboot", | ||
"version": "0.0.12", | ||
"version": "0.0.13-update-resin-lint-3ea48ebf27b884436d01ee4339b307e9a83c7053", | ||
"description": "Transforms Raspberry Pi Compute Modules and Zeros to mass storage devices.", | ||
@@ -8,2 +8,3 @@ "main": "build/index.js", | ||
"scripts": { | ||
"prettier": "prettier --config ./node_modules/resin-lint/config/.prettierrc --write \"lib/**/*.ts\" \"typings/**/*.ts\"", | ||
"lint": "resin-lint --typescript lib/*.ts typings/**/*.d.ts", | ||
@@ -35,3 +36,3 @@ "build": "npm run lint && rimraf build && tsc", | ||
"@types/debug": "0.0.30", | ||
"resin-lint": "^1.5.7", | ||
"resin-lint": "^2.0.1", | ||
"rimraf": "^2.6.2", | ||
@@ -38,0 +39,0 @@ "ts-node": "^6.0.3", |
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
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
27731705
461