I have implemented ReadFile function for reading data through SerialPort.When the other end is responding correctely my program is working fine.
Sometimes when I dont get data from the other end my program hangs.For this I have implemented timeouts for Readfile function.
But It doesnt seem to be working.
My initial timeout settings are :
COMMTIMEOUTS noblock;
GetCommTimeouts(rsi_handle, &noblock);
noblock.ReadIntervalTimeout = 5;
noblock.ReadTotalTimeoutConstant = 1;
noblock.ReadTotalTimeoutMultiplier = 1;
noblock.WriteTotalTimeoutConstant = 1;
noblock.WriteTotalTimeoutMultiplier = 1;
my readfile function read a single character in a loop until it gets a last character which is checked correctely.
if (ReadFile(rsi_handle,&c,1, &dwByteCount_r, NULL) == 0)
{
printf("Uart read Failed\n");
return 1;//failure
}
I am not getting the read failed message also.
can anyone help me on this.I have tried even increasing the "ReadTimeOutMultiplier" and "ReadTimeOutConstant" values also.But in vain.