新闻中心

EEPW首页>嵌入式系统>设计应用> 嵌入式Linux设备驱动开发之:实验内容——test驱动

嵌入式Linux设备驱动开发之:实验内容——test驱动

作者: 时间:2013-09-13 来源:网络 收藏

本文引用地址://m.amcfsurvey.com/article/257106.htm

4.实验结果

首先在虚拟源码目录下编译并加载驱动模块。

$makeclean;make

$./test_drv_load

接下来,编译并运行测试程序

$gcc–otesttest.c

$./test

测试程序运行效果如下:

Inputsomewordstokernel(enter'quit'toexit):Hello,everybody!

Thereadstringisfromkernel:Hello,everybody!/*从内核读取的数据*/

Inputsomewordstokernel(enter'quit'toexit):Thisisasimpledriver

Thereadstringisfromkernel:Thisisasimpledriver

Inputsomewordstokernel(enter'quit'toexit):quit

Thereadstringisfromkernel:quit

最后,卸载驱动程序

$./test_drv_unload

通过dmesg命令可以查看内核打印的信息:

$dmesg|tail–n10

……

Themajorofthetestdeviceis250/*当加载模块时打印*/

Thisisopenoperation/*当打开设备时打印*/

Thisisreleaseoperation/*关闭设备时打印*/

Testdeviceuninstalled/*当卸载设备时打印*/

linux操作系统文章专题:linux操作系统详解(linux不再难懂)

linux相关文章:linux教程



上一页 1 2 3 4 下一页

评论


相关推荐

技术专区

关闭