Wednesday 23 November 2011

Getting MSP430 error and another errors in tinyos-2.1.1

When I tried to install tinyos-2.1.1 in Ubuntu-11.04, I found a terrible errors in make commands such as Error in MSP430 and when I tried to reinstall this rpm I faced errors again.

I was following instructions installation in http://docs.tinyos.net/tinywiki/index.php/Installing_TinyOS_2.1.1.
Then I released that the problem was in this command:
 deb http://hinrg.cs.jhu.edu/tinyos karmic main

So I tried to install tinyos-2.1.1 from another source and it work fine, no MSP430 error and no errors in make commands.
I write instructions instillation down in this link:
http://wsn-tinyos.blogspot.com/2011/08/tinyos-211-installation-steps-using.html

 
 

Monday 21 November 2011

Using User Button in TELOSB for multi-func

Hi,
Today I tried an experiment to use TelosB user button to do more than one function. e.g. user button can used to activate a spacific procedre or set a value to a variable (almost one function), while we can use it to do more than one function just by clicking on it.

Here an example for three moods each of them connected to specific function. First of all user button used to determine the mood on long click (3 seconds switch to mood Red, 6 seconds switch to mood Yellow, and 9 seconds switch to mood Blue) after mood set  user button now will used to do the chosen mood function.
In this example:
I used user button to increase variables each connected to mood.
redVar increases if Red mood selected
yellowVar increases if Yellow mood selected
blueVar increases if Blue mood selected

Here is the code (looks like long but very simple indeed):
// TestUserButtonAppC.nc file

configuration TestUserButtonAppC {}
implementation {

  components TestUserButtonC;

  components MainC;
  TestUserButtonC.Boot -> MainC;
 
  components UserButtonC;
  TestUserButtonC.Get -> UserButtonC;
  TestUserButtonC.Notify -> UserButtonC;

  components LedsC;
  TestUserButtonC.Leds -> LedsC;

  components new TimerMilliC() as MoodTimerC;
  TestUserButtonC.MoodTimer -> MoodTimerC;
  components new TimerMilliC() as MoodTimerFuncC;
  TestUserButtonC.MoodTimerFunc -> MoodTimerFuncC;
}

 // TestUserButtonC.nc file
#include <Timer.h>
#include <UserButton.h>

module TestUserButtonC {
  uses {
    interface Boot;
    interface Get<button_state_t>;
    interface Notify<button_state_t>;
    interface Leds;
    interface Timer<TMilli> as MoodTimer;
    interface Timer<TMilli> as MoodTimerFunc;

  }
}
implementation {
  uint8_t mood;
  uint8_t isMoodFuncTimerStart;
  uint8_t redVar;
  uint8_t yellowVar;
  uint8_t blueVar;

  event void Boot.booted() {
    call Notify.enable();
    mood=0;       
    isMoodFuncTimerStart=0;
    redVar=0;
    yellowVar=0;
    blueVar=0;
  }
 
  event void Notify.notify( button_state_t state ) {
    if ( state == BUTTON_PRESSED && mood==0) {
    call MoodTimer.startPeriodic( 3000 );
    } else if ( state == BUTTON_PRESSED && mood!=0 ) {
       call MoodTimerFunc.startPeriodic(1000);
       isMoodFuncTimerStart = 1;
    } else if ( state == BUTTON_RELEASED && isMoodFuncTimerStart==0) {
       call MoodTimer.stop();     

    } else if ( state == BUTTON_RELEASED && isMoodFuncTimerStart==1) {
       call MoodTimerFunc.stop();     
    }

  }
  event void MoodTimer.fired() {   
   if(mood==0)
    {
     mood=1;
     call Leds.led0On();
     call Leds.led1Off();
     call Leds.led2Off();

    }
   else
   if(mood==1)
    {   
     mood=2;
     call Leds.led1On();
     call Leds.led0Off();
     call Leds.led2Off();
    }
  else
   if(mood==2)
    {   
     mood=3;
     call Leds.led2On();
     call Leds.led1Off();
     call Leds.led0Off();

    }
  else
    {   
     mood=0;
     call Leds.led0Off();
     call Leds.led1Off();
     call Leds.led2Off();
    }
  }
  event void MoodTimerFunc.fired() {   
   if(mood==1) // RED mood, toggle yellow
    {
      // write RED procedure here e.g.
         redVar= redVar+1;

     call Leds.led1Toggle();
    }   
   else
   if(mood==2) // Yellow mood, toggle blue
    {
      // write Yellow procedure here
         yellowVar= yellowVar+1;

     call Leds.led2Toggle();
    }   
   else
   if(mood==3) // Blue mood, toggle red
    {
      // write Blue procedure here
         blueVar= blueVar+1;

     call Leds.led0Toggle();
    }   
  }
}
// end.

Saturday 20 August 2011

Installing and Test BLIP 6LoWPAN implementation using Telosb & MicaZ platforms

- BLIP is one of some well known 6LowPAN implementation (6LowPAN IPv6 packets to be sent to and received from over IEEE 802.15.4 based networks).
- BLIP included as a core part of TinyOS-2.1.1 so you need to install tinyos-2.1.1 if you want to use blip. 

Steps of install BLIP:
  1. Add an 802.15.4 interface to the device (Edge router).
  2. Upload your program image on the motes (node router)
  3. Compile and run the routing driver (on pc/laptop).
  4. Communicate with motes via IPV6.

BLIP Network Items



















 1- Upload blip Interface on edge router
  • cd $TOSROOT/apps/IPBaseStation
  • $ make telosb blip install 
    (for telosb mote)
  • $ make micaz blip install  mib520, /dev/ttyUSB0
    (for micaz mote)
 2- Upload program image on node routers 
  • cd $TOSROOT/apps/UPDEcho
  • make micaz blip install,ID mib520,/dev/ttyUSB0
  • make telosb blip install,ID
3- Compile and run routing driver on PC/laptop
Build it first (for one time): 
cd $TOSROOT/support/sdk/c/sf
./bootstrap
./configure
make
cd $TOSROOT/support/sdk/c/blip
./bootstrap.sh
./configure
make
 
While you are still in the $TOSROOT/support/sdk/c/blip directory run routing driver
sudo driver/ip-driver /dev/ttyUSB1 micaz

- Router driver loads its configuration from $TOSROOT/support/sdk/c/blip/serial_tun.conf.
  You can change channel # and IPv6 prefix fec0:: used.
4- Test connection
    ping6 fec0::ID
 
- fec0::/10 This is a site-local prefix  offered by IPv6.
- The prefix fec0:: is coming from serial_tun.conf file and the suffix is coming from Node Id. 
 

TinyOS-2.1.1 configuration


Edit $TOSROOT/tinyos.sh file
sudo gedit /opt/tinyos-2.1.1/tinyos.sh
add /tinyos.jar to the end of CLASSPATH to be : CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java/tinyos.jar
Also edit user bash file as following:
sudo gedit ~/.bashrc
and add this line to the end of the file

source /opt/tinyos-2.1.1/tinyos.sh
You can export some helpful directories export apps=$TOSROOT/apps
export blipdir=$TOSROOT/support/sdk/c/blip
cd $apps





 

TinyOS-2.1.1 installation steps using ubuntu-11.04


Open Terminal to edit sources.list file 
sudo gedit /etc/apt/sources.list
add this line at the end of the file opened
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu karmic main
“karmic” for all type of ubuntu distribution.
Install aptitude package
sudo apt-get install aptitude
Install autoconf package
sudo apt-get install autoconf2.13
Then type this command to install TinyOS-2.1.1
sudo aptitude install tinyos-2.1.1 
Maybe you will need to change the owner of the tinyos-2.1.1 folder
sudo chown –R username:group /opt/tinyos-2.1.1/
    change username and group by your user name and group.