From 906a48fa61c87ee02a009aad2db34789615b37d3 Mon Sep 17 00:00:00 2001 From: Takayoshi Kawamorita Date: Mon, 16 Nov 2020 23:54:48 +0900 Subject: [PATCH] The problem that the input contents disappear when multiple keys are input at the same time. (#717) --- hardware/PiGpio/36-rpi-gpio.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hardware/PiGpio/36-rpi-gpio.js b/hardware/PiGpio/36-rpi-gpio.js index c5b11dfc..f2502ec9 100644 --- a/hardware/PiGpio/36-rpi-gpio.js +++ b/hardware/PiGpio/36-rpi-gpio.js @@ -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) {