?? main.c
字號:
#include <stdio.h>#include <string.h>#include <malloc.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <signal.h>#include <sys/ioctl.h>#define put_wtd_data 0x5010void FeedDog(); int fd;int main(void){ int times; if((fd=open("/dev/2410wtd",O_RDWR))==-1) { perror("open eror"); exit(1); } printf("open ok\n"); times=0; while(1) { FeedDog(); //*(int *)0=0; //sleep(10); sleep(1); times++; printf("times=%d\n",times); } close(fd); return 0;}void FeedDog(){ unsigned int *arginfo=(unsigned int *)malloc(4); *arginfo=0x2000;//5s mast feed dog in "5"s you can define it according your programm , such as *arginfo=0x1000 "2.5"S if(ioctl(fd,put_wtd_data,arginfo)!=0) { perror("ioctl erreor"); exit(1); } }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -