SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
Open a file for read only succeeds if the file has been closed or aborted. The open-for-read function does not involve any SFLASH updates, and it has no effect on the SFLASH endurance.
The open-for-read function returns a negative value in case of an error.
Table 9-8 shows a partial list of errors that might be returned by the open-for-read function.
Error | Description |
---|---|
SL_ERROR_FS_FILE_IS_ALREADY_OPENED | The file is already opened for read or write. |
SL_ERROR_FS_INVALID_TOKEN_SECURITY_ALERT | For a secure file, the input token is not valid; this triggers security alerts if the device is secured. |
SL_ERROR_FS_FILE_NOT_EXISTS | The file does not exist. |
SL_ERROR_FS_DEVICE_NOT_SECURED | Reading the secure file can only be done in a secure device type. |
SL_ERROR_FS_WRONG_SIGNATURE_SECURITY_ALERT | For secure-signed files, each time the file is opened for read, the file integrity is tested. If the test is failed, an error and a security alert is raised. |
Example:
_i32 FileHdl;
_u8 DeviceFileName[180];
_u32 MasterToken;
FileHdl = sl_FsOpen(unsigned char *)DeviceFileName, SL_FS_READ, &MasterToken);
if( FileHdl < 0 )
{
/*error */
}