Skip to main content Accessibility help
×
Hostname: page-component-84b7d79bbc-g5fl4 Total loading time: 0 Render date: 2024-07-29T06:31:49.036Z Has data issue: false hasContentIssue false

3 - Components and interfaces

Published online by Cambridge University Press:  05 August 2012

Philip Levis
Affiliation:
Stanford University, California
David Gay
Affiliation:
Intel Research, Berkeley
Get access

Summary

This chapter describes components, the building blocks of nesC programs. Every component has a signature, which describes the functions it needs to call as well as the functions that others can call on it. A component declares its signature with interfaces, which are sets of functions for a complete service or abstraction. Modules are components that implement and call functions in C-like code. Configurations connect components into larger abstractions. This chapter focuses on modules, and covers configurations only well enough to modify and extend existing applications: Chapter 4 covers writing new configurations from scratch.

Component signatures

A nesC program is a collection of components. Every component is in its own source file, and there is a one-to-one mapping between component and source file names. For example, the file LedsC.nc contains the nesC code for the component LedsC, while the component PowerupC can be found in the file PowerupC.nc. Components in nesC reside in a global namespace: there is only one PowerupC definition, and so the nesC compiler loads only one file named PowerupC.nc.

There are two kinds of components: modules and configurations. Modules and configurations can be used interchangeably when combining components into larger services or abstractions. The two types of components differ in their implementation sections. Module implementation sections consist of nesC code that looks like C. Module code declares variables and functions, calls functions, and compiles to assembly code. Configuration implementation sections consist of nesC wiring code, which connects components together. Configurations are the major difference between nesC and C (and other C derivatives).

Type
Chapter
Information
TinyOS Programming , pp. 21 - 48
Publisher: Cambridge University Press
Print publication year: 2009

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×