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.
seonr
Posts: 37
Joined: Mon Sep 10, 2018 6:54 am

Re: rshell - Remote Shell

Post by seonr » Fri Jan 25, 2019 7:37 pm

pythoncoder wrote:
Fri Jan 25, 2019 1:14 pm
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.
Ahh, ok I miss-understood... I thought it was suggested to use pyboard from inside rshell, as it ships with it... not to use it stand alone. Ok, I'll give that a crack, thanks!

The reason I was using rshell to start with is to get files copied over from the PI to my dev board, which I still need to do.

Seon
unexpectedmaker.com

seonr
Posts: 37
Joined: Mon Sep 10, 2018 6:54 am

Re: rshell - Remote Shell

Post by seonr » Fri Jan 25, 2019 10:39 pm

Ok, I am now using a combo of rshell and pyboard as I still need to copy over a bunch of files to the TinyPICO after the firmware is flashed, and couldn't see a way of doing a file copy with pyboard directly.

Using pyboard and directly inserting code via REPL reduced my overall flash time by 5 seconds!

Image

I'm pretty stocked with this result... Under 30secs would be better, but at least I am now under 40!

Thanks for the help folks!

Seon
unexpectedmaker.com

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

Re: rshell - Remote Shell

Post by pythoncoder » Sat Jan 26, 2019 7:34 am

Just to clarify rshell is a tool for managing the filesystem on the device and accessing its REPL. In normal use you write code on a PC and use rshell to copy the script to the device. Using rshell's REPL you run and test your code. It is a powerful utility and it's well worth studying the docs to get the best from it.

The pyboard utility is a more specialist tool intended for remote execution of code.

rshell happens to use pyboard internally.
Peter Hinch

seonr
Posts: 37
Joined: Mon Sep 10, 2018 6:54 am

Re: rshell - Remote Shell

Post by seonr » Sun Jan 27, 2019 7:41 am

pythoncoder wrote:
Sat Jan 26, 2019 7:34 am
Just to clarify rshell is a tool for managing the filesystem on the device and accessing its REPL. In normal use you write code on a PC and use rshell to copy the script to the device. Using rshell's REPL you run and test your code. It is a powerful utility and it's well worth studying the docs to get the best from it.

The pyboard utility is a more specialist tool intended for remote execution of code.

rshell happens to use pyboard internally.
Thanks... I got it working without rshell until the last step, where I use it to copy a bunch of files to the TinyPICO that I want included when they ship to customers.

pyboard took a bit to work out, but it's working great now, thanks everyone for your patience :-)

Seon
unexpectedmaker.com

fma
Posts: 163
Joined: Wed Jan 01, 2014 5:38 pm
Location: France

Re: rshell - Remote Shell

Post by fma » Mon Mar 02, 2020 1:09 pm

Hi!

I just bought a Pycom Wipy 3.0 board, and I'm trying to use it with rshell. Everything seems to works, except files transert. For example:

Code: Select all

> cat /flash/main.py
# main.py -- put your code here!Traceback (most recent call last):
  File "/usr/local/bin/rshell", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/rshell/command_line.py", line 4, in main
    rshell.main.main()
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 2913, in main
    real_main()
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 2896, in real_main
    shell.cmdloop(cmd_line)
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 1730, in cmdloop
    cmd.Cmd.cmdloop(self)
  File "/usr/lib/python3.7/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 1760, in onecmd
    self.onecmd_exec("".join(group))
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 1771, in onecmd_exec
    return cmd.Cmd.onecmd(self, line)
  File "/usr/lib/python3.7/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 2043, in do_cat
    cat(filename, self.stdout)
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 622, in cat
    xfer_func=recv_file_from_remote)
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 1472, in remote
    xfer_func(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/rshell/main.py", line 1077, in recv_file_from_remote
    dst_file.write(binascii.unhexlify(write_buf[0:read_size]))
binascii.Error: Non-hexadecimal digit found
I get the same error if I copy a file from or to the board.

On the other hand, if I try to cat /flash/boot.py, it does nothing (but does not return).

Any idea what can cause this?

Thanks,
Frédéric

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

Re: rshell - Remote Shell

Post by dhylands » Mon Mar 02, 2020 5:32 pm

Hi Frederic,

I'm guessing that there must be some subtle differences in the data being sent back and forth. Unfortunately, I don't have a WiPy 3 board to try and reproduce the problem.

I could send you a modified rshell that would help me to understand what's going on.

fma
Posts: 163
Joined: Wed Jan 01, 2014 5:38 pm
Location: France

Re: rshell - Remote Shell

Post by fma » Mon Mar 02, 2020 5:36 pm

dhylands wrote:
Mon Mar 02, 2020 5:32 pm
I could send you a modified rshell that would help me to understand what's going on.
I would be great!
Frédéric

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

Re: rshell - Remote Shell

Post by dhylands » Mon Mar 02, 2020 6:54 pm

Can you send me your email? My email is dhylands at gmail dot com

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

Re: rshell - Remote Shell

Post by yogotech » Thu Mar 05, 2020 4:51 am

Long-time developer, just getting started in Python, using micropython because I like embedded systems.

I was using ampy, but am trying to switch to rshell since the Filesystem commands are very useful.

However, one of the things that I'm struggling with (and it may be my unfamiliarity with Python) is how to do the edit/run cycle.

I created a new python file, and now I want to to run it, all from the comfort of rshell.

Code: Select all

% rshell
Using buffer-size of 32
Connecting to /dev/cu.SLAB_USBtoUART (buffer-size 32)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ...  Y
Retrieving root directories ...
...
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
/Users/myname/esp32>
So far so good, I just created a file on the board

Code: Select all

/Users/myname/esp32> cd /pyboard
/pyboard> edit blink.py
...

Code: Select all

from machine import Pin
import time

def blink(pin=2):
    p = Pin(pin, Pin.OUT)
    try:
        while True:
            p.value(not p.value())
            time.sleep_ms(500)
    except:
        p.value(0)
        Pin(pin, Pin.IN)

blink()
Ok, now what? I want to run the code in blink.py, and I'm not sure how. I know with ampy, I would do the following (but I would lose all the console output)

Code: Select all

% ampy run blink.py 
How can I do this with rshell, and is there a way to capture the output?

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

Re: rshell - Remote Shell

Post by jimmo » 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"

Hit Ctrl-X to get back to the rshell prompt.

Edit: you can also use

Code: Select all

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

Post Reply