| 1 | /* |
| 2 | * INSN_CONFIG_FILTER example |
| 3 | * Part of Comedilib |
| 4 | * |
| 5 | * Copyright (c) 1999,2000 David A. Schleef <[email protected]> |
| 6 | * Copyright (c) 2007 Frank Mori Hess <[email protected]> |
| 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_SOURCEcxx . . $ `demo/choose_filter.c:18:9`! |
| 19 | |
| 20 | #include <stdio.h> |
| 21 | #include <comedilib.h>cxx . . $ `<file>/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"cxx . . $ `<file>/demo/examples.h`/ |
| 30 | |
| 31 | |
| 32 | comedi_tcxx . . $ comedi_t# *devicecxx . . $ device.; |
| 33 | |
| 34 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 35 | { |
| 36 | int retval; |
| 37 | lsampl_tcxx . . $ lsampl_t# filter_selection; |
| 38 | struct parsed_optionscxx . . $ parsed_options# options; |
| 39 | |
| 40 | init_parsed_optionscxx . . $ init_parsed_options(8caace97c9c42d8f).(&options); |
| 41 | parse_optionscxx . . $ parse_options(b6aabb1543a6f628).(&options, argc, argv); |
| 42 | |
| 43 | devicecxx . . $ device. = comedi_opencxx . . $ comedi_open(d67864c6c007fe39).(options.filenamecxx . . $ parsed_options#filename.); |
| 44 | if(!devicecxx . . $ device.){ |
| 45 | comedi_perrorcxx . . $ comedi_perror(85c52e162fed56f9).(options.filenamecxx . . $ parsed_options#filename.); |
| 46 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 47 | } |
| 48 | filter_selection = options.valuecxx . . $ parsed_options#value.; |
| 49 | printfcxx . . $ printf(581fddd72a8db8fc).("Selecting filter %d on subdevice %d channel %d.\n", filter_selection, options.subdevicecxx . . $ parsed_options#subdevice., options.channelcxx . . $ parsed_options#channel.); |
| 50 | |
| 51 | retval = comedi_set_filtercxx . . $ comedi_set_filter(e80ed4ed1c56b623).(devicecxx . . $ device., options.subdevicecxx . . $ parsed_options#subdevice., options.channelcxx . . $ parsed_options#channel., filter_selection); |
| 52 | if(retval < 0) comedi_perrorcxx . . $ comedi_perror(85c52e162fed56f9).("comedi_do_insn"); |
| 53 | return retval; |
| 54 | } |
| 55 |