Contiki源碼結構


Contiki源碼結構

 

apps目錄下,用於存放Application,也就是我們的應用程序放在這個目錄下。如webserver,webrowser等,如下圖所示。

 

core目錄是contiki操作系統的內核所在。

其中cfs是contiki file system interface 模塊,provide a lightweight flash system,called Coffee。

也就是文件系統。

 

其中ctk是contiki的圖形界面模塊,提供了graphical user interface。

 

其中dev外部設備的驅動文件,如led,radio,watchdog等。

這里要和cpu目錄下的dev做區分,cpu/dev是cpu內部的設備,像串口rs232等。

 

其中lib提供一些常用庫文件,如memb、mmem內存分配,list數據結構,random隨機數生成等。

如圖:

 

 其中loader模塊支持運行時動態加載和鏈接模塊(support dynamic loading and linking of modules at run-time)。

這可用於重編程,即節點布設好之后,發現bug或者想更新程序,可用這個模塊實現。

The Contiki module loader can load, relocate, and link standard ELF files that can optionally be stripped off their debugging symbols to keep their size down.

 

其中net提供兩個協議棧,即uip和rime,uip支持ip6和ip4,這個是contiki的重頭戲,整體概覽,下一篇再寫。

 

 其中sys是系統運行的機制所在:

protothread機制的實現文件pt.h,lc.h,lc-switch.h,lc-addrlabels.h等。

process相關文件如proces.c,procinit.c等。

timer相關文件:clock.h,timer.c,stimer.c,etimer.c,ctimer.c,rtimer.c等。

power awareness相關文件:energest.c,記錄能量消耗情況(Contiki provides mechanisms for estimating the system power consumption and for understanding where the power was spent.)

 

cpu目錄下提供特定硬件底層的實現,contiki支持很多cpu(stm8官方沒有提供),如:

 

用stm32w108來說明:

可以看到底層實現文件clock.c和rtimer-arch.c等文件。

這里的dev和core/dev有區別,cpu/dev是cpu內部的設備,如串口通信等。

 

doc目錄下提供了一些說明文檔,這是學習資料之一。

 

examples目錄下,提供了大量的例子,通過閱讀相應的例子可以更好地理解怎樣應用contiki。

There are plenty of examples in the Contiki source code tree to help you get started with your own code.

Some examples show how to program network code, others show how to interact with the platform hardware,

yet others demonstrate different aspects of the Contiki system. 

 

platform目錄提供不同平台的實現文件,可以理解為main函數就在這個目錄下。

注意跟cpu目錄區分開來,cpu目錄是底層實現的目錄。

platform是最終展示給用戶的,舉個例子,在pc機中相同cpu可以有不同的platform,如win7,win10,linux(ubuntu,red等)。

 

regression-tests目錄,測試contiki是否正常工作。

To ensure that the Contiki code works as expected, the Contiki developers use a set of nightly regression tests that test important aspects of Contiki on a daily basis in the Cooja simulator.

The regression test scripts can be used as a starting point for setting up simulations or to investigate how different Contiki mechanisms work.

 

 

tools目錄,提供一些常用的工具,比如大名鼎鼎的仿真工具cooja就在這里。

Contiki devices often make up large wireless networks. Developing and debugging software for such networks is really hard.

Cooja, the Contiki network simulator, makes this tremendously easier by providing a simulation environment that

allows developers to both see their applications run in large-scale networks or in extreme detail on fully emulated hardware devices.

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM