cylon-beaglebone-stub
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -0,1 +1,6 @@ | ||
0.1.3 / 2015-02-25 | ||
================== | ||
* Random values on reads | ||
0.1.2 / 2014-12-23 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16148
4
383
+ Addedbluebird@2.11.0(transitive)
+ Addedcylon@0.22.2(transitive)
- Removedcylon@~0.21.1
- Removedcylon-gpio@>= 0.21.0 < 1
- Removedcylon-i2c@>= 0.18.0 < 1
- Removedaccepts@1.1.4(transitive)
- Removedbody-parser@1.9.0(transitive)
- Removedbytes@1.0.0(transitive)
- Removedcookie@0.1.2(transitive)
- Removedcookie-signature@1.0.5(transitive)
- Removedcrc@3.0.0(transitive)
- Removedcylon@0.21.2(transitive)
- Removeddebug@2.0.0(transitive)
- Removeddepd@0.4.51.0.1(transitive)
- Removeddestroy@1.0.3(transitive)
- Removedee-first@1.0.5(transitive)
- Removedescape-html@1.0.1(transitive)
- Removedetag@1.4.0(transitive)
- Removedexpress@4.9.8(transitive)
- Removedfinalhandler@0.2.0(transitive)
- Removedforwarded@0.1.2(transitive)
- Removedfresh@0.2.4(transitive)
- Removediconv-lite@0.4.4(transitive)
- Removedipaddr.js@1.0.5(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@0.0.2(transitive)
- Removedmethods@1.1.0(transitive)
- Removedmime@1.2.11(transitive)
- Removedmime-db@1.12.0(transitive)
- Removedmime-types@2.0.14(transitive)
- Removedms@0.6.2(transitive)
- Removednegotiator@0.4.9(transitive)
- Removedon-finished@2.1.0(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@0.1.3(transitive)
- Removedproxy-addr@1.0.10(transitive)
- Removedqs@2.2.4(transitive)
- Removedrange-parser@1.0.3(transitive)
- Removedraw-body@1.3.0(transitive)
- Removedrobeaux@0.3.0(transitive)
- Removedsend@0.9.3(transitive)
- Removedserve-static@1.6.5(transitive)
- Removedtype-is@1.5.7(transitive)
- Removedutils-merge@1.0.0(transitive)
- Removedvary@1.0.1(transitive)