📄 stepquery.c
字号:
#include <stdlib.h>#include <stdio.h>#include <string.h>#include <assert.h>#include <unistd.h>main(){ FILE *in; FILE *out; char buf[128]; in=fopen("/dev/stepper","r"); assert(in); out=fopen("/dev/stepper","w"); assert(out); /* bypass stdio buffering */ setbuf(in,NULL); setbuf(out,NULL); /* exercize motor */ fprintf(stdout, "X=0,Y=0,Z=0\n"); fprintf(out, "X=0,Y=0,Z=0\n"); fprintf(stdout, "X=300,Y=300,Z=300\n"); fprintf(out, "X=300,Y=300,Z=300\n"); fprintf(stdout, "X=100,Y=100,Z=100\n"); fprintf(out, "X=100,Y=100,Z=100\n"); fprintf(stdout, "X=200,Y=200,Z=200\n"); fprintf(out, "X=200,Y=200,Z=200\n"); /* report position */ fprintf(out, "?\n"); fflush(out); fgets(buf,sizeof(buf),in); printf("Position report: %s\n",buf); /* move motor back to home position */ fprintf(out, "X=0,Y=0,Z=0\n"); fflush(out); fclose(out); fclose(in);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -