Support communication via stdin/stderr rather than serial port #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My ideal workflow with micropython would be to editing source files in my text editor, with mpy-watch syncing the changes to the microcontroller, but also to have the repl open so that I could manually try out functions or whatever.
Having the repl and mpy-watch connected at the same time isn't really an option, so this is an attempt at a workaround.
picocom has a
--send-cmd
option which is intended for use with a file-send program such as sx or sz. The specified command is spawned with picocom's serial port attached to stdin and stdout.This PR adds a
--pipe
option to each of the mpy-utils programs, which will use the stdin/stdout filehandles instead of using the serial port directly, allowing these to be spawned from picocom.eg.
picocom -b 115200 -s "mpy-sync --pipe --reset src/"
From with picocom, hitting C-a C-s enter will run mpy-sync, and then return to the repl.
The serial port handling code in replcontrol.py has been factored out into a
ReplIOSerial
class, and aReplIOFileHandle
class has been added.All four mpy-utils have been converted. I don't quite see a use-case for spawning mpy-fuse from the repl, but it got added for completeness.
These can be tested directly from the Linux command-line by redirecting the serial device file to both stdin and stdout.
eg.
mpy-watch --pipe --debug < /dev/ttyUSB0 > /dev/ttyUSB0
All logging and trace messages have been changed to use stderr.