From bd15c5d6dd4cb361a876f0013a1656ceea9db960 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 15 Mar 2023 10:21:31 +0000 Subject: [PATCH] fix pi gpio to catch close timing error --- hardware/PiGpio/36-rpi-gpio.js | 23 ++++++++++++++----- hardware/PiGpio/locales/de/36-rpi-gpio.json | 4 ++-- .../PiGpio/locales/en-US/36-rpi-gpio.json | 4 ++-- hardware/PiGpio/locales/ja/36-rpi-gpio.json | 4 ++-- hardware/PiGpio/locales/ko/36-rpi-gpio.json | 4 ++-- hardware/PiGpio/package.json | 2 +- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/hardware/PiGpio/36-rpi-gpio.js b/hardware/PiGpio/36-rpi-gpio.js index ab7a690a..ae234c49 100644 --- a/hardware/PiGpio/36-rpi-gpio.js +++ b/hardware/PiGpio/36-rpi-gpio.js @@ -83,9 +83,15 @@ module.exports = function(RED) { }); node.child.on('error', function (err) { - if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); } - else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); } - else { node.error(RED._("rpi-gpio.errors.error",{error:err.errno})) } + if (err.code === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")+err.path,err); } + else if (err.code === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")+err.path,err); } + else { node.error(RED._("rpi-gpio.errors.error",{error:err.code}),err) } + }); + + node.child.stdin.on('error', function (err) { + if (!node.finished) { + node.error(RED._("rpi-gpio.errors.error",{error:err.code}),err); + } }); } @@ -198,11 +204,16 @@ module.exports = function(RED) { }); node.child.on('error', function (err) { - if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); } - else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); } - else { node.error(RED._("rpi-gpio.errors.error")+': ' + err.errno); } + if (err.code === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")+err.path,err); } + else if (err.code === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")+err.path,err); } + else { node.error(RED._("rpi-gpio.errors.error",{error:err.code}),err) } }); + node.child.stdin.on('error', function (err) { + if (!node.finished) { + node.error(RED._("rpi-gpio.errors.error",{error:err.code}),err); + } + }); } else { node.warn(RED._("rpi-gpio.errors.invalidpin")+": "+node.pin); diff --git a/hardware/PiGpio/locales/de/36-rpi-gpio.json b/hardware/PiGpio/locales/de/36-rpi-gpio.json index 9024f880..8f8c621e 100644 --- a/hardware/PiGpio/locales/de/36-rpi-gpio.json +++ b/hardware/PiGpio/locales/de/36-rpi-gpio.json @@ -66,8 +66,8 @@ "invalidinput": "Ungültige Eingabe", "needtobeexecutable": "__command__ muss ausführbar sein", "mustbeexecutable": "nrgpio muss ausführbar sein", - "commandnotfound": "nrgpio-Befehl nicht gefunden", - "commandnotexecutable": "nrgpio-Befehl nicht ausführbar", + "commandnotfound": "nrgpio-Befehl nicht gefunden ", + "commandnotexecutable": "nrgpio-Befehl nicht ausführbar ", "error": "Fehler: __error__", "pythoncommandnotfound": "nrgpio-Python-Befehl nicht aktiv" } diff --git a/hardware/PiGpio/locales/en-US/36-rpi-gpio.json b/hardware/PiGpio/locales/en-US/36-rpi-gpio.json index 8931f170..fdc1bcec 100644 --- a/hardware/PiGpio/locales/en-US/36-rpi-gpio.json +++ b/hardware/PiGpio/locales/en-US/36-rpi-gpio.json @@ -66,8 +66,8 @@ "invalidinput": "Invalid input", "needtobeexecutable": "__command__ needs to be executable", "mustbeexecutable": "nrgpio must to be executable", - "commandnotfound": "nrgpio command not found", - "commandnotexecutable": "nrgpio command not executable", + "commandnotfound": "nrgpio command not found ", + "commandnotexecutable": "nrgpio command not executable ", "error": "error: __error__", "pythoncommandnotfound": "nrgpio python command not running" } diff --git a/hardware/PiGpio/locales/ja/36-rpi-gpio.json b/hardware/PiGpio/locales/ja/36-rpi-gpio.json index 619eb3ef..644980a8 100644 --- a/hardware/PiGpio/locales/ja/36-rpi-gpio.json +++ b/hardware/PiGpio/locales/ja/36-rpi-gpio.json @@ -66,8 +66,8 @@ "invalidinput": "入力が不正です", "needtobeexecutable": "__command__ は実行可能である必要があります", "mustbeexecutable": "nrgpio は実行可能である必要があります", - "commandnotfound": "nrgpio コマンドが見つかりません", - "commandnotexecutable": "nrgpio コマンドが実行可能ではありません", + "commandnotfound": "nrgpio コマンドが見つかりません ", + "commandnotexecutable": "nrgpio コマンドが実行可能ではありません ", "error": "エラー: __error__", "pythoncommandnotfound": "nrgpio python コマンドが実行されていません" } diff --git a/hardware/PiGpio/locales/ko/36-rpi-gpio.json b/hardware/PiGpio/locales/ko/36-rpi-gpio.json index 323ae882..a5161ac9 100644 --- a/hardware/PiGpio/locales/ko/36-rpi-gpio.json +++ b/hardware/PiGpio/locales/ko/36-rpi-gpio.json @@ -65,8 +65,8 @@ "invalidinput": "입력이 올바르지 않습니다", "needtobeexecutable": "__command__ 은 실행가능상태일 필요가 있습니다 ", "mustbeexecutable": "nrgpio 은 실행가능상태일 필요가 있습니다 ", - "commandnotfound": "nrgpio 커맨드를 찾을수 없습니다", - "commandnotexecutable": "nrgpio 커맨드가 실행가능상태가 아닙니다", + "commandnotfound": "nrgpio 커맨드를 찾을수 없습니다 ", + "commandnotexecutable": "nrgpio 커맨드가 실행가능상태가 아닙니다 ", "error": "에러: __error__", "pythoncommandnotfound": "nrgpio python 커맨드가 실행되지 않았습니다" } diff --git a/hardware/PiGpio/package.json b/hardware/PiGpio/package.json index b9ee921b..7581e563 100644 --- a/hardware/PiGpio/package.json +++ b/hardware/PiGpio/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-pi-gpio", - "version": "2.0.5", + "version": "2.0.6", "description": "The basic Node-RED node for Pi GPIO", "dependencies" : { },