Title: TinyOS: Key Concepts
1TinyOS Key Concepts
- Charley Robinson
- Presented to the Group of Robotics, External
Monitoring, and Little Networked Systems - (GREMLNS)?
2TinyOS vs. Embedded C
- TinyOS is implemented in nesC
- Component based programming
- Interface defined behavior
- Event driven runtime
- No heap
3A C(ish) Light Blinking Program
4How nesC does it
5nesC Blink Configuration
6Components, Interfaces, Commands Events
- A component may be both a provider and a user of
any number of interfaces. - Interfaces, therefore, are bi-directional. An
interface may have any number of commands and
events. - Commands will be implemented by a providing
component, and called by user. - Events will be implemented by a using component,
and signaled by provider.
7Previous Slide as a Picture
- TimerComponent provides StdCtrl, Timer.
- TimerComponent uses Clock.
- Picture Credit Karl, Willig, 2005. Protocols and
Architectures for Wireless Sensor Networks.
8Tasks
- Commands and Event handlers are synchronous,
unless explicitly stated otherwise. - Long running commands or events can cause other
event signals to be missed entirely. - Tasks are asynchronous jobs that can be scheduled
after the current call stack returns. - Posted tasks are executed FIFO.
9Split-Phase Command Processing
- Since TinyOS does not have any blocking
operations, long-running commands are
split-phase. - Commands are issued and return immediately,
events handle command completion some time later. - This allows multiple commands to be issued in
parallel without consuming much stack space.
10Blocking vs. Split-Phase Operations
11A More Complex Example
- module ForwarderP
- uses interface Boot,
- interface Receive as ReceiveMsg
- interface AMSend as SendMsg
- interface SplitControl as MsgCtrl
- implementation
- IntMsg_t buf message_t packet
- event void Boot.booted()
- call MsgCtrl.start()
- return SUCCESS
-
- event void MsgCtrl.startDone() ...
- event void MsgCtrl.stopDone() ...
- event message_t ReceiveMsg.receive(message_t
msg, void payload, uint8_t len) - call Leds.yellowToggle()
- memcpy(buf, payload, sizeof(IntMsg_t))
- post processPacket()
- return m
-
12Structures and Configuration
intmsg.h typedef nx_struct IntMsg_t
nx_uint16_t accumulator IntMsg_t enum
INTMSG_AM_ID 0x77 -- ForwarderC.nc configu
ration ForwarderC implementation
components ForwarderP as App components
MainC, ActiveMessageC components new
AMSender(INTMSG_AM_ID) components new
AMReceiver(INTMSG_AM_ID) App. SendMsg -gt
AMSender.Send App.ReceiveMsg -gt AMReceiver
App.MsgCtrl -gt ActiveMessageC App.Boot -gt
MainC
13Relevant Interfaces
interface Boot event void Booted() interface
AMSend command error_t send(am_addr_t addr,
message_t msg, uint8_t len) command void
getPayload(message_t msg, uint8_t
len) ... event void sendDone(message_t msg,
error_t error) interface Receive event
message_t receive(message_t msg ,void payload,
uint8_t len) interface SplitControl command
error_t start() command error_t stop() event
void startDone(error_t error) event void
stopDone(error_t error)
14More Resources
- TinyOS Tutorialshttp//docs.tinyos.net/index.php
/TinyOS_Tutorials - TinyOS Reference Documentationhttp//docs.tinyos
.net/index.php/Source_Code_Documentation - TinyOS TEP Papershttp//docs.tinyos.net/index.ph
p/TEPs - TinyOS Programming Manualhttp//www.tinyos.net/t
inyos-2.x/doc/pdf/tinyos-programming.pdf - ...and so much more
- http//www.tinyos.net/