wwatson4506 / UsbMscFat

Teensy 36/40/41 Compatiblility Layer for MSC and SdFat
MIT License
10 stars 4 forks source link

Why msDriveInfo.mounted always return 0 ? #9

Closed BOBILLIER closed 3 years ago

BOBILLIER commented 3 years ago

I have played with your library and want to test if there is a mount-unmount mechanism, but don't really found it. I just found msDriveInfo.mounted property, but in my test, before or after operation write in file opération, the mount stay always to 0. I want to play with this because, in my project, I need to start USB, write some datas, and sometimes, unplug USB Stick to get them, plug the USB stick again, and record some datas again. And I need a clean "unmount" "mount" operation. For the moment my operation is to lock write operation, unplug and when I plug again I proceed one MSC.begin again and free record operation. That's run, but I'm not sure that it's a good thing, and If I will do that a lot that impacts memory allocation. Do know what is good way to do that? Thanks

wwatson4506 commented 3 years ago

BOBILLIER, Now that we are using SdFat instead of FatFs there is no real mount or ummount. The nice thing about SdFat is that it does not use any memory allocation like malloc. so you won't see an impact on memory. If I understand right it is done at compile time. As far as hot plugging just make sure that you close any open files before you remove any USB drive, It does not hurt to flush or sync any open file before you close them. You can call MSC.begin as many times as needed without problems. Calling begin is pretty much the same as mounting a USB drive😀

On Mon, Jun 7, 2021 at 11:07 AM BOBILLIER @.***> wrote:

I have played with your library and want to test if there is a mount-unmount mechanism, but don't really found it. I just found msDriveInfo.mounted property, but in my test, before or after operation write in file opération, the mount stay always to 0. I want to play with this because, in my project, I need to start USB, write some datas, and sometimes, unplug USB Stick to get them, plug the USB stick again, and record some datas again. And I need a clean "unmount" "mount" operation. For the moment my operation is to lock write operation, unplug and when I plug again I proceed one MSC.begin again and free record operation. That's run, but I'm not sure that it's a good thing, and If I will do that a lot that impacts memory allocation. Do know what is good way to do that? Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wwatson4506/UsbMscFat/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2Q7XQ5ONT6DQOVQUU5YLTRUDGZANCNFSM46IFWQQA .

BOBILLIER commented 3 years ago

Ok Nice to know that. I will just need to test that the file is close before unplugging the USB stick.