Re:comedi_command - analog input - only runs once

Hi, try with     cmd.data_len = sizeof(sampl_t) . Anyway the best solution is
managing data directly from buffer if you want to write a kernel module. 
Bye
Alberto.

> I am trying to run a slightly modified version of the
> it.c example, which I have copied below.  In another
> modified version (not included), I read data from the
> buffer, and it seemed to be correct data.  However, in
> both cases, the callback function is only called once.
>  There are no error messages in the kernel log.  The
> kernel log is shown below.  Any idea why it doesn't
> continue to run?  Thanks,
> 
> Tim Lee
> 
> System details:
> kernel: linux-2.4.24-adeos
> RTAI: v3.0r2
> comedi: a CVS snapshot soon after 0.7.68
> 
> Jun 21 23:10:27 Chivo kernel: Comedi real-time example
> #1
> Jun 21 23:10:27 Chivo kernel: Tapping: comedi_lock: 0
> Jun 21 23:10:27 Chivo kernel: command test returned 0
> Jun 21 23:10:27 Chivo kernel: command test returned 0
> Jun 21 23:10:27 Chivo kernel: command returned 0
> Jun 21 23:10:28 Chivo kernel: who's yer daddy? 0
> 
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/comedi.h>
> #include <linux/comedilib.h>
> #include <rtai.h>
> 
> comedi_t * dev=NULL;
> int subd=0;
> 
> int do_cmd(void)
> {
> 	int ret;
> 
> 	comedi_cmd cmd;
> 	unsigned int chanlist[1];
> 
> 	cmd.subdev = subd;
> 	cmd.flags = TRIG_RT | TRIG_WAKE_EOS;
> 
> 	cmd.start_src = TRIG_NOW;
> 	cmd.start_arg = 0;
> 
> 	cmd.scan_begin_src = TRIG_TIMER;
> 	cmd.scan_begin_arg = 1000000000;
> 
> 	cmd.convert_src = TRIG_TIMER;
> 	cmd.convert_arg = 10000;
> 
> 	cmd.scan_end_src = TRIG_COUNT;
> 	cmd.scan_end_arg = 1;
> 
> 	cmd.stop_src = TRIG_NONE;
> 	cmd.stop_arg = 0;
> 
> 	cmd.chanlist = chanlist;
> 	cmd.chanlist_len = 1;
> 
> 	chanlist[0] = CR_PACK(0,0,0);
> 
> 	ret = comedi_command_test(dev,&cmd);
> 	printk("command test returned %d\n",ret);
> 
> 	cmd.chanlist = chanlist;
> 	cmd.chanlist_len = 1;
> 
> 	ret = comedi_command_test(dev,&cmd);
> 	printk("command test returned %d\n",ret);
> 	if(ret)return ret;
> 
> 	cmd.chanlist = chanlist;
> 	cmd.chanlist_len = 1;
> 	cmd.data = NULL;
> 	cmd.data_len = 0;
> 	ret = comedi_command(dev,&cmd);
> 	printk("command returned %d\n",ret);
> 
> 	return ret;
> }
> 
> static int counter = 0;
> 
> int callback(unsigned int i,void *arg)
> {
> 	rt_printk("who's yer daddy? %d\n",counter);
> 	counter++;
> 
> 	return 0;
> }
> 
> int init_module(void)
> {
> 	int ret;
> 	char dev_name[] = "/dev/comedi0";
> 
> 	printk("Comedi real-time example #1\n");
> 
> 	dev = comedi_open(dev_name);
>         if (dev == NULL)
> 	{
>            rt_printk("Tapping: Failed opening DAQ
> card.\n");
> 	   return(1);
> 	}
> 	
> 	ret = comedi_lock(dev, subd);
> 	rt_printk("Tapping: comedi_lock: %d\n", ret);
> 
> 
> comedi_register_callback(dev,subd,COMEDI_CB_EOS,callback,NULL);
> 
> 	do_cmd();
> 
> 	return 0;
> }
> 
> void cleanup_module(void)
> {
> 	int ret;
> 
> 	ret = comedi_cancel(dev,subd);
> 	printk("comedi_cancel: %d\n",ret);
> 	
> 	ret = comedi_unlock(dev, subd);
> 	printk("comedi_unlock: %d\n",ret);
> 	comedi_close(dev);
> 	printk("comedi_close:\n");
> }
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> _______________________________________________
> comedi mailing list
> comedi_at_comedi.org
> https://cvs.comedi.org/cgi-bin/mailman/listinfo/comedi

> 

Received on 2004-06-22Z06:20:57