TinyOS Tutorial. Greg Hackmann CSE 521S Fall 2010

Similar documents
TinyOS Tutorial. Greg Hackmann CSE 467S Spring 2011

TinyOS. Lecture Overview. UC Berkeley Family of Motes. Mica2 and Mica2Dot. MTS300CA Sensor Board. Programming Board (MIB510) 1.

Introduction to Programming Motes

Embedded System Design : Project Specification Crowd Information Monitor

Interfacing Java-DSP with Sensor Motes

Politecnico di Milano Advanced Network Technologies Laboratory. Internet of Things. TinyOS Programming and TOSSIM (and Cooja)

Introduction to TinyOS

Politecnico di Milano Advanced Network Technologies Laboratory. Internet of Things. TinyOS Programming and TOSSIM

Politecnico di Milano Advanced Network Technologies Laboratory. Internet of Things. TinyOS Programming and TOSSIM (and Cooja)

Networking Level Laboratory WSN Software Platform TinyOS: Installation and Configuration

Exposure to Sensor Motes

Indriya_DP_03A14. Features. Block Diagram. XBEE based Wireless Sensor Network development platform

EMBEDDED SYSTEMS WITH ROBOTICS AND SENSORS USING ERLANG

TinyOS. Wireless Sensor Networks

Politecnico di Milano Advanced Network Technologies Laboratory. TinyOS

WSN Programming. Introduction. Olaf Landsiedel

CM5000 DATASHEET v0.1

WSN Programming. Introduction. Olaf Landsiedel. Programming WSNs. ! What do we need to write software for WSNs?! Programming language

Wireless Sensor Networks. FireFly 2.2 Datasheet

Interesting Items Volume 16. Dave Jaffe 04/23/2011

Overview The Microcontroller The Flex Board Expansion boards Multibus board Demo board How to: Compile demo Flash & Run Demos

Installation and Maintenance

ArduCAM CC3200 UNO board

Networking Level Laboratory Mote-Computer Serial Communication

Nano RK And Zigduino. wnfa ta course hikaru4

KMote - Design and Implementation of a low cost, low power platform for wireless sensor networks. Naveen Madabhushi

Middleware for Wireless Sensor Networks: An Outlook

Practical Aspects of CTI WSN Testbed

Internship at Sentilla. Chris Merlin March 08 - June 08

Energy-aware Reconfiguration of Sensor Nodes

System Energy Efficiency Lab seelab.ucsd.edu

Self-Organization in Autonomous Sensor/Actuator Networks [SelfOrg]

Crossbow: MoteWorks Getting Started Guide. Presented by Catherine Greene, Bretny Khamphavong, Chloe Norris, and Nancy White

Wireless Embedded Systems and Networking. How to get TinyOS open source dist.

System Architecture Directions for Networked Sensors[1]

Reminder. Course project team forming deadline. Course project ideas. Friday 9/8 11:59pm You will be randomly assigned to a team after the deadline

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

Microcontroller Basics

Microcontrollers for Ham Radio

Integrating Custom Hardware into Sensor Web. Maria Porcius Carolina Fortuna Gorazd Kandus Mihael Mohorcic

Hardware Design of Wireless Sensors

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite.

PS Telematik-Projekt: Wireless Embedded Systems

Enabling Networked Sensors

Renesas Starter Kit for RX111

SBC8140 Single Board Computer

Use of ISP1507-AL Evaluation Boards

ez430-chronos Wireless Watch Development Tool: Teardown & Getting Started

Reminder. Course project team forming deadline. Course project ideas. Next milestone

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

Integrating Concurrency Control and Energy Management in Device Drivers. Chenyang Lu

Wireless Systems Laboratory 4 November 2013

M M WIFI Module

Yun Shield User Manual VERSION: 1.0. Yun Shield User Manual 1 / Version Description Date. 0.1 Initiate 2014-Jun-21

extended external Benchmarking extension (XXBX)

M M WIFI Module

Integrating Concurrency Control and Energy Management in Device Drivers

MYD-C437X-PRU Development Board

The Emergence of Networking Abstractions and Techniques in TinyOS

BR03 Raspberry Pi Zero Bridge

Hands on Experience with AVR32

EMBEDDED SYSTEM FOR VIDEO AND SIGNAL PROCESSING

USB2510T Transverse High-Field USB Magnetometer

Towards a Resilient Operating System for Wireless Sensor Networks

UISP, Mote Programming, and Mote Fuse Help Guide version UISP, Mote Programming, and Mote Fuse HELP GUIDE

An overview of mobile and embedded platforms

MT2 Introduction Embedded Systems. MT2.1 Mechatronic systems

Getting started with the FP-SNS-ALLMEMS1 Bluetooth low energy and sensors software expansion for STM32Cube

Accelerometer with Analog and Digital I/O for StackableUSB USB1600

NFC Framework and NT3H1201 Device Driver v1.1

Sensor Network Application Development ZIGBEE CONCEPTS 0

CoLinkEx_LPC11C14 EVB Kit User Guide

Atmel AVR2059: BitCloud Porting Guide. 8-bit Atmel Microcontrollers. Application Note. Features. Introduction

STM32 Cortex-M3 STM32F STM32L STM32W

CORRIGENDUM ISSUED FOR NATIONAL COMPETITIVE BIDDING UNDER TEQIP PHASE-II

参考資料. LinkSprite.com. pcduino V2

Lab Course Microcontroller Programming

Raspberry Pi - I/O Interfaces

Unwired One. Main Features. Wireless embedded computer

Here to take you beyond. ECEP Course syllabus. Emertxe Information Technologies ECEP course syllabus

EMBEDDED HARDWARE. Core Board. ARM7 Development board. ARM7 Evaluation Board. Page 1 of 5

This presentation of uclinux-on-microblaze given

Network-centric Middleware for Service Oriented Architectures across Heterogeneous Embedded Systems

Use of ISP1807-LR Evaluation Boards

MB95260H/MB95270H. MB95280H Series. MB95260H Series/MB95270H Series/

A VIRTUALLAB APPROACH FOR WIRELESS SENSOR MOTES AND WIRELESS SENSOR NETWORKS

Embedded Vision Processor. CMUcam3 SDK Installation Guide

User Guide. for TAHOE 8718

HARDWARE REFERENCE IMM-NRF51822

Hands-On Workshop: ARM mbed

Nov 24, 2006 FOSS.in, Bangalore

ARDUINO YÚN Code: A000008

MYD-JA5D2X Development Board

PXA270 EPIC Computer with Power Over Ethernet & Six Serial Protocols SBC4670

Lab 1. OMAP5912 Starter Kit (OSK5912)

Implementation of Gradient Routing in WSNs

Embest SOC8200 Single Board Computer

Getting Started with STK200 Dragon

Intel Galileo gen 2 Board

Transcription:

TinyOS Tutorial Greg Hackmann CSE 521S Fall 2010

Outline Installing TinyOS and Building Your First App Hardware Primer Basic nesc Syntax Advanced nesc Syntax Network Communication Sensor Data Acquisition Debugging Tricks and Techniques 2

TinyOS Installation TinyOS Documentation Wiki: http://docs.tinyos.net/ Various installation options listed under Getting started section Pre-compiled.rpm and.deb packages for Fedora and Ubuntu Linux users Ubuntu users: be sure to remove brltty package All necessary drivers already included with Linux kernel 3

TinyOS Installation (cont.) OS X unofficially supported but works well Precompiled packages available at http://www.cse.wustl.edu/~gwh2/tinyos-2.1.1.dmg Need to install pyserial (http://pyserial.sourceforge.net) and FTDI FT232R serial drivers (http://www.ftdichip.com/drivers/vcp.htm) separately Can also compile using MacPorts: see TinyOS Wiki 4

TinyOS Installation (cont.) Windows installation uses Cygwin to emulate Linux software layer Problematic under XP, refuses to work on some Vista/7 machines (updating Cygwin after the installation may help) gcc is also very slow under Cygwin Running a XubunTOS Virtual Machine Image in VMware Player tutorial recommended instead Or pick your favorite VM software and install Ubuntu yourself 5

TinyOS Directory Structure /opt/tinyos-2.1.1 ($TOSROOT) apps support make sdk tools tos 8

make System $TOSROOT/support/make includes lots of Makefiles to support the build process Create a simple stub Makefile in your app directory that points to main component COMPONENT=[MainComponentC] SENSORBOARD=[boardtype] # if needed include $(MAKERULES) make [platform] in app directory Builds but does not install program platform: one of the platforms defined in $TOSROOT/tos/platforms (mica2, micaz2, telosb) 9

make System make [re]install.[node ID] [platform] [programming options] node ID: 0-255 programming options: mica2/micaz: mib510,/dev/ttyxyz telosb: bsl,/dev/ttyxyz make clean make docs [platform] Generates HTML documentation in $TOSROOT/doc/nesdoc/[platform] 10

Build Stages Preprocess.nc to.c, then compile.c to binary Set AM address and node ID in binary Program mote 11

How to Get Help TinyOS Documentation Wiki: http://docs.tinyos.net TinyOS Programming Manual: 139-page PDF intro to nesc and TinyOS 2.x: http://www.tinyos.net/tinyos-2.x/doc/pdf/tinyosprogramming.pdf TinyOS Tutorials: short HTML lessons on using parts of TinyOS (sensors, radio, TOSSIM, etc.):http://docs.tinyos.net/index.php/tinyos_tutorials 12

How to Get Help nesdoc: annotated API for all interfaces and components in TinyOS: http://docs.tinyos.net/index.php/source_code_document ation TinyOS Enhancement Protocols (TEP): formal documentation for TinyOS features: http://docs.tinyos.net/index.php/teps 13

Outline Installing TinyOS and Building Your First App Hardware Primer Basic nesc Syntax Advanced nesc Syntax Network Communication Sensor Data Acquisition Debugging Tricks and Techniques 14

MICA2 Mote (MPR400CB) 128KB Instruction EEPROM 2 AA Chipcon CC1000 radio, 38K or 19K baud, Manchester, 315, 433, or 900MHz Quantity: 56 4KB Data EEPROM Atmel ATmega128L μp 7.3827MHz (8 MIPS) UART 2 512KB External Flash Memory SPI bus ADC 0-7 UART 1 I2C Bus 3 LEDs To Sensors, JTAG, and/or 51 pin I/O Connector Programming Board 16

MPR2400 MICAz Same as Mica2 except with IEEE 802.15.4 radio 2.4GHz 250kbps Quantity: 7 17

Programming Board (MIB510) Serial interface to laptop Mote JTAG MICA2Dot interface MICA2 interface ISPJTAG Block data to laptop Quantity: 3 5V Power Reset 18

MTS310CA Sensor Board 4.6KHz Speaker 51 pin MICA2 Interface Tone Detector 2 Axis Accelerometer Light and Temperature Microphone Magnetometer Quantity: 3 19

MTS420 Sensor Board GPS Accelerometer Light Temperature Humidity Barometric Pressure 2KB EEPROM Conf. Quantity: 1 20

Tmote Sky (aka TelosB) IEEE 802.15.4 Radio 250kbps TI MSP430 microcontroller 16MHz, 16 MIPS, 10kB RAM Integrated antenna & USB interface Low power utilization 1.8mA/5.1µA vs. Mica 2 s 8mA/15µA Quantity w/o on-board sensors: 6 Quantity w/temperature, light, and humidity sensors: 20 Quantity w/sbt80 sensor board: 4 21

NSLU2 Network Storage Link ( Slug ) 266MHz Xscale CPU, 32MB SDRAM, 8MB flash, 1x Ethernet port Wired power No built-in radio, but 2x USB 2.0 ports for add-on 802.11/Bluetooth/mote interface Can be easily converted to an embedded Linux box with third-party firmware Our testbed uses the OpenWrt distribution (http://openwrt.org) Quantity: 15 22

Outline Installing TinyOS and Building Your First App Hardware Primer Basic nesc Syntax Advanced nesc Syntax Network Communication Sensor Data Acquisition Debugging Tricks and Techniques 25

TinyOS Execution Model To save energy, node stays asleep most of the time Computation is kicked off by hardware interrupts Interrupts may schedule tasks to be executed at some time in the future TinyOS scheduler continues running until all tasks are cleared, then sends mote back to sleep z Z z handlepacket readsensor sendresponse 26

provides SplitControl TinyOS Component Model NetworkHandlerP event command startdone() start() provides SplitControl uses Receive provides Receive ActiveMessageC NetworkHandlerC 27

Components!= Objects AppLogicP NetworkHandlerP AnotherHandlerP ActiveMessageC ActiveMessageC ActiveMessageC 28

Interfaces List of exposed events and commands Like ordinary C function declarations, except with event or command in front interface Receive { event message_t * Receive(message_t * msg, void * payload, uint8_t len); command void * getpayload(message_t * msg, uint8_t * len); command uint8_t payloadlength(message_t * msg); } 29

Modules Modules provide the implementation of one or more interfaces They may consume (use) other interfaces to do so module ExampleModuleP { provides interface SplitControl; uses interface Receive; uses interface Receive as OtherReceive; } implementation {... } Rename interfaces with the as keyword -- required if you are using/providing more than one of the same interface! 30

Modules implementation block may contain: Variable declarations Helper functions Tasks Event handlers Command implementations 31

Modules: Variables and Functions Placed inside implementation block exactly like standard C declarations:... implementation { uint8_t localvariable; void increment(uint8_t amount);... } void increment(uint8_t amount) { localvariable += amount; } 32

Modules: Tasks Look a lot like functions, except: Prefixed with task Can t return anything or accept any parameters implementation {... task void legaltask() { // OK } task bool illegaltask() { // Error: can t have a return value! } task void anotherillegaltask(bool param1) { // Error: can t have parameters! } } 33

Modules: Task Scheduling Tasks are scheduled using the post keyword error_t retval; retval = post handlepacket(); // retval == SUCCESS if task was scheduled, or E_FAIL if not TinyOS guarantees that task will eventually run Default scheduling policy: FIFO task1 task2 task1 task3 task1... 34

Modules: Commands and Events Commands and events also look like C functions, except: e.g. they start with the keyword command or event the function name is in the form InterfaceName.CommandOrEventName implementation { command error_t SplitControl.start() { // Implements SplitControl s start() command } } event message_t * Receive.receive(message_t * msg, void * payload, uint8_t len) { // Handles Receive s receive() event } 35

Modules: Commands and Events Commands are invoked using the call keyword: call Leds.led0Toggle(); // Invoke the led0toggle command on the Leds interface Event handlers are invoked using the signal keyword: signal SplitControl.startDone(); // Invoke the startdone event handler on the SplitControl interface 36

Modules: Commands and Events A command, event handler, or function can call or signal any other command or event from any interface wired into the module: module ExampleModuleP { uses interface Receive; uses interface Leds; } implementation { event message_t Receive.receive(message_t * msg, void * payload, uint8_t len) { // Just toggle the first LED call Leds.led0Toggle(); return msg; }... } 37