[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Data to FIFO



On Sat, 7 Oct 2000, Ren Yuhong wrote:

> int data;
> char * buf;
here you have not allocated any memory. Use something like buf[20].
Your buf was a random pointer to nowhere.

> 
>     comedi_read_data(cf,AI_device, AI_chan,range,aref,&data);
> 
>     rtl_printf("AI data = %d \n", data);           (1)
>     rtf_put(1,"data=32776", 10);                        (1)
> 
>     sprintf(buf, "%d", data);                                (2)
why do you use sprintf? You do not want for format it as string?
You can do just:
	rtf_put(1,&data,sizeof(data));
>     rtf_put(1,buf,sizeof(data));                            (2)

Best regards,
--
Tomek