下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

最新资讯
FreeRTOS-Plus-TCP 现具有统一的 IPv4 和 IPv6 功能,支持多接口。
为基于 FreeRTOS 的固件实现防砖化 MCU FOTA:
宣布停止支持 FreeRTOS 202012 LTS。
FreeRTOS 网站现已提供简体中文版本
新的 FreeRTOS Long Term Support 版本现已发布。

ff_fgetc()

[FreeRTOS-Plus-FAT 标准 API 引用]

ff_stdio.h
int ff_fgetc( FF_FILE * pxStream );
		

从嵌入的 FAT 文件系统的打开文件中读取单个字节。 增加了一个读/写位置。

在 int 中返回字符可能不是最佳方式,但 ff_fgetc() 原型符合标准和预期的 stdio fgetc() 函数原型。

参数:

pxStream   指向数据待读取的文件的指针。 该指针与调用 ff_fopen() 返回的指针相同,最初用于打开文件。

返回:

如果成功,将返回从文件系统读取的字节。 如果无法从文件读取 一个字节,因为读取位置已位于 文件末尾,则返回 FF_EOF。

用法示例:


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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.