tcf-agent service开发例子

前几天打算基于tcf实现一个lttng control程序,所以完成了tcf-agent service开发例子git

1. 下载tcf-agent:http://git.eclipse.org/c/tcf/org.eclipse.tcf.agent.gitapi

git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git
ssh://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git
http://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git

 

2. 建立一个project目录,放在tcf-agent源代码目录下,eclipse

例如,拷贝example目录下的daytime项目,而后在上面进行修改。ssh

2.1 首先是项目名字:例如daytime --->hello_service函数

2.2 修改Makefile文件:TCF_AGENT_DIR=../../agent ---->TCF_AGENT_DIR=../agentip

2.3 修改hello_service/tcf/main/services-ext.h开发

#include <tcf/services/daytime.h>

static void ini_ext_services(Protocol * proto, TCFBroadcastGroup * bcg) {
    ini_daytime_service(proto);   ------> 修改或增长外部services
}get

2.4 增长外部的service源码文件,参考daytime.c和daytime.h.源码

2.4.1 增长command,调用tcf-agent api函数 add_command_handler()it

      例如: add_command_handler(proto, DAYTIME, "getTimeOfDay", command_get_time_of_day);

      proto是协议;DAYTIME是service名字,"getTimeOfDay"是命令,command_get_time_of_day是命令处理函数。

3 编译

   在hellow_service目录下:make

   会在hellow_service目录下生成一个obj的目录

4 运行: ./obj/GNU/Linux/i686/Debug/agent

相关文章
相关标签/搜索