Tiny OS Handson Session Goals 1 Install Tiny

  • Slides: 58
Download presentation
Tiny. OS Hands-on Session

Tiny. OS Hands-on Session

Goals 1. Install Tiny. OS 2. Layout of tinyos-2. x 3. Write two applications

Goals 1. Install Tiny. OS 2. Layout of tinyos-2. x 3. Write two applications (A) Dissemination. Demo. Client (B) Collections. Demo. Client 2

Options • Live. CD – Xubun. TOS – Customized Ubuntu 8. 10 Live. CD

Options • Live. CD – Xubun. TOS – Customized Ubuntu 8. 10 Live. CD Today • Native – Linux –. rpm packages –. deb packages Recommended – Windows: Cygwin +. rpm packages – Mac. OS X – stow – macports 3

Other Options • VMware – Jetos – based on Je. OS (Ubuntu Server 8.

Other Options • VMware – Jetos – based on Je. OS (Ubuntu Server 8. 04) – optimized for ssh access – very small: 190 MB compressed – Lenny – based on Debian 5. 0 “Lenny” – graphical interface using XFCE – bigger: 300 MB compressed – Xubun. TOS 4

Components • Nes. C: nesc_*. deb • Cross compiler – binutils: msp 430 -binutils-tinyos_*.

Components • Nes. C: nesc_*. deb • Cross compiler – binutils: msp 430 -binutils-tinyos_*. deb – gcc: msp 430 -gcc-tinyos_*. deb – libc: msp 430 -libc-tinyos_*. deb – gdb (optional) • Deputy: deputy-tinyos_*. deb 5

Environment export TOSROOT=$HOME/local/src/tinyos-2. xexport TOSDIR=$TOSROOT/tos export MAKERULES=$TOSROOT/support/make/Makerules export CLASSPATH=$TOSROOT/support/sdk/java/tinyos. jar: . export PYTHONPATH=$TOSROOT/support/sdk/python 6

Environment export TOSROOT=$HOME/local/src/tinyos-2. xexport TOSDIR=$TOSROOT/tos export MAKERULES=$TOSROOT/support/make/Makerules export CLASSPATH=$TOSROOT/support/sdk/java/tinyos. jar: . export PYTHONPATH=$TOSROOT/support/sdk/python 6

Architectures • AVR – – mica 2, mica 2 dot micaz btnode IRIS •

Architectures • AVR – – mica 2, mica 2 dot micaz btnode IRIS • ARM – imote 2 • MSP 430 – – – telosb, sky shimmer eyes. IFX tinynode epic • 8051 – CC 2430 – CC 1110/CC 1111 7

Layout + tinyos-2. x + apps + docs + support + tools + tos

Layout + tinyos-2. x + apps + docs + support + tools + tos 8

Layout + apps + Blink + Null + Radio. Count. To. Leds + Multihop.

Layout + apps + Blink + Null + Radio. Count. To. Leds + Multihop. Oscilloscope + tests +. . . + docs + support + tools + tos 9

Layout + apps + docs + html + pdf + txt +. . .

Layout + apps + docs + html + pdf + txt +. . . + support + tools + tos 10

Layout + apps + docs + support + make - Makerules + avr/ +

Layout + apps + docs + support + make - Makerules + avr/ + msp/ +. . . + sdk + tools + tos 11

Layout + apps + docs + support + make + sdk +c + cpp

Layout + apps + docs + support + make + sdk +c + cpp + java + python + tools + tos 12

Layout + support + sdk +c + blip + sf + cpp + sf

Layout + support + sdk +c + blip + sf + cpp + sf + java - tinyos. jar + python + tinyos - tos. py 13

Layout + apps + docs + support + tools + tos + chips +

Layout + apps + docs + support + tools + tos + chips + interfaces + lib + platforms + sensorboards + systems + types 14

Layout + tos + chips + atm 128 + msp 430 + pxa 27

Layout + tos + chips + atm 128 + msp 430 + pxa 27 x + cc 2420 + cc 1000 + at 45 db + stm 25 p + sht 11 +. . . 15

Layout + tos + chips + interfaces - Boot. nc - Split. Control. nc

Layout + tos + chips + interfaces - Boot. nc - Split. Control. nc - Std. Control. nc -. . . + lib + platforms + sensorboards + systems + types 16

Layout + tos + lib + net + printf + timer + tosthreads +

Layout + tos + lib + net + printf + timer + tosthreads + serial - Serial. Active. Message. C. nc - Serial. AMSender. C. nc - Serial. AMReceiver. C. nc -. . . +. . . 17

Layout + tos + lib + net + ctp + 4 bitle + drip

Layout + tos + lib + net + ctp + 4 bitle + drip + Deluge + dip + blip +. . . 18

Layout + tos + systems - AMReceiver. C. nc - AMSender. C. nc -

Layout + tos + systems - AMReceiver. C. nc - AMSender. C. nc - Main. C. nc - Leds. C. nc - Timer. Milli. C. nc -. . . 19

Layout + tos + chips + interfaces + lib + platforms + sensorboards +

Layout + tos + chips + interfaces + lib + platforms + sensorboards + systems + types - Tiny. Error. h - messssage. h -. . . 20

Applications Dissemination. Demo Collection. Demo

Applications Dissemination. Demo Collection. Demo

Dissemination. Demo 22

Dissemination. Demo 22

Dissemination. Demo • Dissemination. Demo. Client – start the radio – start Drip –

Dissemination. Demo • Dissemination. Demo. Client – start the radio – start Drip – when a new value is received print its contents • Dissemination. Demo. Server – – start the radio start Drip start a periodic timer on each firing or the timer increment a counter and disseminate it 23

Dissemination. Demo. Client. C Boot Main. C Split. Control Active. Message. C Std. Control

Dissemination. Demo. Client. C Boot Main. C Split. Control Active. Message. C Std. Control Dissemination. C Dissemination. Value <nx_uint 32_t> Disseminator. C 24

Dissemination. Demo. Client • Interfaces – – Boot Std. Control Split. Control Dissemination. Value<t>

Dissemination. Demo. Client • Interfaces – – Boot Std. Control Split. Control Dissemination. Value<t> • Components – – Main. C Active. Message. C Dissemination. C Disseminator. C 25

tos/interfaces/Boot. nc interface Boot { event void booted(); } 26

tos/interfaces/Boot. nc interface Boot { event void booted(); } 26

tos/interfaces/Std. Control. nc interface Std. Control { command error_t start(); command error_t stop(); }

tos/interfaces/Std. Control. nc interface Std. Control { command error_t start(); command error_t stop(); } 27

tos/interfaces/Split. Control. nc interface Split. Control { command error_t start(); event void start. Done(error_t

tos/interfaces/Split. Control. nc interface Split. Control { command error_t start(); event void start. Done(error_t error); command error_t stop(); event void stop. Done(error_t error); } 28

tos/lib/net/Dissemination. Value. nc interface Dissemination. Value<t> { command const t* get(); command void set(const

tos/lib/net/Dissemination. Value. nc interface Dissemination. Value<t> { command const t* get(); command void set(const t*); event void changed(); } 29

tos/system/Main. C. nc configuration Main. C { provides interface Boot; uses interface Init as

tos/system/Main. C. nc configuration Main. C { provides interface Boot; uses interface Init as Software. Init; } implementation {. . . } 30

tos/platforms/telosa/Active. Message. C. nc configuration Active. Message. C { provides { interface Split. Control;

tos/platforms/telosa/Active. Message. C. nc configuration Active. Message. C { provides { interface Split. Control; . . . } } implementation {. . . } 31

tos/lib/net/drip/Dissemination. C. nc configuration Dissemination. C { provides interface Std. Control; } implementation {.

tos/lib/net/drip/Dissemination. C. nc configuration Dissemination. C { provides interface Std. Control; } implementation {. . . } 32

tos/lib/net/drip/Disseminator. C. nc generic configuration Disseminator. C(typedef t, uint 16_t key) { provides interface

tos/lib/net/drip/Disseminator. C. nc generic configuration Disseminator. C(typedef t, uint 16_t key) { provides interface Dissemination. Value<t>; provides interface Dissemination. Update<t>; } implementation {. . . } 33

Makefile COMPONENT=Dissemination. Demo. Client. App. C CFLAGS += -I%T/lib/net/drip CFLAGS += -I%T/lib/printf include $(MAKERULES)

Makefile COMPONENT=Dissemination. Demo. Client. App. C CFLAGS += -I%T/lib/net/drip CFLAGS += -I%T/lib/printf include $(MAKERULES) 34

Commands $ make telosb install, 42 $ tos-dump. py serial@/dev/tty. USB 0: 115200 35

Commands $ make telosb install, 42 $ tos-dump. py serial@/dev/tty. USB 0: 115200 35

Summary tos/interfaces/Boot. nc tos/interfaces/Std. Control. nc tos/interfaces/Split. Control. nc tos/system/Main. C. nc tos/platforms/telosa/Active. Message.

Summary tos/interfaces/Boot. nc tos/interfaces/Std. Control. nc tos/interfaces/Split. Control. nc tos/system/Main. C. nc tos/platforms/telosa/Active. Message. C. nc tos/lib/net/drip/Dissemination. C. nc tos/lib/net/drip/Disseminator. C. nc 36

Dissemination. Demo. Client. App. C. nc configuration Dissemination. Demo. Client. App. C { }

Dissemination. Demo. Client. App. C. nc configuration Dissemination. Demo. Client. App. C { } implementation { components Main. C; components Dissemination. C; components new Disseminator. C(nx_uint 32_t, 2009); components Dissemination. Demo. Client. C; components Active. Message. C; Dissemination. Demo. Client. C. Boot -> Main. C; Dissemination. Demo. Client. C. Dissemination. Std. Control -> Dissemination. C; Dissemination. Demo. Client. C. Dissemination. Value -> Disseminator. C; Dissemination. Demo. Client. C. Radio. Split. Control -> Active. Message. C; } 37

Dissemination. Demo. Client. C. nc module Dissemination. Demo. Client. C { uses { interface

Dissemination. Demo. Client. C. nc module Dissemination. Demo. Client. C { uses { interface Boot; interface Dissemination. Value<nx_uint 32_t>; interface Std. Control as Dissemination. Std. Control; interface Split. Control as Radio. Split. Control; } } implementation { nx_uint 32_t counter; event void Boot. booted() { call Radio. Split. Control. start(); }. . . } 38

Dissemination. Demo. Client. C. nc module Dissemination. Demo. Client. C {. . . }

Dissemination. Demo. Client. C. nc module Dissemination. Demo. Client. C {. . . } implementation {. . . event void Radio. Split. Control. start. Done(error_t error) { call Dissemination. Std. Control. start(); } event void Dissemination. Value. changed() { printf("R: %lun", *(call Dissemination. Value. get())); printfflush(); } } event void Radio. Split. Control. stop. Done(error_t error) { } 39

http: //docs. tinyos. net/index. php/Ipsn 2009 -tutorial 40

http: //docs. tinyos. net/index. php/Ipsn 2009 -tutorial 40

Collection. Demo 41

Collection. Demo 41

Collection. Demo • Collection. Demo. Client – – start the radio start CTP start

Collection. Demo • Collection. Demo. Client – – start the radio start CTP start a periodic timer on each firing or the timer increment a counter and sent it over CTP • Collection. Demo. Server – start the radio – start CTP – when a new value is received print its contents 42

Collection. Demo. Client. C Boot Main. C Split. Control Active. Message. C Std. Control

Collection. Demo. Client. C Boot Main. C Split. Control Active. Message. C Std. Control Collection. C Timer <TMilli> Send Collection. Sender. C 43 Timer. Milli. C

Collection. Demo. Client • Interfaces – – – Boot Std. Control Split. Control Send

Collection. Demo. Client • Interfaces – – – Boot Std. Control Split. Control Send Timer<TMilli> • Components – – – Main. C Active. Message. C Collection. Sender. C Timer. Milli. C 44

Collection. Demo. Client • Interfaces – – – Boot Std. Control Split. Control Send

Collection. Demo. Client • Interfaces – – – Boot Std. Control Split. Control Send Timer<TMilli> • Components – – – Main. C Active. Message. C Collection. Sender. C Timer. Milli. C 45

tos/interfaces/Send. nc interface Send { command error_t send(message_t* msg, uint 8_t len); event void

tos/interfaces/Send. nc interface Send { command error_t send(message_t* msg, uint 8_t len); event void send. Done(message_t* msg, error_t error); command uint 8_t max. Payload. Length(); command void* get. Payload(message_t* msg, uint 8_t len); command error_t cancel(message_t* msg); } 46

tos/lib/net/ctp/Collection. C. nc configuration Collection. C { provides { interface Std. Control; . .

tos/lib/net/ctp/Collection. C. nc configuration Collection. C { provides { interface Std. Control; . . . } } implementation {. . . } 47

tos/lib/net/ctp/Collection. Sender. C. nc generic configuration Collection. Sender. C(collection_id_t collectid) { provides { interface

tos/lib/net/ctp/Collection. Sender. C. nc generic configuration Collection. Sender. C(collection_id_t collectid) { provides { interface Send; interface Packet; } } implementation {. . . } 48

tos/system/Timer. Milli. C. nc generic configuration Timer. Milli. C() { provides interface Timer<TMilli>; }

tos/system/Timer. Milli. C. nc generic configuration Timer. Milli. C() { provides interface Timer<TMilli>; } implementation {. . . } 49

Makefile COMPONENT=Collection. Demo. Client. App. C CFLAGS += -I%T/lib/net/ctp CFLAGS += -I%T/lib/net/4 bitle CFLAGS

Makefile COMPONENT=Collection. Demo. Client. App. C CFLAGS += -I%T/lib/net/ctp CFLAGS += -I%T/lib/net/4 bitle CFLAGS += -I%T/lib/printf include $(MAKERULES) 50

Summary tos/interfaces/Boot. nc tos/interfaces/Std. Control. nc tos/interfaces/Split. Control. nc tos/interfaces/Send. nc tos/lib/timer/Timer. nc tos/system/Main.

Summary tos/interfaces/Boot. nc tos/interfaces/Std. Control. nc tos/interfaces/Split. Control. nc tos/interfaces/Send. nc tos/lib/timer/Timer. nc tos/system/Main. C. nc tos/system/Timer. Milli. C. nc tos/platforms/telosa/Active. Message. C. nc tos/lib/net/ctp/Collection. Sender. C. nc 51

Collection. Demo. Client. App. C. nc configuration Collection. Demo. Client. App. C { }

Collection. Demo. Client. App. C. nc configuration Collection. Demo. Client. App. C { } implementation { components Main. C; components Active. Message. C; components Collection. C; components new Collection. Sender. C(16); components new Timer. Milli. C() as Timer; components Collection. Demo. Client. C; Collection. Demo. Client. C. Boot -> Main. C; Collection. Demo. Client. C. Radio. Split. Control -> Active. Message. C; Collection. Demo. Client. C. Collection. Std. Control -> Collection. C; Collection. Demo. Client. C. Send -> Collection. Sender. C; Collection. Demo. Client. C. Timer -> Timer; } 52

Collection. Demo. Client. C. nc module Collection. Demo. Client. C { uses { interface

Collection. Demo. Client. C. nc module Collection. Demo. Client. C { uses { interface Boot; interface Split. Control as Radio. Split. Control; interface Std. Control as Collection. Std. Control; interface Send; interface Timer<TMilli>; } } implementation { message_t smsg; typedef nx_struct { nx_uint 8_t string[8]; nx_uint 16_t counter; } name_t; name_t *name; } . . . 53

Collection. Demo. Client. C. nc module Collection. Demo. Client. C {. . . }

Collection. Demo. Client. C. nc module Collection. Demo. Client. C {. . . } implementation {. . . event void Boot. booted() { name = call Send. get. Payload(&smsg, sizeof(name_t)); strcpy((char*)name->string, "name"); name->counter = 0; call Radio. Split. Control. start(); }. . . } 54

Collection. Demo. Client. C. nc module Collection. Demo. Client. C {. . . }

Collection. Demo. Client. C. nc module Collection. Demo. Client. C {. . . } implementation {. . . event void Radio. Split. Control. start. Done(error_t error) { call Collection. Std. Control. start(); call Timer. start. Periodic(1024); }. . . } 55

Collection. Demo. Client. C. nc module Collection. Demo. Client. C {. . . }

Collection. Demo. Client. C. nc module Collection. Demo. Client. C {. . . } implementation {. . . event void Timer. fired() { error_t error; name->counter++; error = call Send. send(&smsg, sizeof(name_t)); printf("S: %d %dn", name->counter, error); printfflush(); } } event void Send. send. Done(message_t* msg, error_t error) { } event void Radio. Split. Control. stop. Done(error_t error) { } 56

http: //docs. tinyos. net/index. php/Ipsn 2009 -tutorial 57

http: //docs. tinyos. net/index. php/Ipsn 2009 -tutorial 57

The End. 58

The End. 58