中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

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

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

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

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

        (6)編寫(xiě)測(cè)試代碼。

        最后一步是編寫(xiě)測(cè)試代碼,也就是用戶空間的程序,該程序調(diào)用來(lái)測(cè)試驅(qū)動(dòng)的運(yùn)行是否正常。以下實(shí)例只實(shí)現(xiàn)了簡(jiǎn)單的讀寫(xiě)功能,測(cè)試代碼如下所示:

        /*test.c*/

        #includestdio.h>

        #includestdlib.h>

        #includestring.h>

        #includesys/stat.h>

        #includesys/types.h>

        #includeunistd.h>

        #includefcntl.h>

        #defineTEST_DEVICE_FILENAME/dev/test_dev/*設(shè)備文件名*/

        #defineBUFF_SZ1024/*緩沖大小*/

        intmain()

        {

        intfd,nwrite,nread;

        charbuff[BUFF_SZ];/*緩沖區(qū)*/

        /*打開(kāi)設(shè)備文件*/

        fd=open(TEST_DEVICE_FILENAME,O_RDWR);

        if(fd0)

        {

        perror(open);

        exit(1);

        }

        do

        {

        printf(Inputsomewordstokernel(enter'quit'toexit):);

        memset(buff,0,BUFF_SZ);

        if(fgets(buff,BUFF_SZ,stdin)==NULL)

        {

        perror(fgets);

        break;

        }

        buff[strlen(buff)-1]='