下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

最新资讯
简化任何设备的身份验证云连接。
利用 CoAP 设计节能型云连接 IoT 解决方案。
11.0.0 版 FreeRTOS 内核简介:
FreeRTOS 路线图和代码贡献流程。
使用 FreeRTOS 实现 OPC-UA over TSN。

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.