Presentation is loading. Please wait.

Presentation is loading. Please wait.

PtinyOS: Simulating TinyOS in Ptolemy II Elaine Cheong Dec 10, 2004 EE290N Project Presentation (Initial NC code generator by Yang Zhao and Edward Lee)

Similar presentations


Presentation on theme: "PtinyOS: Simulating TinyOS in Ptolemy II Elaine Cheong Dec 10, 2004 EE290N Project Presentation (Initial NC code generator by Yang Zhao and Edward Lee)"— Presentation transcript:

1 PtinyOS: Simulating TinyOS in Ptolemy II Elaine Cheong Dec 10, 2004 EE290N Project Presentation (Initial NC code generator by Yang Zhao and Edward Lee)

2 Motivation Infrastructure for sensor network research VisualSense Pro: provides network level simulation Con: lacks real code simulation TinyOS Pro: provides interrupt level simulation Con: lacks detailed environment models and heterogenous node simulation

3 VisualSense

4 TinyViz/SimDriver/Tython

5 nesC includes TestTinyViz; configuration TestTinyViz { } implementation { components Main, TestTinyVizM, TimerC, RandomLFSR, GenericComm as Comm; Main.StdControl -> Comm; Main.StdControl -> TimerC; Main.StdControl -> TestTinyVizM; TestTinyVizM.Random -> RandomLFSR; TestTinyVizM.Timer -> TimerC.Timer[unique("Timer")]; TestTinyVizM.SendMsg -> Comm.SendMsg[AM_TESTTINYVIZ]; TestTinyVizM.ReceiveMsg -> Comm.ReceiveMsg[AM_TESTTINYVIZ]; } TestTinyViz.nc module TestTinyVizM { provides { interface StdControl; } uses { interface Timer; interface ReceiveMsg; interface SendMsg; interface Random; } } implementation { enum { MAX_NEIGHBORS = 8, }; uint16_t neighbors[MAX_NEIGHBORS]; TOS_Msg beacon_packet; command result_t StdControl.init() { int i; for (i = 0; i < MAX_NEIGHBORS; i++) { neighbors[i] = 0xffff; } *((uint16_t *)beacon_packet.data) = TOS_LOCAL_ADDRESS; return call Random.init(); } 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() { uint16_t nbr; nbr = call Random.rand() % MAX_NEIGHBORS; // Don't worry if we can't send the message if (neighbors[nbr] != 0xffff) { dbg(DBG_USR1, "TestTinyVizM: Sending message to node %d\n", neighbors[nbr]); call SendMsg.send(neighbors[nbr], sizeof(uint16_t), &beacon_packet); } else { dbg(DBG_USR1, "TestTinyVizM: Sending beacon\n"); call SendMsg.send(TOS_BCAST_ADDR, sizeof(uint16_t), &beacon_packet); } return SUCCESS; } event result_t SendMsg.sendDone(TOS_MsgPtr msg, bool success) { dbg(DBG_USR1, "TestTinyVizM: Done sending, success=%d\n", success); return SUCCESS; } event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr recv_packet) { int n; uint16_t nodeaddr = *((uint16_t *)recv_packet->data); dbg(DBG_USR1, "TestTinyVizM: Received message from %d\n", nodeaddr); for (n = 0; n < MAX_NEIGHBORS; n++) { if (neighbors[n] == 0xffff) { neighbors[n] = nodeaddr; break; } return recv_packet; }

6 TinyOS includes TestTinyViz; configuration TestTinyViz { } implementation { components Main, TestTinyVizM, TimerC, RandomLFSR, GenericComm as Comm; Main.StdControl -> Comm; Main.StdControl -> TimerC; Main.StdControl -> TestTinyVizM; TestTinyVizM.Random -> RandomLFSR; TestTinyVizM.Timer -> TimerC.Timer[unique("Timer")]; TestTinyVizM.SendMsg -> Comm.SendMsg[AM_TESTTINYVIZ]; TestTinyVizM.ReceiveMsg -> Comm.ReceiveMsg[AM_TESTTINYVIZ]; } TestTinyViz.nc celaine:~/tos/apps/TestTinyViz: build/pc/main.exe 1 SIM: EEPROM system initialized. SIM: event queue initialized. SIM: Random seed is 783860 SIM: Initializing sockets SIM: Created server socket listening on port 10584. SIM: Created server socket listening on port 10585. SIM: eventAcceptThread running. SIM: commandReadThread running. SIM: Time for mote 0 initialized to 33403762. 0: BOOT: Scheduling for boot at 0:0:8.35094050. 0: Popping event for mote 0 with time 0:0:8.35094050. 0: Setting TOS_LOCAL_ADDRESS to 0 0: BOOT: Mote booting at time 0:0:8.35094050. 0: CLOCK: Setting clock rate to interval 231, scale 3 0: malloc data entry for clock event: 0x812b4b0 0: UART initialized. 0: RANDOM_LFSR initialized. 0: malloc channel mon event. 0: malloc Channel Mon event data. 0: AM Module initialized 0: CLOCK: Setting clock rate to interval 231, scale 3 0: malloc data entry for clock event: 0x812b528 0: RANDOM_LFSR initialized. 0: UART started. nesC compiler

7 PtinyOS Editor Front end to nesC compiler Simulator (interface to TOSSIM) Simulator (interface to other Ptolemy II domains)

8 PtinyOS as Editor configuration CntToLeds { } implementation { components Main, TimerC, IntToLeds, Counter; Main.StdControl -> TimerC.StdControl; Counter.Timer -> TimerC.Timer[unique("Timer")]; Counter.IntOutput -> IntToLeds.IntOutput; Main.StdControl -> IntToLeds.StdControl; Main.StdControl -> Counter.StdControl; }

9 PtinyOS as Simulator

10 PtinyOS Director preinitialize() Generate.nc file(s) and makefile Call make Compile.nc code with nesC compiler Create shared library (.so or.dll) initialize() Load shared library Call TOSSIM main() Boot virtual mote fire() Process all events with same timestamp Process all TinyOS tasks in task queue

11 Related Work GRATIS II TinyViz ATEMU Avrora Em* (EMTOS)

12 Future Work Single node radio simulation Multiple node simulation Homogenous Heterogeneous Integration with VisualSense TinyGALS Distributed programming for sensor networks

13 Demo


Download ppt "PtinyOS: Simulating TinyOS in Ptolemy II Elaine Cheong Dec 10, 2004 EE290N Project Presentation (Initial NC code generator by Yang Zhao and Edward Lee)"

Similar presentations


Ads by Google