Debian Codegraph @

demo/sv.c

raw symbols SCIP
1 /*
2 * Demo of the comedi_sv_*() functions
3 *
4 * Part of Comedilib
5 *
6 * Copyright (c) 1999,2000 David A. Schleef <[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 #include <stdio.h>
14 #include <comedilib.h>cxx . . $ `<file>/include/comedilib.h`/
15 #include <fcntl.h>
16 #include <unistd.h>
17 #include <errno.h>
18 #include <getopt.h>
19 #include <ctype.h>
20 #include <stdlib.h>
21 #include "examples.h"cxx . . $ `<file>/demo/examples.h`/
22
23 comedi_tcxx . . $ comedi_t# *devicecxx . . $ device.;
24
25
26 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
27 {
28 int ret;
29 comedi_sv_tcxx . . $ comedi_sv_t# sv;
30 double volts;
31 struct parsed_optionscxx . . $ parsed_options# options;
32
33 init_parsed_optionscxx . . $ init_parsed_options(8caace97c9c42d8f).(&options);
34 parse_optionscxx . . $ parse_options(b6aabb1543a6f628).(&options, argc, argv);
35
36 devicecxx . . $ device. = comedi_opencxx . . $ comedi_open(d67864c6c007fe39).(options.filenamecxx . . $ parsed_options#filename.);
37 if(!devicecxx . . $ device.){
38 comedi_perrorcxx . . $ comedi_perror(85c52e162fed56f9).(options.filenamecxx . . $ parsed_options#filename.);
39 exitcxx . . $ exit(3ca292c338df9bb3).(-1);
40 }
41
42 if(options.verbosecxx . . $ parsed_options#verbose.){
43 printfcxx . . $ printf(581fddd72a8db8fc).("measuring device=%s subdevice=%d channel=%d range=%d analog reference=%d\n",
44 options.filenamecxx . . $ parsed_options#filename., options.subdevicecxx . . $ parsed_options#subdevice., options.channelcxx . . $ parsed_options#channel., options.rangecxx . . $ parsed_options#range., options.arefcxx . . $ parsed_options#aref.);
45 }
46
47 comedi_sv_initcxx . . $ comedi_sv_init(d7fc568dcd53d8c2).(&sv, devicecxx . . $ device., options.subdevicecxx . . $ parsed_options#subdevice., options.channelcxx . . $ parsed_options#channel.);
48
49 sv.rangecxx . . $ comedi_sv_struct#range. = options.rangecxx . . $ parsed_options#range.;
50 sv.arefcxx . . $ comedi_sv_struct#aref. = options.arefcxx . . $ parsed_options#aref.;
51 sv.ncxx . . $ comedi_sv_struct#n. = 100;
52
53 ret = comedi_sv_measurecxx . . $ comedi_sv_measure(9ea339efb20aeab2).(&sv, &volts);
54 if(ret < 0){
55 comedi_perrorcxx . . $ comedi_perror(85c52e162fed56f9).("comedi_sv_measure()");
56 exitcxx . . $ exit(3ca292c338df9bb3).(-1);
57 }
58
59 printfcxx . . $ printf(581fddd72a8db8fc).("%g\n", volts);
60
61 return 0;
62 }
63