博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TinyOS实例介绍
阅读量:4518 次
发布时间:2019-06-08

本文共 2480 字,大约阅读时间需要 8 分钟。

TinyOS

locate Timer.nc# /home/user/src/tinyos-release-tinyos_2_1_2/tos/lib/timer/Timer.nccd /home/user/src/tinyos-release-tinyos_2_1_2/tos/lib/timervim Timer.nc# lots of Interface that provided by Timer
vim Timer.h#
can be TSecond;TMilli;T32khz;TMicro

这意味着在BlinkC.nc的module中可通过uses interface Timer<TMicro> as Timer从而使得计时器定时精度从默认的毫秒级改为微秒级

TinyOS例程说明(telosb通信节点)

Ref:

  • 示波器(Oscilloscope)的使用:

Oscilloscope is an application that let's you visualize sensor readings on the PC. Every node that has Oscilloscope installed periodically samples the default sensor via () and broadcasts a message with 10 accumulated readings over the radio. A node running the BaseStation application will forward these messages to the PC using the serial communication.

即一个节点需要跑BaseStation程序发送消息给PC,另一个节点安装Oscilloscope程序周期性采样传感器并广播出去。

Each node is represented by a line of different color , The x-axis is the packet counter number and the y-axis is the sensor reading.

# 启动 Serial Forwarder 以允许多个程序访问串口读取的数据包java net.tinyos.sf.SerialForwarder -comm serial@/dev/ttyUSB0:telosb# 进入并运行java程序cd 
/apps/Oscilloscope/javamake./run
  • 节点端到端的通信实例:
cd 
/apps/BlinkToRadiomake telosbmake telosb reinstall bsl,/dev/ttyUSB0# both motes should be blinking their LEDs
  • 节点端作基站与电脑通信:
# install Blink in one motecd 
/apps/BlinkToRadiomake telosbmake telosb reinstall bsl,/dev/ttyUSB0# second motecd
/apps/BaseStation make telosbmake telosb reinstall bsl,/dev/ttyUSB1# 读取telosb节点数据(telosb: 115200 baud)java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb
  • RSSI Demo

运行代码:

make telosbmake telosb reinstall bsl,/dev/ttyUSB0makejava RssiDemo -comm serial@/dev/ttyUSB1:telosb

Ref: https://hujunyu1222.github.io/2015/08/01/2015-08-01-tinyOSnote1/

//在XXXAppC.nc中添加components CC2420ActiveMessageC as CC2420Reader;XXX.CC2420Packet = CC2420Reader;//在XXXC.nc中,uses内添加interface CC2420Packet;//在XXXC.nc中,例如在Receive.receive()通过接口提供的get.Rssi(msg)函数获得RSSI。int_8 rssi;rssi = call CC2420Packet.getRssi(msg);

获取的RSSi值是16进制的,要将其转换为dBm, 需要

1.将得到的16进制数换算为10进制。
2.将这个10进制数 减去256
3.最后,计算出的RSSI 有45的偏移量,所以最后得到的数值需要 减去 45。

[/tests/cc2420/RssiToSerial]

Ref: https://hujunyu1222.github.io/2015/08/05/2015-08-12-tinyOSnote3/

原始读数转换为dBm:

//我们设原始获得的数据是valdBm = (int8_t) (((val - 0x7F) & 0xFF) -45);//简单的换算temp = int(val,16)     //将val转换为10进制数dBm = temp -127 -45;   //再将10进制数减去127,然后再减去45(cc2420手册中说的偏移量45)

转载于:https://www.cnblogs.com/WindyZ/p/11255837.html

你可能感兴趣的文章
Tomcat分析-启动过程
查看>>
IOS开发-基于WebDriverAgent代理服务,实现iOS手机app自动化测试的框架搭建
查看>>
实现JS数组的深拷贝
查看>>
xStream完美转换XML、JSON(转)
查看>>
code::Blocks 汉化经验
查看>>
(2017.10.10) 我对 JavaScript 历史的认识
查看>>
用aiohttp代替requests写异步爬虫
查看>>
ipv6下jdbc的连接数据库方式
查看>>
201521123069 《Java程序设计》第1周学习总结
查看>>
一线咨询师的絮絮叨叨
查看>>
文字分散对齐
查看>>
【NOIP 2012 国王游戏】 贪心+高精度
查看>>
【UOJ 117】欧拉回路
查看>>
用Pytorch训练MNIST分类模型
查看>>
一些不错的动画效果---郭雪彬
查看>>
iOS - TableViewCell分割线 --By吴帮雷
查看>>
jquery 获取input的值
查看>>
UVA 10003 - Cutting Sticks ( 区间dp )
查看>>
BETA 版冲刺前准备
查看>>
vue-表单绑定
查看>>