fsFileFlush (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.05 / 1.00.00


This function writes any cached data to the media.

To improve performance, the file system caches data written by the application and only physically writes data to the media after several writes operations or when the file is closed.

Calling fsFileFlush is equal to closing the file and opening it again - except that the current position in the file is maintained.

 

Input:                

fd : FILE

FILE descriptor for the file retrieved from fsFileOpen or fsFileCreate.

 

Returns: INT

0

- File flushed.

-8

- File not open.

-16

- Media not present.

-22

- Media is busy.

-38

- File is no longer accessible and must be closed.

 

Declaration:

FUNCTION fsFileflush : INT;
VAR_INPUT
  fd : FILE;
END_VAR;

 

 

Example:

...
IF fsFileStatus(fd:=fd) = 0 THEN
  // File open, write data
  ...
  fsFileWrite(fd:=fd,buffer:=ADDR(gps.latitude),length:=SIZEOF(gps.latitude));
  fsFileWrite(fd:=fd,buffer:=ADDR(gps.longitude),length:=SIZEOF(gps.longitude));
  fsFileFlush(fd:=fd);
  ...
END_IF;
...