在cooja上使用collectview(二)

来源:互联网 发布:ps for mac如何破解 编辑:程序博客网 时间:2024/05/23 20:52

上一篇文章中通过运行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 0
原创粉丝点击