Benchmark库的建立01:数组越界bug

正确版本程序

  1. tinyos-2.x/apps/Oscilloscope

程序描述

  1. 节点周期性启动传感器采集数据,传感器收集10个数据之后通过无线发送给基站节点;
  2. 无线开启失败或者采集数据失败时切换LED0的状态;节点成功发送数据时切换LED1的状态;节点接收到消息时切换LED2的状态。

Avrora运行程序

  1. alias avrora=’java -jar avrora-beta-1.7.113.jar -colors=false -banner=false’;

  2. SENSORBOARD=mts300 make mica2;

  3. mv build/mica2/main.exe os.elf;

  4. avrora -platform=mica2 -monitors=leds,packet -seconds=10 -simulation=sensor-network -nodecount=1 -sensor-data=”light”:0:. os.elf 。

运行结果分析(正确版本)

这里写图片描述

  1. 能正确发送传感器采集的数据;
  2. LED0,LED1、LED2切换结果正确。

bug版本程序

  1. tinyos-2.x/apps/bm_Oscilloscope

程序修改的部分

  1. event void Timer.fired()事件中注释掉数组索引置0操作;
  2. event void Read.readDone(error_t result, uint16_t data)事件中添加数组越界判断操作:
   if(reading >= NREADINGS) {
     printf("Error:out of Bound, please check the index of the array!\n");
    }

bug的显现条件

  1. 传感器采集的数据大于10

Bug症状
这里写图片描述

  1. 只能发送一组(10个)传感器采集的数据;
  2. LED1的状态始终不切换,表示之后无法成功通过无线发送采集的数据;
  3. 运行net.tinyos.tools.PrintClient程序会显示数组越界信息:Error:out of Bound, please check the index of the array!
    注:PrintfClient程序的使用:
    1、引入库文件:#include “printf.h”
    2、在makefile文件中引入:修改makefile为:
COMPONENT=TestPrintfAppC
CFLAGS += -I$(TOSDIR)/lib/printf
include $(MAKERULES

3、通过-monitors=serial -port=2390绑定一个端口,并重新启动一个Cygwin执行程序java net.tinyos.tools.PrintClient -comm network@localhost:2390

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值