SimpleLink CC3100/CC3200 Host Driver  Version 1.0.1.6
Simplifies the implementation of Internet connectivity
FileSystem

Functions

_u32 _sl_GetCreateFsMode (_u32 maxSizeInBytes, _u32 accessFlags)
 
_i32 sl_FsOpen (const _u8 *pFileName, const _u32 AccessModeAndMaxSize, _u32 *pToken, _i32 *pFileHandle)
 open file for read or write from/to storage device More...
 
_i16 sl_FsClose (const _i32 FileHdl, const _u8 *pCeritificateFileName, const _u8 *pSignature, const _u32 SignatureLen)
 close file in storage device More...
 
_i32 sl_FsRead (const _i32 FileHdl, _u32 Offset, _u8 *pData, _u32 Len)
 Read block of data from a file in storage device. More...
 
_i32 sl_FsWrite (const _i32 FileHdl, _u32 Offset, _u8 *pData, _u32 Len)
 write block of data to a file in storage device More...
 
_i16 sl_FsGetInfo (const _u8 *pFileName, const _u32 Token, SlFsFileInfo_t *pFsFileInfo)
 get info on a file More...
 
_i16 sl_FsDel (const _u8 *pFileName, const _u32 Token)
 Delete specific file from a storage or all files from a storage (format) More...
 

Enumerations

enum  SlFsFileOpenAccessType_e {
  _FS_MODE_OPEN_READ = 0,
  _FS_MODE_OPEN_WRITE,
  _FS_MODE_OPEN_CREATE,
  _FS_MODE_OPEN_WRITE_CREATE_IF_NOT_EXIST
}
 
enum  SlFileOpenFlags_e {
  _FS_FILE_OPEN_FLAG_COMMIT = 0x1,
  _FS_FILE_OPEN_FLAG_SECURE = 0x2,
  _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST = 0x4,
  _FS_FILE_OPEN_FLAG_STATIC = 0x8,
  _FS_FILE_OPEN_FLAG_VENDOR = 0x10,
  _FS_FILE_PUBLIC_WRITE = 0x20,
  _FS_FILE_PUBLIC_READ = 0x40
}
 
enum  _SlFsFileOpenMaxSizeGran_e {
  _FS_MODE_SIZE_GRAN_256B = 0,
  _FS_MODE_SIZE_GRAN_1KB,
  _FS_MODE_SIZE_GRAN_4KB,
  _FS_MODE_SIZE_GRAN_16KB,
  _FS_MODE_SIZE_GRAN_64KB,
  _FS_MAX_MODE_SIZE_GRAN
}
 

Detailed Description

Function Documentation

_i16 sl_FsClose ( const _i32  FileHdl,
const _u8 *  pCeritificateFileName,
const _u8 *  pSignature,
const _u32  SignatureLen 
)

close file in storage device

Parameters
[in]FileHdlPointer to the file (assigned from sl_FsOpen)
[in]pCeritificateFileNameReserved for future use. Use NULL.
[in]pSignatureReserved for future use. Use NULL.
[in]SignatureLenReserved for future use. Use 0.
Returns
On success, zero is returned. On error, an error code is returned
See also
sl_FsRead sl_FsWrite sl_FsOpen
Note
Call the fs_Close with signature = 'A' signature len = 1 for activating an abort action
Warning
Example:
1 sl_FsClose(FileHandle,0,0,0);
_i16 sl_FsDel ( const _u8 *  pFileName,
const _u32  Token 
)

Delete specific file from a storage or all files from a storage (format)

Parameters
[in]pFileNameFile Name
[in]TokenReserved for future use. Use 0
Returns
On success, zero is returned. On error, an error code is returned
See also
Note
belongs to basic_api
Warning
Example:
1 Status = sl_FsDel("FileName.html",0);
_i16 sl_FsGetInfo ( const _u8 *  pFileName,
const _u32  Token,
SlFsFileInfo_t pFsFileInfo 
)

get info on a file

Parameters
[in]pFileNameFile name
[in]TokenReserved for future use. Use 0
[out]pFsFileInfoReturns the File's Information: flags,file size, allocated size and Tokens
Returns
On success, zero is returned. On error, an error code is returned
See also
sl_FsOpen
Note
belongs to basic_api
Warning
Example:
1 Status = sl_FsGetInfo("FileName.html",0,&FsFileInfo);
_i32 sl_FsOpen ( const _u8 *  pFileName,
const _u32  AccessModeAndMaxSize,
_u32 *  pToken,
_i32 *  pFileHandle 
)

open file for read or write from/to storage device

Parameters
[in]pFileNameFile Name buffer pointer
[in]AccessModeAndMaxSizeOptions: As described below
[in]pTokenReserved for future use. Use NULL for this field
[out]pFileHandlePointing on the file and used for read and write commands to the file

AccessModeAndMaxSize possible input
FS_MODE_OPEN_READ - Read a file
FS_MODE_OPEN_WRITE - Open for write for an existing file
FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) - Open for creating a new file. Max file size is defined in bytes.
For optimal FS size, use max size in 4K-512 bytes steps (e.g. 3584,7680,117760)
Several access modes bits can be combined together from SlFileOpenFlags_e enum

Returns
On success, zero is returned. On error, an error code is returned
See also
sl_FsRead sl_FsWrite sl_FsClose
Note
belongs to basic_api
Warning
Example:
1 char* DeviceFileName = "MyFile.txt";
2 unsigned long MaxSize = 63 * 1024; //62.5K is max file size
3 long DeviceFileHandle = -1;
4 long RetVal; //negative retval is an error
5 unsigned long Offset = 0;
6 unsigned char InputBuffer[100];
7 
8 // Create a file and write data. The file in this example is secured, without signature and with a fail safe commit
9 RetVal = sl_FsOpen((unsigned char *)DeviceFileName,
10  FS_MODE_OPEN_CREATE(MaxSize , _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST | _FS_FILE_OPEN_FLAG_COMMIT ),
11  NULL, &DeviceFileHandle);
12 
13 Offset = 0;
14 //Preferred in secure file that the Offset and the length will be aligned to 16 bytes.
15 RetVal = sl_FsWrite( DeviceFileHandle, Offset, (unsigned char *)"HelloWorld", strlen("HelloWorld"));
16 
17 RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
18 
19 // open the same file for read, using the Token we got from the creation procedure above
20 RetVal = sl_FsOpen((unsigned char *)DeviceFileName,
21  FS_MODE_OPEN_READ,
22  NULL, &DeviceFileHandle);
23 
24 Offset = 0;
25 RetVal = sl_FsRead( DeviceFileHandle, Offset, (unsigned char *)InputBuffer, strlen("HelloWorld"));
26 
27 RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
_i32 sl_FsRead ( const _i32  FileHdl,
_u32  Offset,
_u8 *  pData,
_u32  Len 
)

Read block of data from a file in storage device.

Parameters
[in]FileHdlPointer to the file (assigned from sl_FsOpen)
[in]OffsetOffset to specific read block
[out]pDataPointer for the received data
[in]LenLength of the received data
Returns
On success, returns the number of read bytes. On error, negative number is returned
See also
sl_FsClose sl_FsWrite sl_FsOpen
Note
belongs to basic_api
Warning
Example:
1 Status = sl_FsRead(FileHandle, 0, &readBuff[0], readSize);
_i32 sl_FsWrite ( const _i32  FileHdl,
_u32  Offset,
_u8 *  pData,
_u32  Len 
)

write block of data to a file in storage device

Parameters
[in]FileHdlPointer to the file (assigned from sl_FsOpen)
[in]OffsetOffset to specific block to be written
[in]pDataPointer the transmitted data to the storage device
[in]LenLength of the transmitted data
Returns
On success, returns the number of written bytes. On error, an error code is returned
See also
Note
belongs to basic_api
Warning
Example:
1 Status = sl_FsWrite(FileHandle, 0, &buff[0], readSize);

Data Structure Documentation

struct SlFsFileInfo_t

Definition at line 162 of file fs.h.

Data Fields
_u32 AllocatedLen
_u32 FileLen
_u16 flags
_u32 Token[4]