Chapter 6
Reporting KTx Scanner Status
6-9
Example 6.A
Initialization
/**** ENABLE WATCHDOG TIMER OPERATION
*****
***** ****/
ktx_alive = TRUE;
/* local variable
*/
oldhandler = getvect(CLOCK_INTR);
/* save old vector
*/
wdg_accum = 0;
/* clear current wgd count
*/
wdg_preset = 10;
/* Host counts 10 interrupts
*/
dp–>host_dead_counter =
wdg_preset * WDG_SCALER; /* KTX counts 50
*/
setvect(CLOCK_INTR, KTX_watchdog); /* install new interrupt
*/
/* service routine
*/
The routine in Example 6.B performs the watchdog handshaking with the
scanner (if enabled). If the scanner is dead, this routine resets the clock
interrupt handler, prints a message, and exits.
Example 6.B
Interrupt Service Routine
void
interrupt
KTX_watchdog()
{
/**** If accumulated == preset, check alive_flag */
if (++wdg_accum == wdg_preset) {
if (dp–>alive_flag != KTX_ALIVE) {
/**** Setting this to FALSE will allow main routine ****/
/**** to drop out of its loop and cleanup the ****/
/**** interrupt vectors before exiting ****/
ktx_alive = FALSE;
} else {
/**** Let KTX know that the host is still alive ****/
dp–>alive_flag = HOST_ALIVE;
wdg_accum = 0;
}
}
/**** Call the old routine ****/
oldhandler();
}
Chapter 7 explains how to access the scanner I/O image tables to read and
modify discrete I/O.
What's Next