?? main.c
字號(hào):
/******************************************************************* * 這是一段用戶層的測試程序應(yīng)用代碼 * $$$$ 運(yùn)行在用戶空間 * 按下面的命令編譯: * usr/local/arm/2.95.3/bin/arm-linux-gcc -o drvtest drvtest.c * *******************************************************************/#include <unistd.h>#include <stdio.h>#include <fcntl.h>#include "drv.h"int main(void){ int fd = -1; int num; int ret; fd = open("/dev/cyc_io",O_RDWR); if(fd<0){ printf("Can't open\n"); return -1; } else{ printf("Open OK %x\n", fd); } while(1) { printf("Enter a number:\n"); scanf("%d", &num); ret = ioctl(fd, IOCTL_SET_MSG, &num); ret = write(fd, &num, 4); num = 0; //先清0,然后再看從內(nèi)核中讀出的一個(gè)數(shù)是否為寫入內(nèi)核的值 ret = read(fd, &num, 4); printf("Read a number:%d\n",num); } close(fd); return 0;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -