BOOL
|
FT_W32_SetCommTimeouts
|
(FT_HANDLE ftHandle, LPFTTIMEOUTS lpftTimeouts)
|
Parameters
ftHandle
|
Handle of the device.
|
lpftTimeouts
|
Pointer to an FTTIMEOUTS structure to store timeout information.
|
Return Value
If the function is successful, the return value is nonzero.
If the function is unsuccessful, the return value is zero.
Remarks
Timeouts are calculated using the information in the FTTIMEOUTS structure.
For read requests, the number of bytes to be read is multiplied by the total timeout multiplier, and added to the total timeout constant. So, if TS is an FTTIMEOUTS structure and the number of bytes to read is dwToRead, the read timeout, rdTO, is calculated as follows.
rdTO = (dwToRead * TS.ReadTotalTimeoutMultiplier) + TS.ReadTotalTimeoutConstant
For write requests, the number of bytes to be written is multiplied by the total timeout multiplier, and added to the total timeout constant. So, if TS is an FTTIMEOUTS structure and the number of bytes to write is dwToWrite, the write timeout, wrTO, is calculated as follows.
wrTO = (dwToWrite * TS.WriteTotalTimeoutMultiplier) + TS.WriteTotalTimeoutConstant
Linux ignores the ReadIntervalTimeout, ReadTotalTimeoutMultiplier and WriteTotalTimeoutMultiplier currently.
Example
This example shows how to setup a read timeout of 100 milliseconds and a write timeout of 200 milliseconds.
FT_HANDLE ftHandle; // setup by FT_W32_CreateFile
FTTIMEOUTS ftTS;
ftTS.ReadIntervalTimeout = 0;
ftTS.ReadTotalTimeoutMultiplier = 0;
ftTS.ReadTotalTimeoutConstant = 100;
ftTS.WriteTotalTimeoutMultiplier = 0;
ftTS.WriteTotalTimeoutConstant = 200;
if (FT_W32_SetCommTimeouts(ftHandle,&ftTS))
; // FT_W32_SetCommTimeouts OK
else
; // FT_W32_SetCommTimeouts failed