[求助]字節(jié)模式 并口模塊(CH375)怎么多讀了一個(gè)字節(jié),它自檢也是對(duì)的

08 06 02 0D 0A 01 00 02 01 2D 2D 2D 2E 2E 2E 2F 2F 04 00 FF 50 00 00 00 02 2D 2D 2D 2E 2E 2E 2F 2F 04 00 FF 50 00 00 00

08 06 02 0D 多了個(gè) 0D

for ( j=0; j{ mCmdParam.ByteRead.mByteCount = sizeof( mCmdParam.ByteRead.mByteBuffer ); /* 請(qǐng)求讀出64字節(jié)數(shù)據(jù), 單次讀寫的長(zhǎng)度不能超過(guò) sizeof( mCmdParam.ByteWrite.mByteBuffer ) */ i = ExecCommand( CMD_ByteRead, 1 ); /* 以字節(jié)為單位讀取數(shù)據(jù)*/ mStopIfError( i ); for ( k=0; k!=mCmdParam.ByteRead.mByteCount; k++ ) { printf( "%c", mCmdParam.ByteRead.mByteBuffer[k] ); if ( mCmdParam.ByteRead.mByteCount { printf( "end\n" ); break; } } printf( "Close\n" ); mCmdParam.Close.mUpdateLen = 0; i = ExecCommand( CMD_FileClose, 1 ); /* 關(guān)閉文件 */ mStopIfError( i );

unsigned char xdata tim[]={8,6,2,10,1,0, 2, 1, 45,45,45, 46,46,46, 47,47,4, 0 ,255,80, 0,0,0, 2, 45,45,45, 46,46,46, 47,47,4, 0 ,255,80, 0,0,0 };


你好:按照你的要求,我寫了一個(gè)程序,你參考一下 printf( "Write\n" ); pStr=tim; count = sizeof( tim ); /* 準(zhǔn)備寫入的數(shù)據(jù)的總長(zhǎng)度 */ while ( count ) { /* 如果較大,分多次寫入 */ if ( count < sizeof( mCmdParam.ByteWrite.mByteBuffer ) ) i = count; /* 只剩最后一些數(shù)據(jù)要寫入 */ else i = sizeof( mCmdParam.ByteWrite.mByteBuffer ); /* 數(shù)據(jù)較多,分多次寫入 */ count -= i; /* 計(jì)數(shù) */ memcpy( mCmdParam.ByteWrite.mByteBuffer, pStr, i ); /* 復(fù)制準(zhǔn)備寫入的數(shù)據(jù)到參數(shù)結(jié)構(gòu)中,源數(shù)據(jù)可以來(lái)自ADC等,本例是來(lái)自程序空間的說(shuō)明信息 */ pStr += i; mCmdParam.ByteWrite.mByteCount = i; /* 指定本次寫入的字節(jié)數(shù) */ i = ExecCommand( CMD_ByteWrite, 1+i ); /* 以字節(jié)為單位向文件寫入數(shù)據(jù) */ mStopIfError( i ); }

printf( "Close\n" ); mCmdParam.Close.mUpdateLen = 1; /* 自動(dòng)計(jì)算文件長(zhǎng)度,當(dāng)以字節(jié)為單位向文件寫入數(shù)據(jù)后,如果沒(méi)有用0長(zhǎng)度的CMD_ByteWrite更新文件長(zhǎng)度,那么可以在關(guān)閉文件時(shí)讓模塊自動(dòng)更新文件長(zhǎng)度 */ i = ExecCommand( CMD_FileClose, 1 ); /* 關(guān)閉文件,當(dāng)以字節(jié)為單位向文件寫入(追加)數(shù)據(jù)后,必須在用完文件后關(guān)閉文件 */ mStopIfError( i ); /* 讀取原文件 */ printf( "Open\n" ); strcpy( mCmdParam.Open.mPathName, "\\001.TXT" ); i = ExecCommand( CMD_FileOpen, MAX_PATH_LEN ); /* 打開文件,輸入?yún)?shù)置為最大值,省得再計(jì)算參數(shù)長(zhǎng)度 */ printf( "Query\n" ); i = ExecCommand( CMD_FileQuery, 0 ); /* 查詢當(dāng)前文件的信息,沒(méi)有輸入?yún)?shù) */ mStopIfError( i ); NewSize = mCmdParam.Modify.mFileSize; /* 原文件的長(zhǎng)度 */ printf("NewSize=%02x\n",(unsigned short)NewSize); printf("read \n"); while ( NewSize ) { if ( NewSize < sizeof( mCmdParam.ByteWrite.mByteBuffer ) ) count = NewSize; else count= sizeof( mCmdParam.ByteWrite.mByteBuffer ); NewSize -= count; /* 計(jì)數(shù) */ mCmdParam.ByteRead.mByteCount = count; i=ExecCommand( CMD_ByteRead, 1 ); mStopIfError( i );

for(j=0;j printf("%02x",(unsigned short)mCmdParam.ByteRead.mByteBuffer[j]); } mCmdParam.Close.mUpdateLen = 0; i = ExecCommand( CMD_FileClose, 1 ); /* 關(guān)閉文件 */ mStopIfError( i );

打印輸出為: Start Wait Udisk Ready ? Write Close Open Query NewSize=27 read 0806020a010002012d2d2d2e2e2e2f2f0400ff50000000022d2d2d2e2e2e2f2f0400ff50000000


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频