E
Elmar Jacobs
hi folk,
if I define a SetCommMask for the receive event and the thread is waiting
for an Rx Event the writeFile function will hang up if I try to send byte.
I use the standard settings for the port. Can anybody tell me why the
WriteFile function hang up?
thanks a lot,
elmar
GetCommTimeouts(m_hComPort, &cto);
// Change the COMMTIMEOUTS structure settings.
cto.ReadIntervalTimeout = MAXDWORD;
cto.ReadTotalTimeoutMultiplier = 0;
cto.ReadTotalTimeoutConstant = 0;
cto.WriteTotalTimeoutMultiplier = 0;//10;
cto.WriteTotalTimeoutConstant = 0;//1000;
// Set the time-out parameters for all read and write operations
// on the port.
SetCommTimeouts(m_hComPort, &cto);
DWORD WINAPI ReadThread(PVOID pArg)
{
HANDLE hSerPort = (HANDLE) pArg;
BOOL retVal;
//DWORD dwMask;
if (hSerPort != NULL){
rCntInBuffer = rCntOutBuffer = cntOfNotFetchedBytes = 0;
// Specify a set of events to be monitored for the port.
SetCommMask (hSerPort, EV_RXCHAR | EV_ERR);
do{
WaitCommEvent(hSerPort, &dwMask, 0);
switch (dwMask){
case EV_RXCHAR:
{
if (cntOfNotFetchedBytes < d_receiveBufferSize){ // if
receivedBuffer not full insert byte
do{
retVal = ReadFile(hSerPort, &receiveBuffer[rCntInBuffer], 1,
&numberOfReceiving, 0);
if (numberOfReceiving == 1){
rCntInBuffer++;
cntOfNotFetchedBytes++;
if (rCntInBuffer > d_receiveBufferSize){
rCntInBuffer = 0;
}
}
}while(retVal != NULL); // readFile untile fifo is empty
}
}
break;
case EV_ERR:
break;
}
}while(1);
}
return 0;
}
if I define a SetCommMask for the receive event and the thread is waiting
for an Rx Event the writeFile function will hang up if I try to send byte.
I use the standard settings for the port. Can anybody tell me why the
WriteFile function hang up?
thanks a lot,
elmar
GetCommTimeouts(m_hComPort, &cto);
// Change the COMMTIMEOUTS structure settings.
cto.ReadIntervalTimeout = MAXDWORD;
cto.ReadTotalTimeoutMultiplier = 0;
cto.ReadTotalTimeoutConstant = 0;
cto.WriteTotalTimeoutMultiplier = 0;//10;
cto.WriteTotalTimeoutConstant = 0;//1000;
// Set the time-out parameters for all read and write operations
// on the port.
SetCommTimeouts(m_hComPort, &cto);
DWORD WINAPI ReadThread(PVOID pArg)
{
HANDLE hSerPort = (HANDLE) pArg;
BOOL retVal;
//DWORD dwMask;
if (hSerPort != NULL){
rCntInBuffer = rCntOutBuffer = cntOfNotFetchedBytes = 0;
// Specify a set of events to be monitored for the port.
SetCommMask (hSerPort, EV_RXCHAR | EV_ERR);
do{
WaitCommEvent(hSerPort, &dwMask, 0);
switch (dwMask){
case EV_RXCHAR:
{
if (cntOfNotFetchedBytes < d_receiveBufferSize){ // if
receivedBuffer not full insert byte
do{
retVal = ReadFile(hSerPort, &receiveBuffer[rCntInBuffer], 1,
&numberOfReceiving, 0);
if (numberOfReceiving == 1){
rCntInBuffer++;
cntOfNotFetchedBytes++;
if (rCntInBuffer > d_receiveBufferSize){
rCntInBuffer = 0;
}
}
}while(retVal != NULL); // readFile untile fifo is empty
}
}
break;
case EV_ERR:
break;
}
}while(1);
}
return 0;
}