Appendix a, Programming watchdog timer – Lanner LEC-2110 User Manual
Page 28
![background image](https://www.manualsdir.com/files/820386/content/doc028.png)
28
Programming Watchdog Timer
Embedded and Industrial Computing
Appendix A
#endif
#if BYPASS_PAIR_NUMBER == 5
char pair_str[16]=”[1|2|3|4|5]”;
#endif
void print_usage(char* argv0)
{
#if BYPASS_PAIR_NUMBER > 0
printf(“%s --srbe %s (Set Pair %s Runtime Bypass
Enabled)\n”, argv0, pair_str, pair_str);
printf(“%s --srbd %s (Set Pair %s Runtime Bypass
Disabled)\n”, argv0, pair_str, pair_str);
printf(“%s --sobe %s (Set Pair %s Off-mode Bypass
Enabled)\n”, argv0, pair_str, pair_str);
printf(“%s --sobd %s (Set Pair %s Off-mode Bypass
Disabled)\n”, argv0, pair_str, pair_str);
printf(“%s --swtsb (Set Watchdog Timeout State to
Bypass)\n”, argv0);
printf(“%s --swtsr (Set Watchdog Timeout State to
Reset)\n”, argv0);
#endif
#if ( defined(DIRECT_IO_ACCESS) )
printf(“%s --swt xxx (Set Watchdog Timer 1-255 seconds
and start to count-down)\n”, argv0);
#else
printf(“%s --swt xxx (Set Watchdog Timer 1-255 seconds)\n”,
argv0);
printf(“%s --start (Start Watchdog Timer)\n”, argv0);
#endif
printf(“%s --stop (Stop Watchdog Timer)\n”, argv0);
}
int main( int argc, char** argv )
{
int devfd;
int value;
fprintf(stdout, “=== Lanner platform miscellaneous
utility ===\n”);;
fprintf(stdout, PLATFORM_NAME” Watchdog/
Bypass “CODE_VERSION”\n\n”);;
if ( argc < 2) {
print_usage(argv[0]);
return -1;
}
#if ( defined(DIRECT_IO_ACCESS) && !defined(DJGPP) )
#if defined(LINUX_ENV)
iopl(3);
#endif
#if (defined(FreeBSD_ENV))
int iofl;
SET_IOPL();
#endif
#endif
#ifdef DIRECT_IO_ACCESS
wd_gpio_init();
#else
devfd = open(“/dev/wd_drv”, O_RDONLY);
if(devfd == -1)
{
printf(“Can’t open /dev/wd_drv\n”);
return -1;
}
#endif
/******** set watchdog timer count ***********************
****************/
if ( !strcmp(argv[1], “--swt”)) {
int tmp;
if (argc !=3) {
printf(“No timer input, program terminated\n”);
close(devfd);
exit -1;
}
tmp = atoi(argv[2]);