Hey all,
i looked around and could not find a definite anwer to this.
Currently, I am using a formatted SD card on a TWR-K70F120m for filelogging and want to implement proper hotswapping. I have a seperate Task open, according to the SD-Card example provided with MQX.
I added an non-autoclear event, which shows the status of the SDCard, and gets set when the first partition on the SD is formatted and available and cleared before the SD-Card is uninstalled. It works fine so far.
How do I implement hotswapping the right way? I think the correct way would be the following:
1. User presses unmount button on Touchscreen or something like that, a callback function gets started
2. callback function clears my SD-available event, so no more fopen() happen in other tasks (marking SDCard as unavailable)
3. callback waits till all open files are closed
4. Callback tells the user (s)he can remove the SDCard, and MFS/Partition Manager get uninstalled after removing the SD (like in the SDCard-example).
I searched in this forum, the documentation, and the internet, and the following questions remain:
-Is there a way to ask MFS if there are open files on a drive without trying to close it, or do I have to keep track of the number of open files myself? (for step 3.)
-Is this the right way at all, as nobody else seems to do it in a similar way?
Thanks in advance!
Greetings,
Manuel
Hi,
Please refer to this forum thread and let me know if this helps:
https://community.freescale.com/thread/300934
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
thanks for your answer.
Installing and removing MFS and Partitionmanager etc. is working already.
What does not get mentioned there, is how to prevent the removal of the sd-card while files are open, as this would (maybe) lead to data loss.
At the moment, i am keeping track of SD-Card usage via a semaphore, but i wondered if there is any other solution (e.g. asking MQX how much files are open at the moment).
Greetings,
Manuel