Commit 3a07d0e1 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

fixed node comm

parent 1f5eac07
...@@ -18,7 +18,7 @@ var io = require('socket.io').listen(8080); ...@@ -18,7 +18,7 @@ var io = require('socket.io').listen(8080);
//defaults //defaults
var portName = null; var portName = null;
var currentPort = null; var currentPort = null;
var baudRate = 9600; var baudRate = 115200;
//io.sockets.on('connection', function (socket) { //io.sockets.on('connection', function (socket) {
// socket.emit('baudRate', baudRate); // socket.emit('baudRate', baudRate);
...@@ -50,8 +50,12 @@ io.on('connection', function(socket){ ...@@ -50,8 +50,12 @@ io.on('connection', function(socket){
}); });
socket.on('dataOut', function(data){ socket.on('dataOut', function(data){
data += '\n';
console.log("Sending data: " + data); console.log("Sending data: " + data);
currentPort.write(new Buffer([parseInt(data)])); currentPort.write(new Buffer(data), function(err, res) {
if (err) onPortError(err);
});
// currentPort.write(new Buffer([parseInt(data)]));//write byte
}); });
socket.on('flush', function(){ socket.on('flush', function(){
...@@ -145,7 +149,7 @@ io.on('connection', function(socket){ ...@@ -145,7 +149,7 @@ io.on('connection', function(socket){
} }
function onPortData(data){ function onPortData(data){
// console.log(data); console.log(data);
socket.emit("dataIn", data); socket.emit("dataIn", data);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment