Firmata : OSGi example
Introduction
Ubiquisense comes with Serial communication features which allows to easily connect to Arduino boards over USB.
The communication IO take the form of an Rx/Tx queues full duplex communication. All aspect of the communication gets blended behind a basic Java API in an OSGi/Plugin SDK.
On the other side, Arduino boards are shipped with a software called Firmata which intends to handle analog/digital pins IOs over USB. Firmata protocol is Midi based and so, comes with a very low footprint and minimum bandwidth consumption.
Communication between an Arduino board and an host PC is now made so easy. As easy as developing few lines of an Eclipse RCP plugin. A single class in your plugin and you just get access to an Arduino software instance continuously updated from Firmata midi messages.
Obviously, the OSGi nature of the framework could be of some detestation for few people. Anyway OSGi/Equinox brings so much modularity and flexibility to it !
Let's explore this interesting programming model, leveraging a lot of model driven development inside and getting usable with a simple Java API.
How does it works ?
Below is the minimum amount of code necessary to get a communication and syncronization with an Arduino :
|
| Java2html |
Starting with Firmata (SDK)
In order to get done with Eclipse and Firmata, you will need Ubiquisense to get installed from update site and create a new plugin. Because Ubiquisense is an OSGi based framework, it is mandatory to get this plugin and create an application. If you are comfortable with eclipse/RCP development, you can also inspire yourself from the code and get it integrated into a view or a console.
The following steps are describing various installations and manipulations needed to get the example running. At the end of the day, it will be a good Eclipse training and will open so many new horizons !
Let's start the fun part ;-)
Step 1
Install Ubiquisense from update site or Eclipse marketplace : http://ubiquisense.com/p/ubiquisense/updates/0.5.1/site.xml
Step 2
Get Arduino for your platform : http://arduino.cc/en/Main/Software
Step 3
Install Standard Firmata on your Arduino board using Arduino IDE (Files > examples > Firmata > Standard Firmata)
Step 4
Import firmata example code com.ubiquisense.firmata.example plugin with code
Step 5
Open plugin.xml in the manifest editor and go to the extensions tab. Select the org.eclipse.core.runtime.applications contribution and then click the green arrow icon at the top of the page.
Troubleshooting :
If getting following error while running application, just try to add a -d32 option in launch configuration program arguments tab.
java.lang.UnsatisfiedLinkError: /eclipse-4.2RC2/plugins/org.rxtx.macosx.x86_2.1.72.201206301655/lib/librxtxSerial.jnilib: no suitable image found. Did find: /eclipse-4.2RC2/plugins/org.rxtx.macosx.x86_2.1.72.201206301655/lib/librxtxSerial.jnilib: no matching architecture in universal wrapper
1AcVECc3ysGMqqVDTEZLxAy8Z3XScCfX81


