introduction to ide and programming of tinyos devices...tinyos open source system by uc, berkeley...

55
Introduction to IDE and programming of TinyOS devices Quratulain Taj WATCHNETs Lab Presented in Open Source Series Workshop 2010 22-24 December, 2010 © ICOSST 2010

Upload: others

Post on 13-Mar-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Introduction to IDE and programming of TinyOS devices

Quratulain Taj

WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 2: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Agenda Introduction to WSN

WSN architecture

--what are motes?

--what are base stations?

Challenges of WSN

Why a new OS design is needed?

TinyOS

TinyOS Architecture

Installations and configurations

NesC and TinyOS

--Modules

--Cofigurations

--Interfaces

--Commands and events

--Task scheduler

--Hardware event Handler

--Data race and atomic statement

IEEE 802.15.4 and TinyOS communication

Overview of Crossbow equipment

Some applications

WATCHNETs Lab 2

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 3: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Introduction to WSN

WSNs are networks that consists of sensors which are distributed in an ad hoc manner.

These sensors work with each other to sense some physical phenomenon and then the information gathered is processed to get relevant results.

WSNs consists of protocols and algorithms with self-organizing and self healing capabilities.

3 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 4: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Applications

Wireless Control that

Simply Works

RESIDENTIAL/

LIGHT

COMMERCIAL

CONTROL

CONSUMER

ELECTRONICS

TV

VCR

DVD/CD

remote

security

HVAC

lighting control

access control

lawn & garden irrigation

PC &

PERIPHERALS

INDUSTRIAL

CONTROL

asset mgt

process

control

environmental

energy mgt

PERSONAL

HEALTH CARE

BUILDING

AUTOMATION

security

HVAC

AMR

lighting control

access control

mouse

keyboard

joystick

patient

monitoring

fitness

monitoring

4 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 5: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

WATCHNETs Lab 5

Internet

WSN Architecture

Sensor nodes

Base station

Cell phone client PDA client

Desktop PC client Laptop client

WSNs can entertain

GSM, Bluetooth, Wired

and Wireless internet

clients.

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 6: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

What are motes or nodes?

Motes mainly consist of three parts: A low cost and power computer. Transceiver to connect with outside world with a radio link. One or more sensors( e.g. temperature, light, sound, position,

acceleration, vibration, stress, weight, pressure, humidity, etc. ) Size of the mote is at most 4x2 inches.

6 WATCHNETs Lab

ADC Power

source

Sensor A

Sensor B

Transceiver

(802.15.4 radio)

Micro-Controller

External memory

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 7: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

What are Base Stations?

WATCHNETs Lab 7

Base station is basically the same node connected with an interface board or programming board.

Interface board is connect with a server or PC via serial, USB or ethernet port.

All the sensed data is accumulated in this server or PC and processed to get relevant information.

This server maybe further connected with internet and GSM network to provide the information to all types of clients.

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 8: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Challenges of Wireless Sensor

Networks

Energy Efficiency

Limited storage and computation

Low bandwidth and high error rates

Errors are common

Wireless communication

Noisy measurements

Node failure are expected

8 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 9: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

In embedded world of sensing , applications are tightly bound to particular hardware.

OS requirements for embedded system are different because of

I. limited hardware resources

II. highly specialized applications

While a WSN node is carrying out its normal data acquisition and processing steps, it also needs to service protocol events and packet transfers that arise asynchronously from the network.

Why a new OS design is needed?

12/23/2010 9 WATCHNETs LAB

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 10: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

TinyOS

Open Source System By UC, Berkeley

TinyOS has a component-based programming model, codified by the NesC language, a dialect of C.

TinyOS is not an OS in the traditional sense; it is a programming framework for embedded systems and set of components that enable building an application-specific OS into each application.

It supports microprocessors ranging from 8bit- architectures 2KB of RAM to 32-bit processors with 32 MB of RAM or more.

WATCHNETs Lab 10

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 11: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Developed for resource constrained WSNs.

Features a task scheduler

Automatically puts the microcontroller to sleep when there is no code to execute.

Allows for concurrency

Lets execution be split-phase

Event-driven operating system

Concurrency model based on tasks , hardware event handlers and detection of data race.

A program is a set of components

Components can be replaced or reused

Components can be hardware or software

TinyOS Features

12/23/2010 11 WATCHNETs LAB

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 12: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

TinyOS Architecture

Sensing Comms

Hardware Abstractions (ADC, CLOCK, I2C, LEDS, PHOTO, UART, SPI) 12/23/2010 12 WATCHNETs LAB

Other Libraries

Application

Main (scheduler)

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 13: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

INSTALLATION AND CONFIGURATIONS

Download TinyOS from:

http://www.tinyos.net/download.html

Version release notes available here:

http://www.tinyos.net/tinyos-1.x/doc/

The default install puts TinyOS in

C:\tinyos\cygwin\opt\tinyps-1.x

Or install MoteWorks platform:

Low Power Operating System – TinyOS

Software Development Tools

13 WATCHNETs Lab

GCC

TinyOS

nesC

Compilation

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 14: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

NESC AND TINYOS

Component oriented programming Programming in nesC / TinyOS is like programming in a hardware description language.

3 file types in TinyOS:

Module (suffixed with P.nc)

Configuration (suffixed with C.nc)

Interface (suffixed with .nc)

Collectively, a Configuration and a Module are combined to create a Component.

14 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 15: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

NESC AND TINYOS

Modules

Define functionality that make your application run.

Provide interfaces to other modules.

Use interfaces from other modules.

Don’t care what’s behind the interface.

Modules are like the IC’s on a circuit board that actually do something.

15 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 16: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

NESC AND TINYOS

Configurations Wire interfaces from several modules together. May forward interfaces from external modules to internal modules. May contain sub-configurations. Configurations are like a Printed Circuit Board, laying out wiring that connects modules together.

16 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 17: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

NESC AND TINYOS

Interfaces

Define the interactions between modules

Commands Implemented by the module providing the interface

Called by the module using the interface

Events Signaled by the module providing the interface

Captured by the module using the interface

17 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 18: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

HELLO WORLD—COMPONENT DIAGRAM

HelloC CONFIGURATION

18 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 19: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

HELLOC CONFIGURATION

configuration HelloC {

}

implementation {

components HelloM;

}

19 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 20: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

COMPONENT DIAGRAM

HelloM

HelloC module

20 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 21: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

HELLOM MODULE

module HelloM {

}

implementation {

}

21 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 22: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

COMPONENT DIAGRAM

HelloM

HelloC functionality

Void

myFunction()

{……}

22 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 23: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

HELLOM MODULE

module HelloM {

uses {

interface Boot;

interface Leds;

}

}

implementation {

}

}

23 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 24: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

COMPONENT DIAGRAM

Boot

HelloM

HelloC functionality

Void

myFunction()

{……}

Leds

interface 24 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 25: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

HELLOM MODULE

module HelloM {

uses {

interface Boot;

interface Leds as MyLeds;

interface Leds as MySecondLeds;

}

}

implementation {

event void Boot.booted() {

call Leds.led0On();

}

}

25 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 26: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

COMPONENT DIAGRAM

Boot

HelloM

HelloC

interfaces

Void

myFunction()

{……}

Leds

LedsC

MainC

26 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 27: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Tasks are functions that are queued up to run at a later time.

Provide split phase execution.

Task Rules:

Tasks do not take or return arguments.

Tasks cannot preempt other tasks.

Tasks run to completion.

Tasks are synchronous Interrupts are asynchronous

All tasks have the same priority.

Cannot post/queue the same task twice, but a task can post itself.

Task Scheduler

12/23/2010 27 WATCHNETs LAB

ComponentA ComponentB

call

Interface.doSomething();

return SUCCESS;

signal Interface.done();

return SUCCESS;

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 28: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

1. When you have a lot of processing to do that will take a long time to execute.

2. When your code can possibly form a recursive loop in execution.

3. When you want to use something that’s currently busy (i.e. the radio or flash file system).

When should you post a task?

12/23/2010 28 WATCHNETs LAB

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 29: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Hardware event handler

Hardware event handlers are executed in response to a hardware interrupt

Also runs to completion

May preempt the execution of a task or other hardware event handler.

Commands and events that are executed as part of a hardware event handler must be declared with the async keyword.

WATCHNETs Lab 29

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 30: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Data race and atomic statement

Because tasks and hardware event handlers may be preempted by other asynchronous code, nesC programs are susceptible to certain race conditions.

Races are avoided either by having all accesses within atomic statements.

The nesC compiler reports potential data races to the programmer at compile-time.

In this case a variable can be declared with the norace keyword.

WATCHNETs Lab 30

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 31: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

TinyOS communication

WSNs consist of low data rate and low power devices.

Multi channel split phase MAC protocol IEEE 802.15.4 is used for TinyOS communication. This protocol:

-reduces energy consumptions by introducing wake/ sleep cycles.

-provides collision avoidance

-provides overhearing avoidance

-provides topology maintenance

-provides guaranteed time slots

Send and Receive interfaces are used for data transmission and reception

SplitControl provides sharing of the half duplex transceiver.

WATCHNETs Lab 31

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 32: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Features of IEEE 802.15.4

16 channels in the 2450 MHz band, 10 channels in the 915 MHz band, and 1 channel in the 868 MHz band

Over-the-air data rates of 250 kb/s, 40 kb/s, and 20 kb/s

Star or peer-to-peer operation

Allocated 16 bit short or 64 bit extended addresses

Allocation of guaranteed time slots (GTSs)

Carrier sense multiple access with collision avoidance (CSMA-CA) channel access

Fully acknowledged protocol for transfer reliability

Low power consumption

Energy detection (ED)

Link quality indication (LQI)

32 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 33: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Topology Models

coordinator

Routers

End Devices

Star

Mesh

Cluster Tree

33 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 34: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Protocol Stack Features

Microcontroller utilized

Full protocol stack <32 k

Simple node-only stack ~4k

Coordinators require extra RAM

Node device database

Transaction table

Pairing table

PHY LAYER 2.4 GHz 915MHz 868 MHz

MAC LAYER MAC LAYER

NETWORK LAYER Star/Cluster/Mesh

APPLICATION INTERFACE

APPLICATIONS

Silicon Application ZigBee Stack

Customer

IEEE 802.15.4

ZigBee

Alliance

SECURITY

34 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 35: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

SplitControl

Provided by ActiveMessageC and SerialActiveMessageC

AMSend

Provided by AMSenderC and SerialAMSenderC

Receive

Provided by AMReceiverC and SerialAMReceiverC

Main Radio and serial Interfaces

12/23/2010 35 WATCHNETs LAB

Radio Hardware

Transmit / Receive / Init

CSMA / Acknowledgements

ActiveMessage

Message Queue

Your Application

SplitControl AMSend

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 36: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

configuration MyAppC {

}

implementation {

components MyAppP,

MainC,

ActiveMessageC,

new AMSenderC(0), // send an AM type 0 message

new AMReceiverC(0); // receive an AM type 0 message

MyAppP.Boot -> MainC;

MyAppP.SplitControl -> ActiveMessageC;

MyAppP.AMSend -> AMSenderC;

MyAppP.Receiver -> AMReceiverC;

}

Setting up the Radio: Configuration

12/23/2010 36 WATCHNETs LAB

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 37: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

module MyAppP { uses { interface Boot; interface SplitControl; interface AMSend; interface Receive; } } implementation { … }

Setting up the Radio: Module and turning it on

12/23/2010 37 WATCHNETs LAB

event void Boot.booted() { call SplitControl.start(); } event void

SplitControl.startDone(error_t error) {

post sendMsg(); } event void

SplitControl.stopDone(error_t error) {

}

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 38: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

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) {

post sendMsg();

}

Send and receive Messages

12/23/2010 38 WATCHNETs LAB

event message_t

*Receive.receive(mess

age_t *msg, void

*payload, uint8_t

length) {

call

Leds.led0Toggle();

return msg;

}

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 39: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

typedef nx_struct message_t {

nx_uint8_t

header[sizeof(message_header_t)];

nx_uint8_t data[TOSH_DATA_LENGTH];

nx_uint8_t

footer[sizeof(message_footer_t)];

nx_uint8_t

metadata[sizeof(message_metadata_t)];

} message_t;

Message structure message_t

12/23/2010 39 WATCHNETs LAB

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 40: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

OVERVIEW OF CROSSBOW WIRELESS SENSOR EQUIPMENT

Sensor Data Acquisition Boards

Processor/Radio Platforms or “Motes”

Gateways and Network Interfaces

40 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 41: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

SENSOR DATA ACQUISITION BOARDS

41 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 42: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

PROCESSOR/RADIO PLATFORMS OR “MOTES”

42 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 43: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

GATEWAYS AND NETWORK INTERFACES

43 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 44: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

A SIMPLE SENSING APPLICATION

Hardware Requirements

Two Motes: standard editions of MICA2 (MPR4x0), MICAz (MPR2400), IRIS (XM2110) or OEM editions MPR600, MPR2600, M2110

One sensor or data acquisition board: MDA100, MTS300 or MTS310

One gateway board: MIB510, MIB520, or MIB600 and the associated hardware (cables, power supply) for each

A Windows PC with MoteWorks installed

44 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 45: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

DEVELOPING AN APPLICATION Within the MoteWorks framework a minimum of five files will be placed in any application’s directory:

1. Makefile

2. Makefile.component

3. Application’s configuration written in nesC

4. Application’s module written in nesC

5. README (optional)

45 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 46: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Hardware setup

Connect a mote on gateway load program in it, plug out that mote

and connect a sensor board on that mote. Connect another mote on

interface board.

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 47: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Compile the application: Select Tools > make iris

Install in Mote: Select Tools>shell and type in

make iris install,1 mib510,com1 or Use MoteConfig

Remove Mote from the programming board, plug sensor

board on Mote and make sure it has battery and turn it on.

Install Xsniffer application onto another Mote that

remains plugged into board

Use Xsniffer to see the display of packets

47 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 48: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

CODE UPDATE ON LOGICAL GROUPS USING MULTIPLE GATEWAYS

Over the Air Programming

If a sensor node is already deployed in the network and code update is required without disturbing the network traffic.

Logical Group

A group of nodes running same application.

Multiple gateways

using more than one base stations

48 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 49: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

WATCHNETs Lab 49

Web s

erv

er

Ethernet cable

Selected nodes for Usecase A

5 4

3

2

1

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 50: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

The OTAP protocol reformats a large code image into pages and fragments in order to reduce the traffic required in downloading process.

A fragment is the amount of the image that can be transmitted in a single TOS packet, i.e. 19 bytes (29-byte TOS message with 7 byte XMesh header and 3 bytes OTAP header).

A page is a sequential set of fragments that are managed as an entity. There can be a maximum of 128 fragments per page.

Every Crossbow Mote has an external serial flash(512 kB) non-volatile memory interfaced to microprocessor.

OTAP divides the serial memory into 4 slots (0, 1, 2& 3).

Each slot can be a user-configured number of pages in 2k byte step.

By default each slot is 128 kB or 64 pages wide.

Unused slots are available to the user for data logging.

Slot zero always holds the OTAP image.

Crossbow mote and OTAP

3/19/2010 50 WATCHNETs LAB

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 51: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Serial Flash Memory Slots

3/19/2010 51 WATCHNETs LAB

Reprogramming the

microprocessor from

serial flash requires that

bootloader code resides

in the top part of the

ATmega

microprocessor’s flash

memory. This code is

loaded once during the

initial programming of

the Mote via

UISP(universal in-

system programmer).

Message structure

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 52: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

CommonSense-sensing for all

Web based data visualization of WSN.

-Take raw data from sensor hardware.

-After parsing raw data into converted form, encode it into XML format.

-Passes XML encoded data through XML query.

-Provides real time query handling ,queuing, cashing and data retrieval from XML file.

-User can connect anytime with sensor network.

-Can be integrated with cellular networks.

WATCHNETs Lab 52

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 53: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

WATCHNETs Lab 53

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 54: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

References

1. Eschenauer, L., and V. Gligor, “A Key-Management Scheme for Distributed Sensor Networks,” Proceedings of ACM Conference on Computer and Communications Security (ACM CCS), Washington DC, pp. 41-47, 2002

2. http://www.xbow.com/products/Product_pdf_files/Wireless_pdf/MICA2_Datasheet.pdf

3. http://www.ece.osu.edu/~bibyk/ee582/telosMote.pdf

4. http://en.wikipedia.org/wiki/Wireless_Sensor_Networks

5. http://arri.uta.edu/acs/networks/WirelessSensorNetChap04.pdf

6. http://www.eecs.harvard.edu/~mdw/course/cs263/papers/jhill-thesis.pdf

7. http://www.polastre.com/papers/polastre-thesis-final.pdf 8. www.cse.fau.edu/~jie/teaching/fall_2004_files/sensorslides1.ppt 9. http://web2.uwindsor.ca/courses/cs/aggarwal/cs60520/SeminarMaterial/WSN-

future.ppt 10. http://web.cecs.pdx.edu/~nbulusu/talks/grace-hopper.ppt 11. http://galaxy.cs.lamar.edu/~bsun/wsn/wsn.html 12. www.dsc.ufcg.edu.br/~maspohn/katia/introduction.ppt 13. http://computer.howstuffworks.com/mote1.htm 14. “Mac protocols for sensor network” by Ki-Hyung Kim

54 WATCHNETs Lab

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010

Page 55: Introduction to IDE and programming of TinyOS devices...TinyOS Open Source System By UC, Berkeley TinyOS has a component-based programming model, codified by the NesC language, a dialect

Thank you!

Presented in Open Source Series Workshop 2010

22-24 December, 2010 © ICOSST 2010