rshell - Remote Shell
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell - Remote Shell
OK. I use rshell on ESP32 running the official build without issue. I use --buffer-size=30 -a. If you try this and it doesn't work it must be a peculiarity of the Loboris port.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: rshell - Remote Shell
Thanks for the suggestion but unfortunately adding -a did not work so could be the port or something about my host setup.
Re: rshell - Remote Shell
I can't reproduce this, running on Ubuntu 17.10, latest MicroPython from repository on ESP-WROVER-KIT v3:
rshell installed with pip3.
Code: Select all
boris@UbuntuMate:/home/LoBo2_Razno/ESP32/MicroPython/test/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD$ rshell -p /dev/ttyUSB1
Connecting to /dev/ttyUSB1 ...
Welcome to rshell. Use Control-D to exit.
/home/LoBo2_Razno/ESP32/MicroPython/test/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD> ls
build/ firmware/ BUILD.sh partitions_mpy.csv sdkconfig.defaults
components/ main/ Makefile sdkconfig sdkconfig.old
/home/LoBo2_Razno/ESP32/MicroPython/test/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD> ls /flash
boot.py
/home/LoBo2_Razno/ESP32/MicroPython/test/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD> ls /pyboard
flash/
/home/LoBo2_Razno/ESP32/MicroPython/test/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD>
/home/LoBo2_Razno/ESP32/MicroPython/test/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD> repl
Entering REPL. Use Control-X to exit.
>
MicroPython ESP32_LoBo_v2.0.8 - 2017-11-04 on ESP32 board with ESP32
Type "help()" for more information.
>>>
>>> import os
>>> os.stat("/")
(16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
>>> os.stat("/flash")
(16384, 0, 0, 0, 0, 0, 999424, 946684800, 946684800, 946684800)
>>>
Re: rshell - Remote Shell
Just to close the loop on my issue with rshell and the @loboris port -- I hadn't pulled the latest firmware and was testing rshell with:
when I updated to
os.stat("/flash") and rshell work fine. Sorry for the noise.
Code: Select all
MicroPython ESP32_LoBo_v2.0.7 - 2017-11-01 on ESP32 board with ESP32
Code: Select all
MicroPython ESP32_LoBo_v2.0.8 - 2017-11-04 on ESP32 board with ESP32
Re: rshell - Remote Shell
Excuse my Python and MicroPython ignorance... super new to all of this... but I have a question about using rshell inside some python code to talk to and issue commands to my ESP32 board.
I have this all working atm using subprocess and using commands like...
where rshell_tests is a list of commands that copies MP code to the ESP32 and then runs it via repl... example:
I do stuff like this a few times.... it's a flashing and testing jig for my TinyPICO boards
it's working great as is, BUT it's slow... each time I do a shell call with
I get hit with the connection time it takes to get to the board I know that doesn't sound too bad, but every second I can shave off the flash/test cycle is super important on a PCB Assembly line.
What I'd really like to do is use rshell directly in my python code, where I can create a connection, and hold it open for all of the tests and stuff I want to do and then at the end, close it... something like
Is something like this possible? I have tried importing rshell to see what I have access to, but nothing pops out as being usable like this.
UPDATE:
So rshell.main has a bunch of stuff in it and I've tried this...
but I get the following error
Thanks
Seon
unexpectedmaker.com
I have this all working atm using subprocess and using commands like...
Code: Select all
cmd = "rshell -p /dev/ttyUSB0 -f rshell_tests";
result = "done" in str(subprocess.check_output(cmd, shell = True ))
Code: Select all
cp doit_tests.py /pyboard/tests.py
cp micropython_dotstar.py /pyboard/micropython_dotstar.py
repl ~ import tests ~ tests.TestIO() ~
echo "done"
it's working great as is, BUT it's slow... each time I do a shell call with
Code: Select all
cmd = "rshell -p /dev/ttyUSB0 xxxxxxxxx
What I'd really like to do is use rshell directly in my python code, where I can create a connection, and hold it open for all of the tests and stuff I want to do and then at the end, close it... something like
Code: Select all
conn = rshell.connect( dev/ttyUSB0 )
conn.command("repl ~ xxxxxxx")
# wait a bit
conn.command("repl ~ yyyyyyy")
# do other stuff
conn.close()
UPDATE:
So rshell.main has a bunch of stuff in it and I've tried this...
Code: Select all
from rshell import main
conn = main.connect_serial("/dev/ttyUSB0")
Code: Select all
Connecting to /dev/ttyUSB0 ...
Traceback (most recent call last):
File "test.py", line 2, in <module>
conn = main.connect_serial("/dev/ttyUSB0")
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1227, in connect_serial
dev = DeviceSerial(port, baud, wait)
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1473, in __init__
Device.__init__(self, pyb)
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1275, in __init__
if not BINARY_XFER:
NameError: name 'BINARY_XFER' is not defined
Seon
unexpectedmaker.com
Re: rshell - Remote Shell
I got a bit further...
But this is putting me into rshell in terminal... and doesn't do any connection until I hit CTRL+D to exit, then it shows it connecting and prints 1 for devices and then quits
I'm sure I'm missing something simple here... but I honestly have no idea what I am doing
Seon
unexpectedmaker.com
Code: Select all
from rshell import main
main.main()
conn = main.connect_serial("/dev/ttyUSB0")
print ( "Num devices: " + str(main.num_devices()))
I'm sure I'm missing something simple here... but I honestly have no idea what I am doing
Seon
unexpectedmaker.com
Re: rshell - Remote Shell
Internally, rshell (and ampy) uses pyboard.py (https://github.com/micropython/micropyt ... pyboard.py) for it's magic. So you might look at that and how rshell (or ampy) use that.
Re: rshell - Remote Shell
Thanks RoberthhRoberthh wrote: ↑Fri Jan 25, 2019 6:37 amInternally, rshell (and ampy) uses pyboard.py (https://github.com/micropython/micropyt ... pyboard.py) for it's magic. So you might look at that and how rshell (or ampy) use that.
So I've managed to get it to run some MP code via RELP using this
Code: Select all
from rshell import main
from rshell import pyboard
main.main()
main.connect_serial("/dev/ttyUSB0")
print ( "Num devices: " + str(main.num_devices()))
pyb = pyboard.Pyboard('/dev/ttyUSB0')
pyb.enter_raw_repl()
pyb.exec("from machine import SPI, Pin")
pyb.exec("from micropython_dotstar import DotStar")
pyb.exec("import network, time, micropython")
pyb.exec("spi = SPI(sck=Pin(12), mosi=Pin(13), miso=Pin(18))")
pyb.exec("dotstar = DotStar(spi, 1)")
pyb.exec("dotstar[0] = (255, 0, 255, 1)")
pyb.exit_raw_repl()
Code: Select all
main.main()
I've tried calling main.autoconnect() before main.main() but that doesn't do anything either.
Calling main.main() tells me there is no board connected, so puts me to the rshell prompt telling me to type connect...
Any idea how I tell it what the board is before I call main.main() ?
I've tried creating a Device() by passing in the pyb but that fails in the same place calling connect before main() fails... with this..
Code: Select all
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1275, in __init__
if not BINARY_XFER:
NameError: name 'BINARY_XFER' is not defined
And I can't seem to find a way and I can't call main.connect_serial() until after I call main.main().
Thanks,
Seon
unexpectedmaker.com
Re: rshell - Remote Shell
Ok, I got it connecting in min.main() by pre-setting the default port in the env
But it still stops at the rshell command prompt after connecting to /dev/ttyUSB0 and doesn't execute the rest of the code until I quit rshell with CTRL+D
Anyone with any ideas?
Seon
unexpectedmaker.com
Code: Select all
from rshell import main
from rshell import pyboard
import os
os.environ['RSHELL_PORT'] = "/dev/ttyUSB0"
main.main()
print ( "Num devices: " + str(main.num_devices()))
Anyone with any ideas?
Seon
unexpectedmaker.com
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell - Remote Shell
I think @Roberthh is right: pyboard.py is your way forward. rshell is a command line utility and is not really intended to be imported into Python code.
You might like to look at run-tests which is the Python script for running the MicroPython test suite. This enables tests to be run on the Pyboard using pyboard.py.
You might like to look at run-tests which is the Python script for running the MicroPython test suite. This enables tests to be run on the Pyboard using pyboard.py.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.