//這是讀塊函數(shù) UINT8 CH376ReadBlock( unsigned char far* buf ) /* 從當(dāng)前主機(jī)端點(diǎn)的接收緩沖區(qū)讀取數(shù)據(jù)塊,返回長度 */ { UINT8 s, l; xWriteCH376Cmd( CMD01_RD_USB_DATA0 ); l = xReadCH376Data( ); /* 長度 */ s = l; // printf("qu dao cang du le mei ? L = %bu \r\n", l); if ( l ) { do { *buf = xReadCH376Data( ); buf ++; } while ( -- l ); } return( s ); }
//這時(shí)讀字節(jié)函數(shù)
UINT8 xReadCH376Data( void ) /* 從CH376讀數(shù)據(jù) */ { UINT32 i; for ( i = 0; i < 500; i ++ ) //源程序中本來是500000,我改成了500 { /* 計(jì)數(shù)防止超時(shí) */ if ( RI ) { /* 串口接收到 */ RI = 0; return( SBUF ); /* 串口輸入 */ } } printf("i=%lu\r\n", i); return( 0 ); /* 不應(yīng)該發(fā)生的情況 */ }
我用UINT8 CH376ByteRead( unsigned char far* buf, UINT16 ReqCount, PUINT16 RealCount )讀某文件100個(gè)字節(jié)的時(shí)候,老是有幾字節(jié)超時(shí),也就是printf打印出500 我該怎么辦??