There was a problem with the solution, at the time I posted the up/down keys for accessing MicroPython history did not seem to work.
I have Pi4B and Pico here in hospital, but no ESP[01].
So I looked for another network to serial code that could be run on Pi4B for testing.
I did find that code (to be run with python3) from pyserial repo:
https://github.com/pyserial/pyserial/bl ... edirect.py
This is how to start on default port 7777:
Code: Select all
$ python3 tcp_serial_redirect.py /dev/serial0 115200
--- TCP/IP to Serial redirect on /dev/serial0 115200,8,N,1 ---
--- type Ctrl-C / BREAK to quit
Waiting for connection on 7777...
I tried netcat (nc) command, but that did not work.
After "sudo apt install telnet", telnet did work:
Code: Select all
$ telnet 127.0.0.1 7777
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
>>> import os
import os
>>> os
os
<module 'uos'>
>>>
MiocroPython REPL worked fine, besides the fact that input was echoed on first response line:
Code: Select all
>>> os.listdir()
os.listdir()
['catalan.py', 'string.mpy']
>>>
Next I tried "up" key and it worked as well (one time as well as pressed two times), as can be seen by echoed line:
Code: Select all
>>> ^[[A
os.listdir()
['catalan.py', 'string.mpy']
>>> ^[[A^[[A
os
<module 'uos'>
>>>
Even down key works, in example after two "up" keys does last command again:
Code: Select all
>>> ^[[A^[[A^[[B
os
<module 'uos'>
>>>
So it is not that history commands don't work, but that:
- input gets echoed on next line
- only after pressing enter, not on pressing up/down keys
Next need to see how to see echoed input on pressing up/down keys, and how to make sure that cursor will be at correct place (after REPL prompt).
P.S:
Left cursor key works as well:
Code: Select all
>>> ^[[A
os
<module 'uos'>
>>> ^[[A^[[D^[[Du
uos
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'uos' isn't defined
>>>