#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) #define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int) 1. 2. 3. 4. 5. 6. 7. 8...
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])...
->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 ...
(fd, WDIOC_SETTIMEOUT, &timeout); if (ret == -1) { perror("Cannot set watchdog timeout"); close(fd); exit(EXIT_FAILURE); } printf("Watchdog timeout set to %d seconds ", timeout); // 循环喂狗,保持系统不被复位 while (1) { printf("Feeding the watchdog... "); ret ...
(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) #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) ...
pretimeout = 10; ioctl(fd, WDIOC_SETPRETIMEOUT, &pretimeout); 注意,预超时值应该是一个相对于超时值提前的秒数。而不是直到预超时的秒数。 比如,如果你设置超时值为60秒,预超时值为10秒,那么预超时将在50秒后到达。设置为0则是禁用它。预超时还有一个get功能: ...
printf("%d\n",ioctl(fd,WDIOC_SETTIMEOUT,&i));//读新的设置时间printf("%d\n",ioctl(fd,WDIOC_GETTIMEOUT,&i)); printf("%d\n",i);//看门狗开始和停止工作,打开和关闭设备具有同样的功能//关闭i=WDIOS_DISABLECARD; printf("%d\n",ioctl(fd,WDIOC_SETOPTIONS,&i));//打开i=WDIOS_ENABLECARD...
if (0 > ioctl(fd, WDIOC_SETTIMEOUT, &timeout)) { fprintf(stderr, "ioctl error: WDIOC_SETTIMEOUT: %s\n", strerror(errno)); close(fd); exit(EXIT_FAILURE); } /* 开启看门狗计时器 */ op = WDIOS_ENABLECARD; if (0 > ioctl(fd, WDIOC_SETOPTIONS, &op)) { ...