TinyOS Naming Conventions

Last updated 28 August 2002

This document outlines the naming conventions used in TinyOS. They are strongly influenced by the Java coding conventions.

Names

Identifier Type Rules for Naming Examples
Interfaces Interfaces should be verbs or nouns, in mixed case with the first letter of each internal word capitalized. ADC

Range

SendMsg

BombillaLocks

Components

Components should be nouns, in mixed case with the first letter of each internal word capitalized.

There are two special cases of component names; those terminating with an uppercase C and those terminating with an uppercase M. These are used to distinguish interfaces from components and configurations from modules.

The uppercase C stands for Component. It is used to distinguish between an interface (e.g Timer) and a component that provides the interface (e.g TimerC).

The uppercase M stands for Module. This naming convention is used when a single logical component has both a configuration and a module. An example of this is the Timer in tos/system. The TimerC component, providing the Timer interface, is a configuration that links its implementation (TimerM) to Clock and LED providers. Otherwise, any user of TimerC would have to explicitly wire its subcomponents.

Counter

IntToRfm

IntToRfmM

TimerC

TimerM

UARTM

Files Filenames should be the name of the type contained within; all nesC files have ".nc" as a suffix. Counter.nc

IntToRfm.nc

IntToRfmM.nc

TimerC.nc

TimerM.nc

UARTM.nc

Applications Applications should be the name of the top level component, with trailing Cs removed. If an application tests a piece of TinyOS code, its first word should be "Test." If an application tests TinyOS hardware, its first word should be "Verify." If an application was part of a demonstration, its first word should be "Demo." CntToRfm

Chirp

DemoTracking

TestTinyAlloc

VerifyMicaHW

TestTimer

Commands, Events and Tasks Commands, events and tasks should be verbs, in mixed case with the first letter of each internal word capitalized, with the first letter lowercase. If a command/event pair form a split-phased operation, the name of the event should be the command suffixed with "Done" or "Complete". Commands that directly access hardware should be prefixed with "TOSH_" and follow the constant naming conventions (described below). sendMsg

output

outputComplete

put

putDone

fired

TOSH_SET_RED_LED_PIN();
Variables Variables should be nouns, in mixed case with the first letter of each internal word capitalized, with the first letter lowercase. They should be descriptive, although temporary and loop variables (e.g. the ubiquitous i) may be used. bool state

uint16_t lastCount

uint16_t counter

result_t writeResult

uint8_t noHeader

Constants Constants should be in all caps, with underscores delimiting internal words. TOS_UART_ADDR

TOS_BCAST_ADDR

TOS_LOCAL_GROUP

TOSH_S1PS


Tutorial Index