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