Page 6 of 9
Re: rshell - Remote Shell
Posted: Fri Jan 25, 2019 7:37 pm
by seonr
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
Re: rshell - Remote Shell
Posted: Fri Jan 25, 2019 10:39 pm
by seonr
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!
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
Re: rshell - Remote Shell
Posted: Sat Jan 26, 2019 7:34 am
by pythoncoder
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.
Re: rshell - Remote Shell
Posted: Sun Jan 27, 2019 7:41 am
by seonr
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
Re: rshell - Remote Shell
Posted: Mon Mar 02, 2020 1:09 pm
by fma
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,
Re: rshell - Remote Shell
Posted: Mon Mar 02, 2020 5:32 pm
by dhylands
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.
Re: rshell - Remote Shell
Posted: Mon Mar 02, 2020 5:36 pm
by fma
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!
Re: rshell - Remote Shell
Posted: Mon Mar 02, 2020 6:54 pm
by dhylands
Can you send me your email? My email is dhylands at gmail dot com
Re: rshell - Remote Shell
Posted: Thu Mar 05, 2020 4:51 am
by yogotech
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)
How can I do this with rshell, and is there a way to capture the output?
Re: rshell - Remote Shell
Posted: Thu Mar 05, 2020 5:22 am
by jimmo
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
to enter the repl and run the command and then back to rshell.