Sync with comedi.
[comedilib.git] / testing / info.c
1
2 #include <stdio.h>
3 #include <comedilib.h>
4 #include <fcntl.h>
5 #include <unistd.h>
6 #include <sys/ioctl.h>
7 #include <errno.h>
8 #include <getopt.h>
9 #include <ctype.h>
10 #include <math.h>
11 #include <sys/time.h>
12 #include <string.h>
13 #include "comedi_test.h"
14
15
16 static char *subdevice_types[]={
17         "unused",
18         "analog input",
19         "analog output",
20         "digital input",
21         "digital output",
22         "digital I/O",
23         "counter",
24         "timer",
25         "memory",
26         "calibration",
27         "processor",
28         "serial"
29 };
30
31
32 int test_info(void)
33 {
34         int j;
35         int type;
36         int chan,n_chans;
37         int n_ranges;
38         comedi_range *rng;
39
40         printf("rev 1\n");
41
42         type = comedi_get_subdevice_type(device,subdevice);
43         printf("I: subdevice type: %d (%s)\n",type,subdevice_types[type]);
44         if(type==COMEDI_SUBD_UNUSED)
45                 return 0;
46         n_chans=comedi_get_n_channels(device,subdevice);
47         printf("  number of channels: %d\n",n_chans);
48         if(!comedi_maxdata_is_chan_specific(device,subdevice)){
49                 printf("  max data value: %d\n",comedi_get_maxdata(device,subdevice,0));
50         }else{
51                 printf("  max data value: (channel specific)\n");
52                 for(chan=0;chan<n_chans;chan++){
53                         printf("    chan%d: %d\n",chan,
54                                 comedi_get_maxdata(device,subdevice,chan));
55                 }
56         }
57         printf("  ranges:\n");
58         if(!comedi_range_is_chan_specific(device,subdevice)){
59                 n_ranges=comedi_get_n_ranges(device,subdevice,0);
60                 printf("    all chans:");
61                 for(j=0;j<n_ranges;j++){
62                         rng=comedi_get_range(device,subdevice,0,j);
63                         printf(" [%g,%g]",rng->min,rng->max);
64                 }
65                 printf("\n");
66         }else{
67                 for(chan=0;chan<n_chans;chan++){
68                         n_ranges=comedi_get_n_ranges(device,subdevice,chan);
69                         printf("    chan%d:",chan);
70                         for(j=0;j<n_ranges;j++){
71                                 rng=comedi_get_range(device,subdevice,chan,j);
72                                 printf(" [%g,%g]",rng->min,rng->max);
73                         }
74                         printf("\n");
75                 }
76         }
77
78         return 0;
79 }
80