vsomeip 快速入门

vsomeip 快速入门

1. 下载仓库
git clone https://github.com/COVESA/vsomeip.git
2. 编译
2.1 安装相关依赖

我的ubuntu 版本是20.04,所以以ubuntu 20.04为例。

vsomeip依赖 Boost,所以我们要先安装 Boost(版本在1.55-1.74之间),官方文档上对应的boost包版本过低。

sudo apt-get install gcc g++ make
sudo apt install cmake
sudo apt-get install libboost-system-dev libboost-thread-dev libboost-log-dev
sudo apt-get install asciidoc source-highlight doxygen graphviz
2.2 编译vsomeip
cd vsomeip
mkdir build
cd build
cmake -DENABLE_MULTIPLE_ROUTING_MANAGERS=1 ..
make
sudo make install

运行上述命令进行编译vsomeip库,其中运行make之后的编译很慢,大约需要四五分钟,耐心等待就好。

2.3 编译hello_world example

clone 下载的vsomeip中自带一个demo hello_world,我们先编译对应的helloworld程序

Helloworld程序的编译方法也可以查看自带的readme vsomeip/examples/hello_world/readme

回到build目录下,执行下列命令:

cmake --build . --target hello_world
cd ./examples/hello_world/
make
sudo make install 
sudo ldconfig

运行后编译就完成。

3. 运行

编译完成之后,会在对应的编译目录下生成对应helloworld的二进制程序:hello_world_client和hello_world_service

此时不能安装readme里面写的执行

Running Hello World Example
---------------------------

The Hello World Example should be run on the same host.
The network addresses within the configuration files need to be adapted to match
the devices addresses.

To start the hello world client and service from their build-directory do:

HOST1:
VSOMEIP_CONFIGURATION=../helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_service \
./hello_world_service

HOST1:
VSOMEIP_CONFIGURATION=../helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_client \
./hello_world_client

我们在 …/ 目录下并不能找到 helloworld-local.json这个文件。

所以我们需要将 vsomeip/examples/hello_world/helloworld-local.json 文件复制到二进制文件生成的目录下才能执行。

复制后,vsomeip/buuld/examples/hello_world的目录结构为:

image-20221220161547585

下面运行

HOST1运行service:
env VSOMEIP_CONFIGURATION=./helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_service \
./hello_world_service

HOST1运行client:
env VSOMEIP_CONFIGURATION=./helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_client \
./hello_world_client

运行结果如下:

image-20221220161725009

image-20221220161743952

此时,一个简单的vsomeip cilent端和service端的通信就搭建完成了。

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NUAA_Peter

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值