Appendix a, Programming watchdog timer – Lanner LEC-3012 User Manual

Page 25

Advertising
background image

25

Programming Watchdog Timer

Embedded and Industrial Computing

Appendix A

if (argc !=3) {
printf(“No timer input, program terminated\n”);
close(devfd);
exit -1;
}
tmp = atoi(argv[2]);
if ( (tmp < 1) || (tmp > 255)) {
printf(“Wrong timer value, please input within

(1~255)\n”);
close(devfd);
exit -1;
}
printf(“Set Watchdog Timer....”);
#if defined(DIRECT_IO_ACCESS)

start_watchdog_timer(tmp);

printf(“OK\n”);

#else
if( ioctl(devfd, IOCTL_SET_WDTO_TIMER, &tmp) != 0)
printf(“Fail\n”);
else
printf(“OK\n”);
#endif
}
/******** Start watchdog timer ***************************

****************/
#if !defined(DIRECT_IO_ACCESS)
else if ( !strcmp(argv[1], “--start”)) {
printf(“Start Watchdog Timer....”);

value = START_WDT;

if( ioctl(devfd, IOCTL_START_STOP_WDT, &value) !=

0)
printf(“Fail\n”);
else
printf(“OK\n”);
}
#endif
/******** Stop watchdog timer ***************************

*****************/
else if ( !strcmp(argv[1], “--stop”)) {
printf(“Stop Watchdog Timer....”);

#if defined(DIRECT_IO_ACCESS)

stop_watchdog_timer();

printf(“OK\n”);

#else

value = STOP_WDT;

if( ioctl(devfd, IOCTL_START_STOP_WDT, &value) != 0)
printf(“Fail\n”);
else
printf(“OK\n”);
#endif
}

#if BYPASS_PAIR_NUMBER > 0
/******** Set lan-bypass enable while watchdog timer

expired *************/
else if ( !strcmp(argv[1], “--swtsb”)) {
printf(“Set Watchdog Timeout State to Lan Bypass....”);
#if defined(DIRECT_IO_ACCESS)

set_wdto_state_system_bypass();

printf(“OK\n”);

#else

value = SET_WDTO_STATE_LAN_

BYPASS;
if( ioctl(devfd, IOCTL_SET_WDTO_STATE, &value) != 0)
printf(“Fail\n”);
else
printf(“OK\n”);
#endif
}
/******** Set system reset while watchdog timer expired

******************/
else if ( !strcmp(argv[1], “--swtsr”)) {
printf(“Set Watchdog Timeout State to System

Reset....”);
#if defined(DIRECT_IO_ACCESS)

set_wdto_state_system_reset();

printf(“OK\n”);

#else

value = SET_WDTO_STATE_SYSTEM_

RESET;

Advertising