Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

PAL Platform Public Functions

PAL Platform Public Functions
[PAL_PLAT_GROUP_FS]

Functions

palStatus_t pal_plat_fsMkdir (const char *pathName)
 This function attempts to create a directory named pathName.
palStatus_t pal_plat_fsRmdir (const char *pathName)
 This function deletes a directory.
palStatus_t pal_plat_fsFopen (const char *pathName, pal_fsFileMode_t mode, palFileDescriptor_t *fd)
 This function opens the file whose name is specified in the parameter `pathName` and associates it with a stream that can be identified in future operations by the `fd` pointer returned.
palStatus_t pal_plat_fsFclose (palFileDescriptor_t *fd)
 This function closes an open file object.
palStatus_t pal_plat_fsFread (palFileDescriptor_t *fd, void *buffer, size_t numOfBytes, size_t *numberOfBytesRead)
 This function reads an array of bytes from the stream and stores them in the block of memory specified by the buffer. The position indicator of the stream is advanced by the total amount of bytes read.
palStatus_t pal_plat_fsFwrite (palFileDescriptor_t *fd, const void *buffer, size_t numOfBytes, size_t *numberOfBytesWritten)
 This function starts to write data from the buffer to the file at the position pointed by the read/write pointer.
palStatus_t pal_plat_fsFseek (palFileDescriptor_t *fd, int32_t offset, pal_fsOffset_t whence)
 This function moves the file read/write pointer without any read/write operation to the file.
palStatus_t pal_plat_fsFtell (palFileDescriptor_t *fd, int32_t *pos)
 This function gets the current read/write pointer of a file.
palStatus_t pal_plat_fsUnlink (const char *pathName)
 This function deletes a single file from the file system.
palStatus_t pal_plat_fsRmFiles (const char *pathName)
 This function deletes all files in a folder from the file system (FLAT remove only).
palStatus_t pal_plat_fsCpFolder (const char *pathNameSrc, char *pathNameDest)
 This function copies all files from a source folder to a destination folder (FLAT copy only).
const char * pal_plat_fsGetDefaultRootFolder (pal_fsStorageID_t dataID)
 This function gets the default value for root directory (primary)
size_t pal_plat_fsSizeCheck (const char *stringToChk)
 This function finds the length of the string received.
palStatus_t pal_plat_fsMountSystem (void)
 This function sets up the mount point.

Function Documentation

palStatus_t pal_plat_fsCpFolder ( const char *  pathNameSrc,
char *  pathNameDest 
)

This function copies all files from a source folder to a destination folder (FLAT copy only).

Parameters:
[in]pathNameSrcA pointer to a null-terminated string that specifies the source folder.
[in]pathNameDestA pointer to a null-terminated string that specifies the destination folder (MUST exist).
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
Both folders must not be open. If a folder does not exist the function fails.
The process copies one file at a time until all files are copied.
The function does not copy a directory found in the path.

Definition at line 457 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsFclose ( palFileDescriptor_t fd )

This function closes an open file object.

Parameters:
[in]fdA pointer to the open file object structure to be closed.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code palError_t.a
Note:
After successful execution of the function, the file object is no longer valid and it can be discarded.
In some platforms, this function needs to free the file descriptor memory.

Definition at line 160 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsFopen ( const char *  pathName,
pal_fsFileMode_t  mode,
palFileDescriptor_t fd 
)

This function opens the file whose name is specified in the parameter `pathName` and associates it with a stream that can be identified in future operations by the `fd` pointer returned.

Parameters:
[out]fdA file descriptor for the file entered in the `pathName`.
[in]*pathNameA pointer to the null-terminated string that specifies the file name to open or create.
[in]modeA mode flag that specifies the type of access and open method for the file.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
The folder path must end with "/".
If necessary, the platform layer allocates memory for the file descriptor. The structure pal_plat_fclose() shall free that buffer.
The mode flags sent to this function are normalized to the pal_fsFileMode_t and each platform needs to replace them with the proper values.

Definition at line 131 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsFread ( palFileDescriptor_t fd,
void *  buffer,
size_t  numOfBytes,
size_t *  numberOfBytesRead 
)

This function reads an array of bytes from the stream and stores them in the block of memory specified by the buffer. The position indicator of the stream is advanced by the total amount of bytes read.

Parameters:
[in]fdA pointer to the open file object structure.
[in]bufferA buffer for storing the read data.
[in]numOfBytesThe number of bytes to read.
[out]numberOfBytesReadThe number of bytes read.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
After successful execution of the function, `numberOfBytesRead` should be checked to detect end of the file. If `numberOfBytesRead` is less than `numOfBytes`, the read/write pointer has reached the end of the file during the read operation or an error has occurred.

Definition at line 185 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsFseek ( palFileDescriptor_t fd,
int32_t  offset,
pal_fsOffset_t  whence 
)

This function moves the file read/write pointer without any read/write operation to the file.

Parameters:
[in]fdA pointer to the open file object structure.
[in]offsetThe byte offset from top of the file to set the read/write pointer.
[out]whenceThe offset is relative to this.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
- The `whence` options are:
  1. PAL_ERR_FS_SEEKSET - relative to the start of the file.
  2. PAL_ERR_FS_SEEKCUR - relative to the current position indicator.
  3. PAL_ERR_FS_SEEKEND - relative to the end-of-file.
In some systems, there is no whence argument. If you need to implement the `whence` argument:
PAL_ERR_FS_SEEKEND - The function first finds the length of the file, then subtracts the file length from the position to find the relative path from the beginning.
PAL_ERR_FS_SEEKCUR - The function finds the current stream position and calculates the relative path from the file start.

In both options, fseek() needs to verify that the offset is smaller than the file end or start.

Definition at line 289 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsFtell ( palFileDescriptor_t fd,
int32_t *  pos 
)

This function gets the current read/write pointer of a file.

Parameters:
[in]fdA pointer to the open file object structure.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.

Definition at line 354 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsFwrite ( palFileDescriptor_t fd,
const void *  buffer,
size_t  numOfBytes,
size_t *  numberOfBytesWritten 
)

This function starts to write data from the buffer to the file at the position pointed by the read/write pointer.

Parameters:
[in]fdA pointer to the open file object structure.
[in]bufferA pointer to the data to be written.
[in]numOfBytesThe number of bytes to write.
[out]numberOfBytesWrittenThe number of bytes written.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code palError_t.
Note:
The read/write pointer advances as number of bytes written. After successful execution of the function,
`numberOfBytesWritten` should be checked to detect if the disk is full. If `numberOfBytesWritten` is less than `numOfBytes`, the volume got full during the write operation.

Definition at line 235 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

const char* pal_plat_fsGetDefaultRootFolder ( pal_fsStorageID_t  dataID )

This function gets the default value for root directory (primary)

Parameters:
[in]dataID- id of the data to ge the root folder for.
Returns:
pointer to the default path.

Definition at line 581 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsMkdir ( const char *  pathName )

This function attempts to create a directory named pathName.

Parameters:
[in]*pathNameA pointer to the null-terminated string that specifies the directory name to create.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
To remove a directory use PAL_ERR_FS_rmdir.

Example

 {.cpp}
    palStatus_t ret;
    ret = PAL_ERR_FS_mkdir("Dir1");
    if(!ret)
    {
        //Error
    }

Definition at line 92 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsMountSystem ( void   )

This function sets up the mount point.

Parameters:
void
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
palStatus_t pal_plat_fsRmdir ( const char *  pathName )

This function deletes a directory.

Parameters:
[in]*pathNameA pointer to the null-terminated string that specifies the name of the directory to be deleted.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
The directory to be deleted must be Empty and closed. The folder path must end with "/". If given "..", the function changes the root directory to one directory down and deletes the working directory.

Definition at line 105 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsRmFiles ( const char *  pathName )

This function deletes all files in a folder from the file system (FLAT remove only).

Parameters:
[in]pathNameA pointer to a null-terminated string that specifies the folder.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
The folder must not be open and the folder path must end with "/".
The process deletes one file at a time by calling pal_plat_fsUnlink until all files are removed.
The function does not remove the directory found in the path.

Definition at line 391 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

size_t pal_plat_fsSizeCheck ( const char *  stringToChk )

This function finds the length of the string received.

Parameters:
[in]stringToChkA pointer to the string received with a null terminator.
Returns:
The size of the string.

Definition at line 701 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.

palStatus_t pal_plat_fsUnlink ( const char *  pathName )

This function deletes a single file from the file system.

Parameters:
[in]pathNameA pointer to a null-terminated string that specifies the file to be removed.
[in]buildRelativeDirectoryNeeded to add a working directory to give pathName.
Returns:
PAL_SUCCESS upon a successful operation.
PAL_FILE_SYSTEM_ERROR - see the error code description palError_t.
Note:
The file must not be opened

Definition at line 370 of file FreeRTOS/Storage/FileSystem/pal_plat_fileSystem.c.