From: Frank Mori Hess Date: Thu, 12 Jul 2007 14:57:08 +0000 (+0000) Subject: New demo program. X-Git-Tag: v0_8_0~21 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=81d55d2a522a88a5595667d2f1c4bdb4b214babf;p=comedilib.git New demo program. --- diff --git a/demo/choose_filter.c b/demo/choose_filter.c new file mode 100644 index 0000000..787d689 --- /dev/null +++ b/demo/choose_filter.c @@ -0,0 +1,65 @@ +/* + * INSN_CONFIG_FILTER example + * Part of Comedilib + * + * Copyright (c) 1999,2000 David A. Schleef + * Copyright (c) 2007 Frank Mori Hess + * + * This file may be freely modified, distributed, and combined with + * other software, as long as proper attribution is given in the + * source code. + */ +/* + * Requirements: A board with a subdevice that supports + * INSN_CONFIG_FILTER, such as the PFI subdevice on an NI m-series + * or 660x board. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "examples.h" + + +comedi_t *device; + +int main(int argc, char *argv[]) +{ + int retval; + lsampl_t filter_selection; + struct parsed_options options; + + init_parsed_options(&options); + parse_options(&options, argc, argv); + + device = comedi_open(options.filename); + if(!device){ + comedi_perror(options.filename); + exit(-1); + } + filter_selection = options.value; + printf("Selecting filter %d on subdevice %d channel %d.\n", filter_selection, options.subdevice, options.channel); + comedi_insn insn; + lsampl_t data[2]; + memset(&insn, 0, sizeof(comedi_insn)); + insn.insn = INSN_CONFIG; + insn.subdev = options.subdevice; + insn.chanspec = options.channel; + insn.data = data; + insn.n = sizeof(data) / sizeof(data[0]); + data[0] = INSN_CONFIG_FILTER; + data[1] = filter_selection; + + retval = comedi_do_insn(device, &insn); + if(retval < 0) comedi_perror("comedi_do_insn"); + return retval; +} +