From: Ryan Clayburn <ryan.clayburn@dsto.defence.gov.au>
To: linux-kernel@vger.kernel.org
Subject: Advantech Watchdog timer query.
Date: 21 Oct 2005 17:12:23 +0930 [thread overview]
Message-ID: <1129880542.2194.49.camel@localhost.localdomain> (raw)
Hi Everyone,
I work for a government agency so please forgive me for not having the
latest version of the kernel. My question concerns an Advantech card PCI
6870 Single Board Computer and its watchdog timer. I am running Redhat 9
linux 2.4.20-8 and it comes with module that supports the hardware
advantechwdt.o. I have been able install and communicate with the card.
Get and set the timeout or margin and get the support information of the
card. Everything seems to work except when i deliberately delay the ping
to the card to let it reboot the system as a watchdog should it does not
reboot. Is there something i am missing. Do i need a update to the
driver? I am attaching the code. It is fairly simple and a lot of it is
just reading and writing information read from the driver about the
card. I would appreciate any help.
Cheers
Ryan Clayburn
Can i please be CC'ed the answers/comments posted to the list in
response to my posting
************************************************************************
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/watchdog.h>
#include <time.h>
#include <sys/time.h>
int main(int argc, const char *argv[])
{
int fd;
struct watchdog_info *wdog_info;
time_t timenow;
char supportOptions[500];
char dtime[50];
int i, err;
int timein, timeout;
fd = open("/dev/watchdog",O_WRONLY);
if (fd==-1)
{
perror("watchdog");
return 1;
}
//printf("argc = %d\n", argc);
err = ioctl(fd, WDIOC_GETSUPPORT, wdog_info);
if (err < 0)
printf("error is %d\n", err);
if (wdog_info->options & WDIOF_KEEPALIVEPING)
strcpy(supportOptions, "WDIOF_KEEPALIVEPING");
if (wdog_info->options & WDIOF_MAGICCLOSE)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_MAGICCLOSE");
}
else
{
strcat(supportOptions, " | WDIOF_MAGICCLOSE");
}
}
if (wdog_info->options & WDIOF_SETTIMEOUT)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_SETTIMEOUT");
}
else
{
strcat(supportOptions, " | WDIOF_SETTIMEOUT");
}
}
if (wdog_info->options & WDIOF_POWEROVER)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_POWEROVER");
}
else
{
strcat(supportOptions, " | WDIOF_POWEROVER");
}
}
if (wdog_info->options & WDIOF_CARDRESET)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_CARDRESET");
}
else
{
strcat(supportOptions, " | WDIOF_CARDRESET");
}
}
if (wdog_info->options & WDIOF_POWERUNDER)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_POWERUNDER");
}
else
{
strcat(supportOptions, " | WDIOF_POWERUNDER");
}
}
if (wdog_info->options & WDIOF_EXTERN2)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_EXTERN2");
}
else
{
strcat(supportOptions, " | WDIOF_EXTERN2");
}
}
if (wdog_info->options & WDIOF_EXTERN1)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_EXTERN1");
}
else
{
strcat(supportOptions, " | WDIOF_EXTERN1");
}
}
if (wdog_info->options & WDIOF_FANFAULT)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_FANFAULT");
}
else
{
strcat(supportOptions, " | WDIOF_FANFAULT");
}
}
if (wdog_info->options & WDIOF_OVERHEAT)
{
if (strlen(supportOptions) == 0)
{
strcpy(supportOptions, "WDIOF_OVERHEAT");
}
else
{
strcat(supportOptions, " | WDIOF_OVERHEAT");
}
}
printf("\nWATCHDOG TIMER DAEMON\n");
printf("---------------------\n\n");
printf("Wdioc Get Support Information\n");
printf("-------------------------------------\n");
printf("Options: %s\nFirmware Version: %d\n", supportOptions,
wdog_info->firmware_version);
printf("Identity: ", wdog_info->identity);
for (i = 0; i < 32; i++)
{
printf("%c", wdog_info->identity[i]);
}
printf("\n-------------------------------------\n\n");
ioctl(fd, WDIOC_GETTIMEOUT, &timein);
printf("The current timeout is %d seconds\n", timein);
timeout = 30;
ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
printf("The timeout was set to %d seconds\n", timeout);
time(&timenow);
strcpy(dtime, ctime(&timenow));
printf("%s", dtime);
while(1)
{
//write(fd, "\0", 1);
ioctl(fd, WDIOC_KEEPALIVE, 0);
if (err < 0)
printf("error is %d\n", err);
sleep(timeout*2+10);
time(&timenow);
strcpy(dtime, ctime(&timenow));
printf("%s", dtime);
}
close(fd);
printf("bye bye...\n");
return 0;
}
next reply other threads:[~2005-10-21 7:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-21 7:42 Ryan Clayburn [this message]
2005-10-21 9:22 ` Alan Cox
2005-10-21 9:41 ` P
2005-11-04 5:31 Ryan Clayburn
2005-11-04 10:03 ` Pádraig Brady
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1129880542.2194.49.camel@localhost.localdomain \
--to=ryan.clayburn@dsto.defence.gov.au \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome