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

linux 嵌入式驱动程序测试实例

2014-04-26 23:44 267 查看
#include
#include
#include
#include
#include
#include
#include
int main() {
int fd,i,nwrite,nread;
char *buf = "hello/n";
char read_buf[6] = {0};
fd = open("/dev/fs",O_RDWR);
if( fd <= 0 )
{ perror("open");
exit(1); }
else printf("open ok!");
nwrite = write(fd,buf,strlen(buf));
if( nwrite < 0 )
{ perror("write");
exit(1); }
nread = read(fd,read_buf,6);
if( nread < 0 ) { perror("read");
exit(1); }
else printf("read is %s/n",read_buf); close(fd); exit(0); } //查看结果 // /var/log/messages
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: