ports/unix: Add raw REPL support.#16141
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #16141 +/- ##
=======================================
Coverage 98.54% 98.54%
=======================================
Files 169 169
Lines 21898 21898
=======================================
Hits 21579 21579
Misses 319 319 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Code size report: |
75567d5 to
7904157
Compare
|
Pushed a commit to wrap the changes to |
Ah. Thanks for pointing out those PRs. I completely overlooked them when scanning for PRs. I see the value in a more unified approach to the repl - I was just chasing a particular feature and so a much more limited change. I'm happy to close this PR in favour of #12802 or #6008. |
|
This PR is nice and simple, and may still be needed. Let's keep it open until the other ones are merged/closed. |
Add raw REPL support to the unix port. This make it possible to
connect to a unix micropython instance using mpremote and
utilise the functionality of the raw REPL. This is useful for
debugging and CI tests of mpremote and related tools.
Eg:
```
socat PTY,link=$HOME/.upy-pty,rawer |
EXEC:./build-standard/micropython,pty,stderr,onlcr=0 &
mpremote resume connect ~/.upy-pty ls
```
Requires the inclusion of `#include "extmod/modplatform.h"` in
`pyexec.c` so that `MICROPY_BANNER_MACHINE` is fully resolved.
Changes are wrapped in `#ifdef linux` to ensure no impact on
the windows port.
Signed-off-by: Glenn Moloney <[email protected]>
7904157 to
f03f2be
Compare
Summary
Add raw REPL support to the unix port. This make it possible to connect to a unix micropython instance using mpremote and utilise the functionality of the raw REPL. This is useful for debugging and CI tests of mpremote and related tools.
For example, one can run micropython behind a PTY with
socatand connect to the slave pty (as if it were a serial port) withmpremote:(The
resumeargument is required since micropython v1.24 as a soft reset terminates the micropython process).or, using the micropython docker image (thanks to @mattytrentini ):
Testing
This has been tested using private CI workflows adapted from those in the
mpremote-pathtool (which usesmpremoteas a library).Trade-offs and Alternatives
The changes impact only the unix port (adding
pyexec.cto the build) and present a user-visible change through behaviour when a ctrl-A character is entered at the repl. However, this reflects expected behaviour on other ports and should not impact on expected or supported usage.