diff --git a/lib/analog-input.js b/lib/analog-input.js index 5e8e9be..0d72c6b 100644 --- a/lib/analog-input.js +++ b/lib/analog-input.js @@ -27,9 +27,5 @@ AnalogInput.prototype.rawValue = function () { return parseInt(this._rawValueBuffer.toString('utf8', 0, len - 1), 10); }; -AnalogInput.isEnabled = function () { - return fs.existsSync(ADC_PATH); -}; - module.exports = AnalogInput; diff --git a/lib/beaglebone.js b/lib/beaglebone.js index 5a5cf05..61efd43 100644 --- a/lib/beaglebone.js +++ b/lib/beaglebone.js @@ -5,7 +5,6 @@ var LinuxIO = require('linux-io'), boardInfo = require('./board-info'), AnalogInput = require('./analog-input'), PwmOutput = require('./pwm-output'), - slots = require('./slots'), pinmux = require('./pinmux'); var PWM_PERIOD = 1e9 / 2000, // 2000Hz @@ -24,11 +23,6 @@ function BeagleBone() { vref: 3.3 }); - // Analog inputs are enabled by default on Debian Stretch but not on Jessie - if (!AnalogInput.isEnabled()) { - slots.add('BB-ADC'); - } - setImmediate(function () { this.emit('connect'); this.emit('ready'); diff --git a/lib/slots.js b/lib/slots.js deleted file mode 100644 index 2d1ace4..0000000 --- a/lib/slots.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -var fs = require('fs'); - -var SLOTS_PATH = '/sys/devices/platform/bone_capemgr/slots', - FS_OPTIONS = {encoding: 'utf8'}; - -/** - * Returns the number of the slot with the specified name. Returns -1 if there - * is no such slot. - * - * name: string // Slot name - * - * Returns - number // Slot number or -1 - */ -function number(name) { - var slots = fs.readFileSync(SLOTS_PATH, FS_OPTIONS).split('\n'), - i; - - name = ',' + name; - - // Search backwards. Added slots are more likely to be at end of slots file. - for (i = slots.length - 1; i >= 0; i -= 1) { - if (slots[i].indexOf(name, slots[i].length - name.length) !== -1) { - return parseInt(slots[i], 10); - } - } - - return -1; -} -module.exports.number = number; - -/** - * Adds a slot with the specified name if there is not already a slot with - * that name. Does nothing if there is already a slot with the specified name. - * - * name: string // Slot name - * - * Returns - undefined - * - * Throws ENOENT Errors if the required device-tree file does not exist in - * /lib/firmware - */ -module.exports.add = function (name) { - var slotNumber = number(name); - - if (slotNumber === -1) { - fs.writeFileSync(SLOTS_PATH, name, FS_OPTIONS); - } -}; - -/** - * Removes the slot with the specified name if there is a slot with that name. - * Does nothing if there is no such slot. - * - * name: string // Slot name - * - * Returns - undefined - */ -module.exports.remove = function (name) { - var slotNumber = number(name); - - if (slotNumber !== -1) { - fs.writeFileSync(SLOTS_PATH, '' + -slotNumber, FS_OPTIONS); - } -}; - diff --git a/test/beaglebone.js b/test/beaglebone.js index a0cae9b..cbab4af 100644 --- a/test/beaglebone.js +++ b/test/beaglebone.js @@ -3,14 +3,6 @@ var BeagleBone = rewire("../lib/beaglebone"); var Emitter = require("events").EventEmitter; var sinon = require("sinon"); -(function() { - var slotsStub = { - add: function(name) {} - }; - - BeagleBone.__set__("slots", slotsStub); -}()); - function restore(target) { for (var prop in target) { if (typeof target[prop].restore === "function") {