原子兄,你好!
还是关于fatfs文件名递增的问题;目的是在写入一定数量的数据后,自动的新建新的文件来存储数据;
我仿照战舰开发板“录音机实验”的程序,用recoder_new_pathname函数来实现文件名的递增,具体程序如下:
while(1)
{
recoder_new_pathname(pname);
res=f_open(file,(const TCHAR*)pname,FA_OPEN_ALWAYS |FA_WRITE);
f_lseek(file,file->fsize);
printf("size:%d\r\n",file->fsize);
if(res!=FR_OK)
{
printf("error\n");
}
printf("HELLO KITTY!\n");
f_write(file, testdata_temp,sizeof(testdata_temp),&bw);//?????·????
f_close(file);
}
void recoder_new_pathname(u8 *pname)
{
u8 res;
u16 index=0;
while(index<0X11)
{
sprintf((char*)pname,"0:RECORDER/REC%05d.bin",index);
res=f_open(file,(const TCHAR*)pname,FA_READ);
if(res==FR_NO_FILE)break;
index++;
}
}
但经实验,这样根本不行,程序死在
sprintf((char*)pname,"0:RECORDER/REC%05d.bin",index); 这句中,
请问原子兄,是什么地方出问题了吗?这样用行吗,要实现文件名自增,到底该怎样写啊?
请指点,谢谢!
|