Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
b636d024
Commit
b636d024
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
Make pyboard.py have its own exception; update run-tests for pyboard.
parent
d240ff83
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/run-tests
+14
-7
14 additions, 7 deletions
tests/run-tests
tools/pyboard.py
+7
-4
7 additions, 4 deletions
tools/pyboard.py
with
21 additions
and
11 deletions
tests/run-tests
+
14
−
7
View file @
b636d024
...
@@ -46,11 +46,18 @@ for test_file in tests:
...
@@ -46,11 +46,18 @@ for test_file in tests:
output_expected
=
b
'
CPYTHON3 CRASH
'
output_expected
=
b
'
CPYTHON3 CRASH
'
# run Micro Python
# run Micro Python
try
:
if
test_on_pyboard
:
if
test_on_pyboard
:
pyb
.
enter_raw_repl
()
pyb
.
enter_raw_repl
()
try
:
if
test_file
==
'
basics/math-fun.py
'
:
# this test crashes the pyboard
output_mupy
=
b
'
CRASH
'
else
:
output_mupy
=
pyb
.
execfile
(
test_file
).
replace
(
b
'
\r\n
'
,
b
'
\n
'
)
output_mupy
=
pyb
.
execfile
(
test_file
).
replace
(
b
'
\r\n
'
,
b
'
\n
'
)
except
pyboard
.
PyboardError
:
output_mupy
=
b
'
CRASH
\n
'
+
output_mupy
else
:
else
:
try
:
output_mupy
=
subprocess
.
check_output
([
MP_PY
,
'
-X
'
,
'
emit=bytecode
'
,
test_file
])
output_mupy
=
subprocess
.
check_output
([
MP_PY
,
'
-X
'
,
'
emit=bytecode
'
,
test_file
])
except
subprocess
.
CalledProcessError
:
except
subprocess
.
CalledProcessError
:
output_mupy
=
b
'
CRASH
'
output_mupy
=
b
'
CRASH
'
...
...
This diff is collapsed.
Click to expand it.
tools/pyboard.py
+
7
−
4
View file @
b636d024
...
@@ -22,6 +22,9 @@ To run a script from the local machine on the board and print out the results:
...
@@ -22,6 +22,9 @@ To run a script from the local machine on the board and print out the results:
import
time
import
time
import
serial
import
serial
class
PyboardError
(
BaseException
):
pass
class
Pyboard
:
class
Pyboard
:
def
__init__
(
self
,
serial_device
):
def
__init__
(
self
,
serial_device
):
self
.
serial
=
serial
.
Serial
(
serial_device
)
self
.
serial
=
serial
.
Serial
(
serial_device
)
...
@@ -38,7 +41,7 @@ class Pyboard:
...
@@ -38,7 +41,7 @@ class Pyboard:
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
if
not
data
.
endswith
(
b
'
raw REPL; CTRL-B to exit
\r\n
>
'
):
if
not
data
.
endswith
(
b
'
raw REPL; CTRL-B to exit
\r\n
>
'
):
print
(
data
)
print
(
data
)
raise
Exception
(
'
could not enter raw repl
'
)
raise
PyboardError
(
'
could not enter raw repl
'
)
def
exit_raw_repl
(
self
):
def
exit_raw_repl
(
self
):
self
.
serial
.
write
(
b
'
\r\x02
'
)
# ctrl-B: enter friendly REPL
self
.
serial
.
write
(
b
'
\r\x02
'
)
# ctrl-B: enter friendly REPL
...
@@ -56,7 +59,7 @@ class Pyboard:
...
@@ -56,7 +59,7 @@ class Pyboard:
self
.
serial
.
write
(
b
'
\x04
'
)
self
.
serial
.
write
(
b
'
\x04
'
)
data
=
self
.
serial
.
read
(
2
)
data
=
self
.
serial
.
read
(
2
)
if
data
!=
b
'
OK
'
:
if
data
!=
b
'
OK
'
:
raise
Exception
(
'
could not exec command
'
)
raise
PyboardError
(
'
could not exec command
'
)
data
=
self
.
serial
.
read
(
2
)
data
=
self
.
serial
.
read
(
2
)
timeout
=
0
timeout
=
0
while
True
:
while
True
:
...
@@ -72,10 +75,10 @@ class Pyboard:
...
@@ -72,10 +75,10 @@ class Pyboard:
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
if
not
data
.
endswith
(
b
'
\x04
>
'
):
if
not
data
.
endswith
(
b
'
\x04
>
'
):
print
(
data
)
print
(
data
)
raise
Exception
(
'
timeout waiting for EOF reception
'
)
raise
PyboardError
(
'
timeout waiting for EOF reception
'
)
if
data
.
startswith
(
b
'
Traceback
'
)
or
data
.
startswith
(
b
'
File
'
):
if
data
.
startswith
(
b
'
Traceback
'
)
or
data
.
startswith
(
b
'
File
'
):
print
(
data
)
print
(
data
)
raise
Exception
(
'
command failed
'
)
raise
PyboardError
(
'
command failed
'
)
return
data
[:
-
2
]
return
data
[:
-
2
]
def
execfile
(
self
,
filename
):
def
execfile
(
self
,
filename
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment