Page 1 of 5
A simple shell for pyboard
Posted: Thu Jul 31, 2014 7:37 am
by dhylands
I ported part of python's cmd module to MicroPython and then created a simple command line shell which can be run on your pyboard.
You can grab cmd.py from here:
https://raw.githubusercontent.com/dhyla ... cmd/cmd.py
and shell.py from here:
https://github.com/dhylands/upy-shell
Currently, it supports 3 commands: cd, cat, and ls
It allows you to see MicroPython's view of the file systems.
Re: A simple shell for pyboard
Posted: Thu Jul 31, 2014 8:28 am
by Turbinenreiter
Hah!
Now we need nano and keyboard input, display is already there - and we have a computer.
edit:
hm.
ls: os has no attribute stat. my build is from july 12th. was this added later or do I need micropython-lib?
other commands work.
Re: A simple shell for pyboard
Posted: Thu Jul 31, 2014 2:18 pm
by dhylands
Turbinenreiter wrote:hm.
ls: os has no attribute stat. my build is from july 12th. was this added later or do I need micropython-lib?
other commands work.
I took a look at stmhal/modos.c and it appears that os.stat was added on July 19th.
I'll add a note to my README. Thanks
Re: A simple shell for pyboard
Posted: Fri Aug 01, 2014 6:41 am
by Turbinenreiter
Code: Select all
>>> shell.run()
1:/> ls
Cannot access '1:/': No such file or directory
1:/> cd log
Directory '1:/log' does not exist
1:/> cat boot.py
Cannot acces file '1:/boot.py': No such file
Both log and boot py exist in 1:/
Is this due to
780?
Oh, there also is
537
Replacing '1:/' with '/sd/' and O with flash didn't fix it.
Re: A simple shell for pyboard
Posted: Fri Aug 01, 2014 6:49 am
by dhylands
Well - it's actually due to
https://github.com/micropython/micropyt ... 1652a35c82 which landed just after I wrote shell.py
If you want to play with shell.py then you can do this:
Code: Select all
cd stmhal
git checkout 5aac6a
make
I'll get shell.py updated to work with the latest code real soon now.
Re: A simple shell for pyboard
Posted: Fri Aug 01, 2014 7:02 am
by Turbinenreiter
Got it!
Replace 0:/, 1:/ with /sd, /flash
on line 83 change to
Code: Select all
if filename[0] == '/sd' or filename == '/flash':
However, ls cuts the first few characters from the names it prints.
[I'm extremly excited about this.]
Re: A simple shell for pyboard
Posted: Fri Aug 01, 2014 7:08 am
by dhylands
That should work as a hack
I'd like to change cd to use os.chdir and os.getcwd so then the directory change will be changed within the filesystem.
Re: A simple shell for pyboard
Posted: Fri Aug 01, 2014 8:07 am
by Turbinenreiter
That last fix to micropython is pretty cool, implementing the other os methods and making imports work without adding to sys.path(). I have to remeber to
update the wiki on importing after I changed my scripts.
Re: A simple shell for pyboard
Posted: Tue Aug 12, 2014 6:56 am
by dhylands
I've updated shell.py to work with the latest micropython filesystem changes (/flash and /sd).
Let me know if you run into any issues.
Re: A simple shell for pyboard
Posted: Wed Aug 13, 2014 6:43 am
by torwag
Hi,
might it be possible to turn the interactive REPL mode of micropython a bit more into something like ipython.
I use ipython all the time for testing and debugging. It would be really nice to have some of the features in micropython as well.
Esp. nice would be code history. Just use the arrow keys to browse through the last X lines of code and resubmit a certain line would be so helpful to debug at the hardware level.