TinyOS Sandeep Gupta. Operating System (OS) What is an OS? Main functions  Process management  Memory management  Resource management Traditional OSs.

Slides:



Advertisements
Similar presentations
How to use TinyOS Jason Hill Rob Szewczyk Alec Woo David Culler An event based execution environment for Networked Sensors.
Advertisements

1 Tomás Sánchez López July 9, 2004 Real-time & Embedded Systems Laboratory TinyOS … in deep.
NesC Prepared for the Multimedia Networks Group University of Virginia.
Feb 2007WSN Training: First Steps in nesC Programming1 First Steps in TinyOS and nesC Programming Topics  Timer Application: MyApp  Application directory.
1 Lab 3 Objectives  Case study: “Hello world” program on motes  Write you first program on mote.
The nesc Language: A Holistic Approach to Networked Embedded Systems David Gay, Philip Levis, Robert von Behren, Matt Welsh, Eric Brewer, David Culler.
1 Lab4 Objectives  Learn to read light sensor data from sensor board  Learn to transmit a message containing the sensed data  through Mote serial port.
Mote Programming. 如何 compile 程式  make [re]install. : desired device address : target platform  install vs. reinstall install : compile the application.
TinyOS Introduction Advanced Computer Networks. TinyOS Outline  Introduction to the Architecture of TinyOS and nesC  Component Model –Components, interfaces,
GIIS’07 – Marrakech 3 rd July 2007 Behavioural Specification of Wireless Sensor Network Applications Nelson S Rosa and Paulo R F Cunha Universidade Federal.
1 Concurrent and Distributed Systems Introduction 8 lectures on concurrency control in centralised systems - interaction of components in main memory -
Programming Motes A TinyOS and TOSSIM Tutorial By: Brent Rood.
Development of a Mica2 Mote Sensor Network Cliff Macklin Bill Ehrbar December 8, 2004 University of Colorado, Colorado Springs.
2008EECS Embedded Network Programming nesC, TinyOS, Networking, Microcontrollers Jonathan Hui University of California, Berkeley.
TinyOS Tutorial CS580S Sensor Networks and Systems February 7, 2007 Jisu Oh Dept. of Computer Science SUNY-Binghamton.
PtinyOS: Simulating TinyOS in Ptolemy II Elaine Cheong Dec 10, 2004 EE290N Project Presentation (Initial NC code generator by Yang Zhao and Edward Lee)
5/5/2003MobiSys 2003 Tutorial TinyOS Tutorial, Part II Robert Szewczyk, Joe Polastre, Phil Levis, David Culler Mobisys 2003.
NesC: 1.1 Bumps and Future Directions David Gay, Intel Research, Berkeley (and the nesC and TinyOS teams)
1 Lab 3 Objectives  Case study: “Hello world” program on motes  Write you first program on mote.
TinyOS Tutorial Based on Wenyuan Xu’s slides ( NetsF06/Comnet_TinyOS_Tutorial_xwy.ppt)
1 Software Development Infrastructure for Sensor Networks  Operating systems ( TinyOS )  Resource (device) management  Basic primitives  Protocols.
Sown Code Report: Aggregation Tracking Group Management Pascal A. Vicaire University of Virginia
1 Lab 5 Objectives  Use XMesh multi-hop networking service to send sensing data to a base station  Using XServe to display the sensor data message on.
Programming in nesC (and TOSSIM)
By: R Jayampathi Sampath
April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College.
1 TinyOS Computer Network Programming Wenyuan Xu Fall 2007.
TinyOS 1/2 Onsystech Sangjae Han.
1 Lab2 Objectives  Basics of TinyOS  Basics of nesC programming language.
1 Lab2 Objectives  Basics of TinyOS  Basics of nesC programming language.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
HW2: Q&A Oct. 02, Lab Machine TinyOS is installed in one machine (531AB). But, you have to bring your kit. There is a sign up sheet. Please sign.
Vishal Jain, TinyOS Design Viewpoint “TinyOS” Design Viewpoint.
HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Light Sense Lab. Read data from light(photo diode) sensor, display using oscilloscope.
Dhanshree Nimje Smita Khartad
CIS 798 Sensor Network Implementation. Goals Learning sensor network programming with Crossbow motes Implement reasonable sized sensor applications Develop.
Lab 3 Introduction to TinyOS and nesC How to debug programs at PC Examples –Blink Timer –Blink –Hellow World Reference: 1.x/doc/tutorial/lesson1.html.
Simulation of Distributed Application and Protocols using TOSSIM Valliappan Annamalai.
TinyOS Tutorial Lesson 8 Data logging application.
HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 TinyOS & NesC.
Part 2 TinyOS and nesC Programming Selected slides from:
Feb 2007WSN Training: Creating a Simple Sensor Application1 A TinyOS Sensor Application called MyApp Objectives  How to create a simple Mote firmware.
HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Wireless MAC Practice (MAC I)
@ nesC Programming KETI / Ubiquitous Computing Center Jeonghoon Kang
Main Issues Three major issues that we are concerned with in sensor networks are – Clustering Routing and Security To be considered against the backdrop.
WSN Software Platforms - concepts Vinod Kulathumani Lecture uses some slides from tutorials prepared by authors of these platforms.
Lab 3, Part 2 Selected slides from: Wireless Sensor Networks Hardware/Software Tiny OS & NesC Programming borrowed from Turgay Korkmaz.
HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Gossiping Protocol.
TinyOS By Valliappan Annamalai. Hardware Mica motes (Mica2 and Mica2Dot) Hardware –Radio –Microcontroller –Flash memory –ADC –Sensor Board (MTA310)
HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS.
Based on slides from Andreas Larsson Table from CY Chong, SP Kumar, BA Hamilton - Proceedings of the IEEE, 2003.
HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 HelloWorld By using LED & Timer components, we will display “helloworld” in a manner of Morse code.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Blink Blink.nc configuration Blink { } implementation { components Main, BlinkM, SingleTimer, LedsC; Main.StdControl -> BlinkM.StdControl; Main.StdControl.
Feb 2007WSN Training: XMesh Enabled Sensor App1 Lab 5 Objectives  Use XMesh multi-hop networking service to send sensing data to a base station  Using.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Why does it need? [USN] ( 주 ) 한백전자 Background Wireless Sensor Network (WSN)  Relationship between Sensor and WSN Individual sensors are very limited.
Software Architecture of Sensors. Hardware - Sensor Nodes Sensing: sensor --a transducer that converts a physical, chemical, or biological parameter into.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
TinyOS Sandeep Gupta. TinyOS basics TinyOS is  Single tasking OS  Interrupt driven Written using a Component based language A set of components put.
TinyOS and nesC. Outline ● Wireless sensor networks and TinyOS ● Networked embedded system C (nesC) – Components – Interfaces – Concurrency model – Tool.
Simulation of Distributed Application and Protocols using TOSSIM
WSN Training: XMesh Enabled Sensor App
Ad Hoc Networking using Flooding protocol
SOWN Code Review Top-level Control.
Introduction to Operating System (OS)
An Introduction to nesC
Temperature and Humidity Lab.
WSN Training: TinyOS/nesC Basic Concepts TinyOS and nesC
SenseToRfm SenseToInt.Timer -> TimerC; configuration SenseToRfm {
Presentation transcript:

TinyOS Sandeep Gupta

Operating System (OS) What is an OS? Main functions  Process management  Memory management  Resource management Traditional OSs are monolithic.

Sensors Sensor consists of  Processor  Limited memory (128kb)  Transceiver  Peripheral devices (eg. LED)  Limited battery and  Sensing module Deployed for specific application  process and resource management not required

TinyOS Introduction Written using a component based language called NesC (Nested C). Hardware devices are represented using components. For example: LedsC for LED Interrupt driven Only one application runs on sensors. Application contains the OS code. Code to control hardware devices. Application does not contain the whole OS. To avoid problems due to invalid memory access does not allow dynamic memory allocation.

Components Each component will provide a set of services (atleast stdcontrol). stdcontrol provides commands for initializing, starting and stopping the component. Services provided by a component can be used via interfaces. Components can use interfaces provided by other components. Each component is like a state machine.

Interface Interface is like a header file that defines APIs using which components will interact. Interfaces are bidirectional. Interface consists of commands and events. Commands:  Issued by component that uses an interface provided by another component.  Component that provides an interface will have the implementation for commands. Events:  Issued by component that provides an interface to a component that uses an interface.  Component that uses an interface will have the implements for events. Example: LedsC component provides Leds interface to switch on and off the LEDs.

Split-phase operation To avoid delay in response long latency function calls are executed in split-phase. For example: Sending a packet.  The application issues a send call which will schedule the actual sending process to be executed at a later time  Upon transmission the application is notified regarding the successful transmission. Accomplished using commands, events and tasks. Long latency functions are called tasks.

What are tasks? Requirement of realtime OS: bounded delays between events. Event handler should run to completion within a short duration. If a lot of computation is involved in an event handler we defer execution. How?  Implementing it as a task and scheduling it for later execution. TinyOS has simple FIFO scheduler using which tasks are scheduled. Upon occurrence of an event a task that is executing is preempted.

Configuration and Modules Configuration:  Each application will have a main configuration file that wires components together.  Wiring? Wiring is attaching two components together and specifying the interface using which they will exchange information. Eg. BadgeM.Leds  LedsC.Leds; The arrow direction indicates the command calling and event signalling flow. Here BadgeM will call commands on LedsC and LedsC will signal events to BadgeM. Modules:  Each application might contain implementation specific to it.

TinyOS Application Consists of a set of components and a scheduler A configuration file represents an application. Interrupt driven. List of interrupts handled depend on list of hardware components included in the application (e.g. clock and receiver). Waits for interrupts. On occurrence of interrupt, calls interrupt handler. Two threads of execution  Scheduler thread (lower priority)  Interrupt thread (higher priority) Hardware Interrupts ISR Interrupt Handler invokes Calls

Example Application Badge  Components Main BadgeM TimerC GenericComm Leds Badge application sends a beacon message out every 1000ms BadgeM contains our application code. Main is the entry point to any application. All other components will be wired to Main directly or indirectly. Main will initially init all components and then call their start functions. Interrupts used  Clock  Transmitter

Wiring of components BadgeM TimerC HPLClock Hardware Clock Set Interrupt Specific parameters ISR calls clock fired Event handler Clock Interface HPLClock provides the interface for Setting timer interrupt parameters TimerC implements the event handler for fired event Timer Interface TimerC provides the interface for Setting timer interrupt parameters BadgeM implements the event handler for fired event GenericComm SendMsg Interface GenericComm provides interface to send a messgas and BadgeM implements the sendDone event handler Transceiver Main stdControl Interface BadgeM implements stdControl interface Entry point All wirings Below this are predetermined

Event and Commands in BadgeM FIFO Scheduler Clock ISR (TOSH_INTERRUPT) HPLClock TimerM BadgeM Fired Fired event handler posts sendBadge task Task sendBadge Schedules The task GenericComm Send Transmitter Send SendDone Leds greenOn redOff Main Starts FIFO Start Command Event Function Tasks Start setInterval Timer Interface Leds Interface SendMsg Interface stdcontrol Interface stdcontrol Interface

Compilation Phase 1. NesC compiler first converts the application into a c file (app.c. present in build directory of each application). 2. All commands and events are replaced with function. 3. Code for clock interrupt service routine is generated. (handout 1). 4. C file is compiled into an exe format. 5. avr-objcopy application converts it into a flash programmable format.

Execution phase 1. Main calls start of BadgeM. 2. BadgeM sets time interval for timer interrupt via TimerM and HPLClock components. (handout 1) 3. Main then enables the interrupts. 4. Main starts the scheduler. 5. Steps 6 through 11 are repeated every time timer interrupts. 6. Timer interrupt calls the event handler in BadgeM via HPLClock and TimerM. (handout 1) 7. BadgeM fired event handler schedules (posts) a sendBadge task. (handout 3) 8. Scheduler schedules sendBadge when there are no events to be serviced. 9. sendBadge then calls the send command part of SendMsg interface provided by GenericComm. (handout 3) 10. send methods transmits the packet. 11. When packet transmission is complete, sendDone event is sent to BadgeM component. (handout 3)

Problems If components are not initialized then they will initialize at an arbitrary state which will lead to unpredictable results.  e.g. if BadgeM’s stdControl is not wired to Main then the clock will start generating interrupts at 1ms intervals.

Debugging Leds are used for debugging applications. JTAG can also be used for debugging applications loaded onto the motes.

Handout 1 BlinkM initiates the ISR registration and so BlinkM will be the handler for timer interrupt. BlinkM command result_t StdControl.start() { call Timer.start(TIMER_REPEAT, 250); (Execution Phase: Step 2) …. } TimerM command result_t Timer.start (char type, uint32_t interval) { ….. call Clock.setInterval(mInterval); (Execution Phase: Step 2) ….. } HPLClock async command void Clock.setInterval(uint8_t value) (Execution Phase: Step 2) { outp(value, OCR0); } (ISR defined in HPLClock) (Compilation Phase: Step 2) TOSH_INTERRUPT(SIG_OUTPUT_COMPARE0) { …. signal Clock.fire(); }

Handout1 cont. BadgeM event result_t Timer.fired()(Execution Phase: Step 6) { post sendBadge(); return SUCCESS; } No Code here in TimerM. But how does fired event in BadgeM get called? (Code is inserted by the NesC compiler based on the wiring) TimerM default event result_t Timer.fired[uint8_t id]() (Execution Phase: Step 6) { return SUCCESS; } HPLClock default async event result_t Clock.fire() { return SUCCESS; } (ISR defined in HPLClock) TOSH_INTERRUPT(SIG_OUTPUT_COMPARE0) { …. signal Clock.fire(); (Execution Phase: Step 6) }

Handout 2 Configuration file includes Badge; configuration Badge { } implementation { components Main, BadgeM, TimerC, GenericComm as Comm, LedsC as Leds, HPLCC1000M; Main.StdControl -> BadgeM; (step 2) Main.StdControl -> TimerC; BadgeM.Timer -> TimerC.Timer[unique("Timer")]; BadgeM.SendMsg -> Comm.SendMsg[AM_BADGEMSG]; BadgeM.Leds -> Leds; BadgeM.HPLChipcon -> HPLCC1000M; }

Handout 3 BadgeM implementation includes Badge; module BadgeM { provides interface StdControl; uses interface Timer; uses interface SendMsg; uses interface Leds; uses interface HPLCC1000 as HPLChipcon; } implementation { uint16_t cur_seqno = 0; BadgeMsg *badge_msg; TOS_Msg send_msg; bool sendBusy = FALSE; uint8_t counter; uint16_t seqNum = 0; task void sendBadge(); // Called when the application is initialized. command result_t StdControl.init() { badge_msg = (BadgeMsg *)send_msg.data; counter++; return SUCCESS; } // Also called when the application is initialized, but after // all modules have had StdControl.init() invoked. command result_t StdControl.start() { call Timer.start(TIMER_REPEAT, 250); call Leds.greenOn(); return SUCCESS; } // Called if another module wishes to stop this one. This will never // happen in practice, but, we still stop the timer here. command result_t StdControl.stop() { call Timer.stop(); return SUCCESS; }

Handout 3 cont. // Send a radio badge. task void sendBadge() { call Leds.greenOn(); call Leds.redOff(); if (!sendBusy) { badge_msg->sourceaddr = TOS_LOCAL_ADDRESS; badge_msg->seqNo = seqNum++; sendBusy = TRUE; if (!call SendMsg.send(TOS_BCAST_ADDR, sizeof(BadgeMsg), &send_msg)) (Step 9) { sendBusy = FALSE; // Can't send message call Leds.redOn(); return; } else { // Message send completed return; } } else { // Can't send message - still sending previous!? call Leds.redOn(); return; } // Called when the previous message been sent. event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success) (Step 11) { call Leds.greenOff(); sendBusy = FALSE; return SUCCESS; } event result_t Timer.fired() { post sendBadge(); (Step 7) return SUCCESS; }

Commands and Events Commands:  Issued by component that uses an interface provided by another component.  Component that provides an interface will have the implementation for commands. Events:  Issued by component that provides an interface to a component that uses an interface.  Component that uses an interface will have the implements for events.