mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
gpio retry failing pin connection
This commit is contained in:
parent
c32823a85a
commit
c9f57afe22
@ -45,8 +45,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
}
|
||||
|
||||
if (allOK === true) {
|
||||
if (node.pin !== undefined) {
|
||||
var startPin = function() {
|
||||
node.child = spawn(gpioCommand, ["in",node.pin,node.intype,node.debounce]);
|
||||
node.running = true;
|
||||
node.status({fill:"yellow",shape:"dot",text:"rpi-gpio.status.ok"});
|
||||
@ -70,9 +69,13 @@ module.exports = function(RED) {
|
||||
|
||||
node.child.on('close', function (code) {
|
||||
node.running = false;
|
||||
node.child = null;
|
||||
node.child.removeAllListeners();
|
||||
delete node.child;
|
||||
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
|
||||
if (node.finished) {
|
||||
if (!node.finished && code === 1) {
|
||||
setTimeout(function() {startPin()}, 250);
|
||||
}
|
||||
else if (node.finished) {
|
||||
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
|
||||
node.finished();
|
||||
}
|
||||
@ -84,7 +87,11 @@ module.exports = function(RED) {
|
||||
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
|
||||
else { node.error(RED._("rpi-gpio.errors.error",{error:err.errno})) }
|
||||
});
|
||||
}
|
||||
|
||||
if (allOK === true) {
|
||||
if (node.pin !== undefined) {
|
||||
startPin();
|
||||
}
|
||||
else {
|
||||
node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin);
|
||||
@ -109,8 +116,9 @@ module.exports = function(RED) {
|
||||
if (node.child != null) {
|
||||
node.finished = done;
|
||||
node.child.stdin.write("close "+node.pin, () => {
|
||||
if (node.child) {
|
||||
node.child.kill('SIGKILL');
|
||||
setTimeout(function() { if (done) { done(); } }, 25);
|
||||
}
|
||||
});
|
||||
}
|
||||
else { if (done) { done(); } }
|
||||
@ -214,7 +222,7 @@ module.exports = function(RED) {
|
||||
node.finished = done;
|
||||
node.child.stdin.write("close "+node.pin, () => {
|
||||
node.child.kill('SIGKILL');
|
||||
setTimeout(function() { if (done) { done(); } }, 25);
|
||||
setTimeout(function() { if (done) { done(); } }, 50);
|
||||
});
|
||||
}
|
||||
else { if (done) { done(); } }
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-node-pi-gpio",
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.5",
|
||||
"description": "The basic Node-RED node for Pi GPIO",
|
||||
"dependencies" : {
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user