初级会员

- 积分
- 129
- 金钱
- 129
- 注册时间
- 2016-9-24
- 在线时间
- 36 小时
|
1金钱
操作步骤:
1. 挂载文件系统
2. 打开创建文件
3. 写文件
4.读文件
5.关闭文件
- <p>/* Gives a work area to the default drive */
- res = f_mount(&fs, "", 0);
- if (res) while(1);
-
- /* Create a file as new */
- res = f_open(&fil, "hello.txt", FA_OPEN_ALWAYS | FA_WRITE | FA_READ );
- if (res) while(1);
- /* Write a message */
- f_write(&fil, "Hello, World!\r\n", 15, &bw);
- if (bw != 15) while(1);
-
- // f_close(&fil);
- //
- // res = f_open(&fil, "hello.txt",FA_READ);
- // if (res) while(1);
-
- res = f_read(&fil, work, 15, &br);
- if (res) while(1);
- if (br != 15) while(1);</p><p>
- </p><p>/* Close the file */
- f_close(&fil);
- </p>
复制代码 问题是: 打开文件写后再读 读取会失败,读到的br是0,除非先关闭文件再读才可以,看到这个帖子代表也是先关,请问这是什么回事? 平台MSP430
http://www.openedv.com/forum.php?mod=viewthread&tid=279885
|
|