Yuhong,
first of all rtf_put() doesn't require character data. You could simply do
the following:
rtf_put(1,&data,sizeof(data));
OR
if you want to write the data as a string of characters, your sizeof()
argument needs to be changed. using 10 instead of sizeof(data) *may* work,
but it's best if you know exactly how many characters *buf is pointing to.
also, you must allocate memory for a string of characters. you could try:
char buf[10];
sprintf(buf,"%9d",data);
rtf_put(1,buf,10); // 10 because of the 9 characters from sprintf and a
null character
cheers,
brent
Ren Yuhong wrote:
> Hi, Dear All,
>
> Please excuse me for this maybe a newbie question. I need to collect
> Analog Input using my DAQ card, and put the data ( int data) into FIFO
> (dev/rtf1), then handle these data in user space. Following is part of
> the codes:
>
> ------------------------
> int data;
> char * buf;
>
> 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)
> rtf_put(1,buf,sizeof(data)); (2)
> ------------------------
>
> If I try the two line codes labled (1) , the program works, it could
> collect data from Analog Input and print it out, also, my user space
> main program could get the character string "data=32776".
>
> However, actually I want the main user space program to get the value of
> integer "data", so I change the codes to the two lines labeled (2), I
> put the integer "data" to a char buffer "buf", and put its contents into
> FIFO /dev/rtf1, and want the main user space program to get this value.
> But, very time I "insmod" this module, the computer freeze. I don't
> know why?(just due to "sprintf"?)
>
> Now I could not send my kernel AI data collection value to user space
> through FIFO, could you please point out where I was wrong? Thanks a
> lot for any kind hints.
>
> Best regards,
>
> Yuhong
>
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> ---
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/rtlinux/
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/