1 / 14

Wireless Embedded Systems (0120442x) Sensor Network Programming and MoteLib Simulator

Wireless Embedded Systems (0120442x) Sensor Network Programming and MoteLib Simulator. Chaiporn Jaikaeo chaiporn.j@ku.ac.th Department of Computer Engineering Kasetsart University. Outline. Network programming with MoteLib MoteSim – MoteLib's Simulator. Virtual Mote.

glenda
Download Presentation

Wireless Embedded Systems (0120442x) Sensor Network Programming and MoteLib Simulator

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. Wireless Embedded Systems(0120442x)Sensor Network Programmingand MoteLib Simulator Chaiporn Jaikaeo chaiporn.j@ku.ac.th Department of Computer EngineeringKasetsart University

  2. Outline • Network programming with MoteLib • MoteSim – MoteLib's Simulator

  3. Virtual Mote Mote and Network Emulator

  4. Mote and Network Simulation • Motes are modeled with standard C program • Exact same code as used for the actual hardware • Network is modeled with Python program from motesim import Simulator, Mote MOTEAPP = 'build/sim/count-radio.elf' sim = Simulator() sim.addNode(Mote(MOTEAPP), (100,100)) sim.addNode(Mote(MOTEAPP), (200,100)) sim.run()

  5. Creating Executable for Simulator • Executable for simulator can be built by running • Executable will be stored under build/simdirectory make PLATFORM=sim

  6. Modeling Network • Network is modeled with Python • Make sure the following directories are part of PYTHONPATH • Try the following program sim-blink.py • Can be found in examples/ directory $MOTELIB_DIR/platforms/sim/python $MOTELIB_DIR/lib/python from motesim import Simulator, Mote sim = Simulator() sim.addNode(Mote('build/sim/blink.elf'), (100,100)) sim.addNode(Mote('build/sim/blink.elf'), (200,100)) sim.run()

  7. Create a mote running 'blink' app Create a mote running 'count' app Add m2 to the simulationat position (200,100) Virtual Mote Creation • Virtual mote object can be instantiated from class Mote • Each virtual mote instance must be added to the simulation using addNode method from motesim import Simulator, Mote sim = Simulator() m1 = Mote('build/sim/blink.elf') m2 = Mote('build/sim/count.elf') sim.addNode(m1, (100,100)) sim.addNode(m2, (200,100)) sim.run()

  8. Enabling Python Console • IPython is recommended for better interaction from motesim import Simulator, Mote sim = Simulator() sim.addNode(Mote('build/sim/blink.elf'), (100,100)) sim.addNode(Mote('build/sim/blink.elf'), (200,100)) sim.run(script=sim.console) $ sudo apt-get install ipython

  9. Accessing Node Objects • Node objects are stored in the node list inside sim object >>> n = sim.nodes[2] >>> dir(n)

  10. Turning Node On and Off • Node can be turned off using shutdown()method • boot() method turns node back on >>> sim.nodes[3].shutdown() >>> sim.nodes[3].boot()

  11. Emulating Button • Button pressing can be emulated by two methods: • pressButton() • releaseButton() >>> n = sim.nodes[3] >>> n.pressButton() >>> n.releaseButton()

  12. Emulating UART • Node's UART interface can be emulated via TCP socket • Not activated by default • Use activateSocket() inside node's uart object to activate >>> n = sim.nodes[3] >>> n.uart.activateSocket() ('0.0.0.0', 32345) >>> $ telnet localhost 57597 Trying 0.0.0.0... Connected to 0. Escape character is '^]'. ^] telnet> mode c Listening port switch to character mode

  13. Exercise: Voting Machine • Reimplement the wireless voting application • Allow user to cast a vote using the USER button • Voting choices are: Red (1), Yellow (2), Green (3), or No Vote (0) • When the USER button is pressed, • Set LED status accordingly • Report current vote to the base station (#0) with message type 50 • Integrate base station functionality into your app

  14. Exercise (cont'd) • Create a virtual network with 5 nodes • Activate UART at base station (node #0) • Telnet to the open port • Emulate button pressing at other nodes

More Related