Permalink
Browse files

logging off

  • Loading branch information...
1 parent 8d4c3b6 commit e2b8ecf9219b327cc2fc85d7a092434945bd6781 Shawn Van Every committed Oct 7, 2016
Showing with 12 additions and 8 deletions.
  1. +12 −8 p5.serialserver.js
View
@@ -34,7 +34,11 @@ var start = function () {
serialPortName = serialport;
- serialPort = new SerialPort.SerialPort(serialport, serialoptions, false,
+ if (!serialoptions.hasOwnProperty('autoOpen')) {
+ serialoptions.autoOpen = false;
+ }
+
+ serialPort = new SerialPort(serialport, serialoptions,
function(err) {
if (err) {
console.log(err);
@@ -51,7 +55,7 @@ var start = function () {
});
serialPort.on('close', function(data) {
- logit("serialPort.on close " + data);
+ logit("serialPort.on close");
sendit({method: 'close', data:data});
});
@@ -104,6 +108,7 @@ var start = function () {
}
}
);
+ serialPort = null;
}
// Let's try to close a different way
@@ -121,12 +126,12 @@ var start = function () {
var dataToSend = JSON.stringify(toSend);
//console.log("sendit: " + dataToSend + " to " + clients.length + " clients");
- try {
- for (var c = 0; c < clients.length; c++) {
+ for (var c = 0; c < clients.length; c++) {
+ try {
clients[c].send(dataToSend);
+ } catch (e) {
+ //console.log("Error Sending: " + e);
}
- } catch (e) {
- //console.log("Error Sending: " + e);
}
};
@@ -212,13 +217,12 @@ var start = function () {
}
}
- /*
+
if (clients.length == 0) {
logit("clients.length == 0 checking to see if we should close serial port")
// Should close serial port
closeSerial();
}
- */
});
});

0 comments on commit e2b8ecf

Please sign in to comment.