Wdt (watch dog timer), Wdt (watch dog timer) -5 – Moxa Technologies UC-7420/7410 User Manual

Page 81

Advertising
background image

UC-7420/7410 User’s Manual

Programmer’s Guide

5-5

WDT (Watch Dog Timer)

This function is only available for firmware version V1.5 (and later versions).

1. Introduction

The WDT works like a watch dog function. You can enable it or disable it. When the user
enables WDT but the application does not acknowledge it, the system will reboot. You can set
the ack time from a minimum of 50 msec to a maximum of 60 seconds.

2. How the WDT works

The sWatchDog is enabled when the system boots up. The kernel will auto ack it. The user
application can also enable ack. When the user does not ack, it will let the system reboot.

Kernel boot
…..
….
User application running and enable user ack
….
….

3. The user API

The user application must include <moxadevic.h>, and link moxalib.a. A makefile
example is shown below:

all:
mxscaleb-gcc –o xxxx xxxx.c -lmoxalib

int swtd_open(void)

Description
Open the file handle to control the sWatchDog. If you want to do something you must
first to this. And keep the file handle to do other.

Input
None

Output
The return value is file handle. If has some error, it will return < 0 value.

You can get error from errno().

int swtd_enable(int fd, unsigned long time)

Description
Enable application sWatchDog. And you must do ack after this process.

Input
int fd - the file handle, from the swtd_open() return value.

unsigned long time - The time you wish to ack sWatchDog periodically. You must ack
the sWatchDog before timeout. If you do not ack, the system will be reboot automatically.
The minimal time is 50 msec, the maximum time is 60 seconds. The time unit is msec.

Output
OK will be zero. The other has some error, to get the error code from errno().

Advertising