Added comedi_set_filter() and comedi_set_routing() configuration
[comedilib.git] / demo / choose_filter.c
1 /*
2  * INSN_CONFIG_FILTER example
3  * Part of Comedilib
4  *
5  * Copyright (c) 1999,2000 David A. Schleef <ds@schleef.org>
6  * Copyright (c) 2007 Frank Mori Hess <fmhess@users.sourceforge.net>
7  *
8  * This file may be freely modified, distributed, and combined with
9  * other software, as long as proper attribution is given in the
10  * source code.
11  */
12 /*
13  * Requirements:  A board with a subdevice that supports
14  *    INSN_CONFIG_FILTER, such as the PFI subdevice on an NI m-series
15  *    or 660x board.
16  */
17
18 #define _GNU_SOURCE
19
20 #include <stdio.h>
21 #include <comedilib.h>
22 #include <fcntl.h>
23 #include <unistd.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <errno.h>
27 #include <getopt.h>
28 #include <ctype.h>
29 #include "examples.h"
30
31
32 comedi_t *device;
33
34 int main(int argc, char *argv[])
35 {
36         int retval;
37         lsampl_t filter_selection;
38         struct parsed_options options;
39
40         init_parsed_options(&options);
41         parse_options(&options, argc, argv);
42
43         device = comedi_open(options.filename);
44         if(!device){
45                 comedi_perror(options.filename);
46                 exit(-1);
47         }
48         filter_selection = options.value;
49         printf("Selecting filter %d on subdevice %d channel %d.\n", filter_selection, options.subdevice, options.channel);
50
51         retval = comedi_set_filter(device, options.subdevice, options.channel, filter_selection);
52         if(retval < 0) comedi_perror("comedi_do_insn");
53         return retval;
54 }
55