Skip to content

csdehaan/phidgets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phidgets

DESCRIPTION:

Phidgets are a set of “plug and play” building blocks for low cost USB sensing and control from your PC. This gem provides a ruby interface to the phidgets library.

FEATURES/PROBLEMS:

  • Version 1.x of this gem is for Phidget Lib 2.2. For the older Phidget Lib 2.1, use version 0.1.3 of the gem.

  • This gem compiles a c extension for the phidget library, so the library must be installed and the development files must be located in a place that the compiler can find them. For windows the DevKit is required.

  • The gem has been tested to work on both Linux and Windows.

  • Tested with Phidget Library 2.2 Version 1.12

  • Method names follow the naming convention of the C library (getState, setState, etc). In addition, more “rubyish” aliases are provided (state, state=, etc)

SYNOPSIS:

require 'phidgets'

begin
  di = Phidgets::DigitalInput.new
  di.open_wait_for_attachment 500

  puts "Device Name     = #{di.device_name}"
  puts "Serial Number   = #{di.device_serial_number}"
  puts "Device Version  = #{di.device_version}"

  di.close

rescue Phidgets::Error => e
  puts e
end

# Or using callbacks:

di = Phidgets::DigitalInput.new
di.on_attach { |phid|
  puts "Device Name     = #{phid.device_name}"
  puts "Serial Number   = #{phid.device_serial_number}"
  puts "Device Version  = #{phid.device_version}"
}

di.open
sleep 3
di.close

# The gem also installs a command line program that will list all phidget devices
# that are attached. For example:

  => phidget
  ----------------------------------------------------------------------------
  | SerialNumber    | Class                                | Hub    | Index  |
  ----------------------------------------------------------------------------
  | 269819          | Voltage Input                        | 0      | 0      |
  | 269819          | Voltage Input                        | 0      | 1      |
  | 269819          | Voltage Ratio Input                  | 0      | 0      |
  | 269819          | Voltage Ratio Input                  | 0      | 1      |
  | 269819          | Digital Input                        | 0      | 0      |
  | 269819          | Digital Input                        | 0      | 1      |
  | 269819          | Digital Output                       | 0      | 0      |
  | 269819          | Digital Output                       | 0      | 1      |
  ----------------------------------------------------------------------------

REQUIREMENTS:

  • The Phidgets library (www.phidgets.com/)

  • For Windows the ruby DevKit is required

  • The development header file and library must be placed in a location where the compiler can find them. For Linux this should be done when running “make install” for the Phidget Library. For Windows the files need to be copied from the install directory (\Program Files\Phidgets). phidget22.h can be copied to RUBY_DIR\include\ruby-x.x.x. phidget22.lib can be copied to RUBY_DIR\lib.

INSTALL:

  • sudo gem install phidgets

LICENSE:

Copyright © 2009 Craig DeHaan

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

About

A ruby gem to provide an interface to the phidgets library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published