So I've had a little project going on with the foosball table at work: a system to detect when someone scores a goal. I've built a prototype photogate that goes inside of the goal. My design is to have 2 photogates hooked up to my PhidgetSBC2 and write some ruby code to detect a goal and send a message to a connected iPad app to indicate who scored. Everything was going fine until I took the PhidgetSBC2 to our foosball table and discovered our 2.4GHz network had no coverage there. Which means the wifi usb adapter I had for the PhidgetSBC2 was useless. Undeterred I started on 2 different solutions.
Tag archives: phidgetsbc2
PhidgetSBC2 and ruby
Installing ruby (and the phidgets-ffi
gem) on the PhidgetSBC2 is fairly simple. You will need to check Include full Debian Package Repository
under System > Packages
in the SBC admin page. And then just ssh into the server and run the following:
apt-get update && apt-get install ruby1.9.1 ruby1.9.1-dev build-essential -y
And then you can install the phidgets-ffi
gem like so:
gem1.9.1 install ffi phidgets-ffi
The gem doesn't find the libphidgetsbc.so.0
on the PhidgetSBC, so we need to symlink it to somewhere that the gem will find it.
ln -s /usr/lib/libphidget21.so.0 /usr/lib/libphidget21.so
Once we're done this we can test it with this:
ruby1.9.1 -rphidgets-ffi -e 'puts Phidgets::FFI.library_version'
I also like to run this to add the ruby1.9.1
executables (i.e. rake
, irb
, gem
) without the 1.9.1
suffix.
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
--slave /usr/bin/erb erb /usr/bin/erb1.9.1 \
--slave /usr/bin/gem gem /usr/bin/gem1.9.1 \
--slave /usr/bin/rake rake /usr/bin/rake1.9.1 \
--slave /usr/bin/testrb testrb /usr/bin/testrb1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1
I also like to create an .gemrc
to skip installing ri
and rdoc
documentation to save on space.
echo install: --no-rdoc --no-ri >> ~/.gemrc
echo update: --no-rdoc --no-ri >> ~/.gemrc