Created
May 14, 2018 15:38
-
-
Save ravikp7/7feca941e038e97227204f957d4b0e1e to your computer and use it in GitHub Desktop.
beagleboot adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const EventEmitter = require('events') | |
const BeagleBoot = require('beagle-boot') | |
class BeagleBootAdapter extends EventEmitter { | |
/** | |
* @summary USBBootAdapter constructor | |
* @class | |
* @example | |
* const adapter = new USBBootAdapter() | |
*/ | |
constructor () { | |
super() | |
/** @type {String} Adapter name */ | |
this.id = this.constructor.id | |
/** @type {Object} Progress hash */ | |
this.progress = {} | |
this.devices = [] | |
this.on('devices', (devices) => { | |
this.devices = devices | |
}) | |
} | |
scan (options = {}, callback) { | |
const umsServer = BeagleBoot.usbMassStorage(); | |
const device = { | |
displayName: 'Initializing device', | |
description: 'Compute Module', | |
size: null, | |
mountpoints: [], | |
isReadOnly: false, | |
disabled: true, | |
isSystem: false, | |
icon: 'loading', | |
adaptor: this.id, | |
} | |
const devices = [] | |
devices.push(device) | |
umsServer.on('connect', (device) => { | |
if (device == 'ROM') this.emit('devices', devices) | |
}) | |
return this | |
} | |
} | |
/** | |
* @summary The name of this adapter | |
* @public | |
* @type {String} | |
* @constant | |
*/ | |
BeagleBootAdapter.id = 'beagleboot' | |
// Exports | |
module.exports = BeagleBootAdapter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment