ldd3 第三章学习感想(1)
2007-09-04 20:10
316 查看
花了两天的 时间把ldd3上的第三章看完了 ,而且还用书上的 例子进行了 调试,不错,例子都调过了,呵呵,书上的 代码都看过了,不过例子代码还没有看完,我想起来了,那上面包含了管道的知识,这应该是 第六章的 知识吧。这段时间总感觉自己linux有些命令不大会,我也不管了,反正到时候边学边用了,只是不懂的 时候多到网上找找就好了。呵呵,脚本和.c程序都是要先编译后,然后用./运行程序名就可以了,而且,本文里只要insmod 就可以,不用运行scull_load 和 scull_unload (现在,这个问题我还没懂,只有在看看书了)。我准备在这三天的时间里 把第四章的知识看完也把第三章的程序读完吧。其实就只有一些数据结构还有点模糊吧。有时间的话就自己写一个驱动,刚好方便第四章的调试。其下是我在网上看到的 一个例子和调试程序,感觉不错,先拷贝下来,等自己写驱动时会有些帮助。在此先谢谢这位仁兄了。
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
char *device = "/dev/hello";
int hello_fd;
char cBuffer[100];
char readchar[100];
int i,count;
char * constchar;
constchar = "This is a hello device driver/n";
sprintf(cBuffer,constchar);
printf("driver info is : %s/n",cBuffer);
fflush(stdout);
hello_fd = open(device,O_RDWR);
if(hello_fd == -1)
{
printf("Unable to open hello device!/n");
exit(0);
}
count = write(hello_fd,cBuffer,100);
count = read(hello_fd,readchar,100);
printf("Driver info is : %s/n",readchar);
fflush(stdout);
close(hello_fd);
return 0;
}
另外还有些与本知识块相关的测试链接: http://blog.csdn.net/wooin/archive/2007/08/28/1762818.aspx http://bbs.nju.edu.cn/vd100000/blogcon?userid=qfwqh0396&file=1134566184 http://topic.csdn.net/t/20050615/22/4085312.html gogo 加油!
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
char *device = "/dev/hello";
int hello_fd;
char cBuffer[100];
char readchar[100];
int i,count;
char * constchar;
constchar = "This is a hello device driver/n";
sprintf(cBuffer,constchar);
printf("driver info is : %s/n",cBuffer);
fflush(stdout);
hello_fd = open(device,O_RDWR);
if(hello_fd == -1)
{
printf("Unable to open hello device!/n");
exit(0);
}
count = write(hello_fd,cBuffer,100);
count = read(hello_fd,readchar,100);
printf("Driver info is : %s/n",readchar);
fflush(stdout);
close(hello_fd);
return 0;
}
另外还有些与本知识块相关的测试链接: http://blog.csdn.net/wooin/archive/2007/08/28/1762818.aspx http://bbs.nju.edu.cn/vd100000/blogcon?userid=qfwqh0396&file=1134566184 http://topic.csdn.net/t/20050615/22/4085312.html gogo 加油!
相关文章推荐
- 学习Ldd3--字符设备驱动(第三章)
- 编译原理第三章学习感想
- 系统架构师学习笔记_第三章_连载
- 第三章、基本数据类型(iOS学习笔记,从零开始)
- Hibernate学习笔记 第三章 高级映射关系
- 第一阶段学习的感想
- LDD3学习之short
- oracle学习 第三章 常用的SQL*PLUS命令 ——01
- MVC模式职责分工及学习路上的一些感想
- 学习的感想
- java基础学习笔记(一)【第一章至第三章笔记】
- APUE第三章学习笔记
- Day3 《机器学习》第三章学习笔记
- 《数据结构》第三章 栈和队列学习指南
- 【PMP】Head First PMP 学习笔记 第三章 过程框架
- 跟我一起学习MySQL技术内幕(第五版):(第三章学习日记8)
- 学习笔记-[Maven实战]-第三章:Maven使用入门(1)
- Data Types in the Kernel <LDD3 学习笔记>
- QT creator 第一个程序 qt学习笔记第三章
- [汇编语言学习笔记][第三章寄存器(内存访问)]