PWDOG1 card programming example in "C" with the QLIB for Windows 95/98 and Windows NT


The following program example shows, how a simple QLIB Watchdog background program can be written. The Tool can be used to reboot a computer in case of system hang. The sample source is included in the "C:\\QLIB32\Samples\c\pwdog_B" directory.
A typical application would be stand-alone computer systems, a file server or an internet server:



 
/*
** Example program for PWDOG1/2
**
** Simple Watchdog-backgound program for PWDOG1/2, which
** periodically retriggers the board.
**
** Compiler: Borland C++
*/
/*
** Includes
*/
#include
#include
#include
#include "qlib\include\qlib.h"
/*=================
Main program
=================*/
void main ()
{
ULONG pwdog; // handle for PWDOG card
ULONG cnt=0L;
if ((pwdog=QAPIExtOpenCard(PWDOG,0L)) == 0L) // open the card
{ // Failed
printf("PWDOG1/2 could not be opened.");
return;
}
QAPIExtWatchdog(pwdog,JOB_DISABLE_WATCHDOG); // PWDOG deactivated
// (necessary, if
printf("PWDOG1/2 deaktiviert\n"); // before a Watchdog-
// event was started)
Sleep(1000);
QAPIExtWatchdog(pwdog,JOB_ENABLE_WATCHDOG); // PWDOG activate
printf("PWDOG1/2 aktiviert\n");
printf("Zum Abschalten des Watchdogs Taste ESC druecken.\n");
while (!(kbhit() && getch()==27)) // as long as the ESC-button
{ // in not pushed
Sleep(500);
QAPIExtWatchdog(pwdog,JOB_RETRIGGER_WATCHDOG); // PWDOG retriggern
printf("\rWatchdog wurde %ld mal retriggert",++cnt);
}
QAPIExtWatchdog(pwdog,JOB_DISABLE_WATCHDOG); // PWDOG deactivated
printf("\nPWDOG1/2 deaktiviert\n");
QAPIExtCloseCard(pwdog);
}
 



 Continue to "Download QLIB"