1 / 32

How to Code on TinyOS

How to Code on TinyOS. Xufei Mao Advisor: Dr. Xiang-yang Li CS Dept. IIT. Outlines. What is TinyOS? Hardware & Software NesC A simple example Conclusion. So why do we need a new OS?. Traditional OS. Huge ! Multi-threaded architecture =>large memory I/O model

novia
Download Presentation

How to Code on TinyOS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to Code on TinyOS Xufei Mao Advisor: Dr. Xiang-yang Li CS Dept. IIT

  2. Outlines • What is TinyOS? • Hardware & Software • NesC • A simple example • Conclusion

  3. So why do we need a new OS?

  4. Traditional OS Huge ! Multi-threaded architecture =>large memory I/O model Kernel and user space separation Typically no energy constraints Ample available resources

  5. Sensor Hardware Constraints • Lower Power • Limited memory • Slow CPU • Size (Small) • Limited hardware parallelisms • Communication using radio • Low-bandwidth • Short range

  6. Desired OS Properties • Small memory footprint • Efficient in power and computation • Communication is fundamental • Real-time • Support diverse application design

  7. TinyOS Solution • Concurrency: uses event-driven architecture • Modularity • Application composed of components • OS + Application compiles into single executable • Communication • Uses event/command model • FIFO and non pre-emptive scheduling • No kernel/application boundary

  8. The Hardware

  9. Software • TinyOS (Platform) • Coding language • NesC (Network Embedded System C)

  10. TinyOS Memory Model • STATIC memory allocation! • No heap (malloc) • No function pointers • No dynamic, run-time allocation • Global variables • Available on a per-frame basis • Conserve memory • Use pointers • Local variables • Saved on the stack • Declared within a method

  11. TinyOS & nesC Concepts • New Language: nesC. Basic unit of code = Component • Component • Process Commands • Throws Events • Has a Frame for storing local state • Uses Tasks for concurrency • Components provide interfaces • Used by other components to communicate with this component

  12. Components • Two type of components • Module • component written with code • Configuration • components wired together

  13. Components

  14. TinyOS Application(Sample)

  15. Commands/Events/Tasks • Commands • Should be non-blocking i.e. take parameters start the processing and return to app; • postpone time-consuming work by posting a task • Can call commands on other components • Events • Can call commands, signal other events, post tasks but cannot be signal-ed by commands • Pre-empt tasks, not vice-versa • Tasks • FIFO scheduling • Non pre-emptable by other task, pre-emtable by events • Used to perform computationally intensive work • Can be posted by commands and/or events

  16. nesC • Naming conventions • nesC files extension: .nc • Clock.nc : either an interface (or a configuration) • ClockC.nc : a configuration • ClockM.nc : a module

  17. nesC Keywords

  18. nesC Keywords -implementation

  19. Interfaces

  20. Modules • Implement one or more interfaces • Can use one or more other interfaces

  21. Modules (Sample)

  22. Configurations • Two components are linked together in nesC by wiring them • Interfaces on user component are wired to the same interface on the provider component • 3 wiring statements in nesC: • endpoint1 = endpoint2 • endpoint1 -> endpoint2 • endpoint1 <- endpoint2 (equivalent: endpoint2 -> endpoint1)

  23. Configurations (Sample)

  24. nesC Wiring Syntax

  25. Compile & Run • Compiler processes nesC files converting them into a gigantic C file • Has both your application & the relevant OS components you are using • Then platform specific compiler compiles this C file • Becomes a single executable • Loader installs the code onto the Mote (Mica2, Telos, etc.)

  26. Simple Example 1 • Blink Application • Blink.nc configuration

  27. Simple Example 1 • Blink Application • BlinkM.nc module

  28. Simple Example 2 • Communication between two sensors • Environment : Xubuntu + TinyOS 2.0 • Hardware: TelosB sensors

  29. Resources • Gaurav’s TinyOS-1.x installation howto: • http://www.cs.umass.edu/~gmathur/misc/tinyos_setup.htm • Tinyos-2.x installation howto (straightforward): • http://www.tinyos.net/tinyos-2.x/doc/html/install-tinyos.html • The official TinyOS tutorial (pretty good): • http://www.tinyos.net/tinyos-1.x/doc/tutorial/ • The offical TinyOS-2.x tutorial (very good): • http://www.tinyos.net/tinyos-2.x/doc/html/tutorial/index.html • nesC: http://nescc.sourceforge.net/

  30. Resources • Other Docs: • nesC paper: http://none.cs.umass.edu/~gmathur/tinyos/nesc-pldi-2003.pdf • nesC manual: http://none.cs.umass.edu/~gmathur/tinyos/nesc-ref.pdf • TinyOS abstractions: http://none.cs.umass.edu/~gmathur/tinyos/tinyosnsdi04.pdf

  31. Reference • TinyOS Tutorial by Jeremy Gummeson, Sensors Lab, UMass-Amherst • TinyOS Programming by Philip Levis • nesC paper: http://none.cs.umass.edu/~gmathur/tinyos/nesc-pldi-2003.pdf

  32. Conclusion

More Related