给新手----编译VSOMEIP保姆级别教程
创始人
2025-05-28 20:43:42
0

前言:当你学习了SOMEIP理论基础后,一定很希望上手实操一波吧,本文档以SOMEIP协议里比较成熟的VSOMEIP开源框架为例,带你从0到1实现开源框架的下载到上手,坐稳啦,开车!!!!

1. 下载源码:

在linux终端输入或者windows的minGW里输入:

 git clone Gitee 极速下载/vsomeipGitee 极速下载/vsomeiphttps://gitee.com/mirrors/vsomeip.git

完成所有编译工作后的目录结构如下:

 2. 必要包的安装:

由于linux版本之间有差异性,难以全部罗列,统一以ubuntu20.04举例说明:

请敲以下命令完成boost以及其他

代码

sudo apt-get install libboost-system-dev libboost-thread-dev libboost-log-dev

sudo apt-get install asciidoc source-highlight doxygen graphviz

sudo apt-get install gcc g++ make

3. 编译vsomeip:

进入vsomeip路径下。编译vsomeip库,请执行以下命令:

代码

mkdir build

 

cd build

 

cmake ..

 

make

 

sudo make install

完成所有工作后的记录如下:

 

4. 编译官方提供的helloworld测试案例(熟手跳过)

(可以参考官方关于helloworld案例的readme提示:../vsomeip/examples/hello_world/readme)

请cd 到/examples/hello_world路径下:执行同样的编译命令

代码

mkdir build

 

cd build

 

cmake ..

 

make

编译过程如下图所示:

 5. 执行helloworld测试用例:

5.1 请注意,官方helloworld教程关于“Running Hello World Example”部分有误,需要按照以下方式修改:

把helloworld目录下的helloworld-local.json 复制到build目录里去。

给小白的提示:假设您现在处以 /vsomeip/examples/hello_world/build 路径下,请执行以下代码:

代码

cp ../helloworld-local.json ./

复制完成后helloworld的build应该和我一样。如下图所示:

 

5.2 开两个终端,执行程序:(直接复制粘贴代码)

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

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

Tips:如果提示:Configuration module could not be loaded!请在../vsomeip/examples/hello_world/build路径下输入以下命令完成链接工作,再执行上述执行命令。

代码

sudo ldconfig

5.3 测试结果:

服务端:

2023-03-16 11:14:47.394718 [info] vSomeIP 3.3.0 | (default)

2023-03-16 11:14:57.400489 [info] vSomeIP 3.3.0 | (default)

2023-03-16 11:14:58.263600 [info] Application/Client 5555 is registering.

2023-03-16 11:14:58.264118 [info] Client [4444] is connecting to [5555] at /tmp/vsomeip-5555

2023-03-16 11:14:58.268696 [info] REGISTERED_ACK(5555)

2023-03-16 11:14:58.376506 [info] REQUEST(5555): [1111.2222:255.4294967295]

2023-03-16 11:14:58.387110 [info] RELEASE(5555): [1111.2222]

2023-03-16 11:14:58.388448 [info] Application/Client 5555 is deregistering.

2023-03-16 11:14:58.399715 [info] receive_cbk local_uds_client_endpoint: connection_reset/EOF/bad_descriptor

2023-03-16 11:14:58.496182 [info] Client [4444] is closing connection to [5555]

2023-03-16 11:15:03.385937 [info] STOP OFFER(4444): [1111.2222:0.0] (true)

2023-03-16 11:15:03.387130 [info] Stopping vsomeip application "hello_world_service" (4444).

客户端:

私人信息脱敏/someipCode/vsomeip/examples/hello_world/build$ env VSOMEIP_CONFIGURATION=./helloworld-local.json \

> VSOMEIP_APPLICATION_NAME=hello_world_client \

> ./hello_world_client

2023-03-16 11:14:58.257083 [info] Using configuration file: "./helloworld-local.json".

2023-03-16 11:14:58.257952 [info] Parsed vsomeip configuration in 0ms

2023-03-16 11:14:58.258019 [info] Configuration module loaded.

2023-03-16 11:14:58.258052 [info] Initializing vsomeip application "hello_world_client".

2023-03-16 11:14:58.258194 [info] Instantiating routing manager [Proxy].

2023-03-16 11:14:58.258368 [info] Client [5555] is connecting to [0] at /tmp/vsomeip-0

2023-03-16 11:14:58.258511 [info] Application(hello_world_client, 5555) is initialized (11, 100).

2023-03-16 11:14:58.258655 [info] Starting vsomeip application "hello_world_client" (5555) using 2 threads I/O nice 255

2023-03-16 11:14:58.259440 [info] shutdown thread id from application: 5555 (hello_world_client) is: 7f516931d700 TID: 78921

2023-03-16 11:14:58.260555 [info] io thread id from application: 5555 (hello_world_client) is: 7f5169bc0000 TID: 78919

2023-03-16 11:14:58.260802 [info] io thread id from application: 5555 (hello_world_client) is: 7f5168b1c700 TID: 78922

2023-03-16 11:14:58.262858 [info] create_local_server: Listening @ /tmp/vsomeip-5555

2023-03-16 11:14:58.263042 [info] Client 5555 (hello_world_client) successfully connected to routing  ~> registering..

2023-03-16 11:14:58.263117 [info] Registering to routing manager @ vsomeip-0

2023-03-16 11:14:58.263629 [info] main dispatch thread id from application: 5555 (hello_world_client) is: 7f5169b1e700 TID: 78920

2023-03-16 11:14:58.268148 [info] Application/Client 5555 (hello_world_client) is registered.

2023-03-16 11:14:58.378331 [info] ON_AVAILABLE(5555): [1111.2222:0.0]

Sending: World

2023-03-16 11:14:58.379275 [info] Client [5555] is connecting to [4444] at /tmp/vsomeip-4444

Received: Hello World

2023-03-16 11:14:58.386383 [info] Stopping vsomeip application "hello_world_client" (5555).

2023-03-16 11:14:58.389704 [info] Application/Client 5555 (hello_world_client) is deregistered.

2023-03-16 11:14:58.390784 [info] Client [5555] is closing connection to [4444]

相关内容

热门资讯

民办小学学校学籍管理制度 民办小学学校学籍管理制度(通用18篇)  在社会一步步向前发展的今天,各种制度频频出现,制度对社会经...
国家端午节放假通知 2021年国家端午节放假通知  在发展不断提速的社会中,我们都不可避免地要接触到通知,通知适用于批转...
办公室保洁工作职责 办公室保洁工作职责1、配合保洁部领班,努力完成上级领导交付的工作,服从上司的调遣和安排;2、负责定期...
公司厨房管理制度 公司厨房管理制度(通用5篇)  在现实社会中,很多情况下我们都会接触到制度,制度是国家机关、社会团体...
安全整改通知书 安全整改通知书(集合15篇)  在充满活力,日益开放的今天,需要使用通知的场合越来越多,通知大多属于...
角色的转变与感悟的实习体会 角色的转变与感悟的实习体会  时光如梭,我们xx师范大学xx职中小分队已经在这里度过了十三个星期了,...
青年岗位能手事迹材料 青年岗位能手事迹材料(通用10篇)  在平日的学习、工作和生活里,要用到事迹材料的地方还是很多的,借...
章程修正案 章程修正案  公司创建后,根据公司发展的需要而修改公司章程,而章程修正案就是对公司章程的修改内容由公...
人力资源公司运营的管理方案 人力资源公司运营的管理方案(通用10篇)  为了确保工作或事情能有条不紊地开展,就需要我们事先制定方...
社区工作者事迹 社区工作者事迹青春在平凡的岗位上闪光小时候经常看到戴着红袖章,提着土广播走街串巷的婆婆妈妈们,她们是...
文秘工作内容 文秘工作内容  文秘分为行政文员、办公室文员、秘书等,不同的职业也不同的工作内容,本文主要为您介绍有...
网络安全教育方案 网络安全教育方案(精选9篇)  为保障事情或工作顺利开展,常常需要提前进行细致的方案准备工作,方案是...
XX公司人事管理制度(2) XX公司人事管理制度(2)pan> 关键词: 评论 文章“XX公司人事管理制度(2)” 1、...
公司应急值班管理制度 公司应急值班管理制度(精选10篇)  在社会发展不断提速的今天,人们运用到制度的场合不断增多,制度一...
通知的格式、写法 通知的格式、写法通知是一种使用范围较广的文体。凡需要特定机关和人员知道、办理的事宜,都可以用通知。但...
陕西省建筑职工大学分类考试招... 陕西省建筑职工大学2016年分类考试招生章程  根据国家教育部和陕西省教育厅有关规定,陕西省建筑职工...
大学生寒假就业实践报告 大学生寒假就业实践报告(精选25篇)  转眼难忘的社会实践生活就已结束了,这段经历,相信你有很多感悟...
责任状 责任状范本  责任状作为一种公共管理手段,上下级就某项工作签订责任状,上级将工作任务布置给下级,下级...
工地施工现场管理制度 工地施工现场管理制度(精选17篇)  在当今社会生活中,大家逐渐认识到制度的重要性,制度一经制定颁布...
创意提案改善制度 创意提案改善制度□ 目 的 ?第一条 为启发全体员工的想像力,集结个人的智慧与经验,提出有利于本公司...