win32: set comm timeouts when opening serial port.

This commit is contained in:
Daniel Beer 2011-07-30 01:23:08 +12:00
parent 345ad4ae2d
commit a5def5cf92
1 changed files with 7 additions and 0 deletions

View File

@ -106,6 +106,7 @@ sport_t sport_open(const char *device, int rate, int flags)
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
0);
DCB params = {0};
COMMTIMEOUTS timeouts = {0};
if (hs == INVALID_HANDLE_VALUE)
return INVALID_HANDLE_VALUE;
@ -125,6 +126,12 @@ sport_t sport_open(const char *device, int rate, int flags)
return INVALID_HANDLE_VALUE;
}
timeouts.ReadIntervalTimeout = 50;
if (!SetCommTimeouts(hs, &timeouts)) {
CloseHandle(hs);
return INVALID_HANDLE_VALUE;
}
return hs;
}