設(shè)計(jì)為從串口接收數(shù)據(jù)存到mCmdParam.ByteWrite.mByteBuffer中再寫入U(xiǎn)盤,串口查詢方式 大家?guī)臀铱纯闯绦蚰挠袉?wèn)題,謝謝 while(1) { if(RI==1) { c=SBUF; if(Comm_GetcharCtr { *pWriteByteBuffer=c;//mCmdParam.ByteWrite.mByteBuffer的指針 pWriteByteBuffer++; Comm_GetcharCtr++; //mCmdParam.ByteWrite.mByteBuffer中的字符數(shù) if(pWriteByteBuffer==&mCmdParam.ByteWrite.mByteBuffer[MAX_BYTE_IO]) { pWriteByteBuffer==&mCmdParam.ByteWrite.mByteBuffer[0]; mCmdParam.ByteWrite.mByteCount = MAX_BYTE_IO; i = CH375ByteWrite( ); mStopIfError( i ); } } } RI=0; if (c==0) break; } mCmdParam.ByteWrite.mByteCount =Comm_GetcharCtr; i = CH375ByteWrite( ); mStopIfError( i );
我也有這種問(wèn)題,怎么解決呢?給條活路吧
程序上面寫的有點(diǎn)亂,實(shí)際上在寫數(shù)據(jù)的時(shí)候很簡(jiǎn)單,只需要將接收到的數(shù)據(jù)放到mCmdParam.ByteWrite.mByteBuffer里面去就可以了,你可以這樣寫下: *P=mCmdParam.ByteWrite.mByteBuffer; count=0; while(1) { if(RI==1){ c=SBUF; *P=c; p++; RI=0; count++; while(1){ while(RI==0); *P=SBUF; RI=0; p++; if(count==MAX_BYTE_IO) { mCmdParam.ByteWrite.mByteCount = MAX_BYTE_IO; i = CH375ByteWrite( ); mStopIfError( i ); count=0; break; } count++; } } } 這個(gè)程序只是接收到一串字節(jié)之后寫到U盤里面去,前提是你首先要將文件打開。