Wireless Systems Laboratory 4 November 2013

Similar documents
Internship at Sentilla. Chris Merlin March 08 - June 08

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

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

ANEXO D CÓDIGO DE LA APLICACIÓN. El contenido de los archivos de código fuente almacenados en el directorio Nodo desconocido es el siguiente:

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

Politecnico di Milano Advanced Network Technologies Laboratory. TinyOS

TinyOS Lesson 6 Topology Control

Complete Network Embedded System

Networking Level Laboratory Mote-Computer Serial Communication

Enabling Networked Sensors

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

Introduction to TinyOS

WSN Programming. Introduction. Olaf Landsiedel

LiteOS Application Note AN-101: Mote-PC communication and data display

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

Wireless Sensor Networks

Mobile and Ubiquitous Computing TinyOS application example. Niki Trigoni

Sensor Network Application Development ZIGBEE CONCEPTS 2

REMOTE PROGRAMMING FOR HETEROGENEOUS SENSOR NETWORKS VISHAL BHATIA. BCA(Hons), Devi Ahilya Vishwavidyalaya, India, 2006 A REPORT

A Virtual Machine-Based Programming Environment for Rapid Sensor Application Development

INDOOR LOCALIZATION IN WIRELESS SENSOR NETWORK USING FINGERPRINTING METHOD

TinyOS Tutorial. Greg Hackmann CSE 521S Fall 2010

ADHOC ROUTING BASED DATA COLLECTION APPLICATION IN WIRELESS SENSOR NETWORKS MALLIKARJUNA RAO PINJALA B.E, OSMANIA UNIVERSITY, INDIA, 2004 A REPORT

Collection. Abstract. 1. Introduction. Note. TEP: 119 Net2 Working Group

nesc Prof. Chenyang Lu How should network msg be handled? Too much memory for buffering and threads

Exposure to Sensor Motes

TinyOS 2.x. Hongwei Zhang

A VIRTUALLAB APPROACH FOR WIRELESS SENSOR MOTES AND WIRELESS SENSOR NETWORKS

Wireless Sensor Networks (WSN)

NesJ: a translator for Java to NesC

CS4516 Advanced Computer Networks. Final Review

ITEM, TinyOS module for sensor networks

nesc Ø Programming language for TinyOS and applications Ø Support TinyOS components Ø Whole-program analysis at compile time Ø Static language

Using CSP to Model and Analyze TinyOS Applications

Sistemas Distribuídos com Redes de Sensores. Noemi Rodriguez

CSC 714 Real Time Computer Systems. Active Messages for the Renesas M16 Board

An Environmental Sensing Experiment Using IEEE Radio Hop of the WSN TelosB Motes

Introduction to Programming Motes

SpiNNaker Application Programming Interface (API)

BaseStation Based on GenericComm. Aly El-Osery Electrical Engineering Dept. New Mexico Tech Socorro, NM

A TEMPORAL MESSAGE ORDERING AND OBJECT TRACKING APPLICATION. by LAKSHMAN KAVETI

Sensors Network Simulators

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

More about BOOLEAN issues

WIRELESS mesh sensor networks are commonly used

TinyOS Tutorial. Greg Hackmann CSE 467S Spring 2011

Dynamic Routing and Network Monitoring for the Polywog Protocol

LORD MANUAL. Wireless Sensor Networks LXRS Data Communications Protocol

The Emergence of Networking Abstractions and Techniques in TinyOS

WiMOD LR Base Host Controller Interface

TinySec: A Link Layer Security Architecture for Wireless Sensor Networks. Presented by Paul Ruggieri

ProxyMotes: Linux-based TinyOS Platform for Non-TinyOS Sensors and Actuators

Wireless Sensor Networks. Data Communications Protocol

CSE398: Network Systems Design

}w!"#$%&'()+,-./012345<ya

Terra System Low abstraction level built-in functionalities (TerraNet v0.2) Introduction & user guide Adriano Branco

Chapter 4: Processes

WiMOD LR Base Plus Host Controller Interface

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Nabto Serial Link Protocol

This resource describes how to program the myrio in C to perform timer interrupts.

UDCP Unified Decomposition of Cross layer Protocol. Chen Hsiang Feng 7/15/2008

Wireless Sensor Networks. Introduction to the Laboratory

Programming TinyOS. Lesson 3. Basic Structure. Main.nc

Using QualNet Part II. QualNet s Directory Structure. Adding a Custom Protocol

Mobile and Ubiquitous Computing Routing Protocols. Niki Trigoni

Sensors as Software. TinyOS. TinyOS. Dario Rossi Motivation

SYSTEM DESIGN SPECIFICATIONS ZIGBEE BASIC SYSTEM

HILAC: A framework for Hardware In the Loop simulation and multi-platform Automatic Code Generation of WSN Applications

In the CERTAINTY project, an application is defined as a network of independent processes with the following features:

RF Networking With MSP430 & the ez430-rf2500 Session 2 Miguel Morales, MSP430 Applications 6/5/2008 1

Multi Hop Send Protocol Tool for TinyNodes Semesterthesis

Basic Types, Variables, Literals, Constants

PROGRAMMING FUNDAMENTALS

Recitation #11 Malloc Lab. November 7th, 2017

A Domain-Specific Modeling for Dynamically Reconfigurable Environmental Sensing Applications

CS 237 Meeting 19 10/24/12

Using Qualnet Part II

TinyOS. Jan S. Rellermeyer

CSC 1214: Object-Oriented Programming

µtasker Document µtasker Multicasting and Internet Group Management Protocol (IGMP)

CS 268: Computer Networking. Taking Advantage of Broadcast

6.096 Introduction to C++ January (IAP) 2009

libnetfilter_log Reference Manual

Asynchronous Serial Communication Protocol (without Flow Control) using TLM 2.0 (Example of Non memory based protocol )

ACme Quick Start Guide

Tokens, Expressions and Control Structures

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

Task Executive. Gary J. Minden February 9, 2017

Assignment 4: Semantics

Programming Sensor Networks

WiMOD LR Base Host Controller Interface

Introduce C# as Object Oriented programming language. Explain, tokens,

CS349/SE382 A1 C Programming Tutorial

Assignment 6. Methods Homework Spring 2017 P Question 1 all

Three main modules (and a number of helper modules) 4

Programming TinyOS. Lesson 2. Execution Flow. Tasks. commands. Events generated by interrupts preempt tasks Tasks do not preempt tasks

Generalised User Interface for Embedded Applications using an LCD screen and keypad.

... Application Note AN-531. PCI Express System Interconnect Software Architecture. Notes Introduction. System Architecture.

Sensor Networks. Part 3: TinyOS. CATT Short Course, March 11, 2005 Mark Coates Mike Rabbat. Operating Systems 101

Transcription:

Wireless Systems Laboratory 4 November 2013 A. Cammarano, A.Capossele, D. Spenza

Contacts Cammarano: Capossele: Spenza: cammarano@di.uniroma1.it capossele@di.uniroma1.it spenza@di.uniroma1.it Tel: 06-49918430 Room: 333 Slides: http://wwwusers.di.uniroma1.it/~spenza/lab2013.html

Outline The BlinkToRadio Application Mote-PC serial communication BaseStation SerialForwarder

BlinkToRadio Application A counter is incremented every second Whenever the timer fires, the value of the counter is sent over a radio message Whenever a radio message is received, the three least significant bits of the counter in the message payload are displayed on the LEDs

Exercise 1 Assign an unique ID to your nodes Filter radio messages that are not sent to you

Exercise 2 Node A sends the value of its counter to node B Node B displays the three least significant bits of the counter on the LEDs, updates the value of the counter and sends it back to node A Node A displays the three least significant bits of the counter on the LEDs, updates the value of the counter and sends it back to node B.

Mote-Pc Serial Communication TinyOS provides high-level communication interfaces Similar for radio and serial communication Basic interfaces: Packet: Set/get payload of TinyOS message_t packets Send: Send packet by calling send() command Receive: Reception of packets signaled by receive() event Active Message interfaces allow for multiplexing: AMPacket: Provide source and destination address to packet AMSend: Send packet to destination address

TestSerial Application Mote and PC components Both increment counter values and send to the other Mote: nesc and TinyOS Outputs last three bits of PC counter value to LEDs PC: Java and TinyOS Java libraries Outputs mote counter value to stdout Demonstration

TestSerial TestSerialC Interfaces AMSend, Receive wired to TinyOS serial component test_serial_msg_t Payload struct MoteIF TinyOS Java library to send and receive packets TestSerial.java Prints received counter values Increments and sends counter values TestSerialMsg.java Payload encapsulation Generated from TestSerial.h TestSerialC AMSend /Receive SerialAMC (TinyOS) Serial/USB send() msgreceived() MoteIF Mote PC TestSerialAppC TestSerial.h (test_serial_msg_t) TestSerialMsg.java TestSerial.java

Packet Payload Format Usually defined in C header file (TestSerial.h) nx-types abstract away big/little endian hardware/communication differences Default payload size is 29 bytes, but can be enlarged Active Message type AM_TEST_SERIAL_MSG Integer value to distinguish between multiple packet types (multiplexing) TinyOS libraries convert struct to a Java class with set/get methods (TestSerialMsg.java) Message Interface Generator (example in TestSerial Makefile) // TestSerial.h typedef nx_struct test_serial_msg { nx_uint16_t counter; test_serial_msg_t; enum { AM_TEST_SERIAL_MSG=6;

TestSerialAppC: wiring SerialActiveMessageC allows for multiplexing Multiple packet types (e.g. sensor control and data) Differentiate through AM types: AM_TEST_SERIAL_MSG Parameters defined in brackets [] SerialActiveMessageC provides several interfaces Wired to TestSerialC SplitControl to turn on and off the UART/serial bus AMSend and Receive for transmitting and receiving Packet to set and get payload configuration TestSerialAppC { implementation { components SerialActiveMessageC as AM, SplitControl;... App.Receive -> AM.Receive[AM_TEST_SERIAL_MSG]; App.AMSend -> AM.AMSend[AM_TEST_SERIAL_MSG]; App.Control -> AM; App.Packet -> AM;

TestSerialC: Booting When mote boots, turn on UART When UART is powered, start timer to send packets Implement Control.stopDone() to turn off UART event void Boot.booted() { call Control.start(); event void Control.startDone(error_t err) { if (err == SUCCESS) { call MilliTimer.startPeriodic(1000); event void Control.stopDone(error_t err) {

TestSerialC: Sending Packets Timer fires, increment counter Get message_t payload pointer: Packet.getPayload(); Set payload value: rcm->counter = counter; Send packet: AMSend.send(); Provide AM destination address, message_t packet address, payload size Packet sent: AMSend.sendDone(); event void MilliTimer.fired() { counter++; message_t packet; test_serial_msg_t* rcm = (test_serial_msg_t*)call Packet.getPayload(&packet, sizeof(test_serial_msg_t)); rcm->counter = counter; call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(test_serial_msg_t)); event void AMSend.sendDone(message_t* bufptr, error_t error){

TestSerialC: Receiving Packets Packet received: Receive.receive(); Provides message_t packet, payload pointer, and payload size Get payload: cast from void* to test_serial_msg_t* Set LEDs according to value of last 3 bits event message_t* Receive.receive(message_t* bufptr, void* payload, uint8_t len){ test_serial_msg_t* rcm = (test_serial_msg_t*)payload; if (rcm->counter & 0x1) { call Leds.led0On(); // turn on other LEDs accordingly... return bufptr;

PC: TestSerial.java Initialization Create packet source from args[]: -comm serial@\dev\ttyusb0:telosb Register packet listener for TestSerialMsg and source Send packets public class TestSerial implements MessageListener { private MoteIF moteif; public static void main(string[] args) throws Exception {... String source = args[1]; PhoenixSource phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); MoteIF mif = new MoteIF(phoenix); TestSerial serial = new TestSerial(mif); serial.sendpackets(); public TestSerial(MoteIF moteif) { this.moteif = moteif; this.moteif.registerlistener(new TestSerialMsg(), this);

TestSerial.java: send packets Initialize counter and create TestSerialMsg payload While loop Increment counter and sleep for some period Set payload counter: payload.set_counter(); Send packet: moteif.send(); with destination address 0 public void sendpackets() { int counter = 0; TestSerialMsg payload = new TestSerialMsg();... while (true) {... // increment counter and wait for some amount of time before sending System.out.println("Sending packet " + counter); payload.set_counter(counter); moteif.send(0, payload);

TestSerial.java: receiving packets TestSerial.messageReceived() triggered by incoming packet while listener is registered Provides AM destination address and abstract class Message Cast message to TestSerialMsg Retrieve counter: msg.get_counter(); public void messagereceived(int to, Message message) { TestSerialMsg msg = (TestSerialMsg)message; System.out.println("Received packet sequence number " + msg.get_counter());

Serial Forwarder Instead of connecting to the serial port directly, applications connect to the SerialForwarder, which acts as a proxy to read and write packets java net.tinyos.sf.serialforwarder -comm serial@/dev/ttyusb0:telosb

Base Station It is a basic TinyOS utility application. It acts as a bridge between the serial port and radio network. BlinkToRadio Packets Serial Port Destination address (2 bytes) Link source address (2 bytes) Message length (1 byte) Group ID (1 byte) Active Message handler type (1 byte) Payload (up to 28 bytes): source mote ID (2 bytes) sample counter (2 bytes) Radio typedef nx_struct BlinkToRadioMsg { nx_uint16_t nodeid; nx_uint16_t counter; BlinkToRadioMsg; $ java net.tinyos.tools.listen -comm serial@/dev/ttyusb0:telosb

Oscilloscope Periodically samples the default sensor via (DemoSensorC) and broadcasts a message with 10 accumulated readings over the radio. Application Components OscilloscopeAppC (Configuration), OscilloscopeC (Module) BaseStation System Components MainC, LedsC, TimerMilliC, DemoSensorC AMReceiverC, AMSenderC, ActiveMessageC

Oscilloscope OscilloscopeAppC: components graph

Oscilloscope.h enum { NREADINGS = 10, DEFAULT_INTERVAL = 256, AM_OSCILLOSCOPE = 0x93 ; Oscilloscope typedef nx_struct oscilloscope { nx_uint16_t version; /* Version of the interval. */ nx_uint16_t interval; /* Sampling period. */ nx_uint16_t id; /* id of sending mote. */ nx_uint16_t count; /* The readings are samples count * NREADINGS onwards */ nx_uint16_t readings[nreadings]; oscilloscope_t;

Oscilloscope OscilloscopeAppC.nc #include Oscilloscope.h configuration OscilloscopeAppC { implementation { components OscilloscopeC, MainC, ActiveMessageC, LedsC, new TimerMilliC(), new DemoSensorC() as Sensor, new AMSenderC(AM_OSCILLOSCOPE), new AMReceiverC(AM_OSCILLOSCOPE); OscilloscopeC.Boot -> MainC; OscilloscopeC.RadioControl -> ActiveMessageC; OscilloscopeC.AMSend -> AMSenderC; OscilloscopeC.Receive -> AMReceiverC; OscilloscopeC.Timer -> TimerMilliC; OscilloscopeC.Read -> Sensor; OscilloscopeC.Leds -> LedsC;

OscilloscopeC.nc Oscilloscope #include "Timer.h" #include "Oscilloscope.h" module OscilloscopeC{ uses { interface Boot; interface SplitControl as RadioControl; interface AMSend; interface Receive; interface Timer<TMilli>; interface Read<uint16_t>; interface Leds; implementation{ message_t sendbuf; bool sendbusy; oscilloscope_t local; uint8_t reading; bool suppresscountchange;

OscilloscopeC.nc Oscilloscope // Utility C-style functions void report_problem() { call Leds.led0Toggle(); void report_sent() { call Leds.led1Toggle(); void report_received() { call Leds.led2Toggle(); void starttimer() {call Timer.startPeriodic(local.interval); reading = 0; event void Boot.booted() { local.interval = DEFAULT_INTERVAL; local.id = TOS_NODE_ID; if (call RadioControl.start()!= SUCCESS) report_problem(); event void RadioControl.startDone(error_t error) { starttimer(); event void RadioControl.stopDone(error_t error) {

OscilloscopeC.nc Oscilloscope event void Timer.fired(){ if (reading == NREADINGS) { if (!sendbusy&&sizeof local <= call AMSend.maxPayloadLength()) { memcpy(call AMSend.getPayload(&sendBuf, sizeof(local)), &local, sizeof local); if (call AMSend.send(AM_BROADCAST_ADDR, &sendbuf, sizeof local) == SUCCESS) sendbusy = TRUE; if (!sendbusy) report_problem(); reading = 0; if (!suppresscountchange) local.count++; suppresscountchange = FALSE; if (call Read.read()!= SUCCESS) report_problem();

OscilloscopeC.nc Oscilloscope event void Read.readDone(error_t result, uint16_t data) { if (result!= SUCCESS) { data = 0xffff; report_problem(); local.readings[reading++] = data;

OscilloscopeC.nc Oscilloscope event void AMSend.sendDone(message_t* msg, error_t error) { if (error == SUCCESS) report_sent(); else report_problem(); sendbusy = FALSE; event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) { oscilloscope_t *omsg = payload; report_received(); if (omsg->version > local.version) {local.version = omsg->version;local.interval = omsg- >interval; starttimer(); if (omsg->count > local.count) {local.count = omsg->count; suppresscountchange = TRUE; return msg;