1 / 21

TinyOS

TinyOS. Wireless and Mobile Networking Lab. Konkuk University. Outline. Installation Software Architecture NesC Programming Example codes Blink Moss SimpleRf. Installation. TinyOS install. Installation (con't). Cygwin install Cygwin setup. Installation (con't). RPM upgrade

wilks
Download Presentation

TinyOS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TinyOS Wireless and Mobile Networking Lab. Konkuk University

  2. Outline • Installation • Software Architecture • NesC Programming • Example codes • Blink • Moss • SimpleRf

  3. Installation • TinyOS install

  4. Installation (con't) • Cygwin install • Cygwin setup

  5. Installation (con't) • RPM upgrade • rpm -Uvh tinyos-1.1.13May2005cvs-1.cygwin.noarch.rpm

  6. Installation (con't) • msp-gcc install delete

  7. Installation (con't) • msp-gcc path setup • export PATH=$PATH:/cygdrive/c/mspgcc/bin

  8. Installation (con't) • overwriting some files

  9. Software Architecture TinyOS Application Component Main Command Handler Event Handler Counter Clock INT_TO_LED Task LED Tiny Scheduler

  10. Software Architecture (con't) • Relationship of Commands, Tasks, Events and two-level scheduler Higher Level Component • Both event and command can schedule tasks • Commands can not signal events • Tasks preemptive by events • Tasks non preemptive by tasks Signal Events Command Lower Level Component Task Task Task

  11. NesC Programming • Wiring Module Configuration Provide Wiring Interface Use Implement Module

  12. NesC Programming (con't) Module Configuration Provided components Used components • Wiring with interfaces • Declare interfaces using and providing • Implement commands and events

  13. NesC Programming (con't) • Blink module BlinkM { provides { interface StdControl; } uses { interface Timer; interface Leds; } } implementation { uint8_t i; command result_t StdControl.init() { call Leds.init(); return SUCCESS; } command result_t StdControl.start() { return call Timer.start(TIMER_REPEAT, 500); } command result_t StdControl.stop() { return call Timer.stop(); } event result_t Timer.fired() { i++; if(i%3 == 1) call Leds.blueToggle(); else if(i%3 == 2) call Leds.redToggle(); else if(i%3 == 0) call Leds.yellowToggle(); return SUCCESS; } }

  14. NesC Programming (con't) • Blink (con’t) configuration Blink { } implementation { components Main, BlinkM, SingleTimer, LedsC; Main.StdControl -> SingleTimer.StdControl; Main.StdControl -> BlinkM.StdControl; BlinkM.Timer -> SingleTimer.Timer; BlinkM.Leds -> LedsC; }

  15. NesC Programming (con't) • Moss #define MORSE_WPM 12 #define MORSE_UNIT (1200/MORSE_WPM) module MossM { provides { interface StdControl; } uses { interface Timer; interface Leds; interface HPLUART as UART; } } implementation { command result_t StdControl.init() { call UART.init(); call Leds.init(); call Leds.redOff(); call Leds.yellowOff(); call Leds.greenOff(); return SUCCESS; } command result_t StdControl.start() { return call Timer.start(TIMER_REPEAT, 1000); } command result_t StdControl.stop() { return call Timer.stop(); } event result_t Timer.fired() { static char *morse = "... .-.. .-.. -- "; static char *current; if(!current) current = morse;

  16. NesC Programming (con't) • Moss (con’t) switch(*current) { case ' ': if(!call Leds.get()) { call Leds.yellowOn(); call Timer.start(TIMER_ONE_SHOT, 2*MORSE_UNIT); call UART.put(' '); } else { call Leds.yellowOff(); call Timer.start(TIMER_ONE_SHOT, 2*MORSE_UNIT); current++; } break; case '.': if(!call Leds.get()) { call Leds.redOn(); call Timer.start(TIMER_ONE_SHOT, MORSE_UNIT); call UART.put('.'); } else { call Leds.redOff(); call Timer.start(TIMER_ONE_SHOT, MORSE_UNIT); current++; } break; case '-': if(!call Leds.get()) { call Leds.greenOn(); call Timer.start(TIMER_ONE_SHOT, 3*MORSE_UNIT); call UART.put('-'); } else { ..

  17. NesC Programming (con't) • SimpleRf configuration SimpleRf {} implementation { components Main, SimpleRfM, CC2420RadioC, CC2420ControlM, TimerC, LedsC; Main.StdControl -> TimerC.StdControl; Main.StdControl -> SimpleRfM.StdControl; SimpleRfM.Timer -> TimerC.Timer[unique("Timer")]; SimpleRfM.Leds -> LedsC; SimpleRfM.CC2420Control -> CC2420ControlM; SimpleRfM.RadioControl -> CC2420RadioC; SimpleRfM.RadioSend -> CC2420RadioC.Send; SimpleRfM.RadioReceive -> CC2420RadioC.Receive; }

  18. NesC Programming (con't) • SimpleRf (con’t) module SimpleRfM { provides { interface StdControl; } uses { interface Leds; interface Timer; interface CC2420Control; interface StdControl as RadioControl; interface BareSendMsg as RadioSend; interface ReceiveMsg as RadioReceive; } } implementation { TOS_MsgPtr pData; TOS_Msg Data; uint8_t count = 0; task void sendDATA() { pData->addr = 0x0001; pData->length = 1; pData->data[0] = count; count++; call Leds.yellowToggle(); call RadioSend.send(pData); }

  19. NesC Programming (con't) • SimpleRf (con’t) command result_t StdControl.init() { pData = &Data; call Leds.init(); call RadioControl.init(); return TRUE; } command result_t StdControl.start() { // Set CC2420 channel // Valid channel values are 11 through 26. call CC2420Control.TunePreset(11); call RadioControl.start(); if(TOS_LOCAL_ADDRESS == 0x0000) call Timer.start(TIMER_REPEAT, 1024); return TRUE; } command result_t StdControl.stop() { call RadioControl.stop(); call Timer.stop(); return TRUE; } event result_t Timer.fired() { post sendDATA(); return SUCCESS; }

  20. NesC Programming (con't) • SimpleRf (con’t) event TOS_MsgPtr RadioReceive.receive(TOS_MsgPtr packet) { call Leds.redToggle(); return packet; } event result_t RadioSend.sendDone(TOS_MsgPtr msg, result_t success) { return SUCCESS; } }

More Related