mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add better sensehat error handling
This commit is contained in:
parent
c9faed7876
commit
471840b868
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-pi-sense-hat",
|
||||
"version" : "0.0.7",
|
||||
"version" : "0.0.8",
|
||||
"description" : "A Node-RED node to interact with a Raspberry Pi Sense HAT",
|
||||
"repository" : {
|
||||
"type":"git",
|
||||
|
@ -53,6 +53,7 @@ module.exports = function(RED) {
|
||||
var reconnectTimer = null;
|
||||
|
||||
var connect = function() {
|
||||
reconnectTimer = null;
|
||||
var buffer = "";
|
||||
hat = spawn(hatCommand);
|
||||
hat.stdout.on('data', function (data) {
|
||||
@ -115,7 +116,10 @@ module.exports = function(RED) {
|
||||
}
|
||||
});
|
||||
hat.stderr.on('data', function (data) {
|
||||
// Any data on stderr means a bad thing has happened.
|
||||
// Best to kill it and let it reconnect.
|
||||
if (RED.settings.verbose) { RED.log.error("err: "+data+" :"); }
|
||||
hat.kill('SIGKILL');
|
||||
});
|
||||
hat.stderr.on('error', function(err) { });
|
||||
hat.stdin.on('error', function(err) { });
|
||||
@ -129,7 +133,7 @@ module.exports = function(RED) {
|
||||
if (onclose) {
|
||||
onclose();
|
||||
onclose = null;
|
||||
} else {
|
||||
} else if (!reconnectTimer) {
|
||||
reconnectTimer = setTimeout(function() {
|
||||
connect();
|
||||
},5000);
|
||||
|
Loading…
Reference in New Issue
Block a user