On Wed, 15 Aug 2001, Olivier Forget wrote:
Sender: [EMAIL PROTECTED]
Precedence: bulk
Reply-To: [EMAIL PROTECTED]
> Hi,
>
> I am writing a data acquisition and display program, so I need to "send"
> several floats from the RTLinux thread (where the data is acquired) to the
> linux/Qt program for display. There will probably be up to 16 floats being
> sent at a rate of probably 200Hz, possibly up to 1000Hz.
>
> rtf-put only accepts characters, so it desn't seem to be ideal.
Actually, it is ideal. Ignore the fact that rtf_put() expects arrays of
characters. This is simply a c-convention. Memory is memory. rtf_put()
works with character arrays simply because that is the smallest data type,
and it is also the basic unit of size_t units. You simply have to put
your floats into the fifo, and specify the 'count' argument correctly.
So, let's look at the following code:
/* this is some function inside your rt-task */
void write_to_fifo(unsigned int fifo, double sample) {
rtf_put (fifo, (char *)&sample, sizeof(double));
}
Notice that I had to cast my double * to a char *. That's ok. In my
opinion rtf_put() would have been nicer if it was already set up to accept
void *'s instead of char *'s as your buffer data. Anyway memory is
memory, and as long as you are careful to read this fifo correctly on the
receiving end, you should be ok. Here is demonstrative code to read the
data out of the fifo in the Non-Realtime task:
/* a function in your non-realtime task--notice that this is not robust
enough to handle any error conditions */
double read_from_fifo(int fd) {
double sample;
read (fd, &sample, sizeof(double));
return sample;
}
Notice that unlike the rtf_put() function in rt-linux, the read() system
call actually was well enough written to work with void *. It escapes me
why the rt-linux developers chose char * as opposed to void * for their
second argument to rtf_put(). All I have seen it to do to date was
confuse novices. Can anyone enlighten me on this fine point?
-Calin
>
> mbuff looks interesting but I have found the doc to be sparse.
>
> I am sure that many of you have had to do this, so I would like to hear your
> opinions. Code snippets would be appreciated to help me along.
>
> Thank-you!
>
> Oliver
> National Test Pilot School
>
> -- [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/
>
>
-- [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/