Description-
This function instructs the CdrvDelay() and CdrvCheckTime() functions to call the specified user function when awaiting the time-out to occur. The function is called at least once when either of the above functions is called. Additionally, all functions that are dependent on the time-out set by SetTimeout() will cause the user function set by this function to get called.
NOTE:
Effective with v20.0 this function is implicitly called when the port is opened and a local timeout function is installed. CdrvAbort() and CdrvClearAbort() is dependent on this function. As such if this function is called to install
Syntax-
stat = CdrvSetTimeoutFunction(port,Func);
On Entry-
int port;
Port previously opened with InitializePort() or OpenComPort().
int (*Func)(int port);
Pointer to a user function that is called while awaiting a time-out set by CdrvDelay() or a time-out being checked by CdrvCheckTime(). The user function is called at least once when either of the above functions is called. It will be called repeatedly for the duration of the time interval set with CdrvDelay(). It will be called each time CdrvCheckTime() is called to determine if a time-out has occurred. The user function should return 0 to abort a delay in progress(CdrvDelay()), to cause CdrvCheckTime() to indicate that the timer has expired, or to cause any function dependent on the time-out set by SetTimeout() function to be aborted
On Exit-
int stat;
-1 If port was not initialized.
See Also-
CdrvCheckTime()
CdrvDelay()
CdrvSetTime()
CdrvSetTimerResolution()
SetTimeout()
Example-
#include <comm.h>
int stat;
int port=0;
int time_interval=18;
int count;
char buf[256];
if ((stat = CdrvSetTimeoutFunction(port,TimeoutFunction) == -1)
{
printf(“Error setting timeout function\n”);
/* Take remedial action */
}
if ((stat = SetTimeout(port,time_interval)) == -1)
{
printf(“Error setting timeout\n”);
/* Take remedial action */
}
/* Get packet will wait for up to “time_interval” tics to return */
/* or when the user hits the escape key or button */
count = GetPacket(port,sizeof(buf),buf);
/****************************************************/
int TimeoutFunction(int port)
{
if (user hit escape cause an abort)
return(0);
else
return(1);
}