Saturday, November 16, 2013

Simulation of nodes on TOSSIM

11:33 PM By Unknown , , , , , , 1 comment


I have already written a post on how to simulate a TOSSIM program on MSPSim silulator. However, the issue is that when I tried simulating MicaZ platform on it, it won't work so I thought of going back to the simulator already present in TOSSIM which I could not get to work. It kept throwing error saying "Python.h not found" and a few other python related errors. Few sites suggested to install python but I already had python on my system and yet could not get things to work.

So I began searching for a way to make it work and following are the steps which removed my error:

I am assuming that TOSSIM is already installed on your system. If not, please install it first by following the steps available on many sites. 

Open the .bashrc file by typing the following on terminal 
$ sudo gedit ~/.bashrc

Add the following line at the end of .bashrc file:
export PYTHONPATH=$TOSROOT/support/sdk/python


Close the current terminal and Open a new one and you should be able to see message like setting up TinyOS from tinyos-2.x.sh file.

Few sites said once this is done we are ready to install example application on Sensor mote. However I had to the following extra step as I still kept getting error saying 

fatal error: Python.h: No such file or directory

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications. To install this package, enter:

$ sudo apt-get install python-dev
OR

$ apt-get install python-dev
Now we can simulate our program/application on TOSSIM.

1. Change directory to application directory and make for micaz (for TinyOS2.x, TOSSIM provide simulation of MICAz motes only).

$ cd /opt/tinyos-2.x/apps/RadioCountToLeds
$ make micaz sim


2. On successful completion it will create TOSSIM library and you will get message on console something like.

*** Successfully built micaz TOSSIM library.

3. Now open python interpreter and type following code to create a mote (node) and boot it up.

$ python
>>> from TOSSIM import *
// Imports the TOSSIM library.
>>> t = Tossim([])
// Creates a TOSSIM object.
>>> m = t.getNode(32)
// getNode will return the object represented by specific mote (ID as 32).
>>> m.bootAtTime(45654)
// node will boot at time 45654.
>>> t.runNextEvent()
// After the statement for booting. We have an event to run so this command will run that event and boot up the mote.



Hope this helps!


Picture courtesy: Google

1 comments:

  1. hey .. I am facing the same error as you have mentioned above .. Tried the solution given above .. It isn't working any other way to solve this issue ? The error i get is :

    /opt/tinyos-2.1.1/tos/lib/tossim/tossim_wrap.cxx:139:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    make: *** [sim-exe] Error 1

    ReplyDelete