Some Problems of FATFS
来源:互联网 发布:淘宝店掌柜名怎么改 编辑:程序博客网 时间:2024/06/05 03:42
Module: FATFS R0.12b
Problem Summary:
The character conversion from Unicode to ASCII/OEM(especially in 936(Simplified Chinese GBK) ) when _LFN_UNICODE==1.
Environment: MDK5.10.0.2
Description:
Firstly, thank you for your FAT filesystem module FATFS, ChaN, I like it very much.
I didn’t know FATFS can convert Unicode to ASCII/OEM automatically when reading a LFN of a file in the situation of _LFN_UNICODE==0 before, so I have to write a function to convert a LFN which is obtained from filinfo.fname, the member of FILINFO type structure, by
f_readdir(DIR* DirObject, FILINFO* FileInfo)
from Unicode to ASCII/OEM in the situation of _LFN_UNICODE==1. Recently, I have found a problem whether it is a bug or not and I expect to ask you for help.
I create a file with Chinese LFN in SD card. I can see the correct file name in SD Card by computer. However, I fail to display the same string in UART debug software except the English file name. The related part of code, files’ name displayed in computer and files’ name displayed in UART debug software are shown as follow.
In order to find the problem, taking the LFN “English中文.txt” as an example, I trace into the f_readdir() and get the fileinfo.fname, then I obtain the array of fname[] compared with the code of the same file name coded in Unicode shown in following fig.
As is shown, the 1st byte of a DBC is cut out. Then, I trace into the funciton get_fileinfo() which is called by f_readdir(). After rough reading, I find the part of code in get_fileinfo() could cut out the 1st byte in the situation of _LFN_UNICODE==1 but no any problem in the situation of _LFN_UNICODE==0. The part of code is shown in following fig.
I try replacing the part of code with the following code and set _LFN_UNICODE==1 then the UART debug software print Chinese file name successfully. I also try printing Chinese file name in the situation of _LFN_UNICODE==0 and it works as well.
while ((w = *lfn++) != 0) { /* Get an LFN character */#if !_LFN_UNICODE w = ff_convert(w, 0); /* Unicode -> OEM */ if (w == 0) { i = 0; break; } /* No LFN if it could not be converted */ if (i >= _MAX_LFN) { i = 0; break; } /* No LFN if buffer overflow */ if (_DF1S && w >= 0x100) { /* Put 1st byte if it is a DBCS (always false at SBCS cfg) */ fno->fname[i++] = (char)(w >> 8); } fno->fname[i++] = (char)w;#else if (i >= _MAX_LFN) { i = 0; break; } /* No LFN if buffer overflow */ fno->fname[i++] = w;#endif}fno->fname[i] = 0; /* Terminate the LFN */
That is all my description, thanks for reading.
- Some Problems of FATFS
- Some problems of mysql
- some problems
- some problems
- Android PopupWindow & some problems
- Some interesting C problems
- ubuntu android some problems
- Some Sharepoint problems and resolutions
- Some essential problems in C
- 本体开发的有关问题和命名规范——some Problems and Naming Conventions of Ontology development
- 本体开发的有关问题和命名规范——some Problems and Naming Conventions of Ontology development
- Some unsure problems about JCreator Pro
- Some tricky problems related to "protected"
- some problems in video quality detect
- Java Notes: Some Tricky Problems in Java
- Some Problems About Frame Synchronization Framework
- encode problems of browser
- Categories of performance problems
- STL之空间配置器
- Java基础[6]-4-内部类
- Move 指令寻址方式
- 51Nod-1493-数据关联
- 蓝桥杯 算法训练 Cowboys
- Some Problems of FATFS
- 高质量c/c++编程学习之四:函数设计
- 7.23 练习题 H: 木棒
- jupyter notebook 换字体换颜色换主题
- 轮播图swiper的使用
- 【查找】二分法查找
- Elasticsearch全文检索系统实现深入详解
- C/C++ 算术移位&&逻辑移位 int && long long间的转化
- HihoCoder 1394 网络流四·最小路径覆盖