The initial implementation of a Ruby FFI interface to a Vernier GoIO sensor now works!
http://gist.github.com/254981
It's an adaptation of the GoIO_DeviceCheck.cpp sample app supplied with the Vernier GoIO SDK.
http://www.vernier.com/downloads/gosdk.html
Vernier makes all kinds of inexpensive sensors and interfaces:
http://www.vernier.com/go/
$ jruby test.rb
This app is linked to GoIO lib version 2.28
...
GoLink found. Enumerated id: 0x1d100000
Sensor id: 10:
25 measurements received after about 1 second.
Average measurement: 3.352 Volts
$ ruby test.rb
This app is linked to GoIO lib version 2.28
...
GoLink found. Enumerated id: 0x1d100000
Sensor id: 10:
25 measurements received after about 1 second.
Average measurement: 3.350 Volts
While the initial implementation is ugly (and doesn't do much) I think it's quite amazing that I can use one dynamic library
from Vernier and the same FFI code in Ruby and JRuby!
Vernier supplies the full source code for their SDK as public domain. They have dynamic libraries for Mac OS X and Windows (not
sure how hard it would be to also compile one for Linux). I don't have a Windows system here but if Nokogiri can work on
Windows I'll bet this can also.