Now that go is installed (see Part 1), you can get down to business and start using phidgets. I've written a go phidgets library (currently only
IR phidgets are implemented, open an issue or pull request if you want more) at github.com/samuelkadolph/go/phidgets.
The latest version of the PhidgetSBC line includes an ARMv5 processor which means it now has support for go. Unfortunately the current golang package in the debian repository does not work but I was able to compile golang from source on the PhidgetSBC3 and it worked (including
cgo). Thanks to the
"The Go Language Gophers" team I downloaded the
golang-tip package and built it on my PhidgetSBC3. I've made this
deb available in my apt repository so you can easily install go and get rocking.
If you are using a PhidgetSBC3 you might see this a lot:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_CA.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory
This is because perl is very vocal when you are missing the locales that your environment specifies. The fix is easy, just generate the locales that you want to use (
en_CA.UTF-8 is the default). This assumes you have already set up SSH on your PhidgetSBC3.
- Enable full Debian Package Repository
- Update apt
- Install the locales package
apt-get install locales -y
- Add the
echo "en_CA.UTF-8 UTF-8" >> /etc/locale.gen
- Generate the locale
You should see it generating the locale you specified and once it's done, you will no longer see the locale error messages.
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.
gem) without the
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
rdoc documentation to save on space.
echo install: --no-rdoc --no-ri >> ~/.gemrc echo update: --no-rdoc --no-ri >> ~/.gemrc
Since we cannot install
mono-complete on the PhidgetSBC2 currently, we are missing some of the C# namespaces. If you are trying to use any of the following namespaces and
gmcs cannot find it, you will have to install the respective package.
I really wanted to write the code in C# because it's simply better than Java and it's lot easier to implement a server in C# than in C. While the manual for the SBC2 says you can get Mono working if you install the correct packages, I couldn't find any information on the Phidget website on how to do it, so I had to figure it out myself.