下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

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

ff_fputc()

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

ff_stdio.h
int ff_fputc( int iChar, FF_FILE * pxStream );
		

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

在 int 中传递字符可能不是最佳方式,但 ff_fputc() 原型符合标准和预期的 stdio fputc() 函数原型。

参数:

iChar   写入文件的值。 该值在被写入之前 已转换为未签名的字符(8 位)。

pxStream   指向被写入字符的文件的指针。 该指针与调用 ff_fopen() 返回的指针相同,最初用于打开文件。

返回:

如果成功,将返回写入文件的字节。 如果返回有任何 其他值,则未将字节写入文件,并且任务 errno 将设置为指示原因。 任务 可以使用 stdioGET_ERRNO() API 函数 获取其 errno 值。

用法示例:


void vSampleFunction( char *pcFileName, int32_t lNumberToWrite )
{
FF_FILE *pxFile;
const int iCharToWrite = 'A';
int iCharWritten;
int32_t lBytesWritten;

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

/* Write 'A' to the file the number of times specified by the
lNumberToWrite parameter. */

for( lBytesWritten = 0; lBytesWritten < lNumberToWrite; lBytesWritten++ )
{
/* Write the byte. */
iCharWritten = ff_fputc( iCharToWrite, pxFile );

/* Was the character written to the file successfully? */
if( iCharWritten != iCharToWrite )
{
/* The byte could not be written to the file. */
break;
}
}

/* Finished with the file. */
ff_fclose( pxFile );
}

Example use of the ff_fputc() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.