win32: set comm timeouts when opening serial port.
This commit is contained in:
parent
345ad4ae2d
commit
a5def5cf92
7
sport.c
7
sport.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue