- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 ZedBoard 上,我想在 SD 卡上写。我在嵌入式系统上工作,我没有任何操作系统,我正在运行裸机。
我可以从 SD 卡上正常读取,它们没问题。
但是当我尝试阅读时,我有一些奇怪的行为:
但是当我读取文件时,它是空的。
这是我的代码:
void WriteFile(char const* fileName, char* buffer, size_t size)
{
FIL file;
FATFS fs;
UINT bw;
FRESULT fr;
f_mount(&fs, "", 0);
f_open(&file, fileName, FA_WRITE | FA_CREATE_ALWAYS);
fr = f_write(&file, buffer, size, &bw);
if (size != bw || fr != FR_OK)
PRINT(("Error in writing !\n"));
f_close(&file);
f_mount(NULL, "", 0);
}
我这样调用方法:
WriteFile("Hello.txt", "Hello World !", 13);
知道我做错了什么吗?
最佳答案
您可以直接刷新缓冲区 (f_sync):
FRESULT result;
FATFS fs;
FIL file;
const char string[] = "Hallo world\0";
uint16_t written = 0;
FILINFO fno;
/* Open or create a log file and ready to append */
printf("mount:%d",f_mount(&fs, "", 1));
printf("open: %d", f_open(&file, "log.txt", FA_WRITE | FA_OPEN_ALWAYS ));
printf("stat: %d", f_stat("log3.txt", &fno));
printf("write: %d wr: %d", f_write(&file, string, 11, &written), written);
printf("flush: %d", f_sync(&file));
printf("close: %d", f_close(&file)); /* close performs sync before close */
关于c - FatFS f_write 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36241121/
我正在尝试使用 FatFs libery 中的 f_write 函数循环保存 SD 卡上的大量文件,不幸的是,在最多 50 个循环条目之后,f_write 返回 FR_DISK_ERR。 做一个测试花
我在 ZedBoard 上,我想在 SD 卡上写。我在嵌入式系统上工作,我没有任何操作系统,我正在运行裸机。 我可以从 SD 卡上正常读取,它们没问题。 但是当我尝试阅读时,我有一些奇怪的行为: f_
我在 ZedBoard 上,我想在 SD 卡上写。我在嵌入式系统上工作,我没有任何操作系统,我正在运行裸机。 我可以从 SD 卡上正常读取,它们没问题。 但是当我尝试阅读时,我有一些奇怪的行为: f_
我的 SD 卡有问题。我正在使用 FatFs 库版本 R0.10b 来访问 SD 卡。 我的代码: // .... // FATFS fatfs; FIL plik;
几天来,我一直在尝试为一个项目实现 FatFs 模块。我的低级 I/O 配置已正确实现,因为我可以使用示波器查看信号。但我似乎无法在 SD 卡 上进行正确的写入。我得到的只是我的 SD-Card 上的
我是一名优秀的程序员,十分优秀!