在cooja上使用collectview(二)

上一篇文章中通过运行contiki2.7提供的关于collectview的例子,简单了解了collectview的效果。本文主要通过将collectview功能集成到其他网络项目中,达到数据统计的目的。
这里以contiki2.7自带的另一个例子/examples/ipv6/hello-world为例,介绍如何使用collectview。

  1. 首先,修改hello-world的Makefile文件,添加如下内容:
APPS = serial-shell powertrace collect-view

然后修改hello-world.c文件,在里面添加头文件:

#include "contiki.h"
#include "shell.h"
#include "serial-shell.h"
#include "collect-view.h"
#include "net/rime.h"

添加代码:

PROCESS(collect_view_shell_process, "Contiki Collect View Shell");
AUTOSTART_PROCESSES(&hello_world_process,&collect_view_shell_process);

PROCESS_THREAD(collect_view_shell_process, ev, data)
{
  PROCESS_BEGIN();

  serial_shell_init();
  shell_blink_init();

#if WITH_COFFEE
  shell_file_init();
  shell_coffee_init();
#endif /* WITH_COFFEE */

  /* shell_download_init(); */
  /* shell_rime_sendcmd_init(); */
  /* shell_ps_init(); */
  shell_reboot_init();
  shell_rime_init();
  shell_rime_netcmd_init();
  /* shell_rime_ping_init(); */
  /* shell_rime_debug_init(); */
  /* shell_rime_debug_runicast_init(); */
  shell_powertrace_init();
  /* shell_base64_init(); */
  shell_text_init();
  shell_time_init();
  /* shell_checkpoint_init(); */
  /* shell_sendtest_init(); */

#if CONTIKI_TARGET_SKY
  shell_sky_init();
#endif /* CONTIKI_TARGET_SKY */

  shell_collect_view_init();

  PROCESS_END();
}
  1. Makefile文件和.c文件修改完之后,通过make生成相应的.ihex文件: make TARGET=sky hello-world.ihex。(其中hello-world应该与makefile文件中的名称相对应) 运行之后,会在该目录下生成hello-world.ihex文件。
  2. 将上一步生成的hello-world.ihex文件复制到contiki/tools/collect-view/dist目录下,并将原有的.ihex文件删除。
  3. 修改/tools/collect-view下的build.xml文件,将所有collect例子相关的名称、路径改为hello-world的,如将路径/examples/collect改为/examples/hello-world, collect.ihex改为hello-world.ihex,将collect.exists改为hello-world.exists。
  4. 修改完成之后,在/tools/collect-view目录下运行$ant命令,如下图所示:
    这里写图片描述
  5. 成功运行之后,将dist目录复制到/examples/hello-world目录下。
  6. 在cooja中正常模拟运行hello-world sky节点(笔者添加了5个节点),并选择Tools->Collect View->Sky1,然后会新弹出sensor data collect界面,在界面中选择File->Clear Sensor Data,清除历史数据。然后点击Start Collect , Send command to nodes。等待一段时间会显现相应的数据统计结果。
    这里写图片描述
    这里写图片描述
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值