Skip to content

Basics of TinyOS and NesC

March 11, 2011

TinyOS is an operating system for low power embedded devices, especially wireless sensor devices. It is open source with a strong developer community. Specifically it is a system, runtime environment, for nesC programs running on Mote hardware. Its features include:

  • Resource management.
  • Selected components are linked into program at compile time.
  • Written in nesC and C.
  • All time-consuming commands are non-blocking.

Some salient components are:

  • Analogue to digital conversion
  • Cryptography
  • Data logging
  • File system
  • I2C communication
  • LED control
  • Memory allocation
  • Random number generation
  • Routing
  • Sensor board input
  • Serial communication (wired and wireless)
  • Timers
  • Watchdog timer

Programming TinyOS with NesC

NesC is a dialect of C with the basic unit of code being a component. Components connect via interfaces and the process is known as wiring.

Components and Interfaces

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. 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.

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. A single component may use or provide multiple interfaces and multiple instances of the same 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.

Modules and Configurations

There are two types of components in nesC: modules and configurations. Modules provide the implementations of one or more interfaces. Configurations are used to assemble other components together, connecting interfaces used by components to interfaces provided by others. Every nesC application is described by a top-level configuration that wires together the components inside.

We will continue by looking at some simple examples in the next article.

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: