tinyos--随机数
来源:互联网 发布:阿里推荐算法负责人 编辑:程序博客网 时间:2024/04/30 11:54
tinyos2.x/tos/interfaces/中提供了组件Random.nc,其提供了两个命令:async command uint32_t rand32()、async command uint16_t rand16();调用的时候直接int16/32_t num=call Random.rand16/32()即可。
给出简单的Blink例子
1.更改BlinkC.nc
#include <Timer.h>
module BlinkC{
uses interface Timer<TMilli> as Timer0;
// uses interface Timer<TMilli> as Timer1;
// uses interface Timer<TMilli> as Timer2;
uses interface Leds;
uses interface Boot;
uses interface Random;
}
implementation{
event void Boot.booted(){
call Timer0.startPeriodic(250);
// call Timer1.startPeriodic(1000);
// call Timer2.startPeriodic(500);
}
event void Timer0.fired(){
int16_t i=call Random.rand16();
call Leds.set(i);
}
/* event void Timer1.fired(){
call Leds.led1Toggle();
}
event void Timer2.fired(){
call Leds.led2Toggle();
}
*/
}
2.更改BlinkAppC.nc
configuration BlinkAppC{
}
implementation{
components MainC,LedsC,RandomC;
components BlinkC as App;
components new TimerMilliC() as Timer0;
// components new TimerMilliC() as Timer1;
// components new TimerMilliC() as Timer2;
App->MainC.Boot;
App.Timer0->Timer0;
// App.Timer1->Timer1;
// App.Timer2->Timer2;
App.Leds->LedsC;
App.Random->RandomC;
}
- tinyos--随机数
- tinyos--随机数
- TinyOS
- TinyOS
- TinyOS
- TinyOS
- tinyOS
- TinyOS简介
- tinyos手册
- TinyOS简介
- TinyOS 简介
- TinyOS简介
- tinyos主程序
- TinyOS---传感
- TinyOS心得
- TinyOS 笔记
- TinyOS操作系统
- 随机数
- 股市基础知识、股票名词【二】
- Spring声明式事务之代理机制与tx标签两种方式
- 选夫婿1(SDUT 1569)
- 浅入浅出SQL注入
- 微信公众帐号开发教程第11篇-符号表情的发送(上)
- tinyos--随机数
- mysql 库名 表名 大写
- UVa 10827 - Maximum sum on a torus
- 微信公众帐号开发教程第12篇-符号表情的发送(下)
- 海典ERP与汉码盘点机对接门店实时盘点计划及程序使用方法,实时盘点,云盘点方案
- Oracle8i - DISABLE VALIDATE constraint state (文档 ID 69637.1)
- DB2锁机制深度分析
- uafxcwd.lib(afxglobals.obj) : error LNK2001: 无法解析的外部符号 _IID_IWICImagingFactory
- Map和List两个集合类初学入门