Re: question in cmd.c demo file.

On Thu, 09.12.04, JaSeong Ju <jsju_at_kbsi.re.kr> wrote:

> there is this line inside while loop :
> for(i=0;i<ret/2;i++){
> 
> why is ret divided by 2?

Because of

printf("%d ",((sampl_t *)buf)[i]);

buf is cast to (sampl_t *) first, _then_ dereferenced. In comedi.h you find

typedef unsigned short sampl_t;

Unsigned short is 16bits (on IA-32) but read() returns _bytes_, so you have
to cut the index in half.

hth,
Nils

Received on 2004-12-09Z14:58:06