Merge branch 'master' into i18n-de/help

This commit is contained in:
Dave Conway-Jones 2021-03-12 13:16:46 +00:00 committed by GitHub
commit aa18078b45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 208 additions and 47 deletions

View File

@ -11,7 +11,8 @@
"debounce": "Debounce",
"limits": "Limits",
"min": "min",
"max": "max"
"max": "max",
"freq": "Frequency"
},
"place": {
"host": "local or remote ip",
@ -33,7 +34,8 @@
"in": "Only Digital Input is supported - input must be 0 or 1.",
"dig": "Digital output - input must be 0 or 1.",
"pwm": "PWM output - input must be between 0 to 100.",
"ser": "Servo output - input must be between 0 to 100. 50 is centre.<br/>Min must be 500uS or more, Max must be 2500uS or less."
"ser": "Servo output - input must be between 0 to 100. 50 is centre.<br/>min. must be 500 µs or more, max. must be 2500 µs or less.",
"dual": "Pins marked in blue are dual use. Make sure they are not enabled for their other use before using as GPIO."
},
"types": {
"digout": "digital output",

View File

@ -164,8 +164,7 @@
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips"><span data-i18n="[html]pi-gpiod.tip.in"></span></div>
<div class="form-tips" id="pin-tip">Pins marked in blue are dual use. Make sure they are not enabled for
their other use before using as GPIO.</div>
<div class="form-tips" id="pin-tip"><span data-i18n="[html]pi-gpiod.tip.dual"></span></div>
</script>
<script type="text/javascript">
@ -367,9 +366,9 @@
</div>
<div class="form-row" id="node-set-minimax">
<label>&nbsp;&nbsp;&nbsp;&nbsp;<span data-i18n="pi-gpiod.label.limits"></label>
<span data-i18n="pi-gpiod.label.min"></span> <input type="text" id="node-input-sermin" style="width:70px;"> uS
<span data-i18n="pi-gpiod.label.min"></span> <input type="text" id="node-input-sermin" style="width:70px;"> us
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span data-i18n="pi-gpiod.label.max"></span> <input type="text" id="node-input-sermax" style="width:70px;"> uS
<span data-i18n="pi-gpiod.label.max"></span> <input type="text" id="node-input-sermax" style="width:70px;"> us
</div>
<div class="form-row" id="node-set-tick">
<label>&nbsp;</label>
@ -384,8 +383,8 @@
</select>
</div>
<div class="form-row" id="node-set-freq">
<label for="node-input-freq"> <span data-i18n="rpi-gpio.label.freq"></span></label>
Frequency: <select id="node-input-freq" style="width:80px;">
<label for="node-input-freq"> <span data-i18n="pi-gpiod.label.freq"></span></label>
<select id="node-input-freq" style="width:80px;">
<option value="8000">8000</option>
<option value="4000">4000</option>
<option value="2000">2000</option>
@ -417,8 +416,7 @@
<div class="form-tips" id="dig-tip"><span data-i18n="[html]pi-gpiod.tip.dig"></span></div>
<div class="form-tips" id="pwm-tip"><span data-i18n="[html]pi-gpiod.tip.pwm"></span></div>
<div class="form-tips" id="ser-tip"><span data-i18n="[html]pi-gpiod.tip.ser"></span></div>
<div class="form-tips" id="pin-tip">Pins marked in blue are dual use. Make sure they are not enabled for
their other use before using as GPIO.</div>
<div class="form-tips" id="pin-tip"><span data-i18n="[html]pi-gpiod.tip.dual"></span></div>
</script>
<script type="text/javascript">

View File

@ -4,6 +4,14 @@
<label for="node-input-host"><i class="fa fa-dot-circle-o"></i> <span data-i18n="ping.label.target"></span></label>
<input type="text" id="node-input-host" placeholder="192.168.0.1, www.google.com">
</div>
<div class="form-row">
<label for="node-protocol"><i class="fa fa-gear"></i> <span data-i18n="ping.label.protocol"></label>
<select type="text" id="node-input-protocol" style="width: 70%">
<option value="Automatic" data-i18n="ping.label.protocol_option.auto"></option>
<option value="IPv4" data-i18n="ping.label.protocol_option.ipv4"></option>
<option value="IPv6" data-i18n="ping.label.protocol_option.ipv6"></option>
</select>
</div>
<div class="form-row">
<label for="node-input-mode"><i class="fa fa-wrench"></i> <span data-i18n="ping.label.mode"></label>
<select type="text" id="node-input-mode" style="width: 70%">
@ -54,6 +62,7 @@ var timerParameterValidator = function(node,v){
category: "network-input",
color:"#fdf0c2",
defaults: {
protocol: {value:"Automatic"},
mode: {value:"timed"},
name: {value:""},
host: {value:"", validate: function(v){

View File

@ -6,7 +6,7 @@ module.exports = function(RED) {
function doPing(node, host, arrayMode) {
const defTimeout = 5000;
var ex, hostOptions, commandLineOptions;
var ex, ex6, hostOptions, commandLineOptions;
if (typeof host === "string") {
hostOptions = {
host: host,
@ -25,12 +25,33 @@ module.exports = function(RED) {
if (arrayMode) {
msg.ping = hostOptions
}
//User Selected Protocol
if (plat == "linux" || plat == "android") {
commandLineOptions = ["-n", "-w", timeoutS, "-c", "1"]
if (node.protocol === "IPv4") {
commandLineOptions = ["-n", "-4", "-w", timeoutS, "-c", "1"]; //IPv4
} else if (node.protocol === "IPv6") {
commandLineOptions = ["-n", "-6", "-w", timeoutS, "-c", "1"]; //IPv6
} else {
commandLineOptions = ["-n", "-w", timeoutS, "-c", "1"]; //Automatic
}
} else if (plat.match(/^win/)) {
commandLineOptions = ["-n", "1", "-w", hostOptions.timeout]
if (node.protocol === "IPv4") {
commandLineOptions = ["-n", "1", "-4", "-w", hostOptions.timeout]; //IPv4
} else if (node.protocol === "IPv6") {
commandLineOptions = ["-n", "1", "-6", "-w", hostOptions.timeout]; //IPv6
} else {
commandLineOptions = ["-n", "1", "-w", hostOptions.timeout]; //Automatic
}
} else if (plat == "darwin" || plat == "freebsd") {
commandLineOptions = ["-n", "-t", timeoutS, "-c", "1"]
if (node.protocol === "IPv4") {
commandLineOptions = ["-n", "-4", "-t", timeoutS, "-c", "1"]; //IPv4
} else if (node.protocol === "IPv6") {
commandLineOptions = ["-n", "-6", "-t", timeoutS, "-c", "1"]; //IPv6
} else {
commandLineOptions = ["-n", "-t", timeoutS, "-c", "1"]; //Automatic
}
} else {
node.error("Sorry - your platform - "+plat+" - is not recognised.", msg);
return; //dont pass go - just return!
@ -53,6 +74,23 @@ module.exports = function(RED) {
var fail = false;
//var regex = /from.*time.(.*)ms/;
var regex = /=.*[<|=]([0-9]*).*TTL|ttl..*=([0-9\.]*)/;
var tryPing6 = false;
//catch error msg from ping
ex.stderr.setEncoding('utf8');
ex.stderr.on("data", function (data) {
if (!data.includes('Usage')) { // !data: only get the error and not how to use the ping command
if (data.includes('invalid') && data.includes('6')) { //if IPv6 not supported in version of ping try ping6
tryPing6 = true;
//node.error(data, msg); // used for testing output of -6 on ping command. Keep this line untill out of beta testing please. Contact---> https://discourse.nodered.org/u/meeki007
} else if (data.includes('Network is unreachable')) {
node.error(data + " Please check that your service provider or network device has IPv6 enabled", msg);
} else {
node.error(data, msg);
}
}
});
ex.stdout.on("data", function (data) {
line += data.toString();
});
@ -72,20 +110,88 @@ module.exports = function(RED) {
}
});
ex.on("close", function (code) {
if (fail) { fail = false; return; }
var m = regex.exec(line)||"";
if (m !== "") {
if (m[1]) { res = Number(m[1]); }
if (m[2]) { res = Number(m[2]); }
if (tryPing6 === false) {
if (fail) { fail = false; return; }
var m = regex.exec(line)||"";
if (m !== "") {
if (m[1]) { res = Number(m[1]); }
if (m[2]) { res = Number(m[2]); }
}
if (code === 0) { msg.payload = res }
try { node.send(msg); }
catch(e) {console.warn(e)}
} else {
//fallback to ping6 for OS's that have not updated/out of date
if (plat == "linux" || plat == "android") {
commandLineOptions = ["-n", "-w", timeoutS, "-c", "1"];
} else if (plat == "darwin" || plat == "freebsd") {
commandLineOptions = ["-n", "-c", "1"] //NOTE: -X / timeout does not work on mac OSX and most freebsd systems
} else {
node.error("Sorry IPv6 on your platform - "+plat+" - is not supported.", msg);
}
//spawn with timeout in case of os issue
ex6 = spawn("ping6", [...commandLineOptions, hostOptions.host]);
//monitor every spawned process & SIGINT if too long
var spawnTout = setTimeout(() => {
node.log(`ping6 - Host '${hostOptions.host}' process timeout - sending SIGINT`)
try {
if (ex6 && ex6.pid) { ex6.kill("SIGINT"); }
}
catch(e) {console.warn(e); }
}, hostOptions.timeout+1000); //add 1s for grace
//catch error msg from ping6
ex6.stderr.setEncoding('utf8');
ex6.stderr.on("data", function (data) {
if (!data.includes('Usage')) { // !data: only get the error and not how to use the ping6 command
if (data.includes('Network is unreachable')) {
node.error(data + " Please check that your service provider or network device has IPv6 enabled", msg);
} else {
node.error(data, msg);
}
}
});
ex6.stdout.on("data", function (data) {
line += data.toString();
});
ex6.on("exit", function (err) {
clearTimeout(spawnTout);
});
ex6.on("error", function (err) {
fail = true;
if (err.code === "ENOENT") {
node.error(err.code + " ping6 command not found", msg);
}
else if (err.code === "EACCES") {
node.error(err.code + " can't run ping6 command", msg);
}
else {
node.error(err.code, msg);
}
});
ex6.on("close", function (code) {
if (fail) { fail = false; return; }
var m = regex.exec(line)||"";
if (m !== "") {
if (m[1]) { res = Number(m[1]); }
if (m[2]) { res = Number(m[2]); }
}
if (code === 0) { msg.payload = res }
try { node.send(msg); }
catch(e) {console.warn(e)}
});
}
if (code === 0) { msg.payload = res }
try { node.send(msg); }
catch(e) {console.warn(e)}
});
}
function PingNode(n) {
RED.nodes.createNode(this,n);
this.protocol = n.protocol||'Automatic';
this.mode = n.mode;
this.host = n.host;
this.timer = n.timer * 1000;
@ -132,4 +238,4 @@ module.exports = function(RED) {
});
}
RED.nodes.registerType("ping",PingNode);
}
}

View File

@ -15,6 +15,19 @@
<p>Returns <b>false</b> if no response received, or if the host is unresolveable.</p>
<p>Default ping is every 20 seconds but can be configured.</p>
<h4>Protocol...</h4>
<ul>
<li><b>Automatic</b><br>
<P>Will use any Protocol, IPv4 or IPv6, to reach host; based on your operating system network settings</P>
</li>
<li><b>IPv4</b><br>
<P>Forces use of IPv4 to reach host. Will fail if no route availibe</P>
</li>
<li><b>IPv6</b><br>
<P>Forces use of IPv6 to reach host. Will fail if no route availibe</P>
</li>
</ul>
<h4>Mode...</h4>
<ul>
<li><b>Timed</b><br>

View File

@ -9,6 +9,12 @@
"timed": "Timed",
"triggered": "Triggered"
},
"protocol": "Protocol",
"protocol_option": {
"auto": "Automatic",
"ipv4": "IPv4",
"ipv6": "IPv6"
},
"tip": "Note: Leave Target field blank to allow msg.payload to set hosts dynamically."
}
}

View File

@ -15,6 +15,19 @@
<p>ホスト名が解決できなかったり、レスポンスが得られなければ、<b>false</b>を返します。</p>
<p>デフォルトでは20秒ごとにpingを送りますが、設定で変更できます。</p>
<h4>Protocol...</h4>
<ul>
<li><b>Automatic</b><br>
<P>Will use any Protocol, IPv4 or IPv6, to reach host; based on your operating system network settings</P>
</li>
<li><b>IPv4</b><br>
<P>Forces use of IPv4 to reach host. Will fail if no route availibe</P>
</li>
<li><b>IPv6</b><br>
<P>Forces use of IPv6 to reach host. Will fail if no route availibe</P>
</li>
</ul>
<h4>モード...</h4>
<ul>
<li><b>時間</b><br>
@ -25,7 +38,7 @@
<li><b>トリガー</b><br>
<p><code>トリガー</code>モードでは、入力ワイヤを結線し、<code>msg</code>入力によってping処理を起動します。
<p><code>ターゲット</code>フィールドに入力した値はホスト名もしくはIPアドレスとして使用します。 ターゲットはホスト名/IPアドレスをカンマで区切ったものです。例: <code>"192.168.0.1"</code> あるいは <code>"192.168.0.1, www.google.com"</code></p>
<p><code>ターゲット</code>を空にした場合、カンマ区切り文字列、もしくは、ホストの配列を<code>msg.payload</code>に指定します。
<ul>
<li><code>文字列</code> - カンマ区切りのホスト名/IPアドレス 例: <code>"192.168.0.1"</code> あるいは <code>"192.168.0.1, www.google.com"</code> </li>
@ -33,12 +46,12 @@
<li>配列ペイロードの例: <pre>[
"192.168.0.99",
{
"host":"192.168.0.1",
"host":"192.168.0.1",
"name":"ルータ"
},
},
{
"host":"myapiserver.com",
"name":"拡張API",
"host":"myapiserver.com",
"name":"拡張API",
"timeout": 20000,
"support":"support@myapiserver.com"
}

View File

@ -9,6 +9,12 @@
"timed": "時間",
"triggered": "トリガー"
},
"protocol": "プロトコル",
"protocol_option": {
"auto": "自動の",
"ipv4": "IPv4",
"ipv6": "IPv6"
},
"tip": "注: msg.payloadでホスト名を動的に指定する場合は、ターゲットフィールドを空にします。"
}
}

View File

@ -72,7 +72,7 @@ module.exports = function(RED) {
});
}
else {
this.error(RED._("serial.errors.missing-conf"));
this.error(RED._("serial.errors.missing-conf"), {});
}
this.on("close", function(done) {
@ -109,7 +109,7 @@ module.exports = function(RED) {
});
}
else {
this.error(RED._("serial.errors.missing-conf"));
this.error(RED._("serial.errors.missing-conf"), {});
}
this.on("close", function(done) {
@ -186,7 +186,7 @@ module.exports = function(RED) {
});
}
else {
this.error(RED._("serial.errors.missing-conf"));
this.error(RED._("serial.errors.missing-conf"), {});
}
this.on("close", function(done) {
@ -347,7 +347,7 @@ module.exports = function(RED) {
if (err) {
if (err.toString() !== olderr) {
olderr = err.toString();
RED.log.error(RED._("serial.errors.error",{port:port,error:olderr}));
RED.log.error(RED._("serial.errors.error",{port:port,error:olderr}), {});
}
obj.tout = setTimeout(function() {
setupSerial();
@ -355,7 +355,7 @@ module.exports = function(RED) {
}
});
obj.serial.on('error', function(err) {
RED.log.error(RED._("serial.errors.error",{port:port,error:err.toString()}));
RED.log.error(RED._("serial.errors.error",{port:port,error:err.toString()}), {});
obj._emitter.emit('closed');
if (obj.tout) { clearTimeout(obj.tout); }
obj.tout = setTimeout(function() {
@ -366,7 +366,7 @@ module.exports = function(RED) {
if (!obj._closing) {
if (olderr !== "unexpected") {
olderr = "unexpected";
RED.log.error(RED._("serial.errors.unexpected-close",{port:port}));
RED.log.error(RED._("serial.errors.unexpected-close",{port:port}), {});
}
obj._emitter.emit('closed');
if (obj.tout) { clearTimeout(obj.tout); }
@ -472,7 +472,7 @@ module.exports = function(RED) {
connections[port]._closing = true;
try {
connections[port].close(function() {
RED.log.info(RED._("serial.errors.closed",{port:port}));
RED.log.info(RED._("serial.errors.closed",{port:port}), {});
done();
});
}

View File

@ -1,9 +1,9 @@
{
"name" : "node-red-node-serialport",
"version" : "0.11.1",
"version" : "0.12.1",
"description" : "Node-RED nodes to talk to serial ports",
"dependencies" : {
"serialport" : "^9.0.2"
"serialport" : "^9.0.7"
},
"repository" : {
"type":"git",

View File

@ -470,11 +470,12 @@ module.exports = function(RED) {
if (stanza.attrs.type === 'error') {
var error = stanza.getChild('error');
if (error.attrs.code) {
var reas = "";
try {
var reas = error.toString().split('><')[1].split(" xml")[0].trim();
reas = error.toString().split('><')[1].split(" xml")[0].trim();
if (reas == "registration-required") { reas = "membership-required"; }
}
catch(e) {};
catch(e) {}
var msg = {
topic:stanza.attrs.from,
payload: {
@ -692,11 +693,12 @@ module.exports = function(RED) {
if (stanza.attrs.type === 'error') {
var error = stanza.getChild('error');
if (error.attrs.code) {
var reas = "";
try {
var reas = error.toString().split('><')[1].split(" xml")[0].trim();
reas = error.toString().split('><')[1].split(" xml")[0].trim();
if (reas == "registration-required") { reas = "membership-required"; }
}
catch(e) {};
catch(e) {}
var msg = {
topic:stanza.attrs.from,
payload: {

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-xmpp",
"version": "0.5.0",
"version": "0.5.1",
"description": "A Node-RED node to talk to an XMPP server",
"dependencies": {
"@xmpp/client": "^0.12.0"

View File

@ -99,7 +99,7 @@ describe('RPI GPIO Node', function() {
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
try {
msg.should.have.property('topic', 'pi/7');
msg.should.have.property('topic', 'gpio/7');
msg.should.have.property('payload', 1);
done();
} catch(err) {
@ -117,7 +117,7 @@ describe('RPI GPIO Node', function() {
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
try {
msg.should.have.property('topic', 'pi/11');
msg.should.have.property('topic', 'gpio/11');
msg.should.have.property('payload', 0);
done();
} catch(err) {

View File

@ -7,7 +7,7 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.cmd = n.command;
//this.args = n.args.trim().split(" ") || [];
this.args = n.args.trim().match(/("[^"]*")|[^ ]+/g);
this.args = n.args.trim(); //.match(/("[^"]*")|[^ ]+/g);
this.cr = n.cr;
this.op = n.op;
this.redo = n.redo;
@ -15,6 +15,13 @@ module.exports = function(RED) {
this.closer = n.closer || "SIGKILL";
this.autorun = true;
if (n.autorun === false) { this.autorun = false; }
if (this.args.match(/^\[.*\]$/)) {
try { this.args = JSON.parse(this.args); }
catch(e) {
node.warn("Bad parameters - should be a JSON array or space separated")
}
}
else { this.args = this.args.match(/("[^"]*")|[^ ]+/g); }
var node = this;
var lastmsg = {};
@ -63,7 +70,6 @@ module.exports = function(RED) {
while (bits.length > 1) {
var m = RED.util.cloneMessage(lastmsg);
m.payload = bits.shift();
console.log(m);
node.send([m,null,null]);
}
line = bits[0];

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-daemon",
"version" : "0.1.3",
"version" : "0.2.0",
"description" : "A Node-RED node that runs and monitors a long running system command.",
"dependencies" : {
},