From b8a4f1a2658f675d1d47637a9e0a5fcaaece9b3f Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 19 Mar 2010 13:44:56 +0000 Subject: [PATCH] Added channel parameter to comedi_set_clock_source() and comedi_get_clock_source(). Bumped library version to 0.10.0. --- c++/include/comedilib.hpp | 20 ++++++++++++++++---- configure.ac | 4 ++-- demo/choose_clock.c | 4 ++-- demo/gpct_pulse_generator.c | 2 +- doc/extensions_funcref.txt | 11 ++++++++++- include/comedilib.h | 4 ++-- lib/insn_config_wrappers.c | 22 +++++++++++++++++----- lib/version_script | 6 ++++++ 8 files changed, 56 insertions(+), 17 deletions(-) diff --git a/c++/include/comedilib.hpp b/c++/include/comedilib.hpp index a999ec4..e7132df 100644 --- a/c++/include/comedilib.hpp +++ b/c++/include/comedilib.hpp @@ -418,9 +418,9 @@ namespace comedi } return retval; } - void get_clock_source(unsigned *clock, unsigned *period_ns) const + void get_clock_source(unsigned channel, unsigned *clock, unsigned *period_ns) const { - int retval = comedi_get_clock_source(comedi_handle(), index(), clock, period_ns); + int retval = comedi_get_clock_source(comedi_handle(), index(), channel, clock, period_ns); if(retval < 0) { std::ostringstream message; @@ -430,6 +430,18 @@ namespace comedi throw std::runtime_error(message.str()); } } + void get_gate_source(unsigned channel, unsigned gate_index, unsigned *gate_source) + { + int retval = comedi_get_gate_source(comedi_handle(), index(), channel, gate_index, gate_source); + if (retval < 0) + { + std::ostringstream message; + message << __PRETTY_FUNCTION__ << ": comedi_get_gate_source() failed."; + std::cerr << message.str() << std::endl; + comedi_perror("comedi_get_gate_source"); + throw std::runtime_error(message.str()); + } + } unsigned get_routing(unsigned channel) const { unsigned routing = 0; @@ -572,9 +584,9 @@ namespace comedi throw std::runtime_error(message.str()); } } - void set_clock_source(unsigned clock, unsigned period_ns) + void set_clock_source(unsigned channel, unsigned clock, unsigned period_ns) { - int retval = comedi_set_clock_source(comedi_handle(), index(), clock, period_ns); + int retval = comedi_set_clock_source(comedi_handle(), index(), channel, clock, period_ns); if(retval < 0) { std::ostringstream message; diff --git a/configure.ac b/configure.ac index 249d497..01e8ad6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -AC_INIT([comedilib], [0.9.0]) +AC_INIT([comedilib], [0.10.0]) AC_CANONICAL_TARGET([]) AC_CONFIG_MACRO_DIR([m4]) @@ -23,7 +23,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror]) # age to 0. # # AS_LIBTOOL arguments are (prefix, current, revision, age) -AS_LIBTOOL(COMEDILIB, 9, 0, 9) +AS_LIBTOOL(COMEDILIB, 10, 0, 10) #libscxi c:r:a SCXI_SO_VERSION=9:0:9 AC_SUBST(SCXI_SO_VERSION) diff --git a/demo/choose_clock.c b/demo/choose_clock.c index 7e05727..99e546c 100644 --- a/demo/choose_clock.c +++ b/demo/choose_clock.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) else period_ns = 0; clock_selection = options.value; - printf("Selecting master clock %d on subdevice %d.\n", clock_selection, options.subdevice); + printf("Selecting master clock %d for channel %d on subdevice.\n", clock_selection, options.channel, options.subdevice); if(period_ns) { printf("Clock period = %d nanoseconds.\n", period_ns); @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) printf("Clock period unspecified.\n"); } - retval = comedi_set_clock_source(device, options.subdevice, clock_selection, period_ns); + retval = comedi_set_clock_source(device, options.subdevice, options.channel, clock_selection, period_ns); if(retval < 0) comedi_perror("comedi_set_clock_source"); comedi_close(device); diff --git a/demo/gpct_pulse_generator.c b/demo/gpct_pulse_generator.c index 7c85ae9..0517a17 100644 --- a/demo/gpct_pulse_generator.c +++ b/demo/gpct_pulse_generator.c @@ -73,7 +73,7 @@ int ni_gpct_start_pulse_generator(comedi_t *device, unsigned subdevice, unsigned if(retval < 0) return retval; /* 20MHz clock */ - retval = comedi_set_clock_source(device, subdevice, NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS, clock_period_ns); + retval = comedi_set_clock_source(device, subdevice, 0, NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS, clock_period_ns); if(retval < 0) return retval; up_ticks = (up_time_ns + clock_period_ns / 2) / clock_period_ns; diff --git a/doc/extensions_funcref.txt b/doc/extensions_funcref.txt index 01c0a02..bb533ef 100644 --- a/doc/extensions_funcref.txt +++ b/doc/extensions_funcref.txt @@ -18,6 +18,7 @@ Function: comedi_get_clock_source -- get master clock for a subdevice Retval: int Param: comedi_t * device Param: unsigned int subdevice +Param: unsigned int channel Param: unsigned int *clock Param: unsigned int *period_ns Status: alpha @@ -32,6 +33,9 @@ Description: The frequency of the clock in nanoseconds (or zero if it is unknown) will be written to *period_ns. + If the subdevice does not support configuring its master clocks + on a per-channel basis, then the channel + parameter will be ignored. It is safe to pass NULL pointers as the clock or period_ns @@ -123,12 +127,17 @@ Function: comedi_set_clock_source -- set master clock for a subdevice Retval: int Param: comedi_t * device Param: unsigned int subdevice +Param: unsigned int channel Param: unsigned int clock Param: unsigned int period_ns Status: alpha Description: This function selects a master clock for a subdevice. The clock - parameter selects the master clock, and is driver-dependant. The period_ns + parameter selects the master clock, and is driver-dependant. + If the subdevice does not support configuring its master clocks on a + per-channel basis, then the channel parameter + will be ignored. + The period_ns parameter specifies the clock's period in nanoseconds. It may left unspecified by using a value of zero. Drivers will ignore the clock period if they already know what the clock period should be for the specified clock (i.e. for an diff --git a/include/comedilib.h b/include/comedilib.h index 4a0012f..e21c0b7 100644 --- a/include/comedilib.h +++ b/include/comedilib.h @@ -286,12 +286,12 @@ int comedi_internal_trigger(comedi_t *dev, unsigned subd, unsigned trignum); /* INSN_CONFIG wrappers */ int comedi_arm(comedi_t *device, unsigned subdevice, unsigned source); int comedi_reset(comedi_t *device, unsigned subdevice); -int comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned *SWIG_OUTPUT(clock), unsigned *SWIG_OUTPUT(period_ns)); +int comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *SWIG_OUTPUT(clock), unsigned *SWIG_OUTPUT(period_ns)); int comedi_get_gate_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned gate, unsigned *SWIG_OUTPUT(source)); int comedi_get_routing(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *SWIG_OUTPUT(routing)); int comedi_set_counter_mode(comedi_t *device, unsigned subdevice, unsigned channel, unsigned mode_bits); -int comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned clock, unsigned period_ns); +int comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned clock, unsigned period_ns); int comedi_set_filter(comedi_t *device, unsigned subdevice, unsigned channel, unsigned filter); int comedi_set_gate_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned gate_index, unsigned gate_source); int comedi_set_other_source(comedi_t *device, unsigned subdevice, unsigned channel, diff --git a/lib/insn_config_wrappers.c b/lib/insn_config_wrappers.c index 8361425..3fc8f56 100644 --- a/lib/insn_config_wrappers.c +++ b/lib/insn_config_wrappers.c @@ -63,8 +63,8 @@ int _comedi_arm(comedi_t *device, unsigned subdevice, unsigned target) else return -1; } -EXPORT_ALIAS_DEFAULT(_comedi_get_clock_source,comedi_get_clock_source,0.9.0); -int _comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned *clock, unsigned *period_ns) +EXPORT_ALIAS_DEFAULT(_comedi_get_clock_source,comedi_get_clock_source,0.10.0); +int _comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *clock, unsigned *period_ns) { comedi_insn insn; lsampl_t data[3]; @@ -73,7 +73,7 @@ int _comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned *clo memset(&insn, 0, sizeof(comedi_insn)); insn.insn = INSN_CONFIG; insn.subdev = subdevice; - insn.chanspec = 0; + insn.chanspec = channel; insn.data = data; insn.n = sizeof(data) / sizeof(data[0]); memset(data, 0, insn.n * sizeof(data[0])); @@ -86,6 +86,12 @@ int _comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned *clo return 0; } +EXPORT_ALIAS_VER(_comedi_get_clock_source_chan0,comedi_get_clock_source,0.9.0); +int _comedi_get_clock_source_chan0(comedi_t *device, unsigned subdevice, unsigned *clock, unsigned *period_ns) +{ + return _comedi_get_clock_source(device, subdevice, 0, clock, period_ns); +} + EXPORT_ALIAS_DEFAULT(_comedi_get_gate_source,comedi_get_gate_source,0.9.0); int _comedi_get_gate_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned gate, unsigned *source) @@ -151,8 +157,8 @@ int _comedi_set_counter_mode(comedi_t *device, unsigned subdevice, unsigned chan else return -1; } -EXPORT_ALIAS_DEFAULT(_comedi_set_clock_source,comedi_set_clock_source,0.9.0); -int _comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned clock, unsigned period_ns) +EXPORT_ALIAS_DEFAULT(_comedi_set_clock_source,comedi_set_clock_source,0.10.0); +int _comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned clock, unsigned period_ns) { comedi_insn insn; lsampl_t data[3]; @@ -171,6 +177,12 @@ int _comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned cloc else return -1; } +EXPORT_ALIAS_VER(_comedi_set_clock_source_chan0,comedi_set_clock_source,0.9.0); +int _comedi_set_clock_source_chan0(comedi_t *device, unsigned subdevice, unsigned clock, unsigned period_ns) +{ + return _comedi_set_clock_source(device, subdevice, 0, clock, period_ns); +} + EXPORT_ALIAS_DEFAULT(_comedi_set_filter,comedi_set_filter,0.9.0); int _comedi_set_filter(comedi_t *device, unsigned subdevice, unsigned channel, unsigned filter) { diff --git a/lib/version_script b/lib/version_script index 6721f23..6655605 100644 --- a/lib/version_script +++ b/lib/version_script @@ -110,3 +110,9 @@ v0.9.0 { comedi_set_routing; comedi_get_hardware_buffer_size; } v0.8.0; + +v0.10.0 { + global: + comedi_get_clock_source; + comedi_set_clock_source; +} v0.9.0; -- 2.26.2