Friday, November 14, 2014

The almost perfect Raspberry Pi dev setup

I want to learn more coding for Raspberry Pi and Arduino and one problem I have is being able to do so from different places and machines. I use both github and bitbucket and they are awesome but not once it happened that I wrote a bit of code and forgot to commit before leaving that machine. Even if I could be more careful with this, there is the aspect of having an IDE installed everywhere like Eclipse for Java, Arduino IDE, IDLE for Python. The solution for Arduino coding is codebender that I mentioned in a couple of my previous posts. Python I am mostly doing on Raspberry Pi and the solution is Adafruit's WebIDE - it is a great editor and one of the first things I install on every SD card for my Raspberry Pis.

For Java, I started a couple weeks ago to look at online editors like Cloud9 and others. Cloud9 looks great and it is one of the few editors of this kind that handles Java projects. However, recently I found an article (unfortunately, I didn't keep the link) that was reviewing several online editors from a Java coding point of view and the one the author of that article liked the most was Codenvy about which I have to admit I didn't even know until then. There were a lot of pro arguments for it in the article so I decided to give it a try. And I am so happy I did! As I read in the article, creating Java projects is a breeze; I tried both a new project and one cloned from a git repo: both worked like a charm. As a side note, I don't know Maven and Codenvy uses Maven (same as Heroku and other cloud apps) so this was a bit of a hiccup for me but I'm learning.

Codenvy integrates with both github and bitbucket so one can keep online and offline projects in sync this way. Also, there is a very powerful command line utility, Codenvy CLI that can be used to interface with projects, take them offline, or execute critical developer services.

But the thing I absolutely love about Codenvy is the fact that it has an Eclipse plugin that makes Eclipse aware of the Codenvy projects and allows both updating the Eclipse project with the Codenvy changes and the other way around. This is absolutely awesome! Now I can write code from anywhere without having Eclipse installed locally and when I get home, update the Eclipse project with these changes, keep coding and when done pushing the new code back to Codenvy. More, my Eclipse setup at home uses a plugin I found recently, LaunchPi that makes it possible to run and debug Java projects on Raspberry Pi directly from Eclipse. I found another similar plugin but it needed to be configured, with jars to be installed on the Pi and started separately; LaunchPi is so simple, just configure the Pi's IP address, the main class to run and done; and it also allows debugging which is simply great.

And if I want to deploy the code to the Pi, not just test it, I can always use a Maven goal to do this; as an example, look at the pom file used by Robert Savage, the author of the amazing Pi4J - but about this awesome library in another post.

I love this setup and the only reason I said in the title the "almost" perfect setup because there is one thing missing: if I could run and debug the code on the Pi from the Codenvy editor directly, that would be the icing on the cake. Maybe it is possible, I know there are ways to create a Pi emulator using QEMU but I haven't figured out yet how to do it and if it is possible to use it directly from Codenvy; maybe not but I'll try to find a way. Even without that, I am very happy with the current setup. Now, to do some coding!

2 comments:

Anonymous said...

Hey merlin13! I work with Codenvy. Thanks for the shout out! We'd love to send you a Codenvy t-shirt for the blog love here. Shoot me an email at mfloth@codenvy.com. Hope to hear from you! :)

merlin13 said...

Wow, this is so cool! Thank you so much!