Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tinyos Introduction to Programming Pritee Parwekar.

Similar presentations


Presentation on theme: "Tinyos Introduction to Programming Pritee Parwekar."— Presentation transcript:

1 Tinyos Introduction to Programming Pritee Parwekar

2 What is TinyOS? An operation system An open-source development environment Not an operation system for general purpose, it is designed for wireless embedded sensor network.  Official website: http://www.tinyos.net/http://www.tinyos.net/ Programming language: NesC (network embedded systems C - an extension of C) It features a component-based architecture. Supported platforms include Linux, Windows 2000/XP with Cygwin. Pritee Parwekar

3 Application in tinyos Application is collection of components Components consists of any number of modules and configurations Modules provide implementation of one or more interfaces Configuration used to assemble other components together Pritee Parwekar

4 Programming TinyOs ComponentCommandsEvents UseCan callMust implement ProvideMust implementCan signal A component provides and uses interfaces. A interface defines a logically related set of commands and events. Components implement the events they use and the commands they provide: There are two types of components in nesC:  Modules. It implements application code.  Configurations. It assemble other components together, called wiring A component does not care if another component is a module or configuration A component may be composed of other components via configurations Pritee Parwekar

5 About interface Interface is collection of one or more events or commands Command ( ) Event void ( ); Events return type is always void. Pritee Parwekar

6 Components All the components (modules or configuration) as two blocks signature and implementation Module { //signature } implementation { //implementation } Pritee Parwekar

7 configuration { //signature } implementation { //implementation } Pritee Parwekar

8 Configuration Wires A configuration can bind an interface user to a provider using -> or <-  User.interface -> Provider.interface  Provider.interface <- User.interface Bounce responsibilities using =  User1.interface = User2.interface  Provider1.interface = Provider2.interface Pritee Parwekar

9 Difference between C and Nesc In C programs are composed of functions and in nesc programs on built out of components C functions are typically interact by calling and components are specified by interfaces Commands and events are like functions nesC interfaces are similar to Java interfaces with addition of a command or event keyword Pritee Parwekar

10 nesC program is collection of components There are 2 types of components modules and configurations Module code declares variables,functions,calls to functions etc Configuration implementation sections consists of nesC writing code,which connects components together Pritee Parwekar

11 Simple program in C If we have a simple program in c as main() { } Pritee Parwekar

12 Program in nesC For nesC programming First create the folder with some name say test You need to create the Component file testC.nc. This has definition (implementation) of the component testC. module testC { uses interface Boot; } Implementation { event void Boot.booted( ) { //The entry point of the program } } Pritee Parwekar

13 The MainC component provides the Boot.booted signal which essentially is the entry point of the application. Then need to create a Configuration file testAppC.nc configuration testAppC{ } Implementation { components testC, MainC; testC.Boot -> MainC.Boot; } There are two components in this program: your component called testC and the Main component MainC. Pritee Parwekar

14 Now you need to create a Makefile so that the compiler can compile it. Create the file called Makefile with the following two lines: COMPONENT=testAppC include $(MAKERULES) Now you are ready to compile: $ make micaz Now the program can be increased by adding more components takes all system make files and compilation options for diffrent platforms you just type echo $MAKERULES it gives the path tinyos-2.x/support/make/Makerules rules are written for compilation for different platforms Pritee Parwekar

15 How to run the program To run the program go the the particular directory Type make micaz sim will get the msg as successfully built the micaz TOSSIM libraries To see the output we need to write python script # !/user/bin/python from TOSSIM import * import sys t = Tossim( [ ] ) Pritee Parwekar

16 How to get output For the output we have two options We can compile the code and copy to real hardware and then the system automatically does everything But for simulation whatever the hardware does we need to do it through software for that we need to get the compiled code add functionality and make it TOSSIM.py file Pritee Parwekar

17 Once we compile the tinyos program with make micaz sim it generates the python based library file TOSSIM.py. Now the entire program is available in this TOSSIM.py library. In order to use it we have to import this Library using from TOSSIM import * import sys - this is system based library imported to our code. some thing like #include in C. Pritee Parwekar

18 t = Tossim([ ]) This commands create a TOSSIM object. Where t is the TOSSIM object name. We can give any name. In Object Oriented langugaes we need a object, from which we can call all functions defined in it. t.runNextEvent() Pritee Parwekar

19 dbg("channel", "string format", var1, var2); One is channel name second one is message This channel name is needed in python script even we have H/W some times we dont know how program runs so we can dubug the program using simulator using this dgb statements they named as channel bcz the output can be seen in a file Pritee Parwekar

20 We are starting 3 nodes 1 and 2 and3 and booting those nodes at 100 ticks, 800 and 1800 ticks we can give any no of nodes as now we are interested 3even we can give any number not 1 and 2t.getNode(10).BootAtTime(1000); t.getNode(14).BootAtTime(1220); some thing like this the 10 and 14 are sensor node nos we have given sequential here 1, 2 and 3 for i in range(0, 1000): t.runNextEvent() Pritee Parwekar


Download ppt "Tinyos Introduction to Programming Pritee Parwekar."

Similar presentations


Ads by Google