Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
Lego_Robots
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Matthew Baxter
Lego_Robots
Commits
76f316f1
Commit
76f316f1
authored
Jun 29, 2015
by
Carl Hetherington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some fixes; add speak command.
parent
7c9247e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
listen.py
listen.py
+6
-1
snap-ev3.py
snap-ev3.py
+9
-4
snap-ev3.xml
snap-ev3.xml
+21
-0
No files found.
listen.py
View file @
76f316f1
...
...
@@ -16,7 +16,12 @@ class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
if
len
(
parts
)
==
4
and
parts
[
0
]
==
'motor'
:
print
'Run
%
s to
%
s at speed
%
s'
%
(
parts
[
1
],
parts
[
2
],
parts
[
3
])
d
=
MediumMotor
(
parts
[
1
])
d
.
run_position_limited
(
int
(
parts
[
2
]),
int
(
parts
[
3
]),
absolute
=
False
)
d
.
run_position_limited
(
int
(
parts
[
2
]),
int
(
parts
[
3
]),
absolute
=
False
)
elif
len
(
parts
)
==
2
and
parts
[
0
]
==
'say'
:
phrase
=
parts
[
1
]
phrase
=
phrase
.
replace
(
'
%20
'
,
' '
)
print
'Say
%
s'
%
phrase
os
.
system
(
'espeak -a 200 -s 130 -v en-sc --stdout "
%
s" | aplay'
%
phrase
)
self
.
send_response
(
200
)
self
.
send_header
(
'Content-Type'
,
'text/html'
)
...
...
snap-ev3.py
View file @
76f316f1
...
...
@@ -12,7 +12,7 @@ EV3_PORT = 8192
EV3_CONNECTION
=
'root@10.42.0.51'
class
Handler
(
SimpleHTTPServer
.
SimpleHTTPRequestHandler
):
def
send_head
(
self
):
def
do_GET
(
self
):
if
self
.
path
==
'/snap-ev3'
:
f
=
open
(
'snap-ev3.xml'
,
'rb'
)
self
.
send_response
(
200
)
...
...
@@ -22,11 +22,16 @@ class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self
.
send_header
(
"Last-Modified"
,
self
.
date_time_string
(
fs
.
st_mtime
))
self
.
send_header
(
"Access-Control-Allow-Origin"
,
"*"
)
self
.
end_headers
()
return
f
self
.
copyfile
(
f
,
self
.
wfile
)
f
.
close
()
else
:
SimpleHTTPServer
.
SimpleHTTPRequestHandler
.
send_head
(
self
)
urllib2
.
urlopen
(
"http://10.42.0.51:
%
d
%
s"
%
(
EV3_PORT
,
self
.
path
),
timeout
=
5
)
.
read
()
self
.
send_response
(
200
)
self
.
send_header
(
'Content-Type'
,
'text/html'
)
self
.
end_headers
()
self
.
wfile
.
write
(
'OK'
)
self
.
wfile
.
close
()
class
TCPServer
(
SocketServer
.
TCPServer
):
def
server_bind
(
self
):
self
.
socket
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
...
...
snap-ev3.xml
View file @
76f316f1
...
...
@@ -26,4 +26,25 @@
</block>
</script>
</block-definition>
<block-definition
category=
"control"
s=
"speak %'words'"
type=
"command"
>
<inputs>
<input
type=
"%txt"
>
hello
</input>
</inputs>
<script>
<block
s=
"doRun"
>
<block
s=
"reifyReporter"
>
<autolambda>
<block
s=
"reportURL"
>
<block
s=
"reportJoinWords"
>
<list>
<l>
localhost:1330/say/
</l>
<block
var=
"words"
/>
</list>
</block>
</block>
</autolambda>
</block>
</block>
</script>
</block-definition>
</blocks>
Write
Preview
Markdown
is supported
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