mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-09 23:34:51 +01:00
watchdog: fix running on new 4.1 kernel
This commit is contained in:
parent
082a0160a2
commit
a6ac6ad76d
1 changed files with 13 additions and 3 deletions
|
|
@ -5,15 +5,22 @@
|
|||
#include <unistd.h>
|
||||
|
||||
const char *watchdog_file = "/proc/watchdog";
|
||||
const char *watchdog_file_nvram = "/proc/nvram/watchdog";
|
||||
const char *init_string = "1 5000000 1 4";
|
||||
const char *kicker = "OK";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd = open(watchdog_file, O_WRONLY);
|
||||
int ret = 0;
|
||||
char *wdt_string_prt = watchdog_file;
|
||||
int fd = open(wdt_string_prt, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("Open watchdog file");
|
||||
exit(1);
|
||||
wdt_string_prt = watchdog_file_nvram;
|
||||
fd = open(wdt_string_prt, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("Open watchdog file");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* init */
|
||||
|
|
@ -23,14 +30,17 @@ int main(int argc, char **argv)
|
|||
perror("Error init watchdog");
|
||||
exit(1);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
while (1) {
|
||||
fd = open(wdt_string_prt, O_WRONLY);
|
||||
sleep(1);
|
||||
res = write (fd, kicker, strlen(init_string) + 1);
|
||||
|
||||
if (res < 0 ){
|
||||
perror("Error kicking watchdog");
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue