Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS+ Products FreeRTOS Labs Integration Services Contact / Enquiries


[FreeRTOS Embedded File System API]

int f_getc( F_FILE *pxFileHandle );

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

A file can only be read if it was opened with one of the following option strings: "r", "r+", "w+" or "a+" (see f_open()).


pxFileHandle   The handle of the file from which a character is being read. The handle is returned by the call to f_open() used to originally open the file.

-1   A character was not read from the file.

Any other value   The character that was read from the file.

See also


Example usage:

void vSampleFunction( char *pcFileName, char *pcBuffer, long lBufferSize )
F_FILE *pxFile;
long lBytesRead;
int iReturnedByte;

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

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

        if( iReturnedByte == -1 )
            /* A byte could not be read. */
            /* Write the byte into the buffer. */
            pcBuffer[ lBytesRead ] = ( char ) iReturnedByte;

    /* Finished with the file. */
    f_close( pxFile );
Example use of the f_getc() API function

[ Back to the top ]    [ About FreeRTOS ]    [ FreeRTOS+ Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.