All of lore.kernel.org
 help / color / mirror / Atom feed
* Advantech Watchdog timer query.
@ 2005-10-21  7:42 Ryan Clayburn
  2005-10-21  9:22 ` Alan Cox
  2005-10-21  9:41 ` P
  0 siblings, 2 replies; 5+ messages in thread
From: Ryan Clayburn @ 2005-10-21  7:42 UTC (permalink / raw)
  To: linux-kernel

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;
}



^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: Advantech Watchdog timer query
@ 2005-11-04  5:31 Ryan Clayburn
  2005-11-04 10:03 ` Pádraig Brady
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Clayburn @ 2005-11-04  5:31 UTC (permalink / raw)
  To: linux-kernel

>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.

>>Be careful that you're using the correct driver.
>>Certain newer advantech systems use the w83627hf
>>chip, which is not supported in 2.4 by default.
>>Backporting the driver from 2.6 should be trivial.

>>Pádraig.

I have backported the driver as suggested from 2.6 to 2.4 but that
didn't help. I then got a fedora core 3 installation on a separate hard
drive with kernel 2.6.9-1.667. the one thing that i found that is
peculiar and looks like a bug is that the /usr/include/watchdog.h is not
the same as the watchdog.h in the src directory. In any case even after
copying the the header file across i was unable to get the watchdog to
reset the OS. Is there something i am not doing?

Cheers

Ryan



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-11-04 10:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-21  7:42 Advantech Watchdog timer query Ryan Clayburn
2005-10-21  9:22 ` Alan Cox
2005-10-21  9:41 ` P
  -- strict thread matches above, loose matches on Subject: below --
2005-11-04  5:31 Ryan Clayburn
2005-11-04 10:03 ` Pádraig Brady

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.