嵌入式Linux設備驅動開發之:實驗內容——test驅動
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教程






評論