1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

The problem that the input contents disappear when multiple keys are input at the same time. (#717)

This commit is contained in:
Takayoshi Kawamorita 2020-11-16 23:54:48 +09:00 committed by GitHub
parent 640a6d0cb2
commit 906a48fa61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -276,11 +276,16 @@ module.exports = function(RED) {
node.status({fill:"green",shape:"dot",text:"rpi-gpio.status.ok"}); node.status({fill:"green",shape:"dot",text:"rpi-gpio.status.ok"});
node.child.stdout.on('data', function (data) { node.child.stdout.on('data', function (data) {
var b = data.toString().trim().split(","); var d = data.toString().trim().split("\n");
var act = "up"; for (var i = 0; i < d.length; i++) {
if (b[1] === "1") { act = "down"; } if (d[i] !== '') {
if (b[1] === "2") { act = "repeat"; } var b = d[i].trim().split(",");
node.send({ topic:"pi/key", payload:Number(b[0]), action:act }); 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) { node.child.stderr.on('data', function (data) {