~ubuntu-branches/ubuntu/feisty/comedilib/feisty

« back to all changes in this revision

Viewing changes to testing/info.c

  • Committer: Bazaar Package Importer
  • Author(s): David Schleef
  • Date: 2003-09-23 18:11:12 UTC
  • Revision ID: james.westby@ubuntu.com-20030923181112-sat05jyh702rb1at
Tags: upstream-0.7.21
ImportĀ upstreamĀ versionĀ 0.7.21

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
};
 
29
 
 
30
 
 
31
int test_info(void)
 
32
{
 
33
        int j;
 
34
        int type;
 
35
        int chan,n_chans;
 
36
        int n_ranges;
 
37
        comedi_range *rng;
 
38
 
 
39
        printf("rev 1\n");
 
40
 
 
41
        type = comedi_get_subdevice_type(device,subdevice);
 
42
        printf("I: subdevice type: %d (%s)\n",type,subdevice_types[type]);
 
43
        if(type==COMEDI_SUBD_UNUSED)
 
44
                return 0;
 
45
        n_chans=comedi_get_n_channels(device,subdevice);
 
46
        printf("  number of channels: %d\n",n_chans);
 
47
        if(!comedi_maxdata_is_chan_specific(device,subdevice)){
 
48
                printf("  max data value: %d\n",comedi_get_maxdata(device,subdevice,0));
 
49
        }else{
 
50
                printf("  max data value: (channel specific)\n");
 
51
                for(chan=0;chan<n_chans;chan++){
 
52
                        printf("    chan%d: %d\n",chan,
 
53
                                comedi_get_maxdata(device,subdevice,chan));
 
54
                }
 
55
        }
 
56
        printf("  ranges:\n");
 
57
        if(!comedi_range_is_chan_specific(device,subdevice)){
 
58
                n_ranges=comedi_get_n_ranges(device,subdevice,0);
 
59
                printf("    all chans:");
 
60
                for(j=0;j<n_ranges;j++){
 
61
                        rng=comedi_get_range(device,subdevice,0,j);
 
62
                        printf(" [%g,%g]",rng->min,rng->max);
 
63
                }
 
64
                printf("\n");
 
65
        }else{
 
66
                for(chan=0;chan<n_chans;chan++){
 
67
                        n_ranges=comedi_get_n_ranges(device,subdevice,chan);
 
68
                        printf("    chan%d:",chan);
 
69
                        for(j=0;j<n_ranges;j++){
 
70
                                rng=comedi_get_range(device,subdevice,chan,j);
 
71
                                printf(" [%g,%g]",rng->min,rng->max);
 
72
                        }
 
73
                        printf("\n");
 
74
                }
 
75
        }
 
76
 
 
77
        return 0;
 
78
}
 
79