嵌入式Linux設備驅動(dòng)開(kāi)發(fā)之:實(shí)驗內容——test驅動(dòng)
4.實(shí)驗結果
首先在虛擬設備驅動(dòng)源碼目錄下編譯并加載驅動(dòng)模塊。
$makeclean;make
$./test_drv_load
接下來(lái),編譯并運行測試程序
$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
最后,卸載驅動(dòng)程序
$./test_drv_unload
通過(guò)dmesg命令可以查看內核打印的信息:
$dmesg|tail–n10
……
Themajorofthetestdeviceis250/*當加載模塊時(shí)打印*/
Thisisopenoperation/*當打開(kāi)設備時(shí)打印*/
Thisisreleaseoperation/*關(guān)閉設備時(shí)打印*/
Testdeviceuninstalled/*當卸載設備時(shí)打印*/
linux操作系統文章專(zhuān)題:linux操作系統詳解(linux不再難懂)linux相關(guān)文章:linux教程
評論