我用的是STC 单片机 ,CH375,并口连接,要读取的数据为: 0x00, 0x00, 0x02, 0x30, 0x00, 0x00, 0x00, 0x00, 0x25, 0xb1, 0xb1, 0x10, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xd8, 0xcf, 0xc2, 0xa3, 0xb1, 0xb3, 0xac, 0xca, 0xd0, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xca, 0x25, 0x01, 0x01, 0x10, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xd8, 0xcf, 0xc2, 0xa3, 0xb1, 0xb3, 0xac, 0xca, 0xd0, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xcb, 0x25, 0x01, 0x01, 0x10, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xd8, 0xcf,.... 两个OX25之间为一个数据包,共38个数,现在只能读出第一个包中的数据,第二个包读出来的就全是错误了, 代码实现部分如下: mCmdParam.ByteLocate.mByteOffset = 0x00000030; /* 移到文件指定位置*/ i = CH375ByteLocate( ); mStopIfError( i ); z = CH375ByteRead( ); mStopIfError( z ); mDelay100mS(); TotalCount = 600; /* 准备读取总长度,以字节为单位 */ printf( "´从文件第8个数开始读: \n" ); // 从第一个OX25开始读 while ( TotalCount ) { if ( TotalCount > MAX_BYTE_IO ) c = MAX_BYTE_IO; else c = TotalCount; mCmdParam.ByteRead.mByteCount = c; i = CH375ByteRead( ); mStopIfError( i ); TotalCount -= mCmdParam.ByteRead.mByteCount; for( i=0;i { ch = mCmdParam.ByteRead.mByteBuffer[i]; switch(ch) { case 'x': { next1=mCmdParam.ByteRead.mByteBuffer[i+1]; next2=mCmdParam.ByteRead.mByteBuffer[i+2]; if((next1>=0x30)&&(next1<=0x39)) { next1=next1-0x30; } else if((next1>=0x61)&&(next1<=0x66)) { next1=next1-0x61+10; } else printf("error1"); if((next2>=0x30)&&(next2<=0x39)) { next2=next2-0x30; } else if((next2>=0x61)&&(next2<=0x66)) { next2=next2-0x61+10; } else printf("error2"); bao[datalen]= next1*16 + next2; datalen++; count++; } break; default: break; } }

if(count%38==0) { for(i=0;i { printf("%c",bao[i]); } datalen=0; count=0; 问题 :第2个包的38个数读不出来,麻烦 各位帮帮忙,谢谢