From 911288e695bed752a01fb7831fc8d753921e01f6 Mon Sep 17 00:00:00 2001 From: dceejay Date: Wed, 13 May 2015 22:26:01 +0100 Subject: [PATCH] Arduino node - improved logging and port error handling. --- nodes/core/hardware/35-arduino.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nodes/core/hardware/35-arduino.js b/nodes/core/hardware/35-arduino.js index 409c11d02..729fe9e7e 100644 --- a/nodes/core/hardware/35-arduino.js +++ b/nodes/core/hardware/35-arduino.js @@ -28,15 +28,23 @@ module.exports = function(RED) { var node = this; node.board = new ArduinoFirmata(); ArduinoFirmata.list(function (err, ports) { - if (ports.indexOf(node.device) === -1) { + if (!node.device) { + node.log("connecting to first board found."); node.board.connect(); - node.log("connecting to first device found."); } else { - node.board.connect(node.device); + if (ports.indexOf(node.device) === -1) { + node.warn(node.device + " not found. Trying to find board."); + node.board.connect(); + } + else { + node.log("connecting to "+node.device); + node.board.connect(node.device); + } } node.board.on('boardReady', function() { + node.log("connected to "+node.board.serialport_name); if (RED.settings.verbose) { node.log("version "+node.board.boardVersion); } }); });