Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

µC/FS expects that any call to a function that accesses a removable device may fail, since the device may be removed, powered off or suddenly unresponsive. If µC/FS detects such an event, the device will need to be refreshed or closed and re-opened. FSDev_Refresh() refreshes a device:


Code Block
languagecpp
chngd = FSDev_Refresh((CPU_CHAR *)"ide:0:",  /* <-- device name  */
                      (FS_ERR   *)&err);     /* <-- return error */


There are several cases to consider:

  • If the return error is FS_ERR_NONE and the return value

...

  • is DEF_YES, then a new device (e.g., SD card) has been inserted. All files and directories that are open on volumes on the device must be closed and all volumes that are open on the device must be closed or refreshed.
  • If the return error is FS_ERR_NONE and the return value

...

  • is DEF_NO, then the same device (e.g., SD card) is still inserted. The application can continue to access open files, directories and volumes.
  • If the return error is neither FS_ERR_NONE nor FS_ERR_DEV_INVALID_LOW_FMT, then no functioning device is present. The device must be refreshed at a later time.

A device can be refreshed explicitly with FSDev_Refresh(); however, refresh also happens automatically. If a volume access (e.g., FSVol_Fmt(), FSVol_Rd()), entry access (FSEntry_Create(), fs_remove()), file open (fs_fopen() or FSFile_Open()) or directory open (fs_opendir() or FSDir_Open()) is initiated on a device that was not present at the last attempted access, µC/FS attempts to refresh the device information; if that succeeds, it attempts to refresh the volume information.

...