存的时候出现乱码,以及格式不对。现在程序存的是hello word,但存进去的还有之前程序存的内容。
有没有遇到过这个情况的大神呀
case CH376_STATU_5_WaitCMD:
if(CH376_isTimeOut()){
if(ch376.statu_prv == CH376_STATU_4_DiskMount){
CH376_STATU_Jump(CH376_STATU_6_FileOpen,TIMEOUT_200MS);//检查后直接打开文件
ch376.Try_Ctr = 0;
}else if(ch376.statu_prv == CH376_STATU_8_FileClose){
if(1){//有读取指令
CH376_Printf("CH376---sta5--New CMD\n");//
CH376_STATU_Jump(CH376_STATU_6_FileOpen,TIMEOUT_200MS);
}
}
}
break;
case CH376_STATU_6_FileOpen:
if(CH376_isTimeOut()){
ch376.Try_Ctr ++;
CH376_Printf("CH376---sta6--打开文件\n");//打开文件
Date_File_to_String(Str);
sys.u8_test = CH376FileOpenPath(Str);//查看文件存不存在
if(sys.u8_test == 0x22){
if(ch376.Try_Ctr <= 5){
CH376_STATU_Jump(CH376_STATU_6_FileOpen,TIMEOUT_200MS);
break;
}
}
if(ERR_MISS_FILE == sys.u8_test){
sys.u8_test = CH376FileCreatePath(Str);
CH376_STATU_Jump(CH376_STATU_7_ByteWrite,TIMEOUT_200MS);
ch376.Try_Ctr = 0;
}else{
sys.u8_test = CH376ByteLocate(0xFFFFFFFF);//移动文件指针到文件末尾
CH376_STATU_Jump(CH376_STATU_7_ByteWrite,TIMEOUT_200MS);
ch376.Try_Ctr = 0;
}
}
break;
case CH376_STATU_7_ByteWrite:
if(CH376_isTimeOut()){
CH376_Printf("CH376---sta7--写入数据\n");//打开文件
sys.u8_test=CH376ByteWrite("Hello wold!",sizeof("Hello wold!"),NULL); // 以字节为单位向当前位置写入数据块
if(sys.u8_test == 0x22){
if(ch376.Try_Ctr <= 5){
num_flag--;
CH376_STATU_Jump(CH376_STATU_7_ByteWrite,TIMEOUT_200MS);
break;
}
}
CH376_STATU_Jump(CH376_STATU_8_FileClose,TIMEOUT_200MS);
ch376.Try_Ctr = 0;
}
break;
case CH376_STATU_8_FileClose:
if(CH376_isTimeOut()){
CH376_Printf("CH376---sta8--关闭文件,并等待下次命令\n");//打开文件
sys.u8_test=CH376FileClose(TRUE);// 关闭文件,对于字节读写建议自动更新文件长度
if(sys.u8_test == 0x22){
if(ch376.Try_Ctr <= 5){
CH376_STATU_Jump(CH376_STATU_8_FileClose,TIMEOUT_200MS);
break;
}
}
CH376_STATU_Jump(CH376_STATU_5_WaitCMD,TIMEOUT_200MS);
}
break;
default:
break;
}