appback.c
来自「个人根据海德汉平面光栅Windows下的程序编写得Linux下的驱动程去源码」· C语言 代码 · 共 71 行
C
71 行
#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <sys/time.h>#include <sys/types.h>#include <fcntl.h>#include <unistd.h>#include <sys/ioctl.h>#include <linux/ioctl.h>#include "pciioctl.h"#define BUFSIZE 70#define IOCSTART _IO(int main(int argc,char *argv[]){ int fd; int choose,ready; int msg=10; int ch,letdo,a,c,save,period; char mode; int check=1; letdo=1; c=0;while(letdo){ ready=1; if(check) { check=0; /* Open PCI_IK device */ if ((fd = open("/dev/PCI_IK", O_WRONLY))<0) { fprintf(stderr, "Error opening /dev/rtf0\n"); exit(1); } } fprintf(stderr,"set the work mode:r for RUN\ts for stop\te for code set\tg for signal set\tR for reset\t \n"); scanf("%c",&mode); fprintf(stderr,"mode=%c",mode); switch(mode) { case 'r': msg=ioctl(fd,IK_IOCSTART,NULL); break; case 's': msg=ioctl(fd,IK_IOCSTOP,NULL); break; case 'e': msg=ioctl(fd,IK_IOCENCODE,0); break; case 'g': msg=ioctl(fd,IK_IOCSIGNAL,0); break; case 'R': msg=ioctl(fd,IK_IOCRESET,NULL); break; case 'p': fprintf(stderr,"input the sampling period (ms)"); scanf("%d",period); msg=ioctl(fd,IK_IOCSETPERIOD,period); default: break; } fprintf(stderr,"msg=%d",msg); } close(fd); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?