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