存的時候出現(xiàn)亂碼,以及格式不對。現(xiàn)在程序存的是hello word,但存進(jìn)去的還有之前程序存的內(nèi)容。
有沒有遇到過這個情況的大神呀
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--寫入數(shù)據(jù)\n");//打開文件??
? sys.u8_test=CH376ByteWrite("Hello wold!",sizeof("Hello wold!"),NULL); // 以字節(jié)為單位向當(dāng)前位置寫入數(shù)據(jù)塊?
? ? ? ? ? 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--關(guān)閉文件,并等待下次命令\n");//打開文件
????????sys.u8_test=CH376FileClose(TRUE);// 關(guān)閉文件,對于字節(jié)讀寫建議自動更新文件長度?
????????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;
}