Sunday, February 9, 2014

LEGO Mindstorms RCX 2.0 in 2014...

I still have a LEGO Mindstorms RCX 2.0 from 2003, and once more the question was: Is it still possible to program the device?

The Windows XP computer that I had used in 2010 (with difficulty, see post from back then) is no more. A brief search only indicated that there's no driver for Windows Vista/7/8, let alone 64 bit. BUT: I always preferred using the RCX with LeJOS, i.e. Java, instead of the Windows based GUI. Then it turns out that Linux actually contains a `linuxusbtower` kernel driver in most distributions. So overall, this sounded easier than ever?!

After installing a current Ubuntu release, the LEGO USB tower was indeed recognized, creating `/dev/usb/legousbtower1` whenever plugged in. But LeJOS 2.1.0 just didn't work, giving various communication errors in the `firmdl` program. I tried to compile the `linuxusbtower` kernel driver from the 2.1.0 sources, but could not find an easy way to get the required kernel source includes.

The solution was to use the LeJOS 3.0.0 "release candidate" (from 2006). It communicated with the Ubuntu-provided `legousbtower` kernel driver just fine. Only quirks:

  • `lejos/bin/*` scripts needed to be `chmod`ed as executable
  • `lejos/bin/lejos` needed the same "export LD_LIBRARY_PATH" and "java -cp .." for the `*.so` shared library that was already in `lejos/bin/lejosjc`
These changes might be included in the latest CVS checkout, but the `*.tgz` download has the advantage that for example `firmdl` can be invoked right away without having to build anything.

Used Eclipse by creating a plain Java project, then removing the default JRE links and instead adding the `lejos/lib/*.jar` files to the build path.
So with Linux and Java, it's possible to use a 10+ year old LEGO brick, and it works just fine.
Compared to an Arduino, it is actually still quite attractive as an into to computer fun for teenagers: In one box, with batteries, you get a motor controller, sensor reader, and simple display and "beeper". With an Arduino, you'd have to add a battery box, speaker, motor shield, LCD, plus put that all into an enclosure.