您的位置:首页 > 运维架构 > Linux

ARM&Linux 下驱动开发第二节

2014-03-05 20:40 239 查看
驱动文件:qudong.c,make生成qudong.ko文件,烧录到ARM板上

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include<string.h>
int main()
{
int fd=0;
int ret=0;
char bufw[100]={'\0'};
char bufr[100]={'\0'};
fd=open("/dev/rwtest",O_RDWR);
if(fd<0)
{
perror("open error\n");
return 0;
}
printf("Please input string:\n");
scanf("%s",bufw);
ret=write(fd,bufw,strlen(bufw));
if(ret<0)
{
perror("write error\n");
return 0;
}
printf("burw====%s\n",bufw);
ret=read(fd,bufr,99);
if(ret<0)
{
perror("read error\n");
return 0;
}
printf("bufr====%s\n",bufr);
close(fd);
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: