新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 嵌入式Linux設(shè)備驅(qū)動開發(fā)之:實驗內(nèi)容——test驅(qū)動

嵌入式Linux設(shè)備驅(qū)動開發(fā)之:實驗內(nèi)容——test驅(qū)動

作者: 時間:2013-09-13 來源:網(wǎng)絡(luò) 收藏

本文引用地址:http://www.butianyuan.cn/article/257106.htm

4.實驗結(jié)果

首先在虛擬源碼目錄下編譯并加載驅(qū)動模塊。

$makeclean;make

$./test_drv_load

接下來,編譯并運行測試程序

$gcc–otesttest.c

$./test

測試程序運行效果如下:

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

Thereadstringisfromkernel:Hello,everybody!/*從內(nèi)核讀取的數(shù)據(jù)*/

Inputsomewordstokernel(enter'quit'toexit):Thisisasimpledriver

Thereadstringisfromkernel:Thisisasimpledriver

Inputsomewordstokernel(enter'quit'toexit):quit

Thereadstringisfromkernel:quit

最后,卸載驅(qū)動程序

$./test_drv_unload

通過dmesg命令可以查看內(nèi)核打印的信息:

$dmesg|tail–n10

……

Themajorofthetestdeviceis250/*當加載模塊時打印*/

Thisisopenoperation/*當打開設(shè)備時打印*/

Thisisreleaseoperation/*關(guān)閉設(shè)備時打印*/

Testdeviceuninstalled/*當卸載設(shè)備時打印*/

linux操作系統(tǒng)文章專題:linux操作系統(tǒng)詳解(linux不再難懂)

linux相關(guān)文章:linux教程



上一頁 1 2 3 4 下一頁

評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉