Commit 28039c4c authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

serial monitor is happy

parent ac59d35a
#sendSerialMessage {
body {
overflow: hidden;
}
#sendSerialMessage {
position: absolute;
bottom: 0px;
border-radius: 0px;
......
......@@ -11,11 +11,17 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!SerialMoni
el: "#serialMonitorView",
events: {
"click #clearMonitor": "_clear",
"click #clearMonitor": "render",
"change input:checkbox": "_clickCheckbox"
},
__initialize: function(){
this.listenTo(serialComm, "change:baudRate change:portName", this.render);
this.listenTo(serialComm, "change:connected", function(){
if (!serialComm.get("connected")) this._close();
})
this.render();
},
......@@ -57,11 +63,6 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!SerialMoni
return this.model.toJSON();
},
_clear: function(e){
e.preventDefault();
$("#serialMonitorOutput").html("");
},
__sendMessage: function(message){
this._addOutputData("<span class='outgoing'>" + message + "</span><br/>");
},
......@@ -76,6 +77,10 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!SerialMoni
if (this.model.get("autoscroll")) $output.animate({scrollTop:$output.scrollTop()+$output.innerHeight()}, "fast");
},
_close: function(){
window.close();
},
template: _.template(template)
});
......
......@@ -42,6 +42,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'serialComm', 'commPlist'
_updateIncomingMessage: function(){
var message = serialComm.get("lastMessageReceived");
console.log(message);
var $message = $("#incomingSerialMessage");
$message.html(message);
$message.css("background", "#ffff99");
......
......@@ -51,7 +51,6 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'commPlist', 'te
},
_makeTemplateJSON: function(){
console.log("render");
return _.extend(serialComm.toJSON(), commPlist, cam.toJSON(), camPlist, {streaming: this.isStreaming});
},
......
......@@ -53,7 +53,6 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!setupCommM
},
_makeTemplateJSON: function(){
console.log("render");
return _.extend(serialComm.toJSON(), commPlist);
},
......
......@@ -23,7 +23,7 @@
</div>
&nbsp;&nbsp;<a href="#" id="refreshPorts" class="btn btn-lg btn-default btn-icon"><img src="assets/imgs/refreshIcon.png"></a><br/><br/>
<a href="#" id="openSerialMonitor" class="btn btn-block btn-lg btn-default">Open Serial Monitor</a><br/>
Incoming: &nbsp;&nbsp;<pre id="incomingSerialMessage"></pre><br/><br/>
Incoming: &nbsp;&nbsp;<pre id="incomingSerialMessage"><br/></pre><br/>
Out: &nbsp;&nbsp;<input id="sendSerialMessage" value="" placeholder="Send Message" class="seventyFiveWidth form-control unresponsiveInput" type="text"><br/><br/>
<a href="#" id="serialFlushBuffer" class="btn btn-block btn-lg btn-danger">Flush Buffer</a><br/>
<% }else{ %>
......
......@@ -24,7 +24,7 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
attemptToConnectToNode: function(){
if (!this.get("connected")) {
this.socket = io.connect('http://localhost:8080', {'forceNew':true});
addEventHandlers(this.socket);
addEventHandlers(this.socket);//if we're not in the serial monitor window
}
},
......
......@@ -21,7 +21,7 @@ var currentPort = null;
var baudRate = 115200;
//io.sockets.on('connection', function (socket) {
// socket.emit('baudRate', baudRate);
// io.emit('baudRate', baudRate);
//});
......@@ -92,7 +92,7 @@ io.on('connection', function(socket){
if (!portName && _allPorts.length>0) portName = _allPorts[0];
if (callback) callback(allPorts, portName, baudRate);
socket.emit('connected', {
io.emit('connected', {
baudRate: baudRate,
portName: portName,
availablePorts: _allPorts
......@@ -138,19 +138,19 @@ io.on('connection', function(socket){
onPortError(error);
return null;
}
socket.emit("portDisconnected", {baudRate:oldBaud, portName:oldName});
io.emit("portDisconnected", {baudRate:oldBaud, portName:oldName});
});
}
return initPort(_portName, _baudRate);
}
function onPortOpen(name, baud){
socket.emit("portConnected", {baudRate:baud, portName:name});
io.emit("portConnected", {baudRate:baud, portName:name});
}
function onPortData(data){
console.log(data);
socket.emit("dataIn", data);
io.emit('dataIn', data);
}
function onPortClose(){
......@@ -159,7 +159,7 @@ io.on('connection', function(socket){
function onPortError(error){
console.log("Serial port error " + error);
socket.emit("errorMsg", {error:String(error)});
io.emit("errorMsg", {error:String(error)});
}
});
......
Markdown is supported
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