I am using a device driver that occasionaly misses an interrupt from hardware.
To read data from the device, I use the function
BOOL WINAPI ReadFile(
__in HANDLE hFile,
__out LPVOID lpBuffer,
__in DWORD nNumberOfBytesToRead,
__out_opt LPDWORD lpNumberOfBytesRead,
__inout_opt LPOVERLAPPED lpOverlapped
);
This function blocks forever when the device driver misses an interrupt. This results in the program stalling, and one has to restart windows to resolve it.
To fix this, I want to use a timeout-limit when calling Readfile(). But when I use
BOOL WINAPI SetCommTimeouts(
__in HANDLE hFile,
__in LPCOMMTIMEOUTS lpCommTimeouts
);
it fails with error code 87 (invalid parameters). Apparently, I can't use this timeout stuff on a device driver handle. How can I fix this? Is there some other way to set a timeout limit on a device driver?
thanks