feat(SDK): display Compute Modules even if host OS has no drivers (#1892)

This is the first step towards full usbboot Windows support. The driver
selector dialog will now display disabled devices to represent Compute
Modules even when Windows drivers are not installed to act on them.
These drives will state "Missing drivers."

Change-Type: minor
Changelog-Entry: Display connected Compute Modules even if Windows doesn't have the necessary drivers to act on them.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit is contained in:
Juan Cruz Viotti 2017-12-13 13:37:34 -04:00 committed by GitHub
parent f8c3faec79
commit b703a6f5fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="512px" height="512px" viewBox="0 0 512.209 512.209" style="enable-background:new 0 0 512.209 512.209;" xml:space="preserve">
<g>
<path d="M507.345,439.683L288.084,37.688c-3.237-5.899-7.71-10.564-13.429-13.988c-5.705-3.427-11.893-5.142-18.554-5.142 s-12.85,1.718-18.558,5.142c-5.708,3.424-10.184,8.089-13.418,13.988L4.859,439.683c-6.663,11.998-6.473,23.989,0.57,35.98 c3.239,5.517,7.664,9.897,13.278,13.128c5.618,3.237,11.66,4.859,18.132,4.859h438.529c6.479,0,12.519-1.622,18.134-4.859 c5.62-3.23,10.038-7.611,13.278-13.128C513.823,463.665,514.015,451.681,507.345,439.683z M292.655,411.132 c0,2.662-0.91,4.897-2.71,6.704c-1.807,1.811-3.949,2.71-6.427,2.71h-54.816c-2.474,0-4.616-0.899-6.423-2.71 c-1.809-1.807-2.713-4.042-2.713-6.704v-54.248c0-2.662,0.905-4.897,2.713-6.704c1.807-1.811,3.946-2.71,6.423-2.71h54.812 c2.479,0,4.62,0.899,6.428,2.71c1.803,1.807,2.71,4.042,2.71,6.704v54.248H292.655z M292.088,304.357 c-0.198,1.902-1.198,3.47-3.001,4.709c-1.811,1.238-4.046,1.854-6.711,1.854h-52.82c-2.663,0-4.947-0.62-6.849-1.854 c-1.908-1.243-2.858-2.807-2.858-4.716l-4.853-130.47c0-2.667,0.953-4.665,2.856-5.996c2.474-2.093,4.758-3.14,6.854-3.14h62.809 c2.098,0,4.38,1.043,6.854,3.14c1.902,1.331,2.851,3.14,2.851,5.424L292.088,304.357z" fill="#D80027"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -117,6 +117,16 @@ const USBBOOT_CAPABLE_USB_DEVICES = [
]
/**
* @summary Compute module descriptions
* @type {Object}
* @constant
*/
const COMPUTE_MODULE_DESCRIPTIONS = {
[USB_PRODUCT_ID_BCM2708_BOOT]: 'Compute Module 1',
[USB_PRODUCT_ID_BCM2710_BOOT]: 'Compute Module 3'
}
/**
* @summary Estimated device reboot delay
* @type {Number}
@ -251,6 +261,23 @@ class USBBootAdapter extends EventEmitter {
usb.listDevices().filter(isUsbBootCapableUSBDevice).map((device) => {
/* eslint-enable lodash/prefer-lodash-method */
const description = COMPUTE_MODULE_DESCRIPTIONS[device.deviceDescriptor.idProduct] || 'Compute Module'
if (!device.accessible) {
return {
device: `${usbIdToString(device.deviceDescriptor.idVendor)}:${usbIdToString(device.deviceDescriptor.idProduct)}`,
displayName: 'Missing drivers',
description,
mountpoints: [],
protected: false,
system: false,
disabled: true,
icon: 'warning',
size: null,
adaptor: USBBootAdapter.id
}
}
// This is the only way we can unique identify devices
device.raw = `${device.busNumber}:${device.deviceAddress}`
@ -258,7 +285,11 @@ class USBBootAdapter extends EventEmitter {
device: device.raw,
raw: device.raw,
displayName: 'Initializing device',
// At this point we can't differentiate between CMs any more, so
// we can't use the description that changes depending on the PID.
description: 'Compute Module',
size: null,
mountpoints: [],
protected: false,
@ -267,7 +298,7 @@ class USBBootAdapter extends EventEmitter {
icon: 'loading',
vendor: usbIdToString(device.deviceDescriptor.idVendor),
product: usbIdToString(device.deviceDescriptor.idProduct),
adaptor: exports.name
adaptor: USBBootAdapter.id
}
if (_.isNil(this.progress[result.raw])) {

View File

@ -67,7 +67,26 @@ const USB_CONTROL_TRANSFER_TIMEOUT_MS = 0
* })
*/
exports.listDevices = () => {
return Bluebird.resolve(usb.getDeviceList())
const devices = _.map(usb.getDeviceList(), (device) => {
device.accessible = true
return device
})
// Include driverless devices into the list of USB devices.
if (process.platform === 'win32') {
const winusbDriverGenerator = require('winusb-driver-generator')
for (const device of winusbDriverGenerator.listDriverlessDevices()) {
devices.push({
accessible: false,
deviceDescriptor: {
idVendor: device.vid,
idProduct: device.pid
}
})
}
}
return Bluebird.resolve(devices)
}
/**

17
npm-shrinkwrap.json generated
View File

@ -10215,6 +10215,23 @@
"from": "window-size@>=0.2.0 <0.3.0",
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz"
},
"winusb-driver-generator": {
"version": "1.1.1",
"from": "winusb-driver-generator@latest",
"resolved": "https://registry.npmjs.org/winusb-driver-generator/-/winusb-driver-generator-1.1.1.tgz",
"dependencies": {
"bindings": {
"version": "1.3.0",
"from": "bindings@>=1.3.0 <2.0.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz"
},
"nan": {
"version": "2.8.0",
"from": "nan@>=2.7.0 <3.0.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz"
}
}
},
"wordwrap": {
"version": "1.0.0",
"from": "wordwrap@>=1.0.0 <1.1.0",

View File

@ -90,6 +90,7 @@
"unbzip2-stream": "github:resin-io-modules/unbzip2-stream#core-streams",
"usb": "github:tessel/node-usb#1.3.0",
"uuid": "3.0.1",
"winusb-driver-generator": "1.1.1",
"xml2js": "0.4.17",
"yargs": "4.7.1",
"yauzl": "2.6.0"