标识符类型 | 命名规则 | 举例 |
Interfaces | Interfaces应该是用动词或者名词来命名, 连接的几个单词首个字母一般都要大写。 | ADC |
Components | Components应该是用名词来命名, 连接的几个单词首个字母一般都要大写。. 这里有两个特殊的例子: 一种是以大写字母Ct结尾、另外一种是以大写字母M结尾。这主要是用来区分配件中的接口和模件中的配置。 大写字母C代表:Component. 主要用来区分interface (如Timer) 和 component提供的接口interface (如TimerC). 大写字母 M 代表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 |
Files | Filenames should be the name of the type contained within; all nesC files have ".nc" as a suffix. | Counter.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 |
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 |
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 |
Constants | Constants should be in all caps, with underscores delimiting internal words. | TOS_UART_ADDR |