memset(&bc, 0, sizeof(bc));
bc.subdevice = subdev;
bc.size = size;
- ret = ioctl(it->fd, COMEDI_BUFCONFIG, &bc);
+ ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, (unsigned long)&bc);
__comedi_errno = errno;
if(ret < 0) return ret;
memset(&bc, 0, sizeof(bc));
bc.subdevice = subdev;
bc.maximum_size = max_size;
- ret = ioctl(it->fd, COMEDI_BUFCONFIG, &bc);
+ ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, (unsigned long)&bc);
__comedi_errno = errno;
if(ret < 0) return ret;
memset(&bi, 0, sizeof(bi));
bi.bytes_read = bytes;
- ret = ioctl(it->fd, COMEDI_BUFINFO, &bi);
+ ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi);
__comedi_errno = errno;
if(__comedi_errno == EINVAL)__comedi_errno = EBUF_OVR;
return bi.buf_int_count - bi.buf_user_count;
comedi_bufinfo bi;
memset(&bi, 0, sizeof(bi));
- ret = ioctl(it->fd, COMEDI_BUFINFO, &bi);
+ ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi);
if(ret < 0) return ret;
return bi.buf_user_ptr;
}
comedi_bufinfo bi;
memset(&bi, 0, sizeof(bi));
- ret = ioctl(it->fd, COMEDI_BUFINFO, &bi);
+ ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi);
if(ret < 0) return ret;
return bi.buf_int_count;
}
goto cleanup;
}
- if(ioctl(it->fd, COMEDI_DEVINFO, &it->devinfo)<0)
+ if(comedi_ioctl(it->fd, COMEDI_DEVINFO, (unsigned long)&it->devinfo)<0)
goto cleanup;
it->n_subdevices=it->devinfo.n_subdevs;
int comedi_cancel(comedi_t *it,unsigned int subdevice)
{
- return ioctl(it->fd,COMEDI_CANCEL,subdevice);
+ return comedi_ioctl(it->fd,COMEDI_CANCEL,subdevice);
}
int comedi_poll(comedi_t *it,unsigned int subdevice)
{
- return ioctl(it->fd,COMEDI_POLL,subdevice);
+ return comedi_ioctl(it->fd,COMEDI_POLL,subdevice);
}
int comedi_fileno(comedi_t *it)
if(!it || !t)
return -1;
- return ioctl(it->fd, COMEDI_TRIG, t);
+ return comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)t);
}
int comedi_command(comedi_t *it,comedi_cmd *t)
{
int ret;
- ret = ioctl(it->fd,COMEDI_CMD,t);
+ ret = comedi_ioctl(it->fd, COMEDI_CMD, (unsigned long)t);
__comedi_errno = errno;
switch(__comedi_errno){
case EIO:
int comedi_command_test(comedi_t *it,comedi_cmd *t)
{
int ret;
- ret = ioctl(it->fd,COMEDI_CMDTEST,t);
+ ret = comedi_ioctl(it->fd, COMEDI_CMDTEST, (unsigned long)t);
__comedi_errno = errno;
switch(__comedi_errno){
case EIO:
int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il)
{
int ret;
- ret = ioctl(it->fd,COMEDI_INSNLIST,il);
+ ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)il);
__comedi_errno = errno;
return ret;
}
int comedi_do_insn(comedi_t *it,comedi_insn *insn)
{
if(it->has_insn_ioctl){
- return ioctl(it->fd,COMEDI_INSN,insn);
+ return comedi_ioctl(it->fd, COMEDI_INSN, (unsigned long)insn);
}else{
comedi_insnlist il;
int ret;
il.n_insns = 1;
il.insns = insn;
- ret = ioctl(it->fd,COMEDI_INSNLIST,&il);
+ ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)&il);
if(ret<0)return ret;
return insn->n;
int comedi_lock(comedi_t *it,unsigned int subdevice)
{
- return ioctl(it->fd,COMEDI_LOCK,subdevice);
+ return comedi_ioctl(it->fd, COMEDI_LOCK, subdevice);
}
int comedi_unlock(comedi_t *it,unsigned int subdevice)
{
- return ioctl(it->fd,COMEDI_UNLOCK,subdevice);
+ return comedi_ioctl(it->fd, COMEDI_UNLOCK, subdevice);
}
}
cmd.chanlist=&chan;
- return ioctl(it->fd, COMEDI_TRIG, &cmd);
+ return comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)&cmd);
}
}
cmd.data=sdata;
}
- ret = ioctl(it->fd, COMEDI_TRIG, &cmd);
+ ret = comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)&cmd);
if(ret<0)
return ret;
s=malloc(sizeof(comedi_subdinfo)*it->n_subdevices);
debug_ptr(s);
- ret = ioctl(it->fd, COMEDI_SUBDINFO, s);
+ ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, (unsigned long)s);
debug_int(ret);
r=it->subdevices=realloc(it->subdevices,
ci.flaglist = r[i].flags_list;
ci.rangelist = r[i].range_type_list;
ci.maxdata_list = r[i].maxdata_list;
- ret = ioctl(it->fd, COMEDI_CHANINFO, &ci);
+ ret = comedi_ioctl(it->fd, COMEDI_CHANINFO, (unsigned long)&ci);
debug_int(ret);
if(r[i].subd_flags&SDF_RANGETYPE){
ri.range_type = range_type;
ri.range_ptr = kr;
- ret = ioctl(fd, COMEDI_RANGEINFO, &ri);
+ ret = comedi_ioctl(fd, COMEDI_RANGEINFO, (unsigned long)&ri);
if(ret<0){
fprintf(stderr,"ioctl(%d,COMEDI_RANGEINFO,0x%08x,%p)\n",fd,range_type,kr);
}
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;
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){
/* ioctl wrappers */
+int comedi_ioctl_debug(int fd, int request, unsigned long arg)
+{
+ int ret;
+
+ fprintf(stderr,"ioctl(%d,0x%08x,0x%08lx) = ",fd,request,arg);
+ ret = ioctl(fd,request,arg);
+ fprintf(stderr,"%d\n",ret);
+
+ return ret;
+}
+
+
};
+#define comedi_ioctl comedi_ioctl_debug
+
+int comedi_ioctl_debug(int,int,unsigned long);
/* filler routines */
for(n=0;n<it->n;){
t.data=(void *)(val+n);
t.n=it->n-n;
- i = ioctl(it->dev->fd, COMEDI_TRIG, &t);
+ i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, (unsigned long)&t);
if(i<=0){
ret=i;
goto out;
for(n=0;n<it->n;){
t.data=val+n;
t.n=it->n-n;
- i = ioctl(it->dev->fd, COMEDI_TRIG, &t);
+ i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, (unsigned long)&t);
if(i<=0){
ret=i;
goto out;