This function allows you to open a file on CF for reading or writing and obtain a handle, which is to be used as a parameter for subsequent operations on the same file(f_puts(), f_close(), ..).
Syntax |
i32 f_open (string fileName, string mode, i32 maxChar, stru_filehnd stru) |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fileName |
This is the name (complete with extension) of the file you intend to open. NOTE: The name must be preceded by the indication of the logical device you intend to work on, which can be FA, FB, etc. It can be a local or global string variable, or a constant string. |
||||||||||||||
mode |
This is a parameter that specifies how the file is opened and can take one of the following values:
|
||||||||||||||
maxChar |
WARNING: From RTE >= 33 must be imposed equal to zero. This is a parameter that specifies the maximum number of characters that made the file. This value must be given when opening a file for writing, while it must be set to 0 when the file is opened for reading. This parameter is used by the operating system to reserve in flash a fixed portion of memory in which the file will later be written |
||||||||||||||
stru |
Variable of type stru_filehnd where the handle characterizing the opened file will be stored and remain associated with it during all subsequent operations, until the file is closed by the instruction f_close(). This variable is to be used as a parameter in all other file handling functions |
||||||||||||||
Result |
Returns:
|
||||||||||||||
Validity |
Task |
||||||||||||||
Note |
If functions regarding compact flash management are used, it is recommended to impose bit 14 of the sys_cfg variable (0x00004000) to 1, to enable the use of safety routines for flash writing/reading |
Example of use:
|