Hints and Tricks

Hints and Tricks

A few Hints and Tricks we’ve picked up from programming with the BrickPi.

Here is by Far the best productivity booster when Working with Raspberry Pi:

Editing code on RPi from the comfort of Notepad++

We work a lot on Raspberry Pi (Wheezy)and well as the Arduino and Atmel Studio(Windows). The setup that we usually have is the RPi running a VNC which we connect and program on the Rpi. But writing and maintaining code on the RPi is a very big pain. While the Windows is pretty stable and we can easily work for hours on it without any problems, its not the same with the RPi. Many a times due to network issues or some random problem disconnects the RPi. Mostly its harmless and only breaks the workflow, other times we lose the code that we had forgot to save and that just frustrates us. The RPi environment is also not that good to work from. Running a lot of things often slows down the Rpi and just makes it even worse to work with. So, after spending some time experimenting and putting all the bits and pieces together, we have shifted all the development from the usual VNC and SSH terminal to the text editor of our choice on Windows, Notepad++ and that has resulted in massive increase in our productivity. No more time wasted on buggy interface or data lost due to connection problems. We can now code on the go on my Rpi all from the comfort of our Notepad++.

Here’s the look at the setup that we have working.

So let’s get started.

We hope that you guys have the RPi up and running and are able to login at least by SSH, if not then this the definitive guide for that:

http://www.dexterindustries.com/BrickPi/getting-started/using-the-pi/

If you have this screen then you are good to go.

Configuring Notepad++

If you don’t have Notepad++ installed, don’t waste your time and install it now, we are sure you’ll love it. Here’s the page to download it from:

http://notepad-plus-plus.org/download/v6.5.html

Once you have it running just go to Plugins and check if NppFTP is installed. If it is then just click on Show NppFTP Window to get a menu on the right side of the editor.

If not, here’s the link to NppFTP http://sourceforge.net/projects/nppftp/

Now in the NppFTP window,  click on the Setting button(6th button), and select Profile Settings

Add a new profile with the Hostname as IP of RPi, Connection Type– SFTP, Port 22, Username– pi, Password -raspberry(or whatever the password is for you Rpi) and the initial home directory as the one where you work on (like /home/pi)

Close the Profile Settings and hit the first button on the NppFTP Window to connect.

If everything goes right, you’ll be prompted to trust the Host key, just select Yes.

And you’ll have access to your Rpi Files from Notepad++.

Granting Access to File Editing

The access that you have right now would only allow you to Read the files but not make changes to it.

To have the access to make changes and create files directly from your Notepad++ Editor, open the terminal using SSH from a client like Putty.

Now switch to root

# sudo su

And write this command

find path -type d -exec chmod 777 {} ;

with path as the path to the folder that you want to be able to edit from Notepad++.

Here’s what works for us,

find /home/pi -type d -exec chmod 777 {} ;

Found this one on a great Stack overflow post,

http://stackoverflow.com/questions/3740152/how-to-set-chmod-for-a-folder-and-all-of-its-subfolders-and-files-in-linux-ubunt

Have a look at it to know how it works.

Getting SSH working from Notepad++

On Ubuntu, the editor of our choice is Kate, because of the host of features it has, one which we like in particular is the terminal which is embedded in the editor itself, which makes life a lot easier when you need constant access to  the terminal for running the codes when working with languages like Python and C. There is a feature similar to that in Notepad++ too.

We’ll use that along with a few other packages to get access to the terminal on the Rpi from Notepad++ through SSH.

For Running SSH from Notepad++ too, install Npp console Plugin

http://sourceforge.net/projects/nppconsole/

(Just take the dll file and paste it in the Plugins folder where you had installed Notepad++ and restart Notepad++)

Now go to Plugins>NppConsole>Show NppConsole to get the command line in Notepad++.

Now, it’s time to get SSH working with the Console.

Now you need two more things, Putty’s console version and  a software to translate the translates the ANSI code from linux to windows readable code, which is Ansicon

Here are the links:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html(Look for Plink.exe)

https://github.com/adoxa/ansicon/downloads(Download the latest zip)

Unzip all, and put plink.exe as well as ANSI32.dll,ANSI64.dll and ansicon.exe from the Ansicon zip to an easily accessible place.

Now open the NPP console in Notepad++ and go to the directory containing the extracted files and type

 > ansicon.exe plink.exe -ssh user@location -pw yourpasword

> ansicon.exe plink.exe -ssh pi@192.168.3.234 -pw raspberry

And you should have the SSH up and running too.

Now you should have your full blown dev environment running directly from Notepad++.

A huge shout out to the to the guys working on Notepad++ and it’s plugins. Without them we would still have been working in the  the buggy dev environment.

P.S.: If you save a file and the upload icon does not go away after a few second’s it means that you have lost your connection with the Rpi, just copy the contents of the file you were working on in a temporary file, because after connecting again, if you open the file on the Rpi from Notepad++, it will open the previous version and discard the one that you were working on.

{"cart_token":"","hash":"","cart_data":""}