3 comedi library routines
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1997-8 David A. Schleef <ds@stm.lbl.gov>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <sys/types.h>
31 #include <sys/ioctl.h>
36 #include <libinternal.h>
39 int comedi_get_n_subdevices(comedi_t *it)
44 return it->n_subdevices;
47 int comedi_get_version_code(comedi_t *it)
52 return it->devinfo.version_code;
55 char *comedi_get_driver_name(comedi_t *it)
60 return it->devinfo.driver_name;
63 char *comedi_get_board_name(comedi_t *it)
68 return it->devinfo.board_name;
71 int comedi_get_subdevice_type(comedi_t *it,unsigned int subd)
76 return it->subdevices[subd].type;
79 int comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int subd)
81 if(!valid_subd(it,subd))
84 for(;subd<it->n_subdevices;subd++){
85 if(it->subdevices[subd].type==type)
92 int comedi_get_n_channels(comedi_t *it,unsigned int subd)
94 if(!valid_subd(it,subd))
97 return it->subdevices[subd].n_chan;
103 lsampl_t comedi_get_maxdata(comedi_t *it,unsigned int subdevice,unsigned int chan)
105 if(!valid_chan(it,subdevice,chan))
108 if(it->subdevices[subdevice].maxdata_list)
109 return it->subdevices[subdevice].maxdata_list[chan];
111 return it->subdevices[subdevice].maxdata;
114 int comedi_maxdata_is_chan_specific(comedi_t *it,unsigned int subdevice)
116 if(it->subdevices[subdevice].maxdata_list)
121 int comedi_get_rangetype(comedi_t *it,unsigned int subdevice,unsigned int chan)
123 if(!valid_chan(it,subdevice,chan))
126 if(it->subdevices[subdevice].range_type_list)
127 return it->subdevices[subdevice].range_type_list[chan];
129 return it->subdevices[subdevice].range_type;
133 comedi_range * comedi_get_range(comedi_t *it,unsigned int subdevice,unsigned int chan,unsigned int range)
137 if(!valid_chan(it,subdevice,chan))
140 range_type=comedi_get_rangetype(it,subdevice,chan);
142 if(range>=RANGE_LENGTH(range_type))
145 if(it->subdevices[subdevice].rangeinfo_list)
146 return it->subdevices[subdevice].rangeinfo_list[chan]+range;
148 return it->subdevices[subdevice].rangeinfo+range;