Skip to content

Commit

Permalink
Tidy up rawserial node logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dceejay committed Jun 10, 2014
1 parent 94d19b2 commit 9b48709
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions io/rawserial/26-rawserial.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ function RawSerialInNode(n) {
if (this.splitc == '\\n') this.splitc = "\n";
if (this.splitc == '\\r') this.splitc = "\r";
if (!isNaN(parseInt(this.splitc))) { this.splitc = parseInt(this.splitc); }
console.log("Split is",this.out,this.splitc);
var node = this;

var setupSerial = function() {
node.inp = fs.createReadStream(pre+node.port);
node.log("opened "+pre+node.port);
node.log("open "+pre+node.port);
node.tout = null;
var line = "";
var buf = new Buffer(32768);
Expand Down Expand Up @@ -83,14 +82,14 @@ function RawSerialInNode(n) {
});
//node.inp.on('end', function (error) {console.log("End", error);});
node.inp.on('close', function (error) {
util.log("[rawserial] "+node.port+" closed");
node.log(node.port+" closed");
node.tout = setTimeout(function() {
setupSerial();
},settings.serialReconnectTime);
});
node.inp.on('error', function(error) {
if (error.code == "ENOENT") { util.log("[rawserial] port "+node.port+" not found"); }
else { util.log("[rawserial] "+node.port+" error "+error); }
if (error.code == "ENOENT") { node.log(node.port+" not found"); }
else { node.log(node.port+" error "+error); }
node.tout = setTimeout(function() {
setupSerial();
},settings.serialReconnectTime);
Expand Down Expand Up @@ -119,18 +118,18 @@ function RawSerialOutNode(n) {
node.oup.write(msg.payload);
}
});
node.oup.on('open', function (error) { util.log("[rawserial] opened "+node.port); });
node.oup.on('end', function (error) { console.log("End",error); });
node.oup.on('open', function (error) { node.log("opened "+node.port); });
node.oup.on('end', function (error) { node.log("end :"+error); });
node.oup.on('close', function (error) {
util.log("[rawserial] "+node.port+" closed");
node.log(node.port+" closed");
node.tout = setTimeout(function() {
setupSerial();
},settings.serialReconnectTime);
});
node.oup.on('error', function(error) {
if (error.code == "EACCES") { util.log("[rawserial] can't access port "+node.port); }
else if (error.code == "EIO") { util.log("[rawserial] can't write to port "+node.port); }
else { util.log("[rawserial] "+node.port+" error "+error); }
if (error.code == "EACCES") { node.log("can't access port "+node.port); }
else if (error.code == "EIO") { node.log("can't write to port "+node.port); }
else { node.log(node.port+" error "+error); }
node.tout = setTimeout(function() {
setupSerial();
},settings.serialReconnectTime);
Expand Down

0 comments on commit 9b48709

Please sign in to comment.