Example Application: Sense

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

 

  1. Node Configuration

#include "gen/cSense_TinyOSModule.h"
#include "gen/cSense_Main.h"

   cSense_Main *m = new cSense_Main(this,main,"Main",getIndex());
   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@sinan tictoc]# cd components/
[root@sinan components]# cp Sense.nc ../Application.nc
[root@sinan components]# cd ..
[root@sinan tictoc]# ./nesct.exe Application.nc

done.

  1. Updating Makefile

  Type makemake.bat/makemake.sh to create new Makefile for Win32/Linux.
  1. Build

Type "make" 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:4.05357925: LEDS: Red on.
0:0:4.05357925: LEDS: Red on.
0:0:4.05357925: LEDS: Red off.
0:0:4.54182925: HPLADC: request for port 1
0:0:4.54182925: HPLADC: request for port 1
0:0:4.54182925: HPLADC: request for port 1
0:0:4.54182925: adc_tick: port 1 with value 16882
0:0:4.54182925: adc_tick: port 1 with value 7931
0:0:4.54182925: adc_tick: port 1 with value 43491
0:0:4.54182925: LEDS: Yellow off.
0:0:4.54182925: LEDS: Yellow off.
0:0:4.54182925: LEDS: Yellow off.
0:0:4.54182925: LEDS: Green off.
0:0:4.54182925: LEDS: Green on.
0:0:4.54182925: LEDS: Green off.
0:0:4.54182925: LEDS: Red on.
0:0:4.54182925: LEDS: Red off.
0:0:4.54182925: LEDS: Red on.




                               

 


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