实验中设置的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 Timervim 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 hasOscilloscope
installed periodically samples the default sensor via () and broadcasts a message with 10 accumulated readings over the radio. A node running theBaseStation
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:telosbRef: 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)