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_stdio.h
char *ff_fgets( char *pcBuffer, size_t xCount, FF_FILE *pxStream );
Reads a string from a file by reading bytes from pxStream into pcBuffer until either (xCount - 1) bytes have been read,
or a newline ('\n') character has been read into to pcBuffer.
Carriage return characters ('\r') are not treated in any special way, and
are copied into pcBuffer.
The string copied into pcBuffer is NULL terminated before ff_fgets() returns.
Parameters:
pcBuffer
|
A pointer to the buffer into which characters read from
the file will be placed. The buffer must be at least
big enough to hold xCount bytes.
|
xCount
|
Bytes will be read from the file until either a newline
character has been received, or (xCount - 1) bytes have
been read.
|
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 a pointer to pcBuffer is returned. If there is a read error
then NULL is returned and the task's errno is set to indicate the reason.
A task can obtain its errno value using the ff_errno()
API function.
Example usage:
static void prvTest_ff_fgets_ff_printf( const char *pcMountPath )
{
FF_FILE *pxFile;
int iString;
const int iMaxStrings = 1000;
char pcReadString[ 20 ], pcExpectedString[ 20 ], *pcReturned;
const char *pcMaximumStringLength = "Test string 999\n";
pxFile = ff_fopen( "/nand/myfile.txt", "w+" );
for( iString = 0; iString < iMaxStrings; iString++ )
{
ff_fprintf( pxFile, "Test string %d\n", iString );
}
ff_rewind( pxFile );
for( iString = 0; iString < iMaxStrings; iString++ )
{
pcReturned = ff_fgets( pcReadString, sizeof( pcReadString ), pxFile );
if( pcReturned != pcReadString )
{
}
else
{
sprintf( pcExpectedString, "Test string %d\n", iString );
if( strcmp( pcExpectedString, pcReadString ) == 0 )
{
}
else
{
}
}
}
ff_fclose( pxFile );
}
Example use of the ff_fgets() API function
|
|
|
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.