Tuesday, September 22, 2009

Bringing the Cloud Closer: Ruby and the Illuminato X Machina

Cloud processing is all the rage, but everything from privacy concerns to large datasets can be a hinderance. Enter the Illuminato X Machina and the new Ruby LibIXM.

The Illuminato X Machina platform can scale processes to multiple modular segments on the fly. These units are local hardware, not slow remote servers, so IO is cheap. With a library for communication to the host machine, the community can start building powerful libraries.

Those on the Illuminato X Machina mailing list are familiar with the packet interface David Ackley has already written in C++. A partner in that system is the sfbprog binary. sfbprog is meant to auto-program IXMs with new sketches, but through a simple hack can create a packet-based terminal to the Illuminato X Machina hardware:
sfbprog -n /dev/ttyUSB0 -S - -t 0 -f /tmp/old_sketch.hex
old_sketch.hex needs to have an older timestamp than the code currently running on your IXMs. Flavor the device and .hex file to taste, and you've got a real-time packet interface to the Illuminato X Machina hardware.

LibIXM and Ruby

The sfbprog terminal is a simple solution, but not something you want to build on top of. Building a Ruby library gives the Illuminato X Machina's community a toe-hold on the desktop machines connected to IXM hardware. LibIXM for Ruby has two levels of abstraction:
  • Adapters: hardware compatibility layers.
  • Interfaces: software behavior models.
Currently, the adapter layer is limited to a wrapper around sfbprog. That means all communications with the Illuminato X Machina go over the packet interface, guaranteeing a level of consistency.

The basic interface supported by this first release is Simple. This interface is based off a callback pattern, similar to the Body.reflex already available in the IXM core API.

So Happy Together

Enough talk, let's see some code. This sketch is a basic packet-level echo for the Illuminato X Machina hardware:
void yowl(u8 * packet) {
facePrintf(packetSource(packet), "You sent me a '%#p'\n", packet);

void setup() {

void loop() {}
And this is a Ruby LibIXM "yodler" built off the sketch:
require File.join( File.dirname(__FILE__), '..', 'libixm' )

ixm = LibIXM.new()

# Build a reflex for our packet
responded = false

ixm.attach_reflex( /yodel/ ) do |packet|
puts "IXM yodeled: #{packet}"
responded = true

# Send a packet.
ixm << "yodel yo momma ha"

# Wait for the response.
loop { break if responded }
With the default Simple interface you get the method of attach_reflex. Richer interfaces should follow in the future!

LibIXM should be available as a gem from Github, but Github is having yet another epic FAIL this week. You can install it as a gem:
wget http://www.liquidware.com/system/0000/2752/libixm-0.1.0.gem
sudo gem install ./libixm-0.1.0.gem
Or pull the source via git at http://github.com/mixonic/libixm. This takes "throwing hardware at a problem" to a whole new level! Go grab yourself an Illuminato X Machina and IXM Red Terminal Programmer and start pushing some work off your desktop's processor.

** Update **

Github just caught up and built the gem, so now you can install with:

gem sources -a http://gems.github.com
sudo gem install mixonic-libixm


Matt said...

wait are you kidding? nice goin!

Matt said...

do a lot of people use ruby? i wish i knew what lots of coders use... i use perl, for instance, but that kinda fell out of favor in the 1990's i think...