tinyos course 01: basic programming
DESCRIPTION
Lesson 01 slides for one day introductory course on wireless sensor networks and TinyOS, that took place at the University of Alcalá de Henares in Madrid Spain the 18th of September 2013. This course was jointly designed by the Electronics Department of the university and Advanticsys. Find source code for the lessons here: http://www.advanticsys.com/wiki/index.php?title=TinyOS%C2%AE_Course_at_UAH_18th_September_2013TRANSCRIPT
WSN Programming Course
TinyOS Lab: Basic Programming
Manuel Fernández
UAH, 18th September 2013
• Introduction to nesC • Components • File Types • Basic program: NullC • How to compile • NesC variables • Eclipse IDE • Exercises
2
Contents
• A nesC application consists of one or more components assembled, or wired, to form an application executable. • Components define two scopes:
• one for their specification which contains the names of their interfaces, and • a second scope for their implementation.
COMPONENT A SPECIFICATION
IMPLEMENTATION
3
NesC (I)
• A component provides and uses interfaces. • The provided interfaces are intended to represent the functionality that the component provides to its user in its specification. • The used interfaces represent the functionality the component needs to perform its job in its implementation.
4
NesC (II)
• Interfaces are bidirectional: they specify a set of commands, which are functions to be implemented by the interface's provider, and a set of events, which are functions to be implemented by the interface's user. For a component to call the commands in an interface, it must implement the events of that interface. • The set of interfaces which a component provides together with the set of interfaces that a component uses is considered that component's signature.
5
NesC (III)
• There are 2 types of components in nesC:
- Modules: provide the implementations of one or more interfaces.
- Configurations: used to assemble other components together, connecting interfaces used by components to interfaces provided by others.
6
Components
• Naming conventions are as follows:
CONFIGURATION
MODULE
COMPONENTS
INTERFACE
Makefile Only in main app
7
File Types
CONFIGURATION
MODULE
TinyOS Lab: Lesson 01 – Basic Programming
© 2012 Manuel Fernández
Makefile NullAppC.nc NullC.nc
Configuration Module
Makefile:
COMPONENT=NullAppC
include $(MAKERULES)
Name of configuration file
8
Basic program: NullC
NullApp.nc :
SPECIFICATION
IMPLEMENTATION
9
Basic program: NullC
SPECIFICATION
IMPLEMENTATION
NullC.nc :
• Open terminal in the folder • Type:
make telosb
• Insert mote in USB port and type:
make telosb reinstall.1 bsl,/dev/ttyUSB0
Platform
MoteID USB port (type motelist to find which one it is
10
How to compile
• Open terminal in the folder
• Type:
make telosb docs
• Check the created folders
Platform
11
Fun Stuff
• Commonly used units:
• int is NOT used • bool is also used
12
NesC variables
• An alternative to console programming is using a TinyOS plug-in for the Eclipse IDE. • In this IDE it is possible to compile and install programs in motes • We will use this IDE to speed up the lessons.
13
Eclipse IDE
1. Interface Leds has commands to control the 3 leds on the mote. (led0, led1, led2). Try each of them and install them on the mote
2. Add a Timer to blink the Leds periodically, showing a binary timer using the 3 leds.
3. Configure the User Button to do a complete routine with the Leds
4. Pack the previous subroutine in a new component with your own interface.
14
Exercises