从U盘读出来的数据为何是错的?

我用的是STC89C58RD+ 和CH375 ,要读取的数据如下: 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, 0xc2, 0xa3, 0xb1, 0xb,........... 选用的库是ch375hft.c ,并口连接,读数据部分代码如下: TotalCount = 600; printf( "´ÓÎļþÖеÚ8¸ö×Ö½Ú¿ªÊ¼¶Á: \n" ); 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 } datalen=0; count=0; mDelay100mS(); } } 问题: 目前的情况是只能读取前38个数 ,38个数以后的数据就全是错误了,请问该如何做?才能把所有数据都读出来,帮帮忙,谢谢

读出38个字节后将指针跳到38个字节后,再继续读.例如: k=0; while(TotalCount) {     c=20;     mCmdParam.ByteLocate.mByteOffset = k*c;     CH375ByteLocate( );     mCmdParam.ByteRead.mByteCount = c;     CH375ByteRead( ); TotalCount -= mCmdParam.ByteRead.mByteCount; /* 计数,减去当前实际已经读出的字符数 */      k++; }


loveapple,我有点没明白你的意思 上边的那个C=20; 这里的C 是地址吗? 第二个38个数据 我还是没有读出来呀


c是每次读的字节数,这段程序是每次读20字节数据,那你这样做下,直接跳到38字节后,读第2个38字节数,看能不能读出来. mCmdParam.ByteLocate.mByteOffset = 38; CH375ByteLocate( ); mCmdParam.ByteRead.mByteCount = 38; CH375ByteRead( );


还是不行啊,第2个38个数出不来啊 ,我把程序发给你,您帮我看下,好吗 ?


将完整程序发到tech@wch.cn


发过去了 ,麻烦您帮我看下,谢谢


我又给您发过去一个EMAIL ,麻烦您帮我看下,谢谢


只有登录才能回复,可以选择微信账号登录