2 * Multi-channel, multi-range one-shot input demo
5 * Copyright (c) 1999,2000 David A. Schleef <ds@schleef.org>
7 * This file may be freely modified, distributed, and combined with
8 * other software, as long as proper attribution is given in the
12 This demo opens /dev/comedi0 and looks for an analog input
13 subdevice. If it finds one, it measures one sample on each
14 channel for each input range. The value NaN indicates that
15 the measurement was out of range.
19 #include <comedilib.h>
31 int main(int argc, char *argv[])
40 parse_options(argc,argv);
42 device=comedi_open(filename);
44 comedi_perror(filename);
48 subdevice=comedi_find_subdevice_by_type(device,COMEDI_SUBD_AI,0);
50 printf("no analog input subdevice found\n");
54 n_chans=comedi_get_n_channels(device,subdevice);
55 for(chan=0;chan<n_chans;chan++){
58 n_ranges=comedi_get_n_ranges(device,subdevice,chan);
60 maxdata=comedi_get_maxdata(device,subdevice,chan);
61 for(range=0;range<n_ranges;range++){
62 comedi_data_read(device,subdevice,chan,range,aref,&data);
63 voltage=comedi_to_phys(data,comedi_get_range(device,subdevice,chan,range),maxdata);
64 printf("%g ",voltage);