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

Catch board not configured error without crashing

This commit is contained in:
Dave Conway-Jones 2013-09-06 13:57:43 +01:00
parent 6922a71995
commit 28b7009f33

View File

@ -74,6 +74,7 @@ function DuinoNodeIn(n) {
this.state = n.state; this.state = n.state;
this.arduino = n.arduino; this.arduino = n.arduino;
this.serverConfig = RED.nodes.getNode(this.arduino); this.serverConfig = RED.nodes.getNode(this.arduino);
if (typeof this.serverConfig === "object") {
this.board = this.serverConfig.board; this.board = this.serverConfig.board;
this.repeat = this.serverConfig.repeat; this.repeat = this.serverConfig.repeat;
var node = this; var node = this;
@ -106,7 +107,11 @@ function DuinoNodeIn(n) {
this._close = function() { this._close = function() {
clearInterval(this._interval); clearInterval(this._interval);
util.log("[firmata] input eventlistener stopped"); util.log("[arduino] input eventlistener stopped");
}
}
else {
util.log("[arduino] Serial Port not Configured");
} }
} }
RED.nodes.registerType("arduino in",DuinoNodeIn); RED.nodes.registerType("arduino in",DuinoNodeIn);
@ -124,6 +129,7 @@ function DuinoNodeOut(n) {
this.state = n.state; this.state = n.state;
this.arduino = n.arduino; this.arduino = n.arduino;
this.serverConfig = RED.nodes.getNode(this.arduino); this.serverConfig = RED.nodes.getNode(this.arduino);
if (typeof this.serverConfig === "object") {
this.board = this.serverConfig.board; this.board = this.serverConfig.board;
var node = this; var node = this;
@ -163,5 +169,9 @@ function DuinoNodeOut(n) {
node.board.pinMode(node.pin, node.board.MODES[node.state]); node.board.pinMode(node.pin, node.board.MODES[node.state]);
} }
}, 5000); // loop to wait for firmata to connect to arduino }, 5000); // loop to wait for firmata to connect to arduino
}
else {
util.log("[arduino] Serial Port not Configured");
}
} }
RED.nodes.registerType("arduino out",DuinoNodeOut); RED.nodes.registerType("arduino out",DuinoNodeOut);