TinyOS命名惯例

 

标识符类型命名规则举例
InterfacesInterfaces应该是用动词或者名词来命名, 连接的几个单词首个字母一般都要大写。ADC

Range

SendMsg

BombillaLocks

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

IntToRfm

IntToRfmM

TimerC

TimerM

UARTM

FilesFilenames 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

ApplicationsApplications 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 TasksCommands, 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();
VariablesVariables 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

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

TOS_BCAST_ADDR

TOS_LOCAL_GROUP

TOSH_S1PS

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值