当前位置: 首页 > news >正文

给新手----编译VSOMEIP保姆级别教程

前言:当你学习了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]

http://www.lryc.cn/news/40022.html

相关文章:

  • MarkDown设置上下标
  • Python批量爬取游戏卡牌信息
  • 什么是PCB走线的3W原则
  • 计算机网络面试总结
  • VsCode SSH远程连接服务器【内网穿透公网连接】
  • 十八、动画与canvas
  • 自动化测试学习-Day4-selenium的安装和8种定位方法
  • 【Kubernetes】第二十五篇 - 布署 nodejs 后端项目(下)
  • 贪心算法之区间问题总结
  • 无线WiFi安全渗透与攻防(七)之WIFI07-WEP-wifite自动化渗透WEP加密
  • 震撼,支持多模态模型的ChatGPT 4.0发布了
  • IDEA常用插件列表
  • 比df更好用的命令!
  • 【Git使用学习】记录学习过程(1)
  • K_A18_001 基于STM32等单片机采集MQ2传感参数串口与OLED0.96双显示
  • 【云原生·Docker】常用命令
  • 户外露营储能电源芯片CSU3AF10
  • 无线WiFi安全渗透与攻防(八)之WEP-Hirte渗透WEP加密
  • 前端常考面试题整理
  • 二十二、身份验证与权限
  • k8s pod 升级与回滚
  • 【Go】Go语言开发环境安装
  • el-switch使用
  • 【算法入门】字符串基础
  • 前端面试题 —— 浏览器原理(二)
  • 对于植物神经紊乱的治疗 中医采用辩证论治的方法
  • chatGPT之Python API启用上下文管理
  • 油田钻井实时在线监测系统
  • 经典PID控制算法原理以及优化思路
  • 经典面试题之赋值和深浅拷贝的区别