A simple shell for pyboard
A simple shell for pyboard
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.
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.
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
Re: A simple shell for pyboard
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.
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
I took a look at stmhal/modos.c and it appears that os.stat was added on July 19th.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'll add a note to my README. Thanks
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
Re: A simple shell for pyboard
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
Is this due to 780?
Oh, there also is 537
Replacing '1:/' with '/sd/' and O with flash didn't fix it.
Last edited by Turbinenreiter on Fri Aug 01, 2014 6:53 am, edited 1 time in total.
Re: A simple shell for pyboard
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:
I'll get shell.py updated to work with the latest code real soon now.
If you want to play with shell.py then you can do this:
Code: Select all
cd stmhal
git checkout 5aac6a
make
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
Re: A simple shell for pyboard
Got it!
Replace 0:/, 1:/ with /sd, /flash
on line 83 change to
However, ls cuts the first few characters from the names it prints.
[I'm extremly excited about this.]
Replace 0:/, 1:/ with /sd, /flash
on line 83 change to
Code: Select all
if filename[0] == '/sd' or filename == '/flash':
[I'm extremly excited about this.]
Re: A simple shell for pyboard
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.
I'd like to change cd to use os.chdir and os.getcwd so then the directory change will be changed within the filesystem.
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
Re: A simple shell for pyboard
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
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.
Let me know if you run into any issues.
Re: A simple shell for pyboard
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.
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.