Fixes issue with events not being triggered in drivers because .start was not being called to setup.
This commit is contained in:
parent
7f730ed3be
commit
450a87e17e
|
@ -34,7 +34,8 @@
|
|||
}
|
||||
|
||||
Device.prototype.start = function() {
|
||||
return Logger.info("started");
|
||||
Logger.info("Starting driver " + this.driver.name);
|
||||
return this.driver.start();
|
||||
};
|
||||
|
||||
Device.prototype.determineConnection = function(c) {
|
||||
|
|
|
@ -114,6 +114,7 @@
|
|||
for (n in _ref) {
|
||||
device = _ref[n];
|
||||
Logger.info("Starting device '" + device.name + "'...");
|
||||
device.start();
|
||||
_results.push(this[device.name] = device);
|
||||
}
|
||||
return _results;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
spheron = require('spheron')
|
||||
sphero = spheron.sphero()
|
||||
spheroPort = '/dev/rfcomm0'
|
||||
COLORS = spheron.toolbelt.COLORS
|
||||
|
||||
sphero.on('open', ->
|
||||
console.log('EVENT OPEN!')
|
||||
sphero.configureCollisionDetection(0x01, 0x20, 0x20, 0x20, 0x20, 0x50)
|
||||
sphero.setRGB(COLORS.GREEN, false)
|
||||
)
|
||||
|
||||
sphero.on('close', ->
|
||||
console.log('EVENT CLOSE!')
|
||||
)
|
||||
|
||||
sphero.on('end', ->
|
||||
console.log('EVENT END!')
|
||||
)
|
||||
|
||||
sphero.on('error', ->
|
||||
console.log('EVENT ERROR!')
|
||||
)
|
||||
|
||||
sphero.on('notification', (packet) ->
|
||||
console.log('Packet contents:')
|
||||
console.log(packet)
|
||||
)
|
||||
|
||||
sphero.on('message', (packet) ->
|
||||
console.log('Packet contents:')
|
||||
console.log(packet)
|
||||
)
|
||||
|
||||
sphero.open(spheroPort)
|
|
@ -8,14 +8,20 @@ Cylon.robot
|
|||
name: 'sphero', driver: 'sphero'
|
||||
|
||||
work: (me) ->
|
||||
me.sphero.on 'connect', ->
|
||||
Logger.info 'party started...'
|
||||
|
||||
me.sphero.on('connect', ->
|
||||
Logger.info('Setting up Collision Detection...')
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.setRGB(0x00FF00)
|
||||
)
|
||||
|
||||
me.sphero.on 'message', (data) ->
|
||||
me.sphero.setRGB(0x0000FF)
|
||||
Logger.info 'message:'
|
||||
Logger.info data
|
||||
|
||||
me.sphero.on 'notification', (data) ->
|
||||
me.sphero.setRGB(0xFF0000)
|
||||
Logger.info 'notification:'
|
||||
Logger.info data
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ module.exports = class Device extends EventEmitter
|
|||
@addCommands(@driver)
|
||||
|
||||
start: ->
|
||||
Logger.info "started"
|
||||
Logger.info "Starting driver #{ @driver.name }"
|
||||
@driver.start()
|
||||
|
||||
determineConnection: (c) ->
|
||||
@robot.connections[c] if c
|
||||
|
|
|
@ -67,6 +67,7 @@ module.exports = class Robot
|
|||
Logger.info "Starting devices..."
|
||||
for n, device of @devices
|
||||
Logger.info "Starting device '#{ device.name }'..."
|
||||
device.start()
|
||||
this[device.name] = device
|
||||
|
||||
requireAdaptor: (adaptorName, connection) ->
|
||||
|
|
Loading…
Reference in New Issue