->WDIOC_SETOPTIONS--如果包含WDIOS_DISABLECARD和WDIOS_ENABLECARD,则调用watchdog_stop()和watchdog_start()。 ->WDIOC_KEEPALIVE--调用watchdog_ping()喂狗。 ->WDIOC_SETTIMEOUT--设置timeout。 ->WDIOC_GETTIMEOUT--获取timeout值。 ->WDIOC_SETPRETIMEOUT--设置pretimeout。 ->WDIOC_GETPRETIMEOUT-...
", SOFT_WDT_DEV); timeout = 7; printf("set timeout to %d ", timeout); ioctl(fd, WDIOC_SETTIMEOUT, &timeout); timeout = 0; ioctl(fd, WDIOC_GETTIMEOUT, &timeout); printf("get timeout returns %d ", timeout); ioctl(fd, WDIOC_GETSUPPORT, &ident); printf("dog name is %s ...
timeout = atoi(argv[1]); if (1 > timeout) timeout = 1; /* 设置超时时间 */ printf("timeout: %ds\n", timeout); if (0 > ioctl(fd, WDIOC_SETTIMEOUT, &timeout)) { fprintf(stderr, "ioctl error: WDIOC_SETTIMEOUT: %s\n", strerror(errno)); close(fd); exit(EXIT_FAILURE);...
ioctl(fd, WDIOC_SETTIMEOUT, &timeout); printf("The timeout was set to %d seconds\n", timeout); 如果设备的超时值的粒度只能到分钟,则这个例子可能实际打印"The timeout was set to 60 seconds"。 自从Linux 2.4.18内核,通过GETTIMEOUT ioctl命令查询当前超时值也是可能的: ioctl(fd, WDIOC_GETTIME...
#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) #define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) #define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int) #define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int) ...
int fd = -1, cmd = -1, timeout = 0; //打开看门狗 fd = open("/dev/watchdog1", O_RDWR); if (fd < 0) { printf("Error: Failed to open /dev/watchdog1\n"); return -1; } //使能看门狗 ioctl(fd, WDIOC_SETOPTIONS, WDIOS_ENABLECARD); switch (atoi(argv[1])...
("/dev/watchdog", O_WRONLY); if (fd == -1) { perror("cannot open watchdog device"); return 1; } // 设置超时时间 if (ioctl(fd, WDIOC_SETTIMEOUT, &timeout) == -1) { perror("cannot set watchdog timeout"); close(fd); return 1; } // 循环喂狗 while (1) { if (...
ioctl(fd, WDIOC_SETPRETIMEOUT, &pretimeout); 注意,预超时值应该是一个相对于超时值提前的秒数。而不是直到预超时的秒数。 比如,如果你设置超时值为60秒,预超时值为10秒,那么预超时将在50秒后到达。设置为0则是禁用它。预超时还有一个get功能: ...
(fd, WDIOC_SETTIMEOUT, &timeout) < 0) { perror("Failed to set watchdog timeout"); close(fd); return -1; } // 启动 WDOG 定时器 if (ioctl(fd, WDIOC_START, 0) < 0) { perror("Failed to start watchdog"); close(fd); return -1; } printf("Watchdog started with timeout %d...
和#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int)就能编译通过。 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h>