reduce Arduino error messages on failed connect

This commit is contained in:
Dave Conway-Jones 2019-04-11 16:35:02 +01:00
parent d40f433332
commit a475b67a19
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 7 additions and 2 deletions

View File

@ -11,14 +11,19 @@ module.exports = function(RED) {
this.device = n.device || null; this.device = n.device || null;
var node = this; var node = this;
var running = false; var running = false;
var reported = false;
var startup = function() { var startup = function() {
node.board = new Board(node.device, function(e) { node.board = new Board(node.device, function(e) {
if ((e !== undefined) && (e.toString().indexOf("cannot open") !== -1) ) { if ((e !== undefined) && (e.toString().indexOf("cannot open") !== -1) ) {
node.error(RED._("arduino.errors.portnotfound",{device:node.device})); if (!reported) {
node.error(RED._("arduino.errors.portnotfound",{device:node.device}));
reported = true;
}
} }
else if (e === undefined) { else if (e === undefined) {
running = true; running = true;
reported = false;
node.board.once('ready', function() { node.board.once('ready', function() {
node.log(RED._("arduino.status.connected",{device:node.board.sp.path})); node.log(RED._("arduino.status.connected",{device:node.board.sp.path}));
if (RED.settings.verbose) { if (RED.settings.verbose) {

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-arduino", "name" : "node-red-node-arduino",
"version" : "0.2.0", "version" : "0.2.1",
"description" : "A Node-RED node to talk to an Arduino running firmata", "description" : "A Node-RED node to talk to an Arduino running firmata",
"dependencies" : { "dependencies" : {
"firmata" : "^2.0.0" "firmata" : "^2.0.0"