Thursday, May 31, 2012

Networking concepts


Hub, Repeater, Switch, Bridge, Router and Gateway

   Major differences between different networking devices are mentioned in this table.



Network Devices
OSI layer corresponds to the Device
Functions
Hub
Physical
Multiport repeater.
Any electrical signal that comes into one port, goes out of all other ports.
Does not examine or manage traffic.
Repeater
Physical
Regenerates the signal.
Connects two segments of a network cable.
Extends physical length of network.
Is a re-generator not an amplifier.
Active hubs.
Switch
Data link
Connects n/w segments or n/w devices.
Is a multipoint network bridge(bridge with numerous o/p ports).
Process and routes data to the intended receiver.
Intelligent than hub.
Multilayer switch works on Data link and Network layer.
Reduces traffic and divide the collision domain into segments.
Uses MAC address for communication.
Bridge
Data link
A combination of hardware and software to link two similar networks.
Divides a large network to smaller segments.
Very much alike switch.
Does data filtering and separating the collision domain like switch.
Slower compared to switch since it uses s/w for switching.
Controls congestion and isolation.
Uses MAC address for communication.
Router
Network
Route data packets between different networks of same type.
Can connect networks with different architecture like Token Ring and Ethernet.
Cannot connect networks of different protocols like TCP/IP and IPX/SPX.
Controls both collision domains and broadcast domains.
Uses IP address for communication.
Ability to identify best route for the packet to travel using a routing table.
Gateway
Application, Network, Session
Interconnects networks with different network protocol technologies by performing the required protocol conversions.
Very intelligent device
Works at network layer and above, but mostly work at application layer.
Mostly it is a software installed in router.

Tuesday, May 29, 2012

Multiple sensors interfacing to Telosb through I2C connection

   Here i have interfaced two sensors, accelerometer and temperature sensor with Telosb mote using parallel I2C connection. Zigbee part is also integrated with the program.

Connection

TMP102 GND   -> TELOSB 9 pin (GND)
TMP102 VCC    -> TELOSB 1 pin (VCC)
TMP102 SDA    -> TELOSB 8 pin (SDA)
TMP102 SCL    -> TELOSB 6 pin (SCL)
TMP102 ADD0 -> TELOSB 9 pin (GND)
TMP102 ALT    -> Left unconnected

ADXL345 GND -> TELOSB 9 pin (GND)
ADXL345 VCC  -> TELOSB 1 pin (VCC)
ADXL345 CS     -> TELOSB 1 pin (VCC)
ADXL345 SDA  -> TELOSB 8 pin (SDA)
ADXL345 SCL  -> TELOSB 6 pin  (SCL)
ADXL345 SDO  -> TELOSB 9 pin (GND)


The circuit i created for interfacing the sensors with Telosb is given below. I have used an intermediate interfacing board for connection.





Program

   Transmitter Program

      Programming is done with Nesc in TinyOS. Four main files are here I2CAPPC.nc, , I2CC.nc, I2CRadio.h and Makefile.


I2CAPPC.nc
#include "I2CRadio.h"

configuration I2CAppC{
}

implementation {
   components MainC, I2CC as App;
   App.Boot -> MainC;

   components LedsC;
   App.Leds -> LedsC;

   components new TimerMilliC() as I2CTimer;
   App.I2CTimer -> I2CTimer;

   components new ADXL345C();
   App.axis -> ADXL345C.XYZ;
   App.AccelControl -> ADXL345C.SplitControl;

   components new SimpleTMP102C();
   App.Temp -> SimpleTMP102C.Read;

   components new AMSenderC(AM_I2C);
   App.Packet -> AMSenderC;
   App.AMPacket -> AMSenderC;
   App.AMSend -> AMSenderC;

   components ActiveMessageC;
   App.AMControl -> ActiveMessageC.SplitControl;

   components new AMReceiverC(AM_I2C);
   App.Receive -> AMReceiverC;
}

I2CAPPC.nc
#include "printf.h"
#include "ADXL345.h"
module I2CC {
   uses {
      interface Boot;
      interface Leds;
      interface Timer as I2CTimer;
      interface Read as axis;
      interface SplitControl as AccelControl;
      interface Read as Temp;

      interface Packet;
      interface AMPacket;
      interface AMSend;
      interface SplitControl as AMControl;

      interface Receive;
   }
}

implementation {

   bool busy = FALSE;
   message_t pkt;
   uint16_t counter = 0;

   nx_uint16_t X;
   nx_uint16_t Y;
   nx_uint16_t Z;
   nx_uint16_t Tem;

   event void Boot.booted() {
      call AccelControl.start();
   }

   event void AccelControl.startDone(error_t err) {
      printf("\n\n------Accelerometer started-----\n\n");
      call I2CTimer.startPeriodic(1000);
   }

   event void AccelControl.stopDone(error_t err) {
   }

   event void I2CTimer.fired() {
      counter++;
      call Leds.led0Toggle();
      call axis.read();
   }

   event void axis.readDone(error_t result, adxl345_readxyt_t data) {
      if (result == SUCCESS) {
         X = data.x_axis;
         Y = data.y_axis;
         Z = data.z_axis;
         printf("\nX [%d] Y [%d] Z [%d]\n",X,Y,Z);
         call Temp.read();
      }
      else printf("Error in reading Accelerometer sensor\n");
   }

   event void Temp.readDone(error_t err, uint16_t temp) {
      if (err == SUCCESS) {
         call Leds.led1Toggle();
         temp=temp*6.25;
Tem=temp;
         printf("Temperature = %d.%d\n\n",temp/100, temp%100);
         printfflush();
         call AMControl.start();
      }
      //***************AM Part********************
      else printf("Error in reading Temperature sensor\n");
   }
   
   event void AMControl.startDone(error_t res) {
      if (res == SUCCESS) {
 //        printf("****AM STARTED****\n");
         if (!busy) {
            I2CRadioMsg* i2cpkt=(I2CRadioMsg*)(call Packet.getPayload(&pkt,sizeof(I2CRadioMsg)));
            i2cpkt -> counter = counter;
            i2cpkt -> xaxis = X;
            i2cpkt -> yaxis = Y;
            i2cpkt -> zaxis = Z;
            i2cpkt -> temp = Tem;
            if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(I2CRadioMsg)) == SUCCESS) {
               busy = TRUE;
               call Leds.led2Toggle();
            }
         }
      }
      else {
         call AMControl.start();
      }
   }

   event void AMControl.stopDone(error_t error) {
   }

   event void AMSend.sendDone(message_t* msg, error_t error) {
      if (&pkt == msg) busy=FALSE;
      call AMControl.stop();
   }

   event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) {
   }
}

I2CRadio.h
#ifndef I2CRADIO_H
#define I2CRADIO_H

typedef nx_struct I2CRadioMsg {
   nx_uint16_t counter;
   nx_uint16_t xaxis;
   nx_uint16_t yaxis;
   nx_uint16_t zaxis;  
   nx_uint16_t temp;  
}I2CRadioMsg;

enum {
   AM_I2C = 7,
};
#endif

Makefile
COMPONENT=I2CAppC
CFLAGS += -I$(TOSDIR)/lib/printf
CFLAGS += -I$(TOSDIR)/chips/adxl345
CFLAGS += -I$(TOSDIR)/chips/tmp102

include $(MAKERULES) 

Monday, April 30, 2012

TMP102 temperature sensor integration with TelosB mote

Here is a very simple NesC code for getting temperature value from TMP102 digital Temperature sensor with Telosb mote.

Connection
 
TMP102 GND   -> TELOSB 9 pin
TMP102 VCC    -> TELOSB 1 pin
TMP102 ADD0  -> TELOSB 9 pin
TMP102 SDA    -> TELOSB 8 pin 
TMP102 SCL    -> TELOSB 6 pin  

Apart from this connect pull-up resistor(10 KOhm) from SDA &SCL to VCC.

Program

Program has  three main files Accelerometer345AppC.nc, Accelerometer345C.nc and Makefile.

TMP102AppC.nc
configuration TMP102AppC {
}

implementation {
  components MainC, TMP102C as App;
  App.Boot -> MainC;

  components LedsC;
  App.Leds -> LedsC;
  
  components new TimerMilliC() as TimerTemp;
  App.TimerTemp -> TimerTemp;

  components new SimpleTMP102C();
  App.Temp -> SimpleTMP102C.Read;
}

TMP102C.nc
#include "printf.h"

module TMP102C {
  uses {
    interface Boot;
    interface Leds;
    interface Timer as TimerTemp;
    interface Read as Temp;
  }
}

implementation {

  event void Boot.booted() {
    printf("Temperature sensor starting..\n\n");
    call TimerTemp.startPeriodic(1000);
  }

  event void TimerTemp.fired() {
    call Leds.led0On();
    call Temp.read();
  }  

  event void Temp.readDone(error_t result, uint16_t temp) {
    temp=temp*0.0625;
    if (result == SUCCESS) printf("Temperature = %d \n", temp);
    else printf("Error..\n");
    printfflush();
    call Leds.led0Off();
  }
}

Makefile
COMPONENT=TMP102AppC
CFLAGS += -I$(TOSDIR)/lib/printf
CFLAGS += -I$(TOSDIR)/chips/tmp102

include $(MAKERULES)



Files SimpleTMP102C and SimpleTMP102P can be downloaded from TinyOS trunk or use these files given below.

SimpleTMP102C
generic configuration SimpleTMP102C() {
  provides interface Read;
}
implementation {
  components SimpleTMP102P;
  Read = SimpleTMP102P;

  components new TimerMilliC() as TimerSensor;
  SimpleTMP102P.TimerSensor -> TimerSensor;

  components new TimerMilliC() as TimerFail;
  SimpleTMP102P.TimerFail -> TimerFail;

  components new Msp430I2CC();
  SimpleTMP102P.Resource -> Msp430I2CC;
  SimpleTMP102P.ResourceRequested -> Msp430I2CC;
  SimpleTMP102P.I2CBasicAddr -> Msp430I2CC;     
}

SimpleTMP102C 
#include "TMP102.h"

module SimpleTMP102P {
   provides interface Read;
   uses {
    interface Timer as TimerSensor;
    interface Timer as TimerFail;
    interface Resource;
    interface ResourceRequested;
    interface I2CPacket as I2CBasicAddr;        
  }
}

implementation {
  
  uint16_t temp;
  uint8_t pointer;
  uint8_t temperaturebuff[2];
  uint16_t tmpaddr;
  
  norace uint8_t tempcmd;
    
  task void calculateTemp(){
    uint16_t tmp = temp;
    signal Read.readDone(SUCCESS, tmp);
  }
  
  command error_t Read.read(){
 call TimerSensor.startOneShot(100);
 return SUCCESS;
  }

  event void TimerSensor.fired() {
 call Resource.request();  
  }
  
  event void TimerFail.fired() {
   signal Read.readDone(SUCCESS, 0);
  }

  event void Resource.granted(){
    error_t error;
    pointer = TMP102_TEMPREG;
    tempcmd = TMP_READ_TMP;
    error= call I2CBasicAddr.write((I2C_START | I2C_STOP), TMP102_ADDRESS, 1, &pointer); 
    if(error){
      call Resource.release();
      signal Read.readDone(error, 0);
    }
  }
  
  async event void I2CBasicAddr.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t *data){
    if(call Resource.isOwner()) {
 uint16_t tmp;
 for(tmp=0;tmp<0xffff;tmp++); //delay
 call Resource.release();
        printf("\nMSB = %d  ",data[0]);
        printf("LSB = %d\n",data[1]);
 tmp = data[0];
 tmp = tmp << 8;
 tmp = tmp + data[1];
 tmp = tmp >> 4;
 atomic temp = tmp;
 post calculateTemp();
 }
  }

  async event void I2CBasicAddr.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t *data){
    if(call Resource.isOwner()){
      error_t e;
      e = call I2CBasicAddr.read((I2C_START | I2C_STOP),  TMP102_ADDRESS, 2, temperaturebuff);
      if(e){
        call Resource.release();
        signal Read.readDone(error, 0);
       }
     }
  }   
  
  async event void ResourceRequested.requested(){ }
  async event void ResourceRequested.immediateRequested(){ }   
  
}

TMP102.h
#ifndef TMP102_H
#define TMP102_H
#define TMP102_ADDRESS          0x48
#define TMP102_TEMPREG          0x00
#define TMP102_CONFREG          0x01
#define TMP_READ_TMP    1

#endif

Thursday, April 19, 2012

ADXL345 accelerometer integration with TelosB mote

Here is a very simple NesC code for getting X, Y and Z axis value from ADXL345 digital accelerometer with Telosb mote.

Connection
 
ADXL345 GND -> TELOSB 9 pin
ADXL345 VCC  -> TELOSB 1 pin
ADXL345 CS     -> TELOSB 1 pin
ADXL345 SDA  -> TELOSB 8 pin 
ADXL345 SCL  -> TELOSB 6 pin  

Apart from this connect pull-up resistor(10 KOhm) from SDA &SCL to VCC.

Program

Program has  three main files Accelerometer345AppC.nc, Accelerometer345C.nc and Makefile.

Acclerometer345AppC.nc
configuration Accelerometer345AppC {
}

implementation {
  components MainC, Accelerometer345C as App;
  App.Boot -> MainC;
  
  components LedsC;
  App.Leds -> LedsC;

  components new TimerMilliC() as TimerAccel;
  App.TimerAccel -> TimerAccel;

  components new ADXL345C();
  App.Xaxis -> ADXL345C.X;
  App.Yaxis -> ADXL345C.Y;
  App.Zaxis -> ADXL345C.Z;
  App.AccelControl -> ADXL345C.SplitControl;
}

Accelerometer345C.nc
#include "printf.h"

module Accelerometer345C {
  uses {
    interface Boot;
    interface Leds;
    interface Timer<TMilli> as TimerAccel;
    interface Read<uint16_t> as Xaxis;
    interface Read<uint16_t> as Yaxis;
    interface Read<uint16_t> as Zaxis;
    interface SplitControl as AccelControl;
  }
}

implementation {
  event void Boot.booted() {
    call AccelControl.start();
  }

  event void AccelControl.startDone(error_t err) {
    printf("\n\n-----Accelerometer Started-----\n\n");
    call TimerAccel.startPeriodic(1000);
  }

  event void AccelControl.stopDone(error_t err) {
  }

  event void TimerAccel.fired() {
    call Leds.led0Toggle();
    call Xaxis.read();   
  }

  event void Xaxis.readDone(error_t result, uint16_t data) {
    printf("X [%d]  ",data);
    call Yaxis.read();
  }

  event void Yaxis.readDone(error_t result, uint16_t data) {
    printf("Y [%d]  ",data);
    call Zaxis.read();
  }
  event void Zaxis.readDone(error_t result, uint16_t data) {
    printf("Z [%d]\n\n",data);
    printfflush();
  }
} 

Makefile
COMPONENT=Accelerometer345AppC
CFLAGS += -I$(TOSDIR)/lib/printf
CFLAGS += -I$(TOSDIR)/chips/adxl345

include $(MAKERULES) 

Monday, March 26, 2012

Certain Simple C Concepts

C Preprocessor Directives


    C Preprocessor is a separate program invoked by the compiler as first part of the compilation. It includes the directives for source file inclusion (ie #include), macro definition (#define) and conditional inclusion (ie #if).

    Preprocessor directives starts with a "#" sign, and that statement will be executed prior to the actual compilation of the code.

  (1) Source code inclusion

    #include Directive
      Preprocessor will replace the #include directive by entire content of the specified file.
     If the file name is enclosed in angle brackets, compiler will search the file in standard directories where it is configured to search.
 #include < stdio.h> 
     If the file name is enclosed in single quotes, compiler will search the file first in current directory and then if not found search in standard directories.
 #include "Timer.h" 
     Inorder to search in directories other than standard directories, use -I flag in the Makefile.
 CFLAGS += -I$(TOSDIR)/lib/printf

  (2) Macro definition 


    "#define" Directive

       #define Directive Defines the processor to replace all subsequent occurrence of a macro with a specific token.
 #define ADXL345_DEVID 0x00 
     The above example causes the preprocessor to replace the subsequent occurrence of the identifier "ADXL345_DEVID" with constant hex value 0x00.

     "#undef"Directive
        Defines macros are not affected by the block structure of C. A macro once defined will last until a "#undef" directive for that particular token. After undefining you can again redefine that token.
 #define ADXL345_DEVID 0x00 
 #undef ADXL345_DEVID 
 #define ADXL345_DEVID 0x01 

  (3) Conditional Inclusions

         Allows to include or discard certain code based on some conditions.

       #ifdef
 #ifdef NUM
 int amount [NUM];
 #endif
        Here the middle line will be compiled only if the NUM variable is already defined with #define.

        #ifndef
 #ifndef NUM
 #define NUM 46
 int amount [NUM];
 #endif
        Here the NUM variable will be defined only if it is not previously defined.

       #if, #else, #elif
 #if NUM>100
 #undef NUM
 #define NUM 100
 
 #elif NUM<50
 #undef NUM
 #define NUM 50

 #else
 #undef NUM
 #define NUM 200
 #endif 
       Here depending on certain condition the code is compiled.

Race condition

   Usually occurs in threaded programs. When two or more threads try to access same resource and change its value at same time, race condition occurs. Inorder to avoid this condition put a lock around the variable before using.

Printing in C


     To print the remainder

Use % for printing remainder of a division operation.
printf("%d",564%10);

rvalue Vs lvalue


   rvalue: rvalue of a variable is the value stored in that variable.
   lvalue: lvalue of a variable is the value of its address (where it is stored).
j=6;
k=j;

   Here in first line 'j' is at the left side of the equation and it denotes the address to which value 6 is to be copied. In the second line 'j' is at the right side of the equation and it denotes the value stored in 'j' to be copied to the address denoted by 'k'.

Function Pointer

   Declaring function pointer


      "ptFunction" is the function pointer declared and initialized to Null value.
int (*pt2Function)(float, char, char) = NULL; 

   Defining function pointer


      "ptFunction" is initialized to "DoIt" function whose definition is given below
ptFunction = DoIt;        // short form
ptFunction = &DoIt;   // correct assignment using address operator

void DoIt(float a, char b, char c) { }

   Comparing function pointer 


      This checks whether the  "ptFunction" is defined or not.
if(ptFunction >0) { }

   Calling function using function pointer 


       Both the methods will work.
int result1 = ptFunction(12, 'a', 'b'); 
int result2 = (*ptFunction) (12, 'a', 'b');

   Pass function pointer as argument 


       Both the function call and the function definition are given below.
PassPtr(&DoIt);  //Call the function

void PassPtr(int (*pt2Func)(float, char, char)) { } // Definition for the called function

Enumerations (enum)


   It is a set of named integer constants. Is defined like structures.

   Enum definition


enum coin {penny, dollar, paisa=15, dime, quater}

   Each of the enum symbol stands for an integer value starting from 0.

   Printing the values

printf("%d %d %d %d %d\n",penny,dollar,paisa,dime,quater);
   Here penny=0, dollar=1, paisa=15, dime=16 and quater=17.

   Declare variable


enum coin money;
   "money" is an object of type coin. 

   Initialize the variable

money = paisa;
   "money" is initialized to value "paisa". Printing money will print value 15.

Tuesday, March 20, 2012

NesC programming concepts.

Components


   Two kinds of components.

1. Singletons components

    Only one instant can exist. Renaming not possible.
configuration MainC {
}//  Singletons components module
components MainC; //Instantiating a Singletons component.

2. Generic components

    Can have multiple instants.
generic configuration TimerMilliC() {

 }   //  Generic components module

 //Instantiating a Generic component and renaming it.
 components new TimerMilliC() as TimerAccel;

 //Instantiating a Generic component without renaming.
 components new TimerMilliC(); 

Data types


uint8_t  :   Unsigned 8 bit integer.
uint16_t  :   Unsigned 16 bit integer.
uint32_t  :   Unsigned 32 bit integer.
uint8_t var1 =250;
printf("Value1 = %u", var1);
 
uint16_t var2 =65000;
printf("Value2 = %u", var2);

uint32_t var3 =4294960000;
printf("Value3 = %lu", var3);
 

Printf


   In NesC "printf" library will provides the terminal printing functionality for motes connected to PC through serial interface.

For using printf() in your NesC program:
  1. Include "printf.h" header in the component where it is being used.
#include "printf.h"

  2. Give path for the printf library in Makefile.
        CFLAGS += -I$(TOSDIR)/lib/printf   where $TOSDIR=/opt/tinyos-2.x/tos
COMPONENT=PrintfAppC
CFLAGS += -I$(TOSDIR)/lib/printf
include $(MAKERULES) 

 3. For explicit flushing of the printf output use the function printfflush().
printfflush(); 

  4. Default buffer size for the printf is 250 bytes as defined in the printf.h library in /opt/tinyos-2.x/tos/lib/printf/2_0_2/. For changing the buffer size edit the Makefile.
CFLAGS += -DPRINTF_BUFFER_SIZE={NEW_SIZE} 

Adding libraries or drivers in "Makefile" 


1. For adding libraries or drivers into your NesC program, add this line in your Makefile.
 CFLAGS += -I${PATH_OF_LIBRARY} 

2. If you want to add more than one library files, this line can be used repeatedly.
COMPONENT=PrintfAppC
CFLAGS += -I$(TOSDIR)/lib/printf
CFLAGS += -I$(TOSDIR)/chips/adxl345
include $(MAKERULES)

Commands and Events


   In NesC communication between two components are possible by using the interfaces. An interface will be provided by the provider component and used by the used component.
The user component make use of an interface provided by provider component, by making request (calls commands) to provider component. The provider component will make callbacks (signals events) as response to the user component.

  Commands
    Set of functions to be defined and implemented by interface's provider.
 return call Timer.startPeriodic(1000); //Call for the function Timer to start.
  Events
    Set of functions to be defined by interface's provider and implemented by interface's user.
 event result_t Timer.fired() {
} // Event is signaled once the Timer is fired 

"SplitControl" Interface


   This interface is used for switching between ON and OFF power states of the component providing it. If the command returns SUCCESS then corresponding startDone() or stopDone() event must be signalled.

SplitControl is similar to StdControl. StdControl is single-phase with only commands, while SplitControl is split-phase with commands and command completion events.

    Commands
 command error_t start()  // Start this component and all its subcomponents.
 command error_t stop()  //  Start this component and all its subcomponents. 
    Events
 event void startDone(error_t error) // Notify caller that component is 
  started and ready to receive other commands.
 event void stopDone(error_t error) // Notify caller that component has
  been stopped.

Task


   Task is a light weight procedure call. It can be posted at any time and posted task are executed later, one at a time by the TinyOS scheduler. A Task has following features.
    Has return value of void
    Takes no parameters
    Declared with task keyword.
    Task can be called by post operator.
    Posting task will always return success unless the task is pending.

Task declaration
 task void sendEvent1(); 
Task definition
 task void sendEvent1() {
 } 
Post a task
post sendEvent1();

Platform independent Data types


   Tinyos introduces platform independent data format that can be easily accessed and used. Usage of nx_ prefix or nxle_prefix on keywords such as struct and uint16_t or unint32_t means that they are external types, which have same representation on all hardware platforms.
typedef nx_struct BlinkToRadio{
   nx_uint16_t nodeid;            // Big endian 16 bit value
   nxle_uint8_t length;            // Little endian 8 bit value
}

Thursday, March 15, 2012

Manual Installation of Tiny OS in Ubuntu 11.10 from RPM


 The procedure given is for setting up Tiny OS 2.x in Ubuntu 11.10.

  I had followed the TinyOS wiki page and these are the exact steps i followed for Tiny OS installation for my TelosB mote which is using TIMSP430 processor.

After the installation, i dealt  with an error while compiling the TestSerial application for serial communication. It seems the issue is due to the Ubuntu 11.10 version OS.

1. Install Java

    (1) Install "python-software-properties" package.
apt-get install python-software-properties 
    (2) Add proper Repo for Java package.
           Log out from the current terminal and open a new one.
add-apt-repository ppa:ferramroberto/java 
    (3) Update your local package index.
 apt-get update 
    (4) Now install java packages.
 apt-get install sun-java6-jdk sun-java6-plugin 

2. Install  "rpm" package for installing RPM packages in Ubuntu.
 apt-get install rpm 

3. Install compilers for TIMSP430

      (1) Download msp430tools-base from here.
        http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-base-0.1-20050607.i386.rpm
      Install it using this command.
 rpm -Uvh --force --nodeps msp430tools-base-0.1-20050607.i386.rpm 
      (2) Download msp430tools-python-tools from here.
        http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-python-tools-1.0-1.noarch.rpm
      Install it using this command.
 rpm -Uvh --force --nodeps msp430tools-python-tools-1.0-1.noarch.rpm 
      (3) Download msp430tools-binutils from here.
        http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-binutils-2.16-20050607.i386.rpm
      Install it using this command.
rpm -Uvh --force --nodeps msp430tools-binutils-2.16-20050607.i386.rpm 
      (4) Download msp430tools-gcc from here.
        http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-gcc-3.2.3-20050607.i386.rpm
      Install it using this command.
 rpm -Uvh --force --nodeps msp430tools-gcc-3.2.3-20050607.i386.rpm 
      (5) Download msp430tools-libc from here.
        http://www.tinyos.net/dist-2.1.0/tools/linux/msp430tools-libc-20080808-1.i386.rpm
      Install it using this command.
 rpm -Uvh --force --nodeps msp430tools-libc-20080808-1.i386.rpm 
      (6) Downloadmsp430tools-jtag-lib from here.
        http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-jtag-lib-20031101cvs-20050610.i386.rpm
      Install it using this command.
 rpm -Uvh --force --nodeps msp430tools-jtag-lib-20031101cvs-20050610.i386.rpm 
      (7) Download msp430tools-gdb from here.
        http://www.tinyos.net/dist-2.0.0/tools/linux/msp430tools-gdb-6.0-20050609.i386.rpm   
      Install it using this command.
 rpm -Uvh --force --nodeps msp430tools-gdb-6.0-20050609.i386.rpm 

4. Install TinyOS toolchain.

      (1) Download nesc from here.
        http://tinyos.stanford.edu/tinyos-rpms/nesc-1.3.1-1.fc9.i386.rpm
      Install it using this command.
 rpm -Uvh --ignoreos --nodeps nesc-1.3.1-1.fc9.i386.rpm 
      (2) Download tinyos-deputy from here.
        http://www.tinyos.net/dist-2.1.0/tinyos/linux/tinyos-deputy-1.1-1.fc9.i386.rpm
      Install it using this command.
 rpm -Uvh --ignoreos --nodeps tinyos-deputy-1.1-1.fc9.i386.rpm 
      (3) Download tinyos-tools from here.
        http://tinyos.stanford.edu/tinyos-rpms/tinyos-tools-1.4.0-3.ubuntu.i386.rpm          Install it using this command.
rpm -Uvh --ignoreos --nodeps tinyos-tools-1.4.0-3.ubuntu.i386.rpm 

5. Install TinyOS 2.x source tree.

      (1) Download tinyos source from here.
        http://tinyos.stanford.edu/tinyos-rpms/tinyos-2.1.1-3.ubuntu.noarch.rpm
      Install it using this command.
 rpm -Uvh --ignoreos --nodeps tinyos-2.1.1-3.ubuntu.noarch.rpm 

6. Add path.

      (1) Open bashrc file.
 vim ~/.bashrc 
      (2) Add the following lines to end of the bashrc file.
export TOSROOT=/opt/tinyos-2.x
export TOSDIR=$TOSROOT/tos
export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.
export MAKERULES=$TOSROOT/support/make/Makerules
export PATH=/opt/msp430/bin:/opt/jflashmm:$PATH 

7. Graphviz installation.

       (1) You can download graphviz and its dependency libgraphviz from this location.
         http://www.graphviz.org/Download_linux_ubuntu.php
       (3) liblasi0 is a dependency which i installed from ubuntu repo for graphviz.
 apt-get install liblasi0 
       (2) Install graphviz and its dependency.
 dpkg -i libgraphviz4_2.28.0-1_i386.deb

dpkg -i graphviz_2.28.0-1_i386.deb 
      

Errors

(1) Error while compiling the TestSerial application for serial communication.
/apps/tests/TestSerial# make telosb

mkdir -p build/telosb
mig java -target=null -I/opt/tinyos-2.x/tos/lib/T2Hack
-DIDENT_APPNAME=\"TestSerialAppC\" -DIDENT_USERNAME=\"root\"
-DIDENT_HOSTNAME=\"ubuntu\" -DIDENT_USERHASH=0xa3473ba6L
-DIDENT_TIMESTAMP=0x4f634feeL -DIDENT_UIDHASH=0x185584f2L -java-
classname=TestSerialMsg TestSerial.h test_serial_msg -o TestSerialMsg.java
two source files specified (PLATFORM_NULL and IDENT_APPNAME="TestSerialAppC")
failed to parse message file TestSerial.h

make: *** [TestSerialMsg.java] Error 1 

Solution:

  Couldn't solve the issue. It seems  the issue is with the ubuntu version 11.10. I solved the issue by switching back to Ubuntu 10.04 LTS version.

(2) Error with the java files.
        java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb

Exception in thread "main" java.lang.NoClassDefFoundError: net/tinyos/tools/Listen

Caused by: java.lang.ClassNotFoundException: net.tinyos.tools.Listen
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: net.tinyos.tools.Listen.  Program will exit.

Solution:

  1. Download of whole "java" as tarball from Tiny OS CVS repository.
      http://tinyos.cvs.sourceforge.net/viewvc/tinyos/tinyos-2.x/support/sdk/java/
  2. Replace the "java" file from /opt/tinyos-2.x/support/sdk/ with the extracted java file, from the downloaded tarball file.
  3. Go inside the java folder in terminal and give "make" command.
  4. Enjoy.

(3) Error in installing rpm packages.
rpm -Uvh --force --nodeps msp430tools-base-0.1-20050607.i386.rpm

rpm: please use alien to install rpm packages on Debian, if you are really sure use --force-debian switch. See README.Debian for more details.

Solution:
  Use this command instead.
rpm -Uvh --force-debian --nodeps msp430tools-base-0.1-20050607.i386.rpm


(3) Error in "make "
make telosb
make: *** No rule to make target `telosb'.  Stop.

Solution:

This is because you have done the installation as root user and trying to "make" as a different user.
Solve this by doing "make" as root user or give proper permission for that particular user.
sudo chown prasanth:prasanth -R /opt/tinyos-2.x/