Bug in get_cmd_generic_timed

Hi,

I think I've found a bug in comedi_get_cmd_generic_timed.

Have a look at comedilib/lib/cmd.c lines 175ff:

-----------8<----------------------8<----------------------8<-----------
if(!s->cmd_timed){
	s->cmd_timed = malloc(sizeof(comedi_cmd));

	ret = __generic_timed(it,subd,s->cmd_timed,ns);
	if(ret<0){
		s->cmd_mask_errno = errno;
		return -1;
	}
}
*cmd=*s->cmd_timed;
-----------8<----------------------8<----------------------8<-----------

__generic_timed is only called the first time the app uses
get_cmd_generic_timed.
Thus, the ns argument of subsequent queries is simply ignored and all
queries yield the result of the first query.

This makes it impossible to produce commands for different sampling
rates within one program (well, you have to manipulate the cmd struct
manually).

Trivial patch attached.

Regards,
Jan

Received on 2005-04-24Z15:08:30