
Better exception handling. More consistent handling of return values. Updated documentation.
520 lines
12 KiB
Text
520 lines
12 KiB
Text
This directory contains files for building a Ruby extension library
|
|
for Comedi.
|
|
|
|
Instructions for building by hand (you shouldn't need to do this):
|
|
|
|
1. Type 'ruby setup.rb config'. This configures for the local
|
|
environment.
|
|
|
|
2. Type 'ruby setup.rb setup'. This builds the extension library.
|
|
|
|
3. Type 'ruby setup.rb install'. This installs the extension
|
|
library and the file lib/comedi.rb, which provides more
|
|
Ruby-like method syntax.
|
|
|
|
The file 'lib/comedi.rb' provides syntactic sugar in four forms:
|
|
|
|
1. Method names without the 'comedi_' prefix. The Comedi module
|
|
disambiguates the namespace. For example, you can say
|
|
'dev = Comedi::open()' instead of 'dev = Comedi::comedi_open()'.
|
|
|
|
2. Instance methods that take an explicit receiver instead of
|
|
expecting the target object as an initial argument. For example:
|
|
'comedi_close(dev)' can be written as 'dev.close'.
|
|
|
|
3. A pre-defined IO object and an accessor method to simplify
|
|
reading from the file descriptor associated with the comedi device.
|
|
Data from comedi device 'dev' can be read by 'dev.ios.read'.
|
|
|
|
4. A ComediError exception class. If the underlying comedi
|
|
function returns an error indication, the ruby method will raise
|
|
ComediError. If the comedi function returns both a status and a
|
|
value (e.g., comedi_data_read), the status is not returned by the
|
|
ruby method unless it carries information in addition to indication
|
|
of failure (e.g., comedi_command_test).
|
|
|
|
5. Ruby booleans. Comedi functions that return C integer boolean values
|
|
(comedi_range_is_chan_specific, comedi_maxdata_is_chan_specific)
|
|
have corresponding boolean ruby methods with '?' appended to the
|
|
method name.
|
|
|
|
Files in 'demo' are straight ports of their C counterparts from the
|
|
Comedilib 'demo' directory. They illustrate the basics of programming
|
|
Comedi commands using Ruby.
|
|
|
|
For completeness, the set of method definitions invoked by 'comedi.rb'
|
|
is as follows:
|
|
|
|
# Module: Comedi
|
|
|
|
def open(*args)
|
|
value = comedi_open(*args)
|
|
raise ComediError.new if value.nil?
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def parse_calibration_file(*args)
|
|
value = comedi_parse_calibration_file(*args)
|
|
raise ComediError.new if value.nil?
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def loglevel(*args)
|
|
value = comedi_loglevel(*args)
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def perror(*args)
|
|
value = comedi_perror(*args)
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def strerrno(*args)
|
|
value = comedi_strerrno(*args)
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def errno(*args)
|
|
value = comedi_errno(*args)
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def to_phys(*args)
|
|
value = comedi_to_phys(*args)
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def from_phys(*args)
|
|
value = comedi_from_phys(*args)
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi
|
|
|
|
def set_global_oor_behavior(*args)
|
|
value = comedi_set_global_oor_behavior(*args)
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def close(*args)
|
|
value = comedi_close(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def fileno(*args)
|
|
value = comedi_fileno(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_subdevice_type(*args)
|
|
value = comedi_get_subdevice_type(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def find_subdevice_by_type(*args)
|
|
value = comedi_find_subdevice_by_type(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_read_subdevice(*args)
|
|
value = comedi_get_read_subdevice(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_write_device(*args)
|
|
value = comedi_get_write_device(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_subdevice_flags(*args)
|
|
value = comedi_get_subdevice_flags(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_n_channels(*args)
|
|
value = comedi_get_n_channels(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def range_is_chan_specific?(*args)
|
|
value = comedi_range_is_chan_specific(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return ret == 1
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def maxdata_is_chan_specific?(*args)
|
|
value = comedi_maxdata_is_chan_specific(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return ret == 1
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_n_ranges(*args)
|
|
value = comedi_get_n_ranges(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def find_range(*args)
|
|
value = comedi_find_range(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_buffer_size(*args)
|
|
value = comedi_get_buffer_size(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_max_buffer_size(*args)
|
|
value = comedi_get_max_buffer_size(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def set_buffer_size(*args)
|
|
value = comedi_set_buffer_size(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def trigger(*args)
|
|
value = comedi_trigger(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def do_insnlist(*args)
|
|
value = comedi_do_insnlist(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def do_insn(*args)
|
|
value = comedi_do_insn(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def lock(*args)
|
|
value = comedi_lock(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def unlock(*args)
|
|
value = comedi_unlock(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def data_read_hint(*args)
|
|
value = comedi_data_read_hint(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def data_write(*args)
|
|
value = comedi_data_write(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def dio_config(*args)
|
|
value = comedi_dio_config(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def dio_write(*args)
|
|
value = comedi_dio_write(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def cancel(*args)
|
|
value = comedi_cancel(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def command(*args)
|
|
value = comedi_command(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def poll(*args)
|
|
value = comedi_poll(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def set_max_buffer_size(*args)
|
|
value = comedi_set_max_buffer_size(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_buffer_contents(*args)
|
|
value = comedi_get_buffer_contents(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def mark_buffer_read(*args)
|
|
value = comedi_mark_buffer_read(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_buffer_offset(*args)
|
|
value = comedi_get_buffer_offset(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def data_read(*args)
|
|
status, value = comedi_data_read(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def data_read_delayed(*args)
|
|
status, value = comedi_data_read_delayed(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def dio_read(*args)
|
|
status, value = comedi_dio_read(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def dio_bitfield(*args)
|
|
status, value = comedi_dio_bitfield(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_cmd_src_mask(*args)
|
|
status, value = comedi_get_cmd_src_mask(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_cmd_generic_timed(*args)
|
|
status, value = comedi_get_cmd_generic_timed(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def command_test(*args)
|
|
status, value = comedi_command_test(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return status, value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_maxdata(*args)
|
|
value = comedi_get_maxdata(self, *args)
|
|
raise ComediError.new if value == 0
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def apply_calibration(*args)
|
|
value = comedi_apply_calibration(self, *args)
|
|
raise ComediError.new if value < 0
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def apply_parsed_calibration(*args)
|
|
value = comedi_apply_parsed_calibration(self, *args)
|
|
raise ComediError.new if value < 0
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_driver_name(*args)
|
|
value = comedi_get_driver_name(self, *args)
|
|
raise ComediError.new if value.nil?
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_board_name(*args)
|
|
value = comedi_get_board_name(self, *args)
|
|
raise ComediError.new if value.nil?
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_range(*args)
|
|
value = comedi_get_range(self, *args)
|
|
raise ComediError.new if value.nil?
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_default_calibration_path(*args)
|
|
value = comedi_get_default_calibration_path(self, *args)
|
|
raise ComediError.new if value.nil?
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_n_subdevices(*args)
|
|
value = comedi_get_n_subdevices(self, *args)
|
|
return value
|
|
end
|
|
|
|
# Module: SWIG::TYPE_p_comedi_t
|
|
|
|
def get_version_code(*args)
|
|
value = comedi_get_version_code(self, *args)
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi::Comedi_sv_t
|
|
|
|
def sv_init(*args)
|
|
value = comedi_sv_init(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi::Comedi_sv_t
|
|
|
|
def sv_update(*args)
|
|
value = comedi_sv_update(self, *args)
|
|
raise ComediError.new if value == -1
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi::Comedi_sv_t
|
|
|
|
def sv_measure(*args)
|
|
status, value = comedi_sv_measure(self, *args)
|
|
raise ComediError.new if status == -1
|
|
return value
|
|
end
|
|
|
|
# Module: Comedi::Comedi_calibration_t
|
|
|
|
def cleanup_calibration_file(*args)
|
|
value = comedi_cleanup_calibration_file(self, *args)
|
|
return value
|
|
end
|
|
|
|
Steven Jenkins
|
|
steven.jenkins@ieee.org
|
|
2004-03-02
|