rshell - Remote Shell

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
yogotech
Posts: 15
Joined: Tue Feb 25, 2020 5:11 am

Re: rshell - Remote Shell

Post by yogotech » Thu Mar 05, 2020 6:05 am

jimmo wrote:
Thu Mar 05, 2020 5:22 am
yogotech wrote:
Thu Mar 05, 2020 4:51 am
How can I do this with rshell, and is there a way to capture the output?
I think the idea is that you use the "repl" command to get to the MicroPtyhon prompt hit Ctrl-D to soft reset (if you've previously loaded this file), then run "import blink"

Code: Select all

rshell> repl ~ import blink~
to enter the repl and run the command and then back to rshell.

Code: Select all

/pyboard> repl ~ import blink ~
Entering REPL. Use Control-X to exit.
>
MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32
Type "help()" for more information.
>>> 
>>> import blink 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'blink'
>>> /pyboard>
No joy. The above may be due to my unfamiliarity with python, as my simple example code is not a class per-se, but it should be easy to just 'run' the file similar to how ampy does.

wr300000
Posts: 32
Joined: Sun Jan 14, 2018 3:54 pm

Re: rshell - Remote Shell

Post by wr300000 » Thu Mar 05, 2020 6:39 am

Normally I use screen to enter REPL. I recently use rshell as IDE
rshell -p /dev/ttyUSB0 --editor nano --buffer-size=30
/home/wr300000> repl <---- get in repl and release machine.reset() to rerun my main.py

Below is result from my main.py showing normal /sd directory and other configured variables.
GC:
37952 total
12256 : 25696
1=84 2=8 m=264
free RAM = 9312 bytes
I2C(PCF8574) LCD not found
free SDcard = 7926009856 bytes
total SDcard = 7931396096 bytes
stack: 2768 out of 8192
GC: total: 37952, used: 12880, free: 25072
No. of 1-blocks: 99, 2-blocks: 8, max blk sz: 264, max free sz: 1457
Thr 5 MAR 2020 - 12:39 UTC+ 7
MicroPython v1.12-195-gb16990425-dirty on 2020-03-03; ESP module with ESP8266
Type "help()" for more information.
>>> dir()
['winteroff', 'uos', 'sdcheck', 'nettime', 'ppwmstop', 'mem_info', 'clear', 'os', 'sd', 'gc', 'dayl', 'pwordd', 'plow', 'pscl', 'sid', 'esp', 'cat', 'cp', 'platform', 'sdcard', 'pword', 'sleep_ms', 'dlboot', 'machine', 'Pin', 'ssidd', 'sync_ntp', 'i2cPinSCL', 'summeroff', 'I2C', 'now', 'soff', 'webrepl', 'ticks_ms', 'phigh', 'i2cPinSDA', 'bdev', '__name__', 'ppwm', 'delayboot', 'psda', 'daylight', 'woff'] <---- /sd and configured variable are present

>>> os.listdir()
['sd', 'boot.py', 'main.py', 'webrepl_cfg.py', 'confighw.py', 'conf.py', 'board.py'] <---- before ctrl-X

>>> <---- ctrl-X to shell
/home/wr300000> ls /pyboard <---- release rshell list command
board.py conf.py main.py
boot.py confighw.py webrepl_cfg.py <---- /sd and all configured variable gone

/home/wr300000> repl
Entering REPL. Use Control-X to exit.
MicroPython v1.12-195-gb16990425-dirty on 2020-03-03; ESP module with ESP8266
Type "help()" for more information.
>>>
>>> dir() <---- /sd and all configured variable gone
['bdev', 'get_stat', '__name__', 'stat', 'uos', 'esp', 'webrepl', 'gc', 'output']
>>>

Why did rshell Iist command effect to main.py ?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: rshell - Remote Shell

Post by jimmo » Thu Mar 05, 2020 7:30 am

yogotech wrote:
Thu Mar 05, 2020 6:05 am
No joy. The above may be due to my unfamiliarity with python, as my simple example code is not a class per-se, but it should be easy to just 'run' the file similar to how ampy does.
You also need to cp blink.py to the device.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: rshell - Remote Shell

Post by pythoncoder » Thu Mar 05, 2020 9:04 am

The way I work is as follows. I use a programmers' editor (Kate) to edit a file, say myfile.py. Assume I want to run myfile.main(). From the directory containing the file I run rshell. Let's say the target is a Pyboard with an SD card. At the rshell prompt I issue

Code: Select all

path> cp myfile.py /sd
repl
>>> import myfile
>>> myfile.main()
ctrl-x takes you back to rshell.
Note this can be streamlined, so after ctrl-x all you need is an uparrow to run an edited version:

Code: Select all

path> cp myfile.py /sd; repl ~ import myfile ~ myfile.main()
Peter Hinch
Index to my micropython libraries.

yogotech
Posts: 15
Joined: Tue Feb 25, 2020 5:11 am

Re: rshell - Remote Shell

Post by yogotech » Fri Mar 06, 2020 12:04 am

jimmo wrote:
Thu Mar 05, 2020 7:30 am
yogotech wrote:
Thu Mar 05, 2020 6:05 am
No joy. The above may be due to my unfamiliarity with python, as my simple example code is not a class per-se, but it should be easy to just 'run' the file similar to how ampy does.
You also need to cp blink.py to the device.
ARGH, it was on the device, but I must have fat-fingered it.

:evil:

Thanks (I feel stupid now).

yogotech
Posts: 15
Joined: Tue Feb 25, 2020 5:11 am

Re: rshell - Remote Shell

Post by yogotech » Fri Mar 06, 2020 12:06 am

pythoncoder wrote:
Thu Mar 05, 2020 9:04 am
The way I work is as follows. I use a programmers' editor (Kate) to edit a file, say myfile.py. Assume I want to run myfile.main(). From the directory containing the file I run rshell. Let's say the target is a Pyboard with an SD card. At the rshell prompt I issue

Code: Select all

path> cp myfile.py /sd
repl
>>> import myfile
>>> myfile.main()
ctrl-x takes you back to rshell.
Note this can be streamlined, so after ctrl-x all you need is an uparrow to run an edited version:

Code: Select all

path> cp myfile.py /sd; repl ~ import myfile ~ myfile.main()
This would work for me, but many of the example programs I'm using haven't defined a main method, so it appears that just

Code: Select all

>>> import myfile
Is probably adequate for them.

[ I still think having a run command would be faster and more intuitive, but I'll quit whining now.... ;) ]

Thanks everyone!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: rshell - Remote Shell

Post by pythoncoder » Fri Mar 06, 2020 6:52 am

I still think having a run command would be faster and more intuitive
I'm not sure what you're advocating but you could look at pyboard.py to see if that fits the bill.

An rshell line like the one I posted (which is easily adapted for your case with no main() function) gives an extremely fast edit-test cycle because of rshell's ability to recall previous lines.
Peter Hinch
Index to my micropython libraries.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: rshell - Remote Shell

Post by SpotlightKid » Mon May 11, 2020 6:14 pm

Would it be possible to tag new releases of rhell in the repo and also mark them as releases on https://github.com/dhylands/rshell/releases (in addition to the releases on PyPI)?

This would make it easier for distribution package maintainers to get notified about new releases (I recently took over maintenance of the rshell AUR package).

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: rshell - Remote Shell

Post by dhylands » Mon May 11, 2020 6:35 pm

Yeah - I could do that.

I added releases for 0.0.27 and 0.0.28

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: rshell - Remote Shell

Post by SpotlightKid » Mon May 11, 2020 7:08 pm

Very nice.Thank you.

Post Reply