用以下程序写文件如果写的字节比较多,写不进去,咋回事儿??(好像是写100字节好使,再多了就不大行了),我这程序应该没问题吧
ulong addr=0; uchar yehao=1; uchar zongyesu=0; uchar zuihouyeduansu=0;
zongyesu = (uchar)((suzi-1)/256) + 1; zuihouyeduansu = suzi % 256;
//写文件 while(XieWenJian(((uchar far*)&temp), 6)) //如果没成功,一直写 { printf("写开始6字节没成功\n\r"); } // XieWenJian(((uchar far*)&temp), 6); addr = GYRAM; while( yehao < zongyesu ) { // XieWenJian((uchar far*)addr, 256*5); while(XieWenJian((uchar far*)addr, 256*5)) { printf("写yehao = %bu段未成功\n\r", yehao); } addr += 256*5; yehao++; } // XieWenJian((uchar far*)addr, zuihouyeduansu*5); while(XieWenJian((uchar far*)addr, zuihouyeduansu*5)) { printf("写最后页未成功\n\r"); } addr = GYRAM + suzi*5L; XieWenJian((uchar far*)addr, 0); //更新文件长度
//----------------------------------------------------------------------------- // 写入文件数据 // 成功返回0 uchar XieWenJian(uchar far* ucBuf, uint uiZiJieSu) { UINT16 ui = 0; EA = 0; CH376ByteWrite( ucBuf, uiZiJieSu, &ui ); //有些U盘可能会要求在写数据后等待一会才能继续操作,所以,如果在某些U盘中发生数据丢失现象,建议在每次写入数据后稍作延时再继续 EA = 1; mDelaymS( 1 );
if (uiZiJieSu == ui) { return 0; } else { return 1; } }
//-----------------------------------------------------------------------------