📄 test_spioc.c
字号:
#include <stdio.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>int main(int argc, char **argv){ int t; int portfd; char wstr[32], rstr[32]; int number; portfd = open("/dev/spioc", O_RDWR | O_NOCTTY | O_NDELAY); if(portfd == -1) { printf("cannot open /dev/spioc.\n"); return -1; } else { printf("open /dev/spioc successful.\n"); } printf("write string abcdefghij to spioc\n"); strcpy(wstr, "abcdefghij"); number = strlen(wstr) - 1; write(portfd, wstr, number); for(t=1;t<1000000;t++); printf("read data from spioc\n"); read(portfd, rstr, number); rstr[number] = 0; printf("the output string is %s.\n", rstr); close(portfd); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -