您的位置:首页 > 其它

在cooja上使用collectview(二)

2015-12-07 22:13 411 查看
上一篇文章中通过运行contiki2.7提供的关于collectview的例子,简单了解了collectview的效果。本文主要通过将collectview功能集成到其他网络项目中,达到数据统计的目的。

这里以contiki2.7自带的另一个例子/examples/ipv6/hello-world为例,介绍如何使用collectview。

首先,修改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();
}


Makefile文件和.c文件修改完之后,通过make生成相应的.ihex文件: make TARGET=sky hello-world.ihex。(其中hello-world应该与makefile文件中的名称相对应) 运行之后,会在该目录下生成hello-world.ihex文件。

将上一步生成的hello-world.ihex文件复制到contiki/tools/collect-view/dist目录下,并将原有的.ihex文件删除。

修改/tools/collect-view下的build.xml文件,将所有collect例子相关的名称、路径改为hello-world的,如将路径/examples/collect改为/examples/hello-world, collect.ihex改为hello-world.ihex,将collect.exists改为hello-world.exists。

修改完成之后,在/tools/collect-view目录下运行$ant命令,如下图所示:



成功运行之后,将dist目录复制到/examples/hello-world目录下。

在cooja中正常模拟运行hello-world sky节点(笔者添加了5个节点),并选择Tools->Collect View->Sky1,然后会新弹出sensor data collect界面,在界面中选择File->Clear Sensor Data,清除历史数据。然后点击Start Collect , Send command to nodes。等待一段时间会显现相应的数据统计结果。



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: