Hide menu

TDDI07 Distributed embedded software and networks

Lab1, Introduction to TinyOS and NesC


The main objective of this lab is to make the student familiar with the development environment for sensor platforms using TinyOS and understand the basic concepts of its programming language nesC.

Preparatory questions


In order to be prepared for the lab and make the most out of your lab hours you will prepare and answer the following questions that test your understanding of TinyOS and nesC in advance. First, you have to read the assignments of the labs. Some answers can be found in the lesson and tutorials, others require you browse some source code. If you learn how to browse and read the many example applications provided with TinyOS, you will be able to find many hints for your later assignments.
  1. A nesC application is not started and running like a regular C application.
    1. What correspond to the main() function in a nesC application?
    2. Which interface and which component is used to start an application?
    3. The starting point in a nesC application is supposed to be short and return fast. What "drives" the application after it is initiated/started?
  2. Find and have a look at the source code for the Blink application. Find the interface specification for the used interfaces.
    1. How many commands are provided by the Leds interface?
    2. Which commands and events are provided by the Timer interface?
  3. A certain interface Foo provides command A and an event B. The interface Foo is implemented by the component FooC. The configuration FooAppC wires a module BarC to use FooC. Assume B is defined in both FooC and BarC.
    1. Which definition of B is used when the application is run?
    2. Optional question: What is the purpose of the other definition?
      (Hint: The answer to b. can be found in the nesC reference.)
  4. Your application is executing a process A. It is interrupted by an event, dataReady, signaling requested data is available from a sensor. The event handler read the data and post a new process, B, to evaluate it. During the execution of dataReady a timer fires an interrupt. Assume that A, B and the timer event are synchronous code and the dataReady event is asynchronous.
    1. In which order do A, B, dataReady and the timer event finish execution?
    2. Advised by the example, why is it important to keep event handlers short and fast?

Lab 1


Before starting you should learn basics of TinyOS and NesC. You have to be familiar with the environment. By now you should have read how on the file that can be found in index page.

Lab 1 contains two assignments. The first is an introductory assignment where you are requested to complete the application skeleton BlinkTask in order to make blink a led on the sensor node. The led has to be 1 second switched on and 9 seconds off. In the second assignment you are requested to complete the application skeleton PhotoMeter, which measures the illuminance level using a sensor and displays the results on the leds.

Additional resources for this lab:

To hand in:

You must demonstrate the application running in the sensor nodes to the lab assistant during lab hours. Moreover you should send a link to a branch (or tag in master) of your git repo to your assistant. In the repo you should have completed a report containing (use the report template):

  • Correct answers to the lab preparatory questions
  • Brief explanation of how your application works

The e-mail must contain the string
TDDI07 Lab X Group Y
where X is the lab number in the subject name and Y is the group number.


Lab 2


Page responsible: Mikael Asplund
Last updated: 2020-11-02