rt用ReadFile读的串口数据最高位不对。比如0x80,读成了00,0x81读成了01,但是小于0x80的数读出来都对。存储用unsigned char保存。代码如下
unsigned char inbuff[1024];
//memset(inbuff,0,4096);//sizeof(inbuff));
memset(inbuff,0,sizeof(inbuff));
DWORD dwError;
int nBytes;
COMSTAT comstat;
CSF103TESTDlg pthis=(CSF103TESTDlg)lpParam;
HWND hdwnd = pthis->m_hWnd;
while(pthis->hCom != INVALID_HANDLE_VALUE)
{
ClearCommError(pthis->hCom,&dwError,&comstat);
if(comstat.cbInQue>256) nBytes = 256;
else nBytes = comstat.cbInQue;
bReadStat = ReadFile(pthis->hCom,inbuff,nBytes,(unsigned long *)&nBytes,NULL);
if(!bReadStat)
{
break;
}