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:
parent
72e1f20383
commit
911288e695
@ -28,15 +28,23 @@ module.exports = function(RED) {
|
|||||||
var node = this;
|
var node = this;
|
||||||
node.board = new ArduinoFirmata();
|
node.board = new ArduinoFirmata();
|
||||||
ArduinoFirmata.list(function (err, ports) {
|
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.board.connect();
|
||||||
node.log("connecting to first device found.");
|
|
||||||
}
|
}
|
||||||
else {
|
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.board.on('boardReady', function() {
|
||||||
|
node.log("connected to "+node.board.serialport_name);
|
||||||
if (RED.settings.verbose) { node.log("version "+node.board.boardVersion); }
|
if (RED.settings.verbose) { node.log("version "+node.board.boardVersion); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user