diff --git a/nodes/core/hardware/35-arduino.js b/nodes/core/hardware/35-arduino.js index 1241239cb..d5e4fe7b5 100644 --- a/nodes/core/hardware/35-arduino.js +++ b/nodes/core/hardware/35-arduino.js @@ -43,14 +43,15 @@ module.exports = function(RED) { node.log("version "+node.board.boardVersion); }); - node.on('close', function() { + node.on('close', function(done) { if (node.board) { try { node.board.close(function() { + done(); node.log("port closed"); }); - } catch(e) { } - } + } catch(e) { done(); } + } else { done(); } }); } RED.nodes.registerType("arduino-board",ArduinoNode); diff --git a/nodes/core/hardware/36-rpi-gpio.js b/nodes/core/hardware/36-rpi-gpio.js index ce59354c5..adf5674b5 100644 --- a/nodes/core/hardware/36-rpi-gpio.js +++ b/nodes/core/hardware/36-rpi-gpio.js @@ -91,7 +91,7 @@ module.exports = function(RED) { node.running = false; node.status({fill:"red",shape:"circle",text:""}); if (RED.settings.verbose) { node.log("closed"); } - node.done(); + if (node.done) { node.done(); } }); node.child.on('error', function (err) { @@ -109,10 +109,11 @@ module.exports = function(RED) { node.status({fill:"red",shape:"circle",text:""}); delete pinsInUse[node.pin]; if (node.child != null) { + node.done = done; node.child.stdin.write(" close "+node.pin); node.child.kill('SIGKILL'); } - node.done = done; + else { done(); } }); } RED.nodes.registerType("rpi-gpio in",GPIOInNode); @@ -173,7 +174,7 @@ module.exports = function(RED) { node.running = false; node.status({fill:"red",shape:"circle",text:""}); if (RED.settings.verbose) { node.log("closed"); } - node.done(); + if (node.done) { node.done(); } }); node.child.on('error', function (err) { @@ -191,10 +192,11 @@ module.exports = function(RED) { node.status({fill:"red",shape:"circle",text:""}); delete pinsInUse[node.pin]; if (node.child != null) { + node.done = done; node.child.stdin.write(" close "+node.pin); node.child.kill('SIGKILL'); } - node.done = done; + else { done(); } }); } @@ -237,7 +239,7 @@ module.exports = function(RED) { node.running = false; node.status({fill:"red",shape:"circle",text:""}); if (RED.settings.verbose) { node.log("closed"); } - node.done(); + if (node.done) { node.done(); } }); node.child.on('error', function (err) { @@ -249,10 +251,11 @@ module.exports = function(RED) { node.on("close", function(done) { node.status({fill:"red",shape:"circle",text:""}); if (node.child != null) { + node.done = done; node.child.kill('SIGINT'); node.child = null; } - node.done = done; + else { done(); } }); } RED.nodes.registerType("rpi-mouse",PiMouseNode); diff --git a/nodes/core/hardware/nrgpio.py b/nodes/core/hardware/nrgpio.py index 774dbfcfb..414f5fc5e 100755 --- a/nodes/core/hardware/nrgpio.py +++ b/nodes/core/hardware/nrgpio.py @@ -140,6 +140,34 @@ if len(sys.argv) > 1: mask = 1 << bit GPIO.output(list[bit], data & mask) + elif cmd == "borg": + #print "Initialised BORG mode - "+str(pin)+ + GPIO.setup(11,GPIO.OUT) + GPIO.setup(13,GPIO.OUT) + GPIO.setup(15,GPIO.OUT) + r = GPIO.PWM(11, 100) + g = GPIO.PWM(13, 100) + b = GPIO.PWM(15, 100) + r.start(0) + g.start(0) + b.start(0) + + while True: + try: + data = raw_input() + if data == "close": + GPIO.cleanup() + sys.exit(0) + c = data.split(",") + r.ChangeDutyCycle(float(c[0])) + g.ChangeDutyCycle(float(c[1])) + b.ChangeDutyCycle(float(c[2])) + except EOFError: # hopefully always caused by us sigint'ing the program + GPIO.cleanup() + sys.exit(0) + except: + data = 0 + elif cmd == "rev": print GPIO.RPI_REVISION