1.内核配置
------->Device Drivers
-------->Watchdog Timer Support
-------->WatchDog Timer Driver Core[*]
-------->Software watchdog[*]
编译烧录内核,然后在板卡上面可以看到/dev/watchdog
2.看门狗编程
int fd = open("/dev/watchdog", O_WRONLY); if(fd == -1){ printf("open watchdog error \n\n\n"); return false; } int timeout; timeout = 15; ioctl(fd, WDIOC_SETTIMEOUT, &timeout); //设置超时 printf("The timeout was set to %d seconds\n", timeout);
喂狗
ioctl(this->fd, WDIOC_KEEPALIVE);