[an error occurred while processing this directive]
|
class CSerialPort
{
///////////////
protected:
static void __cdecl SerialReceiveRoutine (LPVOID pData);
};
///////////////
void __cdecl CSerialPort::SerialReceiveRoutine (LPVOID pData)
{
CSerialPort *p = reinterpret_cast(pData);
DWORD event = 0;
unsigned char buf[1];
for (;;)
{
WaitCommEvent(p->m_hFile, &event, NULL);
EnterCriticalSection(&p->cs_com);
DWORD rb = 0;
DWORD read = 0;
DWORD bytes = 0;
do {
//
ReadFile (p->m_hFile, buf, 1, &rb, NULL);
int i = 0;
read = rb;
while (read--)
{
p->OnReceiveByte(buf[i++]);
}} while(rb);
LeaveCriticalSection(&p->cs_com);
event = 0;
}
}