Skip to content

Instantly share code, notes, and snippets.

@ravikp7
Created May 14, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravikp7/7feca941e038e97227204f957d4b0e1e to your computer and use it in GitHub Desktop.
Save ravikp7/7feca941e038e97227204f957d4b0e1e to your computer and use it in GitHub Desktop.
beagleboot adapter
'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