3 functions to return information about comedi devices
5 COMEDILIB - Linux Control and Measurement Device Interface Library
6 Copyright (C) 1997-2001 David A. Schleef <ds@schleef.org>
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation, version 2.1
13 This library 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 GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include <sys/types.h>
31 #include <sys/ioctl.h>
35 #include "libinternal.h"
38 EXPORT_ALIAS_DEFAULT(_comedi_get_n_subdevices,comedi_get_n_subdevices,0.7.18);
39 int _comedi_get_n_subdevices(comedi_t *it)
44 return it->n_subdevices;
47 EXPORT_ALIAS_DEFAULT(_comedi_get_version_code,comedi_get_version_code,0.7.18);
48 int _comedi_get_version_code(comedi_t *it)
53 return it->devinfo.version_code;
56 EXPORT_ALIAS_DEFAULT(_comedi_get_driver_name,comedi_get_driver_name,0.7.18);
57 const char* _comedi_get_driver_name(comedi_t *it)
62 return it->devinfo.driver_name;
65 EXPORT_ALIAS_DEFAULT(_comedi_get_board_name,comedi_get_board_name,0.7.18);
66 const char* _comedi_get_board_name(comedi_t *it)
71 return it->devinfo.board_name;
74 EXPORT_ALIAS_VER(_comedi_get_subdevice_flags_old, comedi_get_subdevice_flags,0.7.18);
75 int _comedi_get_subdevice_flags_old(comedi_t *it,unsigned int subd)
77 if(!valid_subd(it,subd))
79 return it->subdevices[subd].subd_flags;
82 EXPORT_ALIAS_DEFAULT(_comedi_get_subdevice_flags,comedi_get_subdevice_flags,0.8.0);
83 int _comedi_get_subdevice_flags(comedi_t *it,unsigned int subd)
88 if(!valid_subd(it,subd))
90 s = calloc(it->n_subdevices, sizeof(comedi_subdinfo));
96 ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, s);
102 flags = s[subd].subd_flags;
107 EXPORT_ALIAS_DEFAULT(_comedi_get_subdevice_type,comedi_get_subdevice_type,0.7.18);
108 int _comedi_get_subdevice_type(comedi_t *it,unsigned int subd)
110 if(!valid_subd(it,subd))
113 return it->subdevices[subd].type;
116 EXPORT_ALIAS_DEFAULT(_comedi_find_subdevice_by_type,comedi_find_subdevice_by_type,0.7.18);
117 int _comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int subd)
119 if(!valid_subd(it,subd))
122 for(;subd<it->n_subdevices;subd++){
123 if(it->subdevices[subd].type==type)
129 EXPORT_ALIAS_DEFAULT(_comedi_get_read_subdevice,comedi_get_read_subdevice,0.7.19);
130 int _comedi_get_read_subdevice(comedi_t *dev)
135 return dev->devinfo.read_subdevice;
138 EXPORT_ALIAS_DEFAULT(_comedi_get_write_subdevice,comedi_get_write_subdevice,0.7.19);
139 int _comedi_get_write_subdevice(comedi_t *dev)
144 return dev->devinfo.write_subdevice;
147 EXPORT_ALIAS_DEFAULT(_comedi_get_n_channels,comedi_get_n_channels,0.7.18);
148 int _comedi_get_n_channels(comedi_t *it,unsigned int subd)
150 if(!valid_subd(it,subd))
153 return it->subdevices[subd].n_chan;
159 EXPORT_ALIAS_DEFAULT(_comedi_get_maxdata,comedi_get_maxdata,0.7.18);
160 lsampl_t _comedi_get_maxdata(comedi_t *it,unsigned int subdevice,unsigned int chan)
162 if(!valid_chan(it,subdevice,chan))
165 if(it->subdevices[subdevice].maxdata_list)
166 return it->subdevices[subdevice].maxdata_list[chan];
168 return it->subdevices[subdevice].maxdata;
171 EXPORT_ALIAS_DEFAULT(_comedi_maxdata_is_chan_specific,comedi_maxdata_is_chan_specific,0.7.18);
172 int _comedi_maxdata_is_chan_specific(comedi_t *it,unsigned int subdevice)
174 if(!valid_subd(it,subdevice))
176 if(it->subdevices[subdevice].maxdata_list)
181 EXPORT_ALIAS_DEFAULT(_comedi_get_rangetype,comedi_get_rangetype,0.7.18);
182 int _comedi_get_rangetype(comedi_t *it,unsigned int subdevice,unsigned int chan)
184 if(!valid_chan(it,subdevice,chan))
187 if(it->subdevices[subdevice].range_type_list)
188 return it->subdevices[subdevice].range_type_list[chan];
190 return it->subdevices[subdevice].range_type;
194 EXPORT_ALIAS_DEFAULT(_comedi_get_range,comedi_get_range,0.7.18);
195 comedi_range * _comedi_get_range(comedi_t *it,unsigned int subdevice,unsigned int chan,unsigned int range)
199 if(!valid_chan(it,subdevice,chan))
202 range_type=comedi_get_rangetype(it,subdevice,chan);
204 if(range>=RANGE_LENGTH(range_type))
207 if(it->subdevices[subdevice].rangeinfo_list)
208 return it->subdevices[subdevice].rangeinfo_list[chan]+range;
210 return it->subdevices[subdevice].rangeinfo+range;