Using the USBFileSystem class to provide SD-card with USBMSD and FATFileSystem support at same time.

Dependents:   SD_USB_FS_HelloWorld

See also helloworld program at http://mbed.org/users/karelv/code/SD_USB_FS_HelloWorld/

Created based on:

  1. comment from Erik Olieman. forum
  2. USBMSD_SD library for the spi-access to SD-card. (no dependency but spi-access code is copied) USBMSD_SD
  3. USBFileSystem libary USBFileSystem

Information

My win7 pc always disconnect/connect the drive and at disconnect it also closes the explorer which show the content of that drive. It does the same with the editor that has the file opened.

Quote:

(by Erik Olieman)

You are correct that that is what happens, got the same on windows 8. The problem is that windows (and probably every other OS) is quite heavy on caching of USB drives. So it reads the data ones, and after that it only writes and assumes its commands have been performed. For example if you have a drive with a bunch of files, and I enable write protection on the library, you can still happily delete the file and windows will tell you it is gone. You can make new files and windows will tell you they are created. Despite nothing actually being done. So the only way to force a refresh is disconnecting/reconnecting. Well not entirely true, I found out if you are writing custom programs you can disable this caching behavior after alot of digging. But in principle it is always on, and you have to reconnect the device. An alternative file browser might have other behavior, but dunno.

So the TL;DR: It is OS behavior that the program can't do anything about. Initially I intended to just use write protection to block the computer from writing, which is why it is still the default, but it doesn't actually work like you want it to work for 99% of the use cases. So reconnecting it is.

Download repository: zip gz

Files at revision 1:88089dd56f0e

Name Size Actions
[up]
USBSDFileSystem.cpp 13848 Revisions Annotate
USBSDFileSystem.h 1747 Revisions Annotate