Você está na página 1de 28

TinyOS

What is it?
component oriented OS
developed in nesC
mainly for research
Whats this
component oriented
business all
about???
Component orientation

2. send
3. blink

1. sense
What does it look like?
What does it support?
platforms: telos, mica, shimmer, zolertia,
Cortex-M3 (SAM3S and SAM3U)
protocols
6LoWPAN: BLIP
RPL: TinyRPL
CoAP
Collection: CTP
Dissemination: Drip
OTA reprogramming: Deluge
security: TinySec, MiniSec, TinyECC, etc
Lets dive in...
nesC?
derivative of C
additional keywords
command, event, task, signal, post
configuration, module, interface, uses, provides
and a few others

TinyOS
nesC app.c gcc
app
elf
Execution model
C functions - nothing new here
commands and events for intercomponent
communication
asynchronous events - caused by HW
interrupts
tasks - delayed execution
Execution model
LedsC MainC TimerC

call command task void blink(){


call Leds.ledOn();
}
signal event
void processData(){
// something
}

event void Timer.fired(){


processData();
post blink();;
}

HW interrupts
Call cascade
commands and events => function calls
A B

call_1 call_3
call_2
signal_2

signal_1 signal_1
signal_2
call_2

call_3 call_1

Call stack
Tasks and the scheduler
tasks break the call cascade
WAIT (idle)

Call cascade, commands, events, local functions


HW interrupt
post Tn
asynchronous
preemptive

T1 T2 T3 ... Tn Task queue

Scheduler pop and execute


Programming model
components: modules and configurations
functionality implementation
in modules
functionality composition Component

in configurations
wiring providers to users

Configuration Module
Programming model
interfaces for component communication
providers
implement commands
users
call commands
multiple endpoints?
parameterised interfaces
translate to switch statements
Some actual examples...
Basic components
MainC: point of entry into applications
provides Boot.booted
LedsC: blinky blink
provides Leds.ledX[On|Off|Toggle] and Leds.set(val)
TimerC: tic-toc
provides Timer.startPeriodic, Timer.startOneShot
event: Timer.fired
Basic components - example

MainC

TimerC

LedsC
Active Messaging comms stack
single buffer network stack
address based
...or anycast
endpoints (ports) => parameterised interfaces
Active Messaging comms stack

start(), stop() interfaces


ActiveMessageC virtual component implemented by radio-specific
component, eg CC2420ActiveMessageC
encapsulates MAC and duty cycling
Active Messaging comms stack

Application

address-based
AMSenderC AMReceiverC single buffer
generic (paremeter = endpoint id)

start(), stop() interfaces


ActiveMessageC virtual component implemented by radio-specific
component, eg CC2420ActiveMessageC
encapsulates MAC and duty cycling
Active Messaging comms stack
Example sending data

Application

AMSenderC AMReceiverC

ActiveMessageC
Active Messaging comms stack
Example receiving data
single buffer must be freed ASAP
delay lengthy processing with
Queues and Pools and tasks

Application

AMSenderC AMReceiverC

ActiveMessageC
Active Messaging comms stack
Application
anycast comms (no address required)
buffer management provided

Collection Tree Protocol

address-based
AMSenderC AMReceiverC single buffer
generic (paremeter = endpoint id)

start(), stop() interfaces


ActiveMessageC virtual component implemented by radio-specific
component, eg CC2420ActiveMessageC
encapsulates MAC and duty cycling
Serial comms
SerialActiveMessageC, same semantics
use BaseStation application
Tools:
java net.tinyos.tools.Listen -comm serial@<PORT>:
<baud>
capture raw packets: 00 FF FF 00 00 04 22 06 00 02 00 01
printf debugging + java client (net.tinyos.tools.PrintfClient)
Python and Java frameworks
support message serialisation
Installation
https://github.com/tinyos/tinyos-main
install avr-gcc or msp430-gcc
setup TinyOS tools
cd $TOSROOT/tools
./Bootstrap
./configure && make && sudo make install
good to go!
Environment
driven by make and Makefiles
compile: make <platform>
install: make <platform> install.<ID> bsl,<port>
the bootstrap loader directive might differ
Makefile should contain:
Complete example: Blink

make telosb install.0 bsl,/dev/ttyUSB0

Você também pode gostar