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
1 changed files with 10 additions and 5 deletions

View File

@ -276,11 +276,16 @@ module.exports = function(RED) {
node.status({fill:"green",shape:"dot",text:"rpi-gpio.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 });
var d = data.toString().trim().split("\n");
for (var i = 0; i < d.length; i++) {
if (d[i] !== '') {
var b = d[i].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) {