Laboratorio di Sistemi Wireless 21 Maggio 2012

Similar documents
Übung zu Drahtlose Kommunikation. 10. Übung

TinyOS 2.0: A wireless sensor network operating system

message t Abstract 1. Introduction Note TEP: 111 Core Working Group TinyOS-Version: 2.x

The BSN Hardware and Software Platform: Enabling Easy Development of Body Sensor Network Applications

TinyOS Programming. Philip Levis and David Gay

Intel Retail Client Manager Audience Analytics

How To Test In Tinyos With Unit Test (Forum) On A Microsoft Microsoft Computer (Forums) On An Ipa (Forms) On Your Computer Or Microsoft Macbook (Forims) On The Network (For

RIOT-Lab. How to use RIOT in the IoT-Lab. Oliver "Oleg" Hahm. November 7, 2014 INRIA. O. Hahm (INRIA) RIOT-Lab November 7, / 29

Wireless Sensor Networks: Motes, NesC, and TinyOS

3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version

APPLICATION NOTE. Atmel AT02607: Wireless Product Development Using Atmel Studio and ASF. Atmel MCU Wireless. Description.

ADL User Guide for Open AT V4.10

Application Note 49. Using the Digi TransPort Fleet Card. October 2011

Use of the ZENA MiWi and P2P Packet Sniffer

Introduction to Java

Bidirectional wireless communication using EmbedRF

RMON, the New SNMP Remote Monitoring Standard Nathan J. Muller

MeshBee Open Source ZigBee RF Module CookBook

Field Software Updates Using TPMS LF An example using the Low Frequency radio (LFR) for wireless software updating

APPLICATION NOTE. AVR2130: Lightweight Mesh Developer Guide. Atmel MCU Wireless. Features. Description

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Binary storage of graphs and related data

Bluetooth for device discovery. Networking Guide

Note: Zebra Printer status: It is recommended to use the PRINTER_INFO_3 structure to inquire for the printer status presented by the LM.

Creating a Simple, Multithreaded Chat System with Java

Freescale MQX USB Device User Guide

Radio sensor powered by a mini solar cell the EnOcean STM 110 now functions with even less light

IP - The Internet Protocol

Application Note: AN00121 Using XMOS TCP/IP Library for UDP-based Networking

Getting Started with the Internet Communications Engine

Marionette: Using RPC for Interactive Development and Debugging of Wireless Embedded Networks

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Object Oriented Software Design

Host Configuration (Linux)

Security of MICA*-based / ZigBee Wireless Sensor Networks

Chapter 13 Embedded Operating Systems

A NOVEL RESOURCE EFFICIENT DMMS APPROACH

2 Basic Concepts. Contents

Semester Thesis Traffic Monitoring in Sensor Networks

CSMA/CA. Information Networks p. 1

Zarząd (7 osób) F inanse (13 osób) M arketing (7 osób) S przedaż (16 osób) K adry (15 osób)

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

Implementing and testing tftp

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

Introduction to Synoptic

Client-server Sockets

Chapter 46 Link Layer Discovery Protocol (LLDP)

Modbus and ION Technology

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

Introduction to Object-Oriented Programming

J a v a Quiz (Unit 3, Test 0 Practice)

LOCAL INTERCONNECT NETWORK (LIN)

RS-485 Protocol Manual

OFDM, Mobile Software Development Framework

ST815 Illumination Sensor with LCD

XMOS Programming Guide

Using Xbee in Serial Communication

BLUETOOTH SERIAL PORT PROFILE. iwrap APPLICATION NOTE

SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

CONTROL MICROSYSTEMS DNP3. User and Reference Manual

TivaWare Utilities Library

Brunata Optuna W (171)

Testing Data Radio Modem with Serial Port Tool V1.20

7.7 Ethernet Communication (AFPX-COM5)

A Brief Overview of SONET Technology

Voice over IP. Demonstration 1: VoIP Protocols. Network Environment

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

MPLAB Harmony System Service Libraries Help

Hadoop WordCount Explained! IT332 Distributed Systems

DSX Master Communications

Single channel data transceiver module WIZ2-434

Sample CSE8A midterm Multiple Choice (circle one)

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL

Chapter 2 Introduction to Java programming

Using IPM to Measure Network Performance

Wireless Home Security System

TinySDN: Enabling TinyOS to Software-Defined Wireless Sensor Networks

Objectives. The Role of Redundancy in a Switched Network. Layer 2 Loops. Broadcast Storms. More problems with Layer 2 loops

Implementing Rexx Handlers in NetRexx/Java/Rexx

Moving from CS 61A Scheme to CS 61B Java

Overview of Network Hardware and Software. CS158a Chris Pollett Jan 29, 2007.

Link Layer Discovery Protocol

Application Note AN0008. Data Logging Extension. For. Venus 8 GPS Receiver

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Internet Firewall CSIS Packet Filtering. Internet Firewall. Examples. Spring 2011 CSIS net15 1. Routers can implement packet filtering

Freescale Semiconductor, I

WIZnet S2E (Serial-to-Ethernet) Device s Configuration Tool Programming Guide

Special Topics in Security and Privacy of Medical Information. Reminders. Medical device security. Sujata Garera

Quick Start Guide. MRB-KW01 Development Platform Radio Utility Application Demo MODULAR REFERENCE BOARD

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Serial Communications / Protocol in AirTest Products

I2C PRESSURE MONITORING THROUGH USB PROTOCOL.

Modbus and ION Technology

Communicating with a Barco projector over network. Technical note

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

Transcription:

Laboratorio di Sistemi Wireless 21 Maggio 2012 A. Cammarano, A.Capossele, D. Spenza

Contatti Cammarano: cammarano@di.uniroma1.it Capossele: capossele@di.uniroma1.it Spenza: spenza@di.uniroma1.it Tel: 06-49918430 Room: 333 Slides: www.dsi.uniroma1.it/~spenza/

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;