Push files from local to PyBoard

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Kip
Posts: 19
Joined: Sat Dec 26, 2015 7:23 am

Push files from local to PyBoard

Post by Kip » Tue May 14, 2019 1:02 am

Hi,

I'm just wondering if there are any methods/projects that would allow me to send files and commands to the PyBoard. I would like to work in a directory on my computer (so I can use git) but not manually copy and paste the files to the pyboard every time. I imagine one command that:
git add .
Pushes the files from local to pyboard
Restarts the pyboard (ctrl+d)
starts displaying the output of the pyboard

I'd write the script myself but I'm scared of changing the write permissions of my /dev/ttyACM0 file as I don't have any experience doing this type of stuff.

If there is an existing/similar method, could someone please point me in that direction. I fear I lack the jargon to google the correct question.

Thanks,

Kip

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

Re: Push files from local to PyBoard

Post by jimmo » Tue May 14, 2019 2:12 am

I mostly use the pyboard.py tool that is part of the MicroPython repo (which is great for testing short scripts because it never writes them to the filesystem at all), but I think what you probably want is https://github.com/dhylands/rshell/blob ... README.rst

Damien
Site Admin
Posts: 610
Joined: Mon Dec 09, 2013 5:02 pm

Re: Push files from local to PyBoard

Post by Damien » Tue May 14, 2019 5:45 am

You may also be interested in the following tool: https://github.com/micropython/micropython/pull/3034

User avatar
Kip
Posts: 19
Joined: Sat Dec 26, 2015 7:23 am

Re: Push files from local to PyBoard

Post by Kip » Wed May 15, 2019 6:57 am

Great, that's just what I needed!

If anyone is interested, I did the following to get what I wanted:

1. Install rshell

Code: Select all

sudo pip3 install rshell
2. Create a custom command by making a upyrun file in /usr/bin/

Code: Select all

sudo nano /usr/bin/upyrun
3. Add the following commands to the upyrun file:

Code: Select all

git add .
rshell cp *.py /sd
rshell repl pyboard import main
I import main to get the main.py file running on the pyboard
Change /sd to /flash if you are not using an sd card

4. make command file executable

Code: Select all

sudo chmod +x /usr/bin/upyrun

5. run the command in the directory that your files are kept on your machine and that are to be reproduced on the pyboard.

Code: Select all

sudo upyrun
This is great because the files are ready to be used straight away unlike when you are editing the files directly from the PyBoard as it can take some time for the files to update after saving.

FYI: to stop code running on the pyboard use ctrl+c and to exit the repl use ctrl+x

User avatar
Kip
Posts: 19
Joined: Sat Dec 26, 2015 7:23 am

Re: Push files from local to PyBoard

Post by Kip » Thu May 16, 2019 10:28 pm







Post Reply