|
WINCE系统串口接收大于0X7F数据出错:
例如我从PC机器向开发板发送16进制:01 21 34 92 87
开发板上串口测试程序接收16进制:01 21 34 0fffff92 0fffff87
有点不解~应该是单字节 双字节问题。。
DWORD CPSerialPort::ReadPort(char *data,int length)
{
BOOL fReadState;
DWORD dwLength,dwBytesRead;
int TimeOutCount;
dwBytesRead=0;
TimeOutCount=0;
while(m_hComm!=INVALID_HANDLE_VALUE)
{
char* buf=new char[length];
fReadState=ReadFile(m_hComm,data,length,&dwLength,NULL);
if(!fReadState)
{
break;
}
else
{
dwBytesRead+=dwLength;
data+=dwLength;
}
if(dwBytesRead==length)
{
break;
}
if(dwLength!=0)
{
TimeOutCount=0;
}
else
{
TimeOutCount++;
Sleep(5);
}
if(TimeOutCount==5)
{
break;
}
}
return dwBytesRead;
}
这个问题?。。应该是从缓冲区读出数据问题吧~~~~呵呵~高手指点下哦。开春第一贴
|
|