USB通讯问题,请高手帮一下忙^-^
lwd2k 2005-12-29 04:10:59 掌上电脑(WINCE.NET)与PC(WIN2000)的数据通讯,现在问题是从WINCE端用writefile写入,但在PC端用readfile读时读到不到任何字节.
奇怪的是在WINXP下运行无误!
下面是PC端程序:
if(hPipe != INVALID_HANDLE_VALUE)
{
int nSaveNum = 0;
long timeout = GetTickCount();
while(GetTickCount()-timeout<20000)
{
COMSTAT stat;
DWORD errs;
ClearCommError( hPipe, &errs, &stat );
int ntemp = stat.cbInQue;
if(ntemp>nSaveNum||nSaveNum==0)
{
nSaveNum = ntemp;
long lStart = GetTickCount();
while(GetTickCount()-lStart<100);
continue;
}
else
{
ReadFile (hPipe, read_data, nSaveNum, &dwBytesTransferred, 0);
*nRdCount = dwBytesTransferred; break;
}
} PurgeComm(hPipe,PURGE_RXABORT|PURGE_RXCLEAR);
}