Page 7 of 9
Re: rshell - Remote Shell
Posted: Thu Mar 05, 2020 6:05 am
by yogotech
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"
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.
Re: rshell - Remote Shell
Posted: Thu Mar 05, 2020 6:39 am
by wr300000
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 ?
Re: rshell - Remote Shell
Posted: Thu Mar 05, 2020 7:30 am
by jimmo
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.
Re: rshell - Remote Shell
Posted: Thu Mar 05, 2020 9:04 am
by pythoncoder
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()
Re: rshell - Remote Shell
Posted: Fri Mar 06, 2020 12:04 am
by yogotech
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.
Thanks (I feel stupid now).
Re: rshell - Remote Shell
Posted: Fri Mar 06, 2020 12:06 am
by yogotech
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
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!
Re: rshell - Remote Shell
Posted: Fri Mar 06, 2020 6:52 am
by pythoncoder
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.
Re: rshell - Remote Shell
Posted: Mon May 11, 2020 6:14 pm
by SpotlightKid
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).
Re: rshell - Remote Shell
Posted: Mon May 11, 2020 6:35 pm
by dhylands
Yeah - I could do that.
I added releases for 0.0.27 and 0.0.28
Re: rshell - Remote Shell
Posted: Mon May 11, 2020 7:08 pm
by SpotlightKid
Very nice.Thank you.