Various little tweaks - less console.log more util.log, add exra try/catch to serial, add wiring-pi url to Pi "error message".

This commit is contained in:
Dave C-J 2013-11-03 19:09:45 +00:00
parent 2e92b9a120
commit d9ed5b46c4
4 changed files with 156 additions and 156 deletions

View File

@ -43,7 +43,7 @@ function Xml2jsNode(n) {
} }
}); });
} }
catch(e) { console.log(e); } catch(e) { util.log("[73-parsexml.js] "+e); }
}); });
} }
RED.nodes.registerType("xml2js",Xml2jsNode); RED.nodes.registerType("xml2js",Xml2jsNode);

View File

@ -22,7 +22,7 @@ var fs = require('fs');
if (!fs.existsSync("/usr/local/bin/gpio")) { if (!fs.existsSync("/usr/local/bin/gpio")) {
exec("cat /proc/cpuinfo | grep BCM27",function(err,stdout,stderr) { exec("cat /proc/cpuinfo | grep BCM27",function(err,stdout,stderr) {
if (stdout.indexOf('BCM27') > -1) { if (stdout.indexOf('BCM27') > -1) {
util.log('[36-rpi-gpio.js] Error: Cannot find Wiring-Pi "gpio" command'); util.log('[36-rpi-gpio.js] Error: Cannot find Wiring-Pi "gpio" command. http://wiringpi.com/download-and-install/');
} }
// else not on a Pi so don't worry anyone with needless messages. // else not on a Pi so don't worry anyone with needless messages.
}); });

View File

@ -15,11 +15,10 @@
**/ **/
var RED = require("../../red/red"); var RED = require("../../red/red");
var settings = RED.settings;
var events = require("events"); var events = require("events");
var util = require("util"); var util = require("util");
var serialp = require("serialport"); var serialp = require("serialport");
var settings = RED.settings;
// TODO: 'serialPool' should be encapsulated in SerialPortNode // TODO: 'serialPool' should be encapsulated in SerialPortNode
@ -58,9 +57,9 @@ function SerialOutNode(n) {
this.error("missing serial config"); this.error("missing serial config");
} }
} }
RED.nodes.registerType("serial out",SerialOutNode); RED.nodes.registerType("serial out",SerialOutNode);
SerialOutNode.prototype.close = function() { SerialOutNode.prototype.close = function() {
if (this.serialConfig) { if (this.serialConfig) {
serialPool.close(this.serialConfig.serialport); serialPool.close(this.serialConfig.serialport);
@ -90,9 +89,9 @@ function SerialInNode(n) {
this.error("missing serial config"); this.error("missing serial config");
} }
} }
RED.nodes.registerType("serial in",SerialInNode); RED.nodes.registerType("serial in",SerialInNode);
SerialInNode.prototype.close = function() { SerialInNode.prototype.close = function() {
if (this.serialConfig) { if (this.serialConfig) {
try { try {
@ -121,6 +120,7 @@ var serialPool = function() {
} }
newline = newline.replace("\\n","\n").replace("\\r","\r"); newline = newline.replace("\\n","\n").replace("\\r","\r");
var setupSerial = function() { var setupSerial = function() {
try {
if (newline == "") { if (newline == "") {
obj.serial = new serialp.SerialPort(port,{ obj.serial = new serialp.SerialPort(port,{
baudrate: baud, baudrate: baud,
@ -163,6 +163,7 @@ var serialPool = function() {
obj._emitter.emit('data',d); obj._emitter.emit('data',d);
} }
}); });
} catch(err) { console.log("Booo!",err,"Booo!"); }
} }
setupSerial(); setupSerial();
return obj; return obj;
@ -178,8 +179,7 @@ var serialPool = function() {
connections[port].close(function() { connections[port].close(function() {
util.log("[serial] serial port closed"); util.log("[serial] serial port closed");
}); });
} catch(err) { } catch(err) { };
};
} }
delete connections[port]; delete connections[port];
} }

View File

@ -330,7 +330,7 @@ a.brand img {
} }
.node_highlighted { .node_highlighted {
stroke: #dd1616; stroke: #dd1616;
stroke-width: 2; stroke-width: 3;
stroke-dasharray: 10, 4; stroke-dasharray: 10, 4;
} }
.node_hovered { .node_hovered {