Peek into TinyOS Programs - PowerPoint PPT Presentation

Loading...

PPT – Peek into TinyOS Programs PowerPoint presentation | free to download - id: 610b4-ZTdlY



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Peek into TinyOS Programs

Description:

1. Peek into TinyOS Programs. Vinod Kulathumani. Presentation schedule ... Application consists of one or more components assembled, or wired ... – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 44
Provided by: vinodkul
Learn more at: http://www.csee.wvu.edu
Category:
Tags: tinyos | peek | programs

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Peek into TinyOS Programs


1
Peek into TinyOS Programs
  • Vinod Kulathumani

2
Presentation schedule
  • We will have one presentation toward the end of
    each class
  • (lt 10 minutes)

3
Basics
  • Application consists of one or more components
    assembled, or wired
  • A component provides and uses interfaces.
  • Interfaces are bidirectional
  • they specify a set of commands
  • and a set of events
  • For a component to call the commands in an
    interface, it must implement the events of that
    interface.
  • A single component may use or provide multiple
    interfaces and multiple instances of the same
    interface.
  • Signature - The set of interfaces a component
    provides set of interfaces that a component uses

4
Components
  • Two types of components in nesC
  • modules and configurations
  • Modules provide the implementations of one or
    more interfaces
  • Configurations are used to assemble other
    components together
  • connect interfaces used by components to
    interfaces provided by others
  • Every nesC application described by a top-level
    configuration

5
Convention
  • Header File abc.h
  • Interface abc.nc
  • Configuration abcAppC.nc
  • Module Public abcC.nc
  • Module Private abcP.nc

6
HelloAppC Configuration
  • configuration HelloAppC
  • implementation

7
HelloAppC Configuration
  • configuration HelloAppC
  • implementation
  • components HelloC

8
HelloC Module
  • module HelloC
  • implementation

9
HelloC Module
  • module HelloC
  • uses
  • interface Boot
  • interface Leds
  • implementation

10
HelloC Module
  • module HelloC
  • uses
  • interface Boot
  • interface Leds
  • implementation

11
Boot Interface
  • interface Boot
  • event void booted()

12
HelloC Module
  • module HelloC
  • uses
  • interface Boot
  • interface Leds
  • implementation
  • event void Boot.booted()

USE an interface, CAPTURE all of its events!
13
Leds Interface
  • interface Leds
  • command void led0On()
  • command void led0Off()
  • command void led0Toggle()
  • …
  • command void set(uint8_t val)

14
HelloC Module
  • module HelloC
  • uses
  • interface Boot
  • interface Leds
  • implementation
  • event void Boot.booted()
  • call Leds.led0On()

15
HelloAppC Configuration
  • configuration HelloAppC
  • implementation
  • components HelloC,
  • MainC,
  • LedsC
  • // USES -gt PROVIDES
  • HelloC.Boot -gt MainC.Boot
  • HelloC.Leds -gt LedsC

16
Hello Application
17
Example 2 Blink
  • Configuration BlinkAppC.nc
  • Module BlinkC.nc

18
Configuration
  • configuration BlinkAppC
  • implementation

19
Implementation
  • module BlinkC
  • implementation

20
Configuration components list
  • configuration BlinkAppC
  • implementation
  • components MainC, BlinkC, LedsC
  • components new TimerMilliC() as Timer0
  • components new TimerMilliC() as Timer1
  • components new TimerMilliC() as Timer2

21
Module provides / uses
  • Module BlinkC
  • uses interface TimerltTMilligt as Timer0
  • uses interface TimerltTMilligt as Timer1
  • uses interface TimerltTMilligt as Timer2
  • uses interface Leds
  • uses interface Boot
  • implementation
  • // implementation code omitted

22
Configuration wiring
  • configuration BlinkAppC
  • implementation
  • components MainC, BlinkC, LedsC
  • components new TimerMilliC() as Timer0
  • components new TimerMilliC() as Timer1
  • components new TimerMilliC() as Timer2
  • BlinkC.Boot -gt MainC.Boot
  • BlinkC.Timer0 -gt Timer0
  • BlinkC.Timer1 -gt Timer1
  • BlinkC.Timer2 -gt Timer2
  • BlinkC.Leds -gt LedsC

23
Radio Stacks
Your Application
SplitControl
Receive
AMSend
Message Queue
ActiveMessage
CSMA / Acknowledgements
Transmit / Receive / Init
Radio Hardware
24
Main Radio Interfaces
  • SplitControl
  • Provided by ActiveMessageC
  • AMSend
  • Provided by AMSenderC
  • Receive
  • Provided by AMReceiverC

25
Main Serial Interfaces
  • SplitControl
  • Provided by SerialActiveMessageC
  • AMSend
  • Provided by SerialAMSenderC
  • Receive
  • Provided by SerialAMReceiverC

26
Setting up the Radio Configuration
  • configuration MyRadioAppC
  • implementation
  • components MyRadioC,
  • MainC,
  • ActiveMessageC,
  • new AMSenderC(0) as Send0, // send an AM type
    0 message
  • new AMReceiverC(0) as Receive0 // receive an
    AM type 0

27
Setting up the Radio Module
  • module MyRadioC
  • uses
  • interface Boot
  • interface SplitControl
  • interface AMSend
  • interface Receive
  • implementation

28
Turn on the Radio
  • event void Boot.booted()
  • call SplitControl.start()
  • event void SplitControl.startDone(error_t
    error)
  • post sendMsg()
  • event void SplitControl.stopDone(error_t error)

29
Setting up the Radio Configuration
  • configuration MyRadioAppC
  • implementation
  • components MyRadioC,
  • MainC,
  • ActiveMessageC,
  • new AMSenderC(0) as Send0, // send an AM type
    0 message
  • new AMReceiverC(0) as Receive0 // receive an
    AM type 0
  • MyRadioC.Boot -gt MainC
  • MyRadioC.SplitControl -gt ActiveMessageC
  • MyRadioC.AMSend -gt Send0
  • MyRadioC.Receiver -gt Receive0

30
Send Messages
  • message_t myMsg
  • task void sendMsg()
  • if(call AMSend.send(AM_BROADCAST_ADDR,
  • myMsg, 0) ! SUCCESS)
  • post sendMsg()
  • event void AMSend.sendDone(message_t msg,
  • error_t error)
  • //message sent

31
Receive a Message
  • event message_t Receive.receive(message_t msg,
    void
  • payload, uint8_t length)
  • call Leds.led0Toggle()
  • return msg

32
Payloads
  • A message consists of
  • Header
  • Payload
  • Optional Footer

33
message_t
  • typedef nx_struct message_t
  • nx_uint8_t headersizeof(message_header_t)
  • nx_uint8_t dataTOSH_DATA_LENGTH
  • nx_uint8_t footersizeof(message_footer_t)
  • nx_uint8_t metadatasizeof(message_metadata_t)
  • message_t

34
Payloads Use Network Types
  • (MyPayload.h)
  • typedef nx_struct MyPayload
  • nx_uint8_t count
  • MyPayload

35
Example Filling out a Payload
  • void createMsg()
  • MyPayload payload (MyPayload ) call
    AMSend.getPayload(myMsg)
  • payload-gtcount (myCount)
  • post sendMsg()

36
Boot sequence and MainC
  • tos/system/MainC.nc
  • configuration MainC
  • provides interface Boot
  • uses interface Init as SoftwareInit
  • implementation
  • components PlatformC, RealMainP, TinySchedulerC
  • RealMainP.Scheduler -gt TinySchedulerC
  • RealMainP.PlatformInit -gt PlatformC
  • // Export the SoftwareInit and Booted for
    applications
  • SoftwareInit RealMainP.SoftwareInit
  • Boot RealMainP

MainC acts as pass through to RealMainP
37
RealMainP
  • module RealMainP
  • provides interface Boot
  • uses
  • interface Scheduler
  • interface Init as PlatformInit
  • interface Init as SoftwareInit
  • Implementation
  • // platform initialization stuff
  • call SoftwareInit.init()
  • signal Boot.booted()
  • // call scheduler task loop

38
SoftwareInit in RealMainP
  • Suppose user writes module RandomIntC
  • provides an interface Init
  • should be initialized before use (to generate
    seed)
  • what if application developer forgets
  • Instead write a configuration RandomC around
    RandomIntC
  • Module RandomC
  • provides interface Init
  • Implementation RandomC
  • components MainC, RandomIntC
  • MainC.SoftwareInit -gt RandomIntc.Init

39
SoftwareInit in RealMainP
  • So far we didnt care in our examples
  • All our examples were applications
  • Did not provide interface
  • Interior components that provide interface may
    need Init
  • MainC.SoftwareInit may be wired to many Inits
  • Each will be called in sequence

40
References
  • TinyOS Tutorials www.tinyos.net
  • David Moss TinyOS 2 tutorial

41
Assignment 2
  • Review one of the following papers
  • L. Doherty, B.A. Warneke, B.E. Boser, and K.S.J.
    Pister, "Energy and Performance Considerations
    for Smart Dust." International Journal of
    Parallel Distributed Systems and Networks, Volume
    4, Number 3, 2001, pp. 121-133.
  • Deborah Estrin, Ramesh Govindan, John Heidemann
    Next Century Challenges Scalable Coordination
    in Sensor Networks

42
Assignment 2
  • 2 pages (10-11 point font)
  • Give a summary of the paper in your own words
  • key ideas
  • Main contributions
  • Criticisms
  • Any points to add?
  • Anything you find contradictory
  • Anything to make the paper better
  • Due Wednesday Sep 3 before class

43
Assignment 2
  • Option 2
  • Summarize a Kalman filter (2-3 pages)
  • State basic use cases
  • State system model and equations
  • How would you use it in the context of sensor
    networks
  • What hurdles do you expect to build Kalman
    filter on top of sensor networks?
About PowerShow.com