嗯 好吧,这是个很简陋的sdk,简陋到我不知道怎么使用它的调试工具,所以大部分bug都是通过排除法解决的。(--!)
sdk中有自带的标准库,而编译器是用的SHC,这里面很多C标准函数都不能用,还有一些匪夷所思的问题,让我琢磨了好长一些时间。
以下是一些问题记录,不断更新:
1.变量声明只能放在函数的最前面或者头文件里,放在函数的其它地方会导致编译错误。
2.Bfile_OpenFile函数的使用,这个问题纠结了我一个多小时,在pdf上文档是这样写的:
int Bfile_OpenFile(
const FONTCHARACTER *filename, // pointer to the file name
int mode // open mode
);
存储在sd卡中的文件路径是这样设置的:
FONTCHARACTER PathName[]={'¥¥','¥¥','c','r','d','0','¥¥','f','i','l','e','n','a','m','e','.','e','x','t',0};
原本我以为那个FONTCHARACTER就是char,结果我错了,我还梦想着用char*,泪奔。。。
而路径里的¥¥很诡异,我试着换成了$$,还是不行,最后看了别人的源代码才写出能正确读取的路径,是这样的:
FONTCHARACTER fontfile[] = { '\\','\\','c','r','d','0','\\','f','o','n','t','.','b','i','n','\0' } ;
int fontptr = -1 ;
fontptr = Bfile_OpenFile(fontfile, _OPENMODE_READ) ;
很不一样是吧,前面是两个\\(转义字符就是两个'\\'了),中间是cdr0然后是\\再然后是文件名,最后是'\0'!!
3.调试器的使用,断点快捷键是F9,步入是F11,这个还是很习惯的,只是在查看局部变量时,还未使用的变量即使初始化了也会显示“Invalid value",就这样又折腾了我一个小时。
4.字符串"Incomplete string"问题,要在字符串后面手动加入'\0',即"字符串\0"。
5.包含头文件时会出现WARNING: The following dependant file(s) do not exist: "9860g.h". Line: 74这样的警告,但是头文件能正常编译。
6.头文件dispbios.h有这样一个定义:#define IMB_WRITEMODIFY_REVERCE 0x02
在library pdf中我看到的是IMB_WRITEMODIFY_REVERSE,于是一直不解为什么编译会说“未定义”,原来只是9860sdk库中的
REVERSE的“S”写成了“C”。
7.存储位置Storage memory的路径"\\\\fls0\\*.*\0"在sdk下调试无效,要在计算器中才能正确调用。
8.数组的初始化可以在函数以外。
9.函数名区分大小写。
10.支持扩展ascii显示,形如:
PrintXY(110, 22, (unsigned char*)"\xE6\x9C\0", 0) ;
11.Bfile_ReadFile的返回值小于0为读取错误,等于0为读取到文件末尾(即EOF,为了这个我百思不得其解了10分钟)
12.
Both SD and storage memory seem to have their individual problems with Bfile_WriteFile, if it's used to change existing files.
Bfile_WriteFile to SD always appends the data to an existing file ignoring the filepointer.
Bfile_WriteFile to storage memory hangs, if it tries to change a zero-bit back to a one-bit.
If you want to change an existing file, it seems to be best to read it into a buffer, apply the changes to the buffer, delete the old file, create a new file and write the changed data back.
hhacker wrote:
...I'l try it in storage memory,hope it works...
Because of the 0-bit to 1-bit transition problem, I doubt this will work.
BTW: the flash's 0 to 1 transition problem is not a bug but a property of the flash chip. But the low level flash writing routine of the fx9860 does not recognize this problem and waits for completition of this impossible transition, which will never happen. That is the bug. At least it should have been mentioned in the manual.
Even if it would be possible, the storage memory is not appropriate to hold big datafiles, which are subject to frequent changes. Soon your program will fail because of an exhausted storage memory, t. i. an optimization will be necessary.
hhacker wrote:
...Anyway,I still wondering why file pointer didn't work in SD card...
I daresay its a bug, too.
---
I do not know, what kind of data your database holds, but possibly a separate index file would be a solution (on SD).
-----------------
by SimonLothar
任何flash器件的写入操作只能在空或已擦除的单元内进行,所以大多数情况下,在进行写入操作之前必须先执行擦除。NAND器件执行擦除操作是十分简单的,而NOR则要求在进行擦除前先要将目标块内所有的位都写为0。
13.通过查看Bfile_WriteFile的返回值,发现Bfile_SeekFile没有起任何作用,写入文件是完全重写了一遍,并且是自动连接到文件末尾的。
14.报错 C3303 (F) Cannot output internal file,这个问题堪称奇葩了,如果使用中文注释,一定要在注释后面添加个空格,可能是因为编译器才词法扫描的时候不能处理以双字节字母结尾的行?
15.同一个c文件下只能存在两个带变参的函数,加入第三个就会出现内存访问错误,这个问题也堪称奇葩了。
---最后更新 2012.05.28 ---
2 responses
[…] casio 9860g sdk编程中遇到的问题 […]
[…] casio 9860g sdk编程中遇到的问题 […]