User's Manual

Doc #: 1ANSU-160004
DNI SGDC-D22 User Manual
i. 31
8.6. SD Card
SD card is designed to be mounted automatically. When a SD card is inserted into the SD card slot, there will be
directory on /var/sd. The mount point will be removed when the SD card is removed.
8.7. Combine WDT Into Your Program
DNI data collector provides a watchdog timer which has a 32- bit down counter with a programmable timeout value.
On timeout it generates an interrupt and reset signal. The WDT is intended to be used to generate a system reset if a
software failure (or a system hang) occurs. The WDT driver provides a set of ioctls to the user. Through this interface
user can configure, program and refresh the WDT. The device node of WDT is /dev/watchdog. The following code
snippets demonstrate how to use the WDT.
To open the WDT interface:
char wdt_dev[] = "/dev/watchdog"
int fd;
fd = open(wdt_dev, O_RDWR);
if (fd < 0) {
printf("Error in opening device\n");
}
To control the WDT and set the timeout as 45 seconds:
int ret = 0;
int timeleft=0;
struct watchdog_info ident;
int timeout = 45; /* in seconds */
/* to find out supported options in watchdog */
ret = ioctl(fd, WDIOC_GETSUPPORT, &ident);
/* to set time out */
ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
/* to find out how much time is left before reset */
ret = ioctl(fd, WDIOC_GETTIMEOUT, &timeleft);
/* Refresh watchdog timer at every 10 secs to prevent reset */
while (1) {
ioctl(fd, WDIOC,KEEPALIVE, 0);
sleep(10);
}