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!