diff --git a/package.json b/package.json index b68208e78..92bc8020d 100644 --- a/package.json +++ b/package.json @@ -54,12 +54,9 @@ "mqtt": "2.18.8", "multer": "1.4.1", "mustache": "3.0.1", - "node-red-node-email": "^1.6.2", - "node-red-node-feedparser": "^0.1.14", "node-red-node-rbe": "^0.2.4", "node-red-node-sentiment": "^0.1.3", "node-red-node-tail": "^0.0.2", - "node-red-node-twitter": "^1.1.5", "nopt": "4.0.1", "oauth2orize": "1.11.0", "on-headers": "1.0.2", @@ -112,7 +109,7 @@ "wdio-mocha-framework": "^0.6.4", "wdio-spec-reporter": "^0.1.5", "webdriverio": "^4.14.1", - "node-red-node-test-helper": "^0.2.2", + "node-red-node-test-helper": "^0.2.3", "jsdoc-nr-template": "node-red/jsdoc-nr-template" }, "engines": { diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 62949efce..63027aed1 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -17,6 +17,8 @@ RED.nodes = (function() { var node_defs = {}; var nodes = []; + var nodeTabMap = {}; + var configNodes = {}; var links = []; var defaultWorkspace; @@ -213,6 +215,11 @@ RED.nodes = (function() { n.i = nextId+1; } nodes.push(n); + if (nodeTabMap[n.z]) { + nodeTabMap[n.z][n.id] = n; + } else { + console.warn("Node added to unknown tab/subflow:",n); + } } RED.events.emit('nodes:add',n); } @@ -246,6 +253,9 @@ RED.nodes = (function() { node = getNode(id); if (node) { nodes.splice(nodes.indexOf(node),1); + if (nodeTabMap[node.z]) { + delete nodeTabMap[node.z][node.id]; + } removedLinks = links.filter(function(l) { return (l.source === node) || (l.target === node); }); removedLinks.forEach(function(l) {links.splice(links.indexOf(l), 1); }); var updatedConfigNode = false; @@ -300,6 +310,8 @@ RED.nodes = (function() { function addWorkspace(ws,targetIndex) { workspaces[ws.id] = ws; + nodeTabMap[ws.id] = {}; + ws._def = RED.nodes.getType('tab'); if (targetIndex === undefined) { workspacesOrder.push(ws.id); @@ -312,6 +324,7 @@ RED.nodes = (function() { } function removeWorkspace(id) { delete workspaces[id]; + delete nodeTabMap[ws.id]; workspacesOrder.splice(workspacesOrder.indexOf(id),1); var removedNodes = []; @@ -357,6 +370,8 @@ RED.nodes = (function() { sf.name = subflowName; } subflows[sf.id] = sf; + nodeTabMap[sf.id] = {}; + RED.nodes.registerType("subflow:"+sf.id, { defaults:{ name:{value:""}, @@ -393,6 +408,7 @@ RED.nodes = (function() { } function removeSubflow(sf) { delete subflows[sf.id]; + delete nodeTabMap[sf.id]; registry.removeNodeType("subflow:"+sf.id); } @@ -1266,12 +1282,13 @@ RED.nodes = (function() { // TODO: supports filter.z|type function filterNodes(filter) { var result = []; + var searchSet = nodes; + if (filter.hasOwnProperty("z") && Object.hasOwnProperty("values") && nodeTabMap.hasOwnProperty(filter.z) ) { + searchSet = Object.values(nodeTabMap[filter.z]); + } - for (var n=0;n - .rpi-gpio-pinTable { - width: 340px; - display: inline-table; - font-size: 13px; - height: 380px; - min-height: 380px; - max-height: 380px; - } - .rpi-gpio-pinTable input[type="radio"] { - width: auto; - margin: 2px 2px; - } - .rpi-gpio-pinTable label { - width: auto; - margin: 0; - display: block; - } - .rpi-gpio-pinTable .pinTableBody { - width: 340px; - display: table-row-group; - line-height: 12px; - } - .rpi-gpio-pinTable .pinTableRow { - width: 340px; - display: table-row; - height: 14px; - } - .rpi-gpio-pinTable .pinTableCellL { - width: 170px; - display: table-cell; - text-align: right; - padding-right: 4px; - vertical-align: top; - border: 1px solid #444; - } - .rpi-gpio-pinTable .pinTableCellR { - width: 170px; - display: table-cell; - text-align: left; - padding-left: 4px; - vertical-align: top; - border: 1px solid #000; - } - .rpi-gpio-pinTable .pinColorPower { - background-color:#FECBCE; - } - .rpi-gpio-pinTable .pinColorGround { - background-color:#DDDDDD; - } - .rpi-gpio-pinTable .pinColorGPIO { - background-color:#BFEBBF; - } - .rpi-gpio-pinTable .pinColorDual { - background-color:#D0E6F4; - } - .rpi-gpio-pinTable .pinColorSD { - background-color:#FFFDD0; - } - - - - - - - - - - - - - - - - diff --git a/packages/node_modules/@node-red/nodes/core/hardware/36-rpi-gpio.js b/packages/node_modules/@node-red/nodes/core/hardware/36-rpi-gpio.js deleted file mode 100644 index 9afcd40dd..000000000 --- a/packages/node_modules/@node-red/nodes/core/hardware/36-rpi-gpio.js +++ /dev/null @@ -1,371 +0,0 @@ - -module.exports = function(RED) { - "use strict"; - var exec = require('child_process').exec; - var spawn = require('child_process').spawn; - var fs = require('fs'); - - var gpioCommand = __dirname+'/nrgpio'; - var allOK = true; - - try { - var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString(); - if (cpuinfo.indexOf(": BCM") === -1) { - allOK = false; - RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.ignorenode")); - } - try { - fs.statSync("/usr/share/doc/python-rpi.gpio"); // test on Raspbian - // /usr/lib/python2.7/dist-packages/RPi/GPIO - } catch(err) { - try { - fs.statSync("/usr/lib/python2.7/site-packages/RPi/GPIO"); // test on Arch - } catch(err) { - try { - fs.statSync("/usr/lib/python2.7/dist-packages/RPi/GPIO"); // test on Hypriot - } catch(err) { - try { - fs.statSync("/usr/local/lib/python2.7/dist-packages/RPi/GPIO"); // installed with pip - } catch(err) { - RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.libnotfound")); - allOK = false; - } - } - } - } - if ( !(1 & parseInt((fs.statSync(gpioCommand).mode & parseInt("777", 8)).toString(8)[0]) )) { - RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.needtobeexecutable",{command:gpioCommand})); - allOK = false; - } - } catch(err) { - allOK = false; - RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.ignorenode")); - } - - // the magic to make python print stuff immediately - process.env.PYTHONUNBUFFERED = 1; - - var pinsInUse = {}; - var pinTypes = {"out":RED._("rpi-gpio.types.digout"), "tri":RED._("rpi-gpio.types.input"), "up":RED._("rpi-gpio.types.pullup"), "down":RED._("rpi-gpio.types.pulldown"), "pwm":RED._("rpi-gpio.types.pwmout")}; - - function GPIOInNode(n) { - RED.nodes.createNode(this,n); - this.buttonState = -1; - this.pin = n.pin; - this.intype = n.intype; - this.read = n.read || false; - this.debounce = Number(n.debounce || 25); - if (this.read) { this.buttonState = -2; } - var node = this; - if (!pinsInUse.hasOwnProperty(this.pin)) { - pinsInUse[this.pin] = this.intype; - } - else { - if ((pinsInUse[this.pin] !== this.intype)||(pinsInUse[this.pin] === "pwm")) { - node.warn(RED._("rpi-gpio.errors.alreadyset",{pin:this.pin,type:pinTypes[pinsInUse[this.pin]]})); - } - } - - if (allOK === true) { - if (node.pin !== undefined) { - node.child = spawn(gpioCommand, ["in",node.pin,node.intype,node.debounce]); - node.running = true; - node.status({fill:"green",shape:"dot",text:"common.status.ok"}); - - node.child.stdout.on('data', function (data) { - var d = data.toString().trim().split("\n"); - for (var i = 0; i < d.length; i++) { - if (d[i] === '') { return; } - if (node.running && node.buttonState !== -1 && !isNaN(Number(d[i])) && node.buttonState !== d[i]) { - node.send({ topic:"pi/"+node.pin, payload:Number(d[i]) }); - } - node.buttonState = d[i]; - node.status({fill:"green",shape:"dot",text:d[i]}); - if (RED.settings.verbose) { node.log("out: "+d[i]+" :"); } - } - }); - - node.child.stderr.on('data', function (data) { - if (RED.settings.verbose) { node.log("err: "+data+" :"); } - }); - - node.child.on('close', function (code) { - node.running = false; - node.child = null; - if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); } - if (node.done) { - node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"}); - node.done(); - } - else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); } - }); - - node.child.on('error', function (err) { - if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); } - else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); } - else { node.error(RED._("rpi-gpio.errors.error",{error:err.errno})) } - }); - - } - else { - node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin); - } - } - else { - node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"}); - if (node.read === true) { - var val; - if (node.intype == "up") { val = 1; } - if (node.intype == "down") { val = 0; } - setTimeout(function(){ - node.send({ topic:"pi/"+node.pin, payload:val }); - node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:val})}); - },250); - } - } - - node.on("close", function(done) { - node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"}); - delete pinsInUse[node.pin]; - if (node.child != null) { - node.done = done; - node.child.stdin.write("close "+node.pin); - node.child.kill('SIGKILL'); - } - else { done(); } - }); - } - RED.nodes.registerType("rpi-gpio in",GPIOInNode); - - function GPIOOutNode(n) { - RED.nodes.createNode(this,n); - this.pin = n.pin; - this.set = n.set || false; - this.level = n.level || 0; - this.freq = n.freq || 100; - this.out = n.out || "out"; - var node = this; - if (!pinsInUse.hasOwnProperty(this.pin)) { - pinsInUse[this.pin] = this.out; - } - else { - if ((pinsInUse[this.pin] !== this.out)||(pinsInUse[this.pin] === "pwm")) { - node.warn(RED._("rpi-gpio.errors.alreadyset",{pin:this.pin,type:pinTypes[pinsInUse[this.pin]]})); - } - } - - function inputlistener(msg) { - if (msg.payload === "true") { msg.payload = true; } - if (msg.payload === "false") { msg.payload = false; } - var out = Number(msg.payload); - var limit = 1; - if (node.out === "pwm") { limit = 100; } - if ((out >= 0) && (out <= limit)) { - if (RED.settings.verbose) { node.log("out: "+out); } - if (node.child !== null) { - node.child.stdin.write(out+"\n"); - node.status({fill:"green",shape:"dot",text:msg.payload.toString()}); - } - else { - node.error(RED._("rpi-gpio.errors.pythoncommandnotfound"),msg); - node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.not-running"}); - } - } - else { node.warn(RED._("rpi-gpio.errors.invalidinput")+": "+out); } - } - - if (allOK === true) { - if (node.pin !== undefined) { - if (node.set && (node.out === "out")) { - node.child = spawn(gpioCommand, [node.out,node.pin,node.level]); - node.status({fill:"green",shape:"dot",text:node.level}); - } else { - node.child = spawn(gpioCommand, [node.out,node.pin,node.freq]); - node.status({fill:"green",shape:"dot",text:"common.status.ok"}); - } - node.running = true; - - node.on("input", inputlistener); - - node.child.stdout.on('data', function (data) { - if (RED.settings.verbose) { node.log("out: "+data+" :"); } - }); - - node.child.stderr.on('data', function (data) { - if (RED.settings.verbose) { node.log("err: "+data+" :"); } - }); - - node.child.on('close', function (code) { - node.child = null; - node.running = false; - if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); } - if (node.done) { - node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"}); - node.done(); - } - else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); } - }); - - node.child.on('error', function (err) { - if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); } - else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); } - else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); } - }); - - } - else { - node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin); - } - } - else { - node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"}); - node.on("input", function(msg){ - node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:msg.payload.toString()})}); - }); - } - - node.on("close", function(done) { - node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"}); - delete pinsInUse[node.pin]; - if (node.child != null) { - node.done = done; - node.child.stdin.write("close "+node.pin); - node.child.kill('SIGKILL'); - } - else { done(); } - }); - - } - RED.nodes.registerType("rpi-gpio out",GPIOOutNode); - - function PiMouseNode(n) { - RED.nodes.createNode(this,n); - this.butt = n.butt || 7; - var node = this; - - if (allOK === true) { - node.child = spawn(gpioCommand+".py", ["mouse",node.butt]); - node.status({fill:"green",shape:"dot",text:"common.status.ok"}); - - node.child.stdout.on('data', function (data) { - data = Number(data); - if (data !== 0) { node.send({ topic:"pi/mouse", button:data, payload:1 }); } - else { node.send({ topic:"pi/mouse", button:data, payload:0 }); } - }); - - node.child.stderr.on('data', function (data) { - if (RED.settings.verbose) { node.log("err: "+data+" :"); } - }); - - node.child.on('close', function (code) { - node.child = null; - node.running = false; - if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); } - if (node.done) { - node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"}); - node.done(); - } - else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); } - }); - - node.child.on('error', function (err) { - if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); } - else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); } - else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); } - }); - - node.on("close", function(done) { - node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"}); - if (node.child != null) { - node.done = done; - node.child.kill('SIGINT'); - node.child = null; - } - else { done(); } - }); - } - else { - node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"}); - } - } - RED.nodes.registerType("rpi-mouse",PiMouseNode); - - function PiKeyboardNode(n) { - RED.nodes.createNode(this,n); - var node = this; - - if (allOK === true) { - node.child = spawn(gpioCommand+".py", ["kbd","0"]); - node.status({fill:"green",shape:"dot",text:"common.status.ok"}); - - node.child.stdout.on('data', function (data) { - var b = data.toString().trim().split(","); - var act = "up"; - if (b[1] === "1") { act = "down"; } - if (b[1] === "2") { act = "repeat"; } - node.send({ topic:"pi/key", payload:Number(b[0]), action:act }); - }); - - node.child.stderr.on('data', function (data) { - if (RED.settings.verbose) { node.log("err: "+data+" :"); } - }); - - node.child.on('close', function (code) { - node.running = false; - node.child = null; - if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); } - if (node.done) { - node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"}); - node.done(); - } - else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); } - }); - - node.child.on('error', function (err) { - if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); } - else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); } - else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); } - }); - - node.on("close", function(done) { - node.status({}); - if (node.child != null) { - node.done = done; - node.child.kill('SIGINT'); - node.child = null; - } - else { done(); } - }); - } - else { - node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"}); - } - } - RED.nodes.registerType("rpi-keyboard",PiKeyboardNode); - - var pitype = { type:"" }; - if (allOK === true) { - exec(gpioCommand+" info", function(err,stdout,stderr) { - if (err) { - RED.log.info(RED._("rpi-gpio.errors.version")); - } - else { - try { - var info = JSON.parse( stdout.trim().replace(/\'/g,"\"") ); - pitype.type = info["TYPE"]; - } - catch(e) { - RED.log.info(RED._("rpi-gpio.errors.sawpitype"),stdout.trim()); - } - } - }); - } - - RED.httpAdmin.get('/rpi-gpio/:id', RED.auth.needsPermission('rpi-gpio.read'), function(req,res) { - res.json(pitype); - }); - - RED.httpAdmin.get('/rpi-pins/:id', RED.auth.needsPermission('rpi-gpio.read'), function(req,res) { - res.json(pinsInUse); - }); -} diff --git a/packages/node_modules/@node-red/nodes/core/hardware/nrgpio b/packages/node_modules/@node-red/nodes/core/hardware/nrgpio deleted file mode 100755 index d81fcf443..000000000 --- a/packages/node_modules/@node-red/nodes/core/hardware/nrgpio +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright JS Foundation and other contributors, http://js.foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -BASEDIR=$(dirname $0) -python -u $BASEDIR/nrgpio.py $@ diff --git a/packages/node_modules/@node-red/nodes/core/hardware/nrgpio.py b/packages/node_modules/@node-red/nodes/core/hardware/nrgpio.py deleted file mode 100755 index 7908ca117..000000000 --- a/packages/node_modules/@node-red/nodes/core/hardware/nrgpio.py +++ /dev/null @@ -1,239 +0,0 @@ -#!/usr/bin/python -# -# Copyright JS Foundation and other contributors, http://js.foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Import library functions we need -import RPi.GPIO as GPIO -import struct -import sys -import os -import subprocess -from time import sleep - -try: - raw_input # Python 2 -except NameError: - raw_input = input # Python 3 - -bounce = 25 - -if len(sys.argv) > 2: - cmd = sys.argv[1].lower() - pin = int(sys.argv[2]) - GPIO.setmode(GPIO.BOARD) - GPIO.setwarnings(False) - - if cmd == "pwm": - #print("Initialised pin "+str(pin)+" to PWM") - try: - freq = int(sys.argv[3]) - except: - freq = 100 - - GPIO.setup(pin,GPIO.OUT) - p = GPIO.PWM(pin, freq) - p.start(0) - - while True: - try: - data = raw_input() - if 'close' in data: - sys.exit(0) - p.ChangeDutyCycle(float(data)) - except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program - GPIO.cleanup(pin) - sys.exit(0) - except Exception as ex: - print("bad data: "+data) - - elif cmd == "buzz": - #print("Initialised pin "+str(pin)+" to Buzz") - GPIO.setup(pin,GPIO.OUT) - p = GPIO.PWM(pin, 100) - p.stop() - - while True: - try: - data = raw_input() - if 'close' in data: - sys.exit(0) - elif float(data) == 0: - p.stop() - else: - p.start(50) - p.ChangeFrequency(float(data)) - except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program - GPIO.cleanup(pin) - sys.exit(0) - except Exception as ex: - print("bad data: "+data) - - elif cmd == "out": - #print("Initialised pin "+str(pin)+" to OUT") - GPIO.setup(pin,GPIO.OUT) - if len(sys.argv) == 4: - GPIO.output(pin,int(sys.argv[3])) - - while True: - try: - data = raw_input() - if 'close' in data: - sys.exit(0) - data = int(data) - except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program - GPIO.cleanup(pin) - sys.exit(0) - except: - if len(sys.argv) == 4: - data = int(sys.argv[3]) - else: - data = 0 - if data != 0: - data = 1 - GPIO.output(pin,data) - - elif cmd == "in": - #print("Initialised pin "+str(pin)+" to IN") - bounce = float(sys.argv[4]) - def handle_callback(chan): - sleep(bounce/1000.0) - print(GPIO.input(chan)) - - if sys.argv[3].lower() == "up": - GPIO.setup(pin,GPIO.IN,GPIO.PUD_UP) - elif sys.argv[3].lower() == "down": - GPIO.setup(pin,GPIO.IN,GPIO.PUD_DOWN) - else: - GPIO.setup(pin,GPIO.IN) - - print(GPIO.input(pin)) - GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=int(bounce)) - - while True: - try: - data = raw_input() - if 'close' in data: - sys.exit(0) - except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program - GPIO.cleanup(pin) - sys.exit(0) - - elif cmd == "byte": - #print("Initialised BYTE mode - "+str(pin)+) - list = [7,11,13,12,15,16,18,22] - GPIO.setup(list,GPIO.OUT) - - while True: - try: - data = raw_input() - if 'close' in data: - sys.exit(0) - data = int(data) - except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program - GPIO.cleanup() - sys.exit(0) - except: - data = 0 - for bit in range(8): - if pin == 1: - mask = 1 << (7 - bit) - else: - 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 'close' in data: - sys.exit(0) - c = data.split(",") - r.ChangeDutyCycle(float(c[0])) - g.ChangeDutyCycle(float(c[1])) - b.ChangeDutyCycle(float(c[2])) - except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program - GPIO.cleanup() - sys.exit(0) - except: - data = 0 - - elif cmd == "mouse": # catch mice button events - file = open( "/dev/input/mice", "rb" ) - oldbutt = 0 - - def getMouseEvent(): - global oldbutt - global pin - buf = file.read(3) - pin = pin & 0x07 - button = ord( buf[0] ) & pin # mask out just the required button(s) - if button != oldbutt: # only send if changed - oldbutt = button - print(button) - - while True: - try: - getMouseEvent() - except: - file.close() - sys.exit(0) - - elif cmd == "kbd": # catch keyboard button events - try: - while not os.path.isdir("/dev/input/by-path"): - sleep(10) - infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip() - infile_path = "/dev/input/by-path/" + infile - EVENT_SIZE = struct.calcsize('llHHI') - file = open(infile_path, "rb") - event = file.read(EVENT_SIZE) - while event: - (tv_sec, tv_usec, type, code, value) = struct.unpack('llHHI', event) - #if type != 0 or code != 0 or value != 0: - if type == 1: - # type,code,value - print("%u,%u" % (code, value)) - event = file.read(EVENT_SIZE) - print("0,0") - file.close() - sys.exit(0) - except: - file.close() - sys.exit(0) - -elif len(sys.argv) > 1: - cmd = sys.argv[1].lower() - if cmd == "rev": - print(GPIO.RPI_REVISION) - elif cmd == "ver": - print(GPIO.VERSION) - elif cmd == "info": - print(GPIO.RPI_INFO) - else: - print("Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}") - print(" only ver (gpio version) and info (board information) accept no pin parameter.") - -else: - print("Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}") diff --git a/packages/node_modules/@node-red/nodes/locales/de/hardware/36-rpi-gpio.html b/packages/node_modules/@node-red/nodes/locales/de/hardware/36-rpi-gpio.html deleted file mode 100755 index a696225c3..000000000 --- a/packages/node_modules/@node-red/nodes/locales/de/hardware/36-rpi-gpio.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - diff --git a/packages/node_modules/@node-red/nodes/locales/de/messages.json b/packages/node_modules/@node-red/nodes/locales/de/messages.json index 3094d8541..acf0447c4 100755 --- a/packages/node_modules/@node-red/nodes/locales/de/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/de/messages.json @@ -729,78 +729,6 @@ "xml_js" : "Dieser Node verarbeitet nur XML-Zeichenfolgen oder JS-Objekte." } }, - "rpi-gpio" : { - "label" : { - "gpiopin" : "GPIO", - "selectpin" : "Auswahlstift", - "resistor" : "Widerstand?", - "readinitial" : "Anfangsstatus des Pins bei Implementierung/Neustart lesen?", - "type" : "Typ", - "initpin" : "Pin-Status initialisieren?", - "debounce" : "Debounce", - "freq" : "Frequenz", - "button" : "Knopf", - "pimouse" : "Pi-Maus", - "pikeyboard" : "Pi-Tastatur", - "left" : "Links", - "right" : "Rechts", - "middle" : "Mitte" - }, - "resistor" : { - "none" : "keine", - "pullup" : "pullup", - "pulldown" : "Pulldown" - }, - "digout" : "Digitale Ausgabe", - "pwmout" : "PWM-Ausgabe", - "servo" : "Servo-Ausgabe", - "initpin0" : "Anfangsstand des Pin-Niedrig (0)", - "initpin1" : "Anfangsebene von Pin-High (1)", - "left" : "links", - "right" : "rechts", - "middle" : "Mitte", - "any" : "beliebig", - "pinname" : "Pin", - "alreadyuse" : "bereits im Gebrauch", - "alreadyset" : "bereits festgelegt als", - "tip" : { - "pin" : " Verwender Pins : ", - "in" : "Tipp: Es wird nur die digitale Eingabe unterstützt. Die Eingabe muss 0 oder 1 sein.", - "dig" : "Tipp: Für die digitale Ausgabe muss der Wert 0 oder 1 sein.", - "pwm" : "Tipp: Für die PWM-Ausgabe muss der Wert zwischen 0 und 100 liegen; die Einstellung der Hochfrequenz kann mehr CPU beanspruchen als erwartet.", - "ser" : " Tipp : Für die Servo-Ausgabe muss ein Wert zwischen 0 und 100 eingegeben werden. 50 ist das Zentrum." - }, - "types" : { - "digout" : "digitale Ausgabe", - "input" : "Eingabe", - "pullup" : "Eingabe mit Pull-up", - "pulldown" : "Eingabe mit Pull-down", - "pwmout" : "PWM-Ausgabe", - "servo" : "Servo-Ausgabe" - }, - "status" : { - "stopped" : "Gestoppt", - "closed" : "geschlossen", - "not-running" : "nicht aktiv", - "not-available" : "nicht verfügbar", - "na" : "N/A: __Wert__" - }, - "errors" : { - "ignorenode" : "Raspberry Pi-spezifische Nodes inaktiv", - "version" : "Abrufen der Version von Pi fehlgeschlagen", - "sawpitype" : "Saw-Pi-Typ", - "libnotfound" : "Pi RPi.GPIO-Python-Bibliothek nicht gefunden", - "alreadyset" : "GPIO-Stift __pin__ ist bereits als Typ festgelegt: __type__", - "invalidpin" : "Ungültiger GPIO-Pin", - "invalidinput" : "Ungültige Eingabe", - "needtobeexecutable" : "__command__ muss ausführbar sein", - "mustbeexecutable" : "nrgpio muss ausführbar sein", - "commandnotfound" : "Befehl 'nrgpio' nicht gefunden", - "commandnotexecutable" : "nrgpio-Befehl nicht ausführbar", - "error" : "Fehler: __error__", - "pythoncommandnotfound" : "Befehl 'nrpgio python' nicht aktiv" - } - }, "tail" : { "tail" : "Tail", "label" : { diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/hardware/36-rpi-gpio.html b/packages/node_modules/@node-red/nodes/locales/en-US/hardware/36-rpi-gpio.html deleted file mode 100644 index 0eecc5ec6..000000000 --- a/packages/node_modules/@node-red/nodes/locales/en-US/hardware/36-rpi-gpio.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json index 76e1cf2f8..40baea337 100755 --- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json @@ -774,78 +774,6 @@ "xml_js": "This node only handles xml strings or js objects." } }, - "rpi-gpio": { - "label": { - "gpiopin": "GPIO", - "selectpin": "select pin", - "resistor": "Resistor?", - "readinitial": "Read initial state of pin on deploy/restart?", - "type": "Type", - "initpin": "Initialise pin state?", - "debounce": "Debounce", - "freq": "Frequency", - "button": "Button", - "pimouse": "Pi Mouse", - "pikeyboard": "Pi Keyboard", - "left": "Left", - "right": "Right", - "middle": "Middle" - }, - "resistor": { - "none": "none", - "pullup": "pullup", - "pulldown": "pulldown" - }, - "digout": "Digital output", - "pwmout": "PWM output", - "servo": "Servo output", - "initpin0": "initial level of pin - low (0)", - "initpin1": "initial level of pin - high (1)", - "left": "left", - "right": "right", - "middle": "middle", - "any": "any", - "pinname": "Pin", - "alreadyuse": "already in use", - "alreadyset": "already set as", - "tip": { - "pin": "Pins in Use: ", - "in": "Tip: Only Digital Input is supported - input must be 0 or 1.", - "dig": "Tip: For digital output - input must be 0 or 1.", - "pwm": "Tip: For PWM output - input must be between 0 to 100; setting high frequency might occupy more CPU than expected.", - "ser": "Tip: For Servo output - input must be between 0 to 100. 50 is centre." - }, - "types": { - "digout": "digital output", - "input": "input", - "pullup": "input with pull up", - "pulldown": "input with pull down", - "pwmout": "PWM output", - "servo": "Servo output" - }, - "status": { - "stopped": "stopped", - "closed": "closed", - "not-running": "not running", - "not-available": "not available", - "na": "N/A : __value__" - }, - "errors": { - "ignorenode": "Raspberry Pi specific node set inactive", - "version": "Failed to get version from Pi", - "sawpitype": "Saw Pi Type", - "libnotfound": "Cannot find Pi RPi.GPIO python library", - "alreadyset": "GPIO pin __pin__ already set as type: __type__", - "invalidpin": "Invalid GPIO pin", - "invalidinput": "Invalid input", - "needtobeexecutable": "__command__ needs to be executable", - "mustbeexecutable": "nrgpio must to be executable", - "commandnotfound": "nrgpio command not found", - "commandnotexecutable": "nrgpio command not executable", - "error": "error: __error__", - "pythoncommandnotfound": "nrpgio python command not running" - } - }, "file": { "label": { "filename": "Filename", diff --git a/packages/node_modules/@node-red/nodes/locales/ja/hardware/36-rpi-gpio.html b/packages/node_modules/@node-red/nodes/locales/ja/hardware/36-rpi-gpio.html deleted file mode 100644 index c84f5c136..000000000 --- a/packages/node_modules/@node-red/nodes/locales/ja/hardware/36-rpi-gpio.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - diff --git a/packages/node_modules/@node-red/nodes/locales/ja/messages.json b/packages/node_modules/@node-red/nodes/locales/ja/messages.json index 562deb332..ef899908e 100755 --- a/packages/node_modules/@node-red/nodes/locales/ja/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/ja/messages.json @@ -768,78 +768,6 @@ "xml_js": "本ノードは、XML形式の文字列またはJSONのみ処理します" } }, - "rpi-gpio": { - "label": { - "gpiopin": "GPIO", - "selectpin": "端子の選択", - "resistor": "抵抗", - "readinitial": "デプロイや再起動時に端子の初期状態を読み込む", - "type": "出力形式", - "initpin": "端子の状態を初期化", - "debounce": "デバウンス", - "freq": "頻度", - "button": "ボタン", - "pimouse": "Pi Mouse", - "pikeyboard": "Pi Keyboard", - "left": "Left", - "right": "Right", - "middle": "Middle" - }, - "resistor": { - "none": "なし", - "pullup": "プルアップ", - "pulldown": "プルダウン" - }, - "digout": "デジタル出力", - "pwmout": "PWM出力", - "servo": "サーボ出力", - "initpin0": "端子の初期レベル - Low (0)", - "initpin1": "端子の初期レベル - High (1)", - "left": "左", - "right": "右", - "middle": "中間", - "any": "全て", - "pinname": "端子", - "alreadyuse": "使用中", - "alreadyset": "設定済", - "tip": { - "pin": "使用中の端子: ", - "in": "注釈: 入力値は、0または1の数値のみ対応しています。", - "dig": "注釈: 「出力形式」として「デジタル出力」を用いる場合、入力値は0または1の数値である必要があります。", - "pwm": "注釈: 「出力形式」として「PWM出力」を用いる場合、入力値は0~100の数値である必要があります。", - "ser": "注釈: サーボ出力向け - 入力値は0~100の間である必要があります。50が中心値です。" - }, - "types": { - "digout": "デジタル出力", - "input": "入力", - "pullup": "プルアップの入力", - "pulldown": "プルダウンの入力", - "pwmout": "PWM出力", - "servo": "サーボ出力" - }, - "status": { - "stopped": "停止", - "closed": "切断", - "not-running": "停止中", - "not-available": "利用不可", - "na": "N/A : __value__" - }, - "errors": { - "ignorenode": "Raspberry Pi固有のノードを無視しました", - "version": "バージョンコマンドが失敗しました", - "sawpitype": "Saw Pi Type", - "libnotfound": "RPi.GPIO pythonライブラリを見つけられませんでした", - "alreadyset": "GPIO端子 __pin__ は既に出力形式が設定されています: __type__", - "invalidpin": "GPIO端子が不正です", - "invalidinput": "入力が不正です", - "needtobeexecutable": "__command__ は実行可能である必要があります", - "mustbeexecutable": "nrgpio は実行可能である必要があります", - "commandnotfound": "nrgpio コマンドが見つかりません", - "commandnotexecutable": "nrgpio コマンドが実行可能ではありません", - "error": "エラー: __error__", - "pythoncommandnotfound": "nrpgio python コマンドが実行されていません" - } - }, "file": { "label": { "filename": "ファイル名", diff --git a/packages/node_modules/@node-red/nodes/locales/ko/hardware/36-rpi-gpio.html b/packages/node_modules/@node-red/nodes/locales/ko/hardware/36-rpi-gpio.html deleted file mode 100644 index dfcde83db..000000000 --- a/packages/node_modules/@node-red/nodes/locales/ko/hardware/36-rpi-gpio.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - diff --git a/packages/node_modules/@node-red/nodes/locales/ko/messages.json b/packages/node_modules/@node-red/nodes/locales/ko/messages.json index f2e555a1d..547b44f08 100755 --- a/packages/node_modules/@node-red/nodes/locales/ko/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/ko/messages.json @@ -774,78 +774,6 @@ "xml_js": "이 노드는, XML형식의 문자열 혹은 JSON만 처리합니다" } }, - "rpi-gpio": { - "label": { - "gpiopin": "GPIO", - "selectpin": "단자의 선택", - "resistor": "저항", - "readinitial": "배포나 재시작시에 단자의 초기상태를 불러옴", - "type": "출력형식", - "initpin": "단자의 상태를 초기화", - "debounce": "디바운스", - "freq": "빈도", - "button": "버튼", - "pimouse": "Pi Mouse", - "pikeyboard": "Pi Keyboard", - "left": "Left", - "right": "Right", - "middle": "Middle" - }, - "resistor": { - "none": "없음", - "pullup": "풀 업", - "pulldown": "풀 다운" - }, - "digout": "디지털 출력", - "pwmout": "PWM 출력", - "servo": "서보 출력", - "initpin0": "단자의 초기레벨 - Low (0)", - "initpin1": "단자의 초기레벨 - High (1)", - "left": "좌", - "right": "우", - "middle": "중간", - "any": "모두", - "pinname": "단자", - "alreadyuse": "사용중", - "alreadyset": "설정됨", - "tip": { - "pin": "사용중인 단자: ", - "in": "주석: 입력값은, 0 혹은 1의 수치만 대응하고 있습니다.", - "dig": "주석: ’출력형식’으로 ’디지털출력’을 사용하는 경우, 입력값은 0 혹은 1의 수치일 필요가 있습니다.", - "pwm": "주석: ’출력형식’으로 ’PWM출력’을 사용하는 경우, 입력값은 0~100의 수치일 필요가 있습니다.", - "ser": "주석: 서보 출력용 - 입력값은 0~100 사이일 필요가 있습니다. 50이 중심값입니다." - }, - "types": { - "digout": "디지털 출력", - "input": "입력", - "pullup": "풀 업 입력", - "pulldown": "풀 다운 입력", - "pwmout": "PWM 출력", - "servo": "서보 출력" - }, - "status": { - "stopped": "정지", - "closed": "절단", - "not-running": "정지중", - "not-available": "이용불가", - "na": "N/A : __value__" - }, - "errors": { - "ignorenode": "Raspberry Pi고유의 노드를 무시했습니다", - "version": "버젼커맨드에 실패했습니다", - "sawpitype": "Saw Pi Type", - "libnotfound": "RPi.GPIO python라이브러리를 발견하지 못했습니다", - "alreadyset": "GPIO단자 __pin__ 은 이미 출력형식이 설정되어 있습니다: __type__", - "invalidpin": "GPIO단자가 올바르지 않습니다", - "invalidinput": "입력이 올바르지 않습니다", - "needtobeexecutable": "__command__ 은 실행가능상태일 필요가 있습니다 ", - "mustbeexecutable": "nrgpio 은 실행가능상태일 필요가 있습니다 ", - "commandnotfound": "nrgpio 커맨드를 찾을수 없습니다", - "commandnotexecutable": "nrgpio 커맨드가 실행가능상태가 아닙니다", - "error": "에러: __error__", - "pythoncommandnotfound": "nrpgio python 커맨드가 실행되지 않았습니다" - } - }, "file": { "label": { "filename": "파일명", diff --git a/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json b/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json index 2b25a02d8..9202bb3a7 100644 --- a/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json @@ -702,76 +702,6 @@ "xml_js": "此节点仅处理XML字符串或JS对象." } }, - "rpi-gpio": { - "label": { - "gpiopin": "GPIO", - "selectpin": "选择引脚", - "resistor": "电阻?", - "readinitial": "在部署/重启时读取引脚的初始状态?", - "type": "类型", - "initpin": "初始化引脚状态?", - "debounce": "去抖动", - "freq": "频率", - "button": "按钮", - "pimouse": "Pi鼠标", - "pikeyboard": "Pi键盘", - "left": "左", - "right": "右", - "middle": "中" - }, - "resistor": { - "none": "无", - "pullup": "上拉电阻", - "pulldown": "下拉电阻" - }, - "digout": "数字输出", - "pwmout": "PWM输出", - "servo": "伺服输出", - "initpin0": "初始引脚电平 - 低(0)", - "initpin1": "初始引脚电平 - 高(1)", - "left": "左", - "right": "右", - "middle": "中", - "any": "任何", - "pinname": "引脚", - "alreadyuse": "已被使用", - "alreadyset": "已被设为", - "tip": { - "pin": "正在使用引脚: ", - "in": "提示: 仅接受数字输入 - 输出必须为0或1.", - "dig": "提示: 如用数字输出 - 输入必须为0或1.", - "pwm": "提示: 如用PWM输出 - 输入必须为0至100之间; 如用高频率可能会比预期占用更多CPU资源.", - "ser": "提示: 如用伺服输出 - 输入必须为0至100之间. 50为中间值." - }, - "types": { - "digout": "数字输出", - "input": "输入", - "pullup": "含有上拉电阻的输入", - "pulldown": "含有下拉电阻的输入", - "pwmout": "PWM输出", - "servo": "伺服输出" - }, - "status": { - "stopped": "已停止", - "closed": "已关闭", - "not-running": "不运行" - }, - "errors": { - "ignorenode": "忽略树莓派的特定节点", - "version": "版本命令失败", - "sawpitype": "查看Pi类型", - "libnotfound": "找不到树莓派RPi.GPIO的python库", - "alreadyset": "GPIO引脚 __pin__ 已经被设定为类型: __type__", - "invalidpin": "无效GPIO引脚", - "invalidinput": "无效输入", - "needtobeexecutable": "__command__须为可运行命令", - "mustbeexecutable": "nrgpio须为可运行", - "commandnotfound": "nrgpio命令不存在", - "commandnotexecutable": "nrgpio命令不可运行", - "error": "错误: __error__", - "pythoncommandnotfound": "nrpgio python命令未处于运行状态" - } - }, "file": { "label": { "filename": "文件名", diff --git a/packages/node_modules/@node-red/registry/lib/deprecated.js b/packages/node_modules/@node-red/registry/lib/deprecated.js index 6818c4969..942429971 100644 --- a/packages/node_modules/@node-red/registry/lib/deprecated.js +++ b/packages/node_modules/@node-red/registry/lib/deprecated.js @@ -50,7 +50,12 @@ var nodes = { "sentiment": {module:"node-red-node-sentiment"}, - "tail": {module:"node-red-node-tail"} + "tail": {module:"node-red-node-tail"}, + + "rpi-gpio in": {module:"node-red-node-pi-gpio"}, + "rpi-gpio out": {module:"node-red-node-pi-gpio"}, + "rpi-mouse": {module:"node-red-node-pi-gpio"}, + "rpi-keyboard": {module:"node-red-node-pi-gpio"} } module.exports = { diff --git a/packages/node_modules/node-red/package.json b/packages/node_modules/node-red/package.json index 4ff73131f..6cfc0fa36 100644 --- a/packages/node_modules/node-red/package.json +++ b/packages/node_modules/node-red/package.json @@ -39,12 +39,9 @@ "bcryptjs": "2.4.3", "express": "4.17.1", "fs-extra": "8.1.0", - "node-red-node-email": "^1.6.2", - "node-red-node-feedparser": "^0.1.14", "node-red-node-rbe": "^0.2.4", "node-red-node-sentiment": "^0.1.3", "node-red-node-tail": "^0.0.2", - "node-red-node-twitter": "^1.1.5", "nopt": "4.0.1", "semver": "6.2.0" }, diff --git a/test/nodes/core/hardware/36-rpi-gpio_spec.js b/test/nodes/core/hardware/36-rpi-gpio_spec.js deleted file mode 100644 index 7c7fb1cd1..000000000 --- a/test/nodes/core/hardware/36-rpi-gpio_spec.js +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright JS Foundation and other contributors, http://js.foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -var should = require("should"); -var rpiNode = require("nr-test-utils").require("@node-red/nodes/core/hardware/36-rpi-gpio.js"); -var statusNode = require("nr-test-utils").require("@node-red/nodes/core/core/25-status.js"); -var helper = require("node-red-node-test-helper"); -var fs = require("fs"); - -describe('RPI GPIO Node', function() { - - before(function(done) { - helper.startServer(done); - }); - - after(function(done) { - helper.stopServer(done); - }); - - afterEach(function() { - helper.unload(); - }); - - var checkIgnore = function(done) { - setTimeout(function() { - try { - var logEvents = helper.log().args.filter(function(evt) { - return ((evt[0].level == 30) && (evt[0].msg.indexOf("rpi-gpio")===0)); - }); - logEvents[0][0].should.have.a.property('msg'); - logEvents[0][0].msg.toString().should.startWith("rpi-gpio : rpi-gpio.errors.ignorenode"); - done(); - } catch(err) { - done(err); - } - },25); - } - - it('should load Input node', function(done) { - var flow = [{id:"n1", type:"rpi-gpio in", name:"rpi-gpio in" }]; - helper.load(rpiNode, flow, function() { - var n1 = helper.getNode("n1"); - n1.should.have.property('name', 'rpi-gpio in'); - try { - var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString(); - if (cpuinfo.indexOf(": BCM") === 1) { - done(); // It's ON a PI ... should really do more tests ! - } else { - checkIgnore(done); - } - } - catch(e) { - checkIgnore(done); - } - }); - }); - - it('should load Output node', function(done) { - var flow = [{id:"n1", type:"rpi-gpio out", name:"rpi-gpio out" }]; - helper.load(rpiNode, flow, function() { - var n1 = helper.getNode("n1"); - n1.should.have.property('name', 'rpi-gpio out'); - try { - var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString(); - if (cpuinfo.indexOf(": BCM") === 1) { - done(); // It's ON a PI ... should really do more tests ! - } else { - checkIgnore(done); - } - } - catch(e) { - checkIgnore(done); - } - }); - }); - - - it('should read a dummy value high (not on Pi)', function(done) { - var flow = [{id:"n1", type:"rpi-gpio in", pin:"7", intype:"up", debounce:"25", read:true, wires:[["n2"]] }, - {id:"n2", type:"helper"}]; - helper.load(rpiNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - n2.on("input", function(msg) { - try { - msg.should.have.property('topic', 'pi/7'); - msg.should.have.property('payload', 1); - done(); - } catch(err) { - done(err); - } - }); - }); - }); - - it('should read a dummy value low (not on Pi)', function(done) { - var flow = [{id:"n1", type:"rpi-gpio in", pin:"11", intype:"down", debounce:"25", read:true, wires:[["n2"]] }, - {id:"n2", type:"helper"}]; - helper.load(rpiNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - n2.on("input", function(msg) { - try { - msg.should.have.property('topic', 'pi/11'); - msg.should.have.property('payload', 0); - done(); - } catch(err) { - done(err); - } - }); - }); - }); - - it('should be able preset out to a dummy value (not on Pi)', function(done) { - var flow = [{id:"n1", type:"rpi-gpio out", pin:"7", out:"out", level:"0", set:true, freq:"", wires:[], z:"1"}, - {id:"n2", type:"status", scope:null, wires:[["n3"]], z:"1"}, - {id:"n3", type:"helper", z:"1"}]; - helper.load([rpiNode,statusNode], flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - var n3 = helper.getNode("n3"); - var count = 0; - n3.on("input", function(msg) { - // Only check the first status message received as it may get a - // 'closed' status as the test is tidied up. - if (count === 0) { - count++; - try { - msg.should.have.property('status'); - msg.status.should.have.property('text', "rpi-gpio.status.na"); - done(); - } catch(err) { - done(err); - } - } - }); - n1.receive({payload:"1"}); - }); - }); - -});