Notes based on Setting Up a python Development Environment with PyCharm for setting up PyCharm editor to work with EV3. Requires passwordless ssh into the brick and the brick on 192.168.1.106 .
We’re going to go round the houses with git checkins to move stuff from the Mac and the PyCharm editor to the brick.
Get into the brick and do some minimal config stuff:
[Mac] ssh robot@192.168.1.106 [EV3] sudo apt-get update [EV3] sudo apt-get install git [EV3] mkdir -p /home/robot/demoproj [EV3] mkdir -p /home/robot/demoproj/.demoproj.git [EV3] git init --bare /home/robot/demoproj/.demoproj.gitNow use the nano editor on the brick to populate the demoproj dir with the files we push, setting them to be executable.
[EV3] nano /home/robot/demoproj/.demoproj.git/hooks/post-receiveIn the nano editor, change the file to:
#!/bin/shgit --work-tree=/home/robot/demoproj --git-dir=/home/robot/demoproj/.demoproj.git checkout -f
chmod ugo+x /home/robot/demoproj/*.py
Then ctrl-x to exit, saying Yes to save the file on the way out and accepting the default file name. Now make that hook executable:
[EV3] chmod +x /home/robot/demoproj/.demoproj.git/hooks/post-receiveIn PyCharm, Check Out From Version Control to crate a new project, selecting git as a the checkout target (so you’ll also need git installed on the Mac etc).
The VCS Repository URL is: robot@192.168.1.106:/home/robot/demoproj/.demoproj , the Parent Directory and Direectory names specifying the location on the Mac where you want to keep a local copy of the project files.
Say yes to all the crap PyCharm wants to create, and Yes when it prompts if you want to open the newly created directory. Create a new python file containing the following test program:
#!/usr/bin/python#The shebang above runs this file with the python shell
from ev3dev.auto import Sound
#Make a short sound
Sound.tone(1000,10)
Save it, press the VCS /UP ARROW/ button top right in PyCharm to commit, add a commit message, then bottom right Commit and Push .
This should commit the file locally and also push it into the git repo on the ev3; the commit hook on the ev3 will copy the file into the demoproj folder and mark it as executable.
You should now be able to locate it and run it from the ev3dev file browser.