add insn support
This commit is contained in:
parent
2baa4dd7f4
commit
80a7835141
2 changed files with 70 additions and 0 deletions
63
lib/filler.c
63
lib/filler.c
|
@ -38,6 +38,8 @@
|
|||
|
||||
/* these functions download information from the comedi module. */
|
||||
|
||||
static int do_test_for_cmd(comedi_t *dev,unsigned int subdevice);
|
||||
static int do_test_for_insn(comedi_t *dev,unsigned int subdevice);
|
||||
|
||||
|
||||
int get_subdevices(comedi_t *it)
|
||||
|
@ -91,6 +93,9 @@ int get_subdevices(comedi_t *it)
|
|||
}else{
|
||||
r[i].rangeinfo=get_rangeinfo(it->fd,r[i].range_type);
|
||||
}
|
||||
|
||||
r[i].has_cmd = do_test_for_cmd(it,i);
|
||||
r[i].has_insn = do_test_for_insn(it,i);
|
||||
}
|
||||
|
||||
free(s);
|
||||
|
@ -124,3 +129,61 @@ comedi_range *get_rangeinfo(int fd,unsigned int range_type)
|
|||
}
|
||||
|
||||
|
||||
/* some command testing */
|
||||
|
||||
static int do_test_for_cmd(comedi_t *dev,unsigned int subdevice)
|
||||
{
|
||||
comedi_cmd it;
|
||||
int ret;
|
||||
|
||||
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;
|
||||
|
||||
ret = ioctl(dev->fd,COMEDI_CMDTEST,&it);
|
||||
|
||||
if(ret<0 && errno==EIO){
|
||||
return 0;
|
||||
}
|
||||
if(ret<0){
|
||||
fprintf(stderr,"BUG in do_test_for_cmd()\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int do_test_for_insn(comedi_t *dev,unsigned int subdevice)
|
||||
{
|
||||
comedi_insn insn;
|
||||
comedi_insnlist il;
|
||||
lsampl_t data[2];
|
||||
int ret;
|
||||
|
||||
memset(&insn,0,sizeof(insn));
|
||||
|
||||
il.n_insns = 1;
|
||||
il.insns = &insn;
|
||||
|
||||
insn.insn = INSN_GTOD;
|
||||
insn.n = 2;
|
||||
insn.data = (void *)&data;
|
||||
insn.subdev = subdevice;
|
||||
|
||||
ret = ioctl(dev->fd,COMEDI_INSN,&il);
|
||||
|
||||
if(ret<0 && errno==EIO){
|
||||
return 0;
|
||||
}
|
||||
if(ret<0){
|
||||
fprintf(stderr,"BUG in do_test_for_insn()\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,13 @@ int ioctl_cmd(int fd,comedi_cmd *it)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COMEDI_INSN
|
||||
int ioctl_insnlist(int fd,comedi_insn *it)
|
||||
{
|
||||
return ioctl(fd,COMEDI_INSNLIST,it);
|
||||
}
|
||||
#endif
|
||||
|
||||
int ioctl_lock(int fd,int subdevice)
|
||||
{
|
||||
return ioctl(fd,COMEDI_LOCK,subdevice);
|
||||
|
|
Loading…
Add table
Reference in a new issue