Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cylon-beaglebone-stub

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cylon-beaglebone-stub - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

5

History.md

@@ -0,1 +1,6 @@

0.1.3 / 2015-02-25
==================
* Random values on reads
0.1.2 / 2014-12-23

@@ -2,0 +7,0 @@ ==================

66

lib/adaptor.js

@@ -11,10 +11,13 @@ /*

var Cylon = require('cylon');
var logger = Cylon.Logger;
var NOP = function() {};
var Promise = require('bluebird');
var BeagleboneStub = module.exports = function BeagleboneStub(opts) {
BeagleboneStub.__super__.constructor.apply(this, arguments);
var t = this;
BeagleboneStub.__super__.constructor.apply(t, arguments);
this.pins = {};
this.i2cAddresses = {};
opts = opts || {};
t.pins = {};
t.i2cAddresses = {};
t.opts = opts || {};
};

@@ -53,5 +56,9 @@

proto.connect = function(callback) {
var my = this;
callback = callback || NOP;
Cylon.Logger.debug("Connecting to '" + this.name + "'...");
process.nextTick(callback);
logger.debug("Connecting to '" + this.name + "'...");
process.nextTick(function(){
my.emit('connect');
callback();
});
};

@@ -62,3 +69,3 @@

callback = callback || NOP;
Cylon.Logger.debug("Disconnecting from '" + this.name + "'...");
logger.debug("Disconnecting from '" + this.name + "'...");
process.nextTick(function(){

@@ -72,9 +79,12 @@ my.emit('disconnect');

var my = this;
var deferred = Promise.defer();
var promise = deferred.promise.nodeify(callback);
callback = callback || NOP;
my._validateAnalogPin(pinNum);
process.nextTick(function() {
my.emit('analogRead', my.pins[pinNum]);
callback(null, my.pins[pinNum]);
my.pins[pinNum] = Math.random();
my.emit('analogRead', pinNum, my.pins[pinNum]);
return deferred.resolve(my.pins[pinNum]);
});
return true;
return promise;
};

@@ -88,3 +98,3 @@

process.nextTick(function() {
my.emit('analogWrite', value);
my.emit('analogWrite', pinNum, value);
});

@@ -96,19 +106,24 @@ return value;

var my = this;
callback = callback || NOP;
var deferred = Promise.defer();
var promise = deferred.promise.nodeify(callback);
my._validateDigitalPin(pinNum);
process.nextTick(function() {
my.emit('digitalRead', my.pins[pinNum]);
callback(null, my.pins[pinNum]);
my.pins[pinNum] = Math.floor(Math.random() * 2);
my.emit('digitalRead', pinNum, my.pins[pinNum]);
return deferred.resolve(my.pins[pinNum]);
});
return true;
return promise;
};
proto.digitalWrite = function(pinNum, value) {
proto.digitalWrite = function(pinNum, value, callback) {
var my = this;
var deferred = Promise.defer();
var promise = deferred.promise.nodeify(callback);
my._validateDigitalPin(pinNum);
my.pins[pinNum] = value;
process.nextTick(function() {
my.emit('digitalWrite', value);
my.emit('digitalWrite', pinNum, value);
return deferred.resolve(value);
});
return value;
return promise;
};

@@ -122,3 +137,3 @@

eventName = eventName || 'pwm';
my.emit(eventName + 'Write', my.pins[pinNum]);
my.emit(eventName + 'Write', pinNum, my.pins[pinNum]);
});

@@ -136,8 +151,10 @@ };

var my = this;
callback = callback || NOP;
var deferred = Promise.defer();
var promise = deferred.promise.nodeify(callback);
buff = buff != null ? buff : [];
my.i2cAddresses[address] = buff;
process.nextTick(function(){
callback(null);
return deferred.resolve();
});
return promise;
};

@@ -147,6 +164,9 @@

var my = this;
callback = callback || NOP;
var deferred = Promise.defer();
var promise = deferred.promise.nodeify(callback);
process.nextTick(function(){
callback(null, my.i2cAddresses[address]);
my.i2cAddresses[address] = Math.random();
return deferred.resolve(my.i2cAddresses[address]);
});
return promise;
};

@@ -153,0 +173,0 @@

{
"name": "cylon-beaglebone-stub",
"version": "0.1.2",
"version": "0.1.3",
"main": "lib/cylon-beaglebone-stub.js",

@@ -27,2 +27,3 @@ "description": "Beaglebone stub for testing",

"peerDependencies": {
"bluebird": ">=2.3.11 <3.0.0",
"cylon": ">= 0.21.0 < 1",

@@ -33,10 +34,5 @@ "cylon-gpio": ">= 0.21.0 < 1",

"dependencies": {
"cylon": "~0.21.1",
"cylon-gpio": ">= 0.21.0 < 1",
"cylon-i2c": ">= 0.18.0 < 1"
},
"scripts": {
"test": "make test"
"test": "make bdd"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc