Last edit: Peter Favrholdt on July 2, 2006 18:07 (5194 days, 11 hours and 27 minutes ago) (diff)
Rtai.Dk | RecentChanges | Preferences | DIAPM RTAI

You really should consider using Mailboxes instead. FIFOs are just legacy support for very old stuff. They are really useful just for interrupt only controllers.

From the mailinglist:

A Fifo is a unidirectional thingy, You should rtf_create() a new fifo for every driver that is e.g. sending data, then on the receivers side just open the fifo-device and rtf_read() from it. At least that is what i do, because Mailboxes seem to be too complicated for me. btw, a fifo is also a very easy way to communicate between kernelspace and userspace.

Q: I have a kernel/RTAI module which open [rtf_create()] a RTAI fifo and write on it with [rtf_put()] periodically. On the other hand there is Linux process which uses the same RTAI fifo, open it with the normal unix open() and read it with the read() function. When the kernel module is installed after the execution of the Linux process, there is no problem. I get evrything right from the beginning. But when I start/kill/start again the Linux process after installing the RTAI module, I get sometimes wrong data. The read() seems to be synchronous of the rtf_put() but the data are meaningless for a while until it returns right.

A: Try resetting the FIFO in your Linux process on startup. Furthermore reset (rtf_reset()) and resize (resize()) the FIFO to the right size in your Kernel module each time you notice that the rtf_put command did not write all the data. In my application the FIFO-size was changed to the default size of 1K in these cases and I still don't know why.

Q: I want to exchange data between a kernel module and an user space task?

A: To use the same semaphore in user and kernel space, use semaphores associated to fifos..;


Q: When two tasks needs to write to the same FIFO, is there a threat on the data integrity? To elaborate, after I write a group of data to a FIFO shared by more than one task, will my rtf_put() completely put the data I gave from First task before another task writes a different group of data to the same FIFO? Rupesh

Q: I need to somehow implement circle buffer in FIFO: if there is no space left for writing required number of bytes to FIFO, some first bytes shall be deleted then. If you do some data acquisition, and FIFO got overloaded, it is better to have recent data in FIFO, then old one. Is there any possibility to get in module how many bytes can be read/wrote to particular FIFO?

A: There should be rtf_overwrite(int fd, void *buf, int count), even if it might not have been used very much. Much more tested should be the same functionality under mailboxes. You can use them as a full fifo substitute with (NEW)LXRT support.

Edit text of this page | View other revisions | Download Rtai.dk