1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Arduino node - improved logging and port error handling.

This commit is contained in:
dceejay 2015-05-13 22:26:01 +01:00
parent 72e1f20383
commit 911288e695

View File

@ -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 {
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); }
});
});