UINT ReadCountOrder(LPVOID pParam)
{
CView2* pV2=(CView2*)pParam;
CString order;
BYTE str[17]={'@','0','0','R','C','0','0','0','0','0','0','0','1',0,0,'*',13};
pV2->Xor(str,12);
for(int i=0;i<17;i++)
{
order+=str[i];
}
OVERLAPPED m_osWrite;
memset(&m_osWrite,0,sizeof(OVERLAPPED));
m_osWrite.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);
DWORD dwBytesWrite=17;
DWORD dwErrorFlags;
BOOL bReadOrderStat;
COMSTAT ComStat;
while(1)
{
TRACE(order);
ClearCommError(pV2->hCom1,&dwErrorFlags,&ComStat);
PurgeComm(pV2->hCom1, PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR);
bReadOrderStat=WriteFile(pV2->hCom1,order,dwBytesWrite,&dwBytesWrite,&m_osWrite);
if(!bReadOrderStat)
{
if(GetLastError()==ERROR_IO_PENDING)
{
WaitForSingleObject(m_osWrite.hEvent,1000);
}
}
else
{
pV2->ReadCountData();
}
Sleep(500);
}
return 0;
}