DSN New User Programming Tutorial
June 2007
Introduction
This tutorial is intended to get the new DSN user up and running,
providing step-by-step instructions on downloading DSN and configuring
your system, writing programs with increasing levels of complexity, and
even looking at the more advanced inner-workings of the system.
Package Download and System Configuration
Downloading DSN onto your computer
The system can be downloaded from the DSN website at: http://db.cs.berkeley.edu/dsn/.
If downloading from the website, the location of DSN on the local
machine is not important; environmental variables will handle this.
Supplemental System Requirements
In order for DSN to function correctly, there are a few prerequisites (version numbers are important).
- TinyOS 1.x - We strongly recommend the latest CVS version of Tinyos 1.x. Refer to the accompanying TinyOS 1.x install mini-walkthrough for some pointers.
- NesC
Version 1.2 - Later builds of TinyOS 1.x come with NesC 1.2
preinstalled. For earlier builds, it will need to be installed
separately.
- Python Version 2.4 - Needed by DSN's compiler. Earlier versions won't work. Check your version with "python -V"
- Java
1.5 or later - Highly recommended for PC side data gathering and
analysis tools. Earlier versions don't support generic templates that
are utilized by the provided tools. Check your version with
"javac -version"
DSN currently supports the TelosB/Telos, Micaz, and Mica2 platforms.
Setting up Environment Variables
Once installed, there are three main variables that need to be set in
the environment (assuming Cygwin is being used) in order for DSN to
work correctly:
- DSNDIR - The directory in which the DSN code resides, i.e. /DSN/code
- DSNPATH - The directory within DSN where the SNLog program specifications reside, i.e. /DSN/code/snlog2
- CLASSPATH
- Make sure to add the java directory in order to be able to run the
data gathering/analysis tools, i.e. /DSN/code/util/java
Directory Structure Overview
This section is designed to provide a high-level overview of the
directory structure of DSN. Greater detail for some sections will be
provided later in the tutorial.
- Compiler - Contains all the files for the DSN compiler
- NesC - Core NesC files, including templates, and built-in components
- Snlog - All the existing (and recommended future) program specifications
Test Run: Downloading My First Program
In order to ensure that
everything is working correctly, in this section we download a basic
existing application, blink, onto a mote.
Switch directories to the DSN Home directory, or DSNDIR
. Type the following command (assumes bash):
$ make clean
$ INFILE=snlog2/raw/blink.snl make telosb
$ cd gen
$ make telosb reinstall,0
The first command deletes all files created by any previous dsn
compliation process. The second file specifies which Snlog
specification is to be compiled and downloaded.
The third command starts the compilation process. You will see a
great deal of text fly by. The details are not important, but in
essence DSN is optimizing the Snlog specification and then compiling
the program into pure nesC code. At the end, you will notice the
familiar output from ncc, the TinyOS nesC compiler.
Once you are returned to the command prompt, you will notice a new directory, gen
has been created. This directory contains the application-specific code
that has been created, as well as the image that must be downloaded
onto the motes. The fourth command enters this directory, and finally
the final command downloads the image onto a TelosB node, assigning it
a local address of 0. If so desired, the micaZ and mica motes, or pc (for TOSSIM) can be used instead.
If all these steps completed successfully, the yellow (or rather blue on the TelosB) LED will
be blinking periodically, and your system is
successfully set up to use DSN. If you encounter problems, the problem
depends on the specific symptoms. If you receive an initial parser
error, this typically implies you do not have the correct version of
python installed, or that your environmental variables have not been
setup correctly. If the nesC compliation process fails, it is likely
due to the incorrect version of nesC being installed, or a problem with
your TinyOS installation. Finally, if downloading onto the motes fails,
this generally indicates a problem with your motes connection to your
computer.