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

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

实验中设置的TinyOS参数

Channel 17, Central Frequency=2435MHz

Payload length = 28bytes,pkt len=36bytes
transmission_rate=250kbps, duration = 1.152ms
The length of a CC2420 packet is [18,133]bytes, the range of valid on-air time is [576, 4256]μs under the standard rate of 250kbit/s
The MPI of adjacent unicast packets is 10ms by default settings in TinyOS-2.1.2, (from ZiSense)

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

你可能感兴趣的文章
Storm学习笔记二
查看>>
BZOJ 1083: [SCOI2005]繁忙的都市
查看>>
JavaSE| String常用方法
查看>>
14.精益敏捷项目管理——认识精益笔记
查看>>
从0开始实现STM32L4XX输出50Hz方波
查看>>
caffe mnist LeNet 参数详细介绍
查看>>
CocoaPods建立私有仓库
查看>>
HIVE中的order by操作
查看>>
Centos下新建用户及修改用户目录
查看>>
iOS开发IPhone以及iPad尺寸汇总
查看>>
Spring Boot RestTemplate文件上传
查看>>
myBatis自动生成mapping,dao和model
查看>>
Android Serivce 高级篇AIDL讲解
查看>>
SpringBoot学习笔记(2):引入Spring Security
查看>>
图片加水印 PDF取缩略图
查看>>
bzoj 4180: 字符串计数
查看>>
安卓--布局设计-计算器
查看>>
Java重写《C经典100题》 --27
查看>>
ABP中的拦截器之EntityHistoryInterceptor
查看>>
【oracle】oracle数据库建立序列、使用序列实现主键自增
查看>>