Example Application: CntToLedsAndRfm

  1. Node Configuration
  2. Code Generation
  3. Updating Makefile
  4. Build
  5. Run

 

  1. Node Configuration

#include "gen/cRfmToLeds_TinyOSModule.h"
#include "gen/cRfmToLeds_Main.h"
#include "gen/cCntToLedsAndRfm_TinyOSModule.h"
#include "gen/cCntToLedsAndRfm_Main.h"

if (index() == 0)
{
   cCntToLedsAndRfm_Main *m = new cCntToLedsAndRfm_Main(this,main,"Main",index());
   m->StdControl_init();
   m->StdControl_start();
}
else
{
   cRfmToLeds_Main *m = new cRfmToLeds_Main(this,main,"Main",index());
   m->StdControl_init();
   m->StdControl_start();
}

  1. Code Generation

NesCT is going to build all the classes in gen directory. Replace "cp" with "copy" and slash (/) with backslash (\) for windows operating system at the following instructions.

[root@maros-lin opt]# cd tictoc
[root@maros-lin tictoc]# cd components
[root@maros-lin components]# cp CntToLedsAndRfm.nc ../Application.nc
[root@maros-lin components]# cd ..
[root@maros-lin tictoc]# ./nesct.exe Application.nc

Enter components directory again:
[root@maros-lin components]# cp RfmToLeds.nc ../Application.nc
[root@maros-lin components]# cd ..
[root@maros-lin tictoc]# ./nesct.exe Application.nc

  1. Updating Makefile

Type 'opp_makemake -c config -f' to create new Makefile for your environment. If your build environment is windows type 'opp_nmakemake -c config.win32 -f' for visual studio to create new Makefile for your environment. Additionally, you need to run 'nmake -f Makefile.vc depend' for windows.

Note that, NesCT assumes that your OMNeT++ distribution is in /opt/omnetpp-3.2 for linux and in c:\omnet++ for windows. If it is installed at some other directory, you'll need to edit config or config.win32 file to change the path for nedtool, lib and include directories of OMNeT++.


[root@sinan tictoc]# opp_makemake -c config -f
Makefile created, adding dependencies...
Done.

  1. Build

Type "make" for linux, "nmake -f makefile.vc" for windows to build the binary.

[root@sinan tictoc]# make
g++ -c -g -fpermissive -fPIC -DWITH_NETBUILDER -w -DTOSNODES=1000 -DLINUX -DPLATFORM_OMNETPP -I./include -I/root/projects/tinyos-1.x/tos/interfaces -I./include_tos -I/opt/omnetpp-3.2/include simstart.cc
g++ tictoc1_n.o debug.o simstart.o tinyos.o tinyosmain.o tossim.o txc1.o -g -L/opt/omnetpp-3.2/lib -lenvir -lcmdenv -lsim_std -lnedxml -lxml2 -ldl -lstdc++ -lpthread -o tictoc
echo>.tstamp

  1. Run

Let's enable all debug options for demonstration purposes. Use "export" keyword for linux and "set" keyword for windows to change environment variable. You should see an output similar to this in TK window.

                           

[root@sinan tictoc]# export DBG=all
[root@sinan tictoc]# ./tictoc
0:0:3.10051525: LEDS: Red on.
0:0:3.10051525: LEDS: Red on.
0:0:3.10051525: LEDS: Red on.
0:0:3.10051525: POWER: Mote 1 LED_STATE RED_ON at 12402061
0:0:3.10051525: POWER: Mote 2 LED_STATE RED_ON at 12402061
0:0:3.10051525: LEDS: Green off.
0:0:3.10051525: LEDS: Green off.
0:0:3.10051525: LEDS: Green off.
0:0:3.10051525: POWER: Mote 1 LED_STATE GREEN_OFF at 12402061
0:0:3.10051525: POWER: Mote 2 LED_STATE GREEN_OFF at 12402061
0:0:3.10051525: LEDS: Yellow off.
0:0:3.10051525: LEDS: Yellow off.
0:0:3.10051525: LEDS: Yellow off.
0:0:3.10051525: POWER: Mote 1 LED_STATE YELLOW_OFF at 12402061
0:0:3.10051525: POWER: Mote 2 LED_STATE YELLOW_OFF at 12402061
0:0:3.10051525: Sending message: ffff, 4
0:0:3.10051525: Sending message: ffff, 4
0:0:3.10051525: Sending message: ffff, 4
0:0:3.10051525: TossimPacketM: Sending Message
0:0:3.10051525: TossimPacketM: Sending Message
0:0:3.10051525: TossimPacketM: Sending Message


                               

 


This project has been supported by Featherlight project at University of Twente, the Netherlands and European Embedded WiseNt project at Yeditepe University.