Hi all Qwerkers,
I have successfully compiled the Ruby language on the Qwerk (Ruby is A Programmer's Best Friend : see www.ruby-lang.org). The port is complete : you can cross-compile C extensions (I have done it for the libqwerk, the serial port library and the camcapture module), use threads, sockets and even the included WEBrick web-server, etc. The good news is that it is very lightweight and can fit into the embedded flash on the qwerk (size of the full thing is 4MB, size of Ruby executable is 500kb).

To make it available, I have created the "Ruby On Qwerk" project on RubyForge.org.
If you are interested, you can download the precompiled binaries for the Qwerk at http://rubyforge.org/frs/?group_id=4614&release_id=15406.
This release includes the wrapper for libqwerk, that enables to use the Qwerk's hardware devices from Ruby.

Just for the beauty of the beast, a small example of code moving a servo :

Code:

require 'qwerk'

servo = Qwerk::RCServo.new(1)
servo.set_bounds(0, 32, 228)
begin
  servo.set_position(0, 0)
  sleep(0.5)
  servo.set_position(0, 128)
  sleep(0.5)
  servo.set_position(0, 255)
  sleep(0.5)
end while true


and a code that plays pacman.wav :

Code:

require "qwerk"

hardware = Qwerk::QwerkHardware.new
audio = Qwerk::QEAudioController.new(hardware)
audio.enable
audio.play_clip("/opt/pacman.wav")
puts "Press <Enter>"
gets



In order to run the examples above, you first need to install Ruby on your Qwerk. This is done by simply copying the ruby directory from the release file to /opt on your qwerk.
The best way to transfer files to/from your qwerk is use NFS (Network File System) : http://nfs.sourceforge.net/nfs-howto/
On Ubuntu, you just need to modify the /etc/exports file. Here is mine for example :

Code:

# /etc/exports: the access control list for filesystems which may be exported
#      to NFS clients.  See exports(5).
/home/steux/Desktop
/home/steux/terk    192.168.22.1/255.255.255.0(rw,sync,no_root_squash)     


(192.168.22.1 is obviously the IP address of my Qwerk on my network, and /home/steux/terk the directory I want to mount on the Qwerk)
After editing this file, you may need to run exportfs to update the NFS server :

Code:

sudo exports


Now, you should log onto your Qwerk, either through the serial port, by using screen on linux :

Code:

screen -U /dev/ttyS0 57600


or minicomm, or HyperTerminal on Windows.
You can also use telnet to access the Qwerk :

Code:

telnet 192.168.22.1


Then, on the Qwerk, you can mount your file system :

Code:

mount -o nolock 192.168.22.4:/home/steux/terk /mnt/terk


and if the Ruby release is under /home/steux/terk, you can copy Ruby to the Qwerk's flash memory by typing :

Code:

cp -r /mnt/terk/ruby /opt


At last, you have to add the ruby binaries to your path :

Code:

export PATH=/opt/ruby/bin:$PATH


You can check that Ruby is working by running irb (instant Ruby):

Code:

irb
irb(main):001:0> 1+1
=> 2
irb(main):002:0> exit


or by typing :

Code:

ruby -e '5.times { puts "Hello World"}'
Hello World
Hello World
Hello World
Hello World
Hello World



For those who want to build Ruby themselves, here are the configure options that do the trick :

Code:

env \
  CROSS_COMPILING=1 \
  CC="arm-linux-gcc"  \
  CPP="arm-linux-cpp" \
  CXX="arm-linux-g++" \
  LDFLAGS="" \
  OBJCOPY="arm-linux-objcopy" \
  LD="arm-linux-ld" \
  AR="arm-linux-ar" \
  RANLIB="arm-linux-ranlib" \
  NM="arm-linux-nm" \
  STRIP="arm-linux-strip" \
  ac_cv_func_setpgrp_void=yes \
  ac_cv_func_isinf=no \
  ac_cv_func_isnan=no \
  ac_cv_func_finite=no \
  ./configure \
    --host=arm-qwerk-linux \
    --without-x \
    --disable-largefile \
    --prefix=/opt/ruby \
    --enable-socket=yes \
    --without-Win32API \
    --disable-ipv6


You will then just need to type make, and sudo make install. This will install Ruby in the /opt/ruby on your machine, which you can then transfer onto the Qwerk...
A short post install script that removes unnecessary libraries (who needs support for japanese?) :

Code:

sudo chown -R $(whoami) /opt/ruby
rm /opt/ruby/lib/libruby-static.a
rm /opt/ruby/lib/ruby/1.8/arm-linux/nkf.so
arm-linux-strip /opt/ruby/bin/ruby
cp rbconfig.rb /opt/ruby


Happy Rubying on the Qwerk !