Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
DMDesign
Commits
28039c4c
Commit
28039c4c
authored
Sep 10, 2015
by
Amanda Ghassaei
Browse files
serial monitor is happy
parent
ac59d35a
Changes
8
Hide whitespace changes
Inline
Side-by-side
css/serialMonitor.css
View file @
28039c4c
#sendSerialMessage
{
body
{
overflow
:
hidden
;
}
#sendSerialMessage
{
position
:
absolute
;
bottom
:
0px
;
border-radius
:
0px
;
...
...
js/SerialMonitor/SerialMonitorView.js
View file @
28039c4c
...
...
@@ -11,11 +11,17 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!SerialMoni
el
:
"
#serialMonitorView
"
,
events
:
{
"
click #clearMonitor
"
:
"
_clea
r
"
,
"
click #clearMonitor
"
:
"
rende
r
"
,
"
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
)
});
...
...
js/menus/CommParentMenu.js
View file @
28039c4c
...
...
@@ -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
"
);
...
...
js/menus/SendMenuView.js
View file @
28039c4c
...
...
@@ -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
});
},
...
...
js/menus/SetupCommMenuView.js
View file @
28039c4c
...
...
@@ -53,7 +53,6 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!setupCommM
},
_makeTemplateJSON
:
function
(){
console
.
log
(
"
render
"
);
return
_
.
extend
(
serialComm
.
toJSON
(),
commPlist
);
},
...
...
js/menus/templates/SetupCommMenuView.html
View file @
28039c4c
...
...
@@ -23,7 +23,7 @@
</div>
<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:
<pre
id=
"incomingSerialMessage"
><
/pre><br/
><br/>
Incoming:
<pre
id=
"incomingSerialMessage"
><
br/></pre
><br/>
Out:
<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
{
%
>
...
...
js/models/SerialComm.js
View file @
28039c4c
...
...
@@ -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
}
},
...
...
node/nodeServer.js
View file @
28039c4c
...
...
@@ -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
)});
}
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment