📄 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 + -