Hi,
I want to open 2 FILE (fopen) on same path:
This seems not to work. Consumer always reads EOF in spite of producer writes in the file.
If producer closes the file, then it seems to work. But, this is not realtime.
I have MQX 4.0 (not 4.01), on Kinetis K60 custom board.
MFS device is SD card.
Would this application be possible ?
Some idea ?
Dear Lucky,
I am afraid that this approach would not work reliably even if the flushing is performed after the write.
Current design of MFS simply does not allow this. I am even surprised that you were successfully able to open the file the second time at all, if it was already open for writing. A file may be opened multiple times, but only for reading.
If you need to use producer/consumer model like a pipe I suggest you looking at MQX IPC (message queues might also suit well).
Best regards, Pavel
Maybe, when read and write the same file on the file system, a flush operation is often required because there is only one buffer used for read and write. When the producer closes the file, a flush operation is done. You may try _io_fflush() first detailed on the MQX MFS user guide page 24 whenever you do a read operation.