/*
lib/filler.c
- comedi library routines
+ functions to retrieve kernel data
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1997-8 David A. Schleef <ds@stm.lbl.gov>
+ COMEDILIB - Linux Control and Measurement Device Interface Library
+ Copyright (C) 1997-2001 David A. Schleef <ds@schleef.org>
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation, version 2.1
+ of the License.
- This program is distributed in the hope that it will be useful,
+ This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
*/
#include <stdio.h>
#include <comedi.h>
#include <string.h>
-#include <libinternal.h>
+#include "libinternal.h"
/* these functions download information from the comedi module. */
int i,j;
int ret;
comedi_subdinfo *s;
+ comedi_chaninfo ci;
subdevice *r;
s=malloc(sizeof(comedi_subdinfo)*it->n_subdevices);
- ret=ioctl_subdinfo(it->fd,s);
+ debug_ptr(s);
+
+ ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, (unsigned long)s);
debug_int(ret);
r=it->subdevices=realloc(it->subdevices,
r[i].range_type_list=malloc(sizeof(*r[i].range_type_list)*r[i].n_chan);
debug_ptr(r[i].range_type_list);
}
- ret=ioctl_chaninfo(it->fd,i,r[i].maxdata_list,r[i].flags_list,r[i].range_type_list);
+ ci.subdev = i;
+ ci.flaglist = r[i].flags_list;
+ ci.rangelist = r[i].range_type_list;
+ ci.maxdata_list = r[i].maxdata_list;
+ ret = comedi_ioctl(it->fd, COMEDI_CHANINFO, (unsigned long)&ci);
debug_int(ret);
if(r[i].subd_flags&SDF_RANGETYPE){
{
comedi_krange *kr;
comedi_range *r;
+ comedi_rangeinfo ri;
int ret;
int i;
kr=malloc(sizeof(comedi_krange)*RANGE_LENGTH(range_type));
r=malloc(sizeof(comedi_range)*RANGE_LENGTH(range_type));
- ret=ioctl_rangeinfo(fd,range_type,kr);
+ ri.range_type = range_type;
+ ri.range_ptr = kr;
+ ret = comedi_ioctl(fd, COMEDI_RANGEINFO, (unsigned long)&ri);
if(ret<0){
- fprintf(stderr,"ioctl_rangeinfo(%d,0x%08x,%p)\n",fd,range_type,kr);
+ fprintf(stderr,"ioctl(%d,COMEDI_RANGEINFO,0x%08x,%p)\n",fd,range_type,kr);
}
for(i=0;i<RANGE_LENGTH(range_type);i++){
static int do_test_for_cmd(comedi_t *dev,unsigned int subdevice)
{
- comedi_cmd it;
- int ret;
+ /* SDF_CMD was added in 0.7.57 */
+ if(dev->devinfo.version_code >= COMEDI_VERSION_CODE(0,7,57)){
+ if(dev->subdevices[subdevice].subd_flags & SDF_CMD)
+ return 1;
+ return 0;
+ }else{
+ comedi_cmd it;
+ int ret;
- memset(&it,0,sizeof(it));
+ memset(&it,0,sizeof(it));
- it.subdev = 0;
- it.start_src = TRIG_ANY;
- it.scan_begin_src = TRIG_ANY;
- it.convert_src = TRIG_ANY;
- it.scan_end_src = TRIG_ANY;
- it.stop_src = TRIG_ANY;
+ it.subdev = subdevice;
+ it.start_src = TRIG_ANY;
+ it.scan_begin_src = TRIG_ANY;
+ it.convert_src = TRIG_ANY;
+ it.scan_end_src = TRIG_ANY;
+ it.stop_src = TRIG_ANY;
- ret = ioctl(dev->fd,COMEDI_CMDTEST,&it);
+ ret = comedi_ioctl(dev->fd, COMEDI_CMDTEST, (unsigned long)&it);
- if(ret<0 && errno==EIO){
- return 0;
- }
- if(ret<0){
- fprintf(stderr,"BUG in do_test_for_cmd()\n");
- return 0;
+ if(ret<0 && errno==EIO){
+ return 0;
+ }
+ if(ret<0){
+ fprintf(stderr,"BUG in do_test_for_cmd()\n");
+ return 0;
+ }
+ return 1;
}
- return 1;
}
static int do_test_for_insnlist(comedi_t *dev)
insn.n = 2;
insn.data = data;
- ret = ioctl(dev->fd,COMEDI_INSNLIST,&il);
+ ret = comedi_ioctl(dev->fd, COMEDI_INSNLIST, (unsigned long)&il);
if(ret<0){
if(errno!=EIO){
insn.n = 2;
insn.data = data;
- ret = ioctl(dev->fd,COMEDI_INSN,&insn);
+ ret = comedi_ioctl(dev->fd, COMEDI_INSN, (unsigned long)&insn);
if(ret<0){
if(errno!=EIO){
lsampl_t data[2];
int ret;
+ if(dev->subdevices[subdevice].maxdata != 1)
+ return 0;
+
memset(&insn,0,sizeof(insn));
il.n_insns = 1;
return 0;
}
if(ret<0){
- fprintf(stderr,"BUG in do_test_for_insn_bits()\n");
+ perror("BUG in do_test_for_insn_bits()\n");
return 0;
}
return 1;