Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
e4ba57c5
Commit
e4ba57c5
authored
May 29, 2021
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/pyboard.py: Add "soft_reset" option to Pyboard.enter_raw_repl().
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
4982d092
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
tools/pyboard.py
tools/pyboard.py
+17
-12
No files found.
tools/pyboard.py
View file @
e4ba57c5
...
...
@@ -322,7 +322,7 @@ class Pyboard:
time
.
sleep
(
0.01
)
return
data
def
enter_raw_repl
(
self
):
def
enter_raw_repl
(
self
,
soft_reset
=
True
):
self
.
serial
.
write
(
b"
\r\x03\x03
"
)
# ctrl-C twice: interrupt any running program
# flush input (without relying on serial.flushInput())
...
...
@@ -332,18 +332,23 @@ class Pyboard:
n
=
self
.
serial
.
inWaiting
()
self
.
serial
.
write
(
b"
\r\x01
"
)
# ctrl-A: enter raw REPL
data
=
self
.
read_until
(
1
,
b"raw REPL; CTRL-B to exit
\r\n
>"
)
if
not
data
.
endswith
(
b"raw REPL; CTRL-B to exit
\r\n
>"
):
print
(
data
)
raise
PyboardError
(
"could not enter raw repl"
)
self
.
serial
.
write
(
b"
\x04
"
)
# ctrl-D: soft reset
data
=
self
.
read_until
(
1
,
b"soft reboot
\r\n
"
)
if
not
data
.
endswith
(
b"soft reboot
\r\n
"
):
print
(
data
)
raise
PyboardError
(
"could not enter raw repl"
)
# By splitting this into 2 reads, it allows boot.py to print stuff,
# which will show up after the soft reboot and before the raw REPL.
if
soft_reset
:
data
=
self
.
read_until
(
1
,
b"raw REPL; CTRL-B to exit
\r\n
>"
)
if
not
data
.
endswith
(
b"raw REPL; CTRL-B to exit
\r\n
>"
):
print
(
data
)
raise
PyboardError
(
"could not enter raw repl"
)
self
.
serial
.
write
(
b"
\x04
"
)
# ctrl-D: soft reset
# Waiting for "soft reboot" independently to "raw REPL" (done below)
# allows boot.py to print, which will show up after "soft reboot"
# and before "raw REPL".
data
=
self
.
read_until
(
1
,
b"soft reboot
\r\n
"
)
if
not
data
.
endswith
(
b"soft reboot
\r\n
"
):
print
(
data
)
raise
PyboardError
(
"could not enter raw repl"
)
data
=
self
.
read_until
(
1
,
b"raw REPL; CTRL-B to exit
\r\n
"
)
if
not
data
.
endswith
(
b"raw REPL; CTRL-B to exit
\r\n
"
):
print
(
data
)
...
...
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