tcf-agent service开发例子

本文详细介绍了如何基于tcf框架实现一个lttngcontrol程序,包括下载源代码、创建项目、修改Makefile、增加外部服务、编译与运行等步骤。通过实际操作案例,为开发者提供了从零开始搭建基于tcf的lttngcontrol程序的指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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

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源代码目录下,

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

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

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

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
}

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

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

      例如: 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

   


转载于:https://my.oschina.net/u/263896/blog/57487

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值