[ ]
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS Labs FreeRTOS+TCP FreeRTOS+FAT FreeRTOS+POSIX Contact / Enquiries


FreeRTOS+FAT is still in the lab
FreeRTOS+FAT is already in use in commercial products and we encourage you to try it yourself. Be aware however that FreeRTOS+FAT was acquired by Real Time Engineers Ltd., and is still being documented and updated to ensure it meets our strict quality standards. Please use the forum for support, or contact us directly if you have a specific business interest.

ff_fgetc()

[FreeRTOS+FAT Standard API Reference]

ff_stdio.h
int ff_fgetc( FF_FILE * pxStream );
		

Reads a single byte from an open file in the embedded FAT file system. The read/write position is incremented by one.

Returning a char in an int may not seem optimal, but the ff_fgetc() prototype conforms to the standard and expected stdio fgetc() function prototype.

Parameters:

pxStream   A pointer to the file from which the data is being read. This is the same pointer that was returned from the call to ff_fopen() used to originally open the file.

Returns:

On success the byte read from the file system is returned. If a byte could not be read from the file because the read position is already at the end of the file then FF_EOF is returned.

Example usage:


void vSampleFunction( char *pcFileName, char *pcBuffer, int32_t lBufferSize )
{
FF_FILE *pxFile;
int32_t lBytesRead;
int iReturnedByte;

    /* Open the file specified by the pcFileName parameter. */
    pxFile = ff_fopen( pcFileName, "r" );

    /* Read the number of bytes specified by the lBufferSize parameter. */
    for( lBytesRead = 0; lBytesRead < lBufferSize; lBytesRead++ )
    {
        iReturnedByte = ff_fgetc( pxFile );

        if( iReturnedByte == FF_EOF )
        {
            /* A byte could not be read because the end of the file has
            been reached. */
            break;
        }
        else
        {
            /* Write the byte into the buffer. */
            pcBuffer[ lBytesRead ] = ( char ) iReturnedByte;
        }
    }

    /* Finished with the file. */
    ff_fclose( pxFile );
}
						
Example use of the ff_fgetc() API function


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ FreeRTOS Labs Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.