| 1 | /* |
| 2 | * A little output demo |
| 3 | * Part of Comedilib |
| 4 | * |
| 5 | * Copyright (c) 1999,2000 David A. Schleef <[email protected]> |
| 6 | * |
| 7 | * This file may be freely modified, distributed, and combined with |
| 8 | * other software, as long as proper attribution is given in the |
| 9 | * source code. |
| 10 | */ |
| 11 | /* |
| 12 | * A little output demo |
| 13 | */ |
| 14 | |
| 15 | #include <stdio.h> |
| 16 | #include <comedilib.h>cxx . . $ `<file>/include/comedilib.h`/ |
| 17 | #include <fcntl.h> |
| 18 | #include <unistd.h> |
| 19 | #include <stdlib.h> |
| 20 | #include <errno.h> |
| 21 | #include <getopt.h> |
| 22 | #include <ctype.h> |
| 23 | #include "examples.h"cxx . . $ `<file>/demo/examples.h`/ |
| 24 | |
| 25 | comedi_tcxx . . $ comedi_t# *devicecxx . . $ device.; |
| 26 | |
| 27 | |
| 28 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 29 | { |
| 30 | lsampl_tcxx . . $ lsampl_t# data; |
| 31 | int ret; |
| 32 | struct parsed_optionscxx . . $ parsed_options# options; |
| 33 | |
| 34 | init_parsed_optionscxx . . $ init_parsed_options(8caace97c9c42d8f).(&options); |
| 35 | parse_optionscxx . . $ parse_options(b6aabb1543a6f628).(&options, argc, argv); |
| 36 | |
| 37 | devicecxx . . $ device. = comedi_opencxx . . $ comedi_open(d67864c6c007fe39).(options.filenamecxx . . $ parsed_options#filename.); |
| 38 | if(!devicecxx . . $ device.){ |
| 39 | comedi_perrorcxx . . $ comedi_perror(85c52e162fed56f9).(options.filenamecxx . . $ parsed_options#filename.); |
| 40 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 41 | } |
| 42 | |
| 43 | data = options.valuecxx . . $ parsed_options#value.; |
| 44 | if(options.verbosecxx . . $ parsed_options#verbose.){ |
| 45 | printfcxx . . $ printf(581fddd72a8db8fc).("writing %d to device=%s subdevice=%d channel=%d range=%d analog reference=%d\n", |
| 46 | data, 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.); |
| 47 | } |
| 48 | |
| 49 | ret = comedi_data_writecxx . . $ comedi_data_write(a3c2e9a72a6aa865).(devicecxx . . $ device., options.subdevicecxx . . $ parsed_options#subdevice., options.channelcxx . . $ parsed_options#channel., options.rangecxx . . $ parsed_options#range., options.arefcxx . . $ parsed_options#aref., data); |
| 50 | if(ret < 0){ |
| 51 | comedi_perrorcxx . . $ comedi_perror(85c52e162fed56f9).(options.filenamecxx . . $ parsed_options#filename.); |
| 52 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 53 | } |
| 54 | |
| 55 | printfcxx . . $ printf(581fddd72a8db8fc).("%d\n", data); |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 |