?? soft_watchdog.c
字號:
#include <stdio.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <linux/types.h>#include <linux/watchdog.h>int main(int argc, char ** argv) { int fd; unsigned char data; int timeout, tmp; if (argc != 2) { printf("soft_watchdog timeout\n"); return 0; } timeout = atoi(argv[1]); do { usleep(100000); fd = open("/dev/misc/watchdog", O_RDWR); } while (fd < 0); // set watchdog timeout value (sec) ioctl(fd, WDIOC_SETTIMEOUT, &timeout); ioctl(fd, WDIOC_GETTIMEOUT, &tmp); printf("timeout = %d sec\n", tmp); tmp *= 100000;#if 1 data = 1; while (1) { // write a value to refresh the timer write(fd, &data, 1); usleep(tmp); }#endif close(fd); return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -