当前位置:网站首页>vsomeip环境搭建及helloworld测试例跑通
vsomeip环境搭建及helloworld测试例跑通
2022-08-08 14:07:00 【xw-何妨吟啸且徐行】
SOME/IP开源库vsomeip系列分析
1. 代码拉取
vsomeip相关代码可以直接从github上获取,如下:
git clone https://github.com/COVESA/vsomeip.git
2. 源码编译及测试例运行
vsomeip工程源码编译方法,参考源码中的README文档,内容如下:
### vsomeip
##### Copyright
Copyright (C) 2015-2017, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
##### License
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
##### vsomeip Overview
----------------
The vsomeip stack implements the http://some-ip.com/ (Scalable service-Oriented
MiddlewarE over IP (SOME/IP)) protocol. The stack consists out of:
* a shared library for SOME/IP (`libvsomeip3.so`)
* a second shared library for SOME/IP's service discovery (`libvsomeip3-sd.so`)
which is loaded during runtime if the service discovery is enabled.
##### Build Instructions for Linux
###### Dependencies
- A C++11 enabled compiler like gcc >= 4.8 is needed.
- vsomeip uses CMake as buildsystem.
- vsomeip uses Boost >= 1.55:
Ubuntu 14.04:
`sudo apt-get install libboost-system1.55-dev libboost-thread1.55-dev libboost-log1.55-dev`
Ubuntu 12.04: a PPA is necessary to use version 1.54 of Boost:
-- URL: https://launchpad.net/~boost-latest/+archive/ubuntu/ppa
--`sudo add-apt-repository ppa:boost-latest/ppa`
--`sudo apt-get install libboost-system1.55-dev libboost-thread1.55-dev
libboost-log1.55-dev`
For the tests Google's test framework https://code.google.com/p/googletest/[gtest] in version 1.7.0 is needed.
-- URL: https://googletest.googlecode.com/files/gtest-1.7.0.zip
To build the documentation asciidoc, source-highlight, doxygen and graphviz is needed:
--`sudo apt-get install asciidoc source-highlight doxygen graphviz`
###### Compilation
For compilation call:
```bash
mkdir build
cd build
cmake ..
make
```
To specify a installation directory (like `--prefix=` if you're used to autotools) call cmake like:
```bash
cmake -DCMAKE_INSTALL_PREFIX:PATH=$YOUR_PATH ..
make
make install
```
###### Compilation with predefined unicast and/or diagnosis address
To predefine the unicast address, call cmake like:
```bash
cmake -DUNICAST_ADDRESS=<YOUR IP ADDRESS> ..
```
To predefine the diagnosis address, call cmake like:
```bash
cmake -DDIAGNOSIS_ADDRESS=<YOUR DIAGNOSIS ADDRESS> ..
```
The diagnosis address is a single byte value.
###### Compilation with custom default configuration folder
To change the default configuration folder, call cmake like:
```bash
cmake -DDEFAULT_CONFIGURATION_FOLDER=<DEFAULT CONFIGURATION FOLDER> ..
```
The default configuration folder is /etc/vsomeip.
###### Compilation with custom default configuration file
To change the default configuration file, call cmake like:
```bash
cmake -DDEFAULT_CONFIGURATION_FILE=<DEFAULT CONFIGURATION FILE> ..
```
The default configuration file is /etc/vsomeip.json.
###### Compilation with signal handling
To compile vsomeip with signal handling (SIGINT/SIGTERM) enabled, call cmake like:
```bash
cmake -DENABLE_SIGNAL_HANDLING=1 ..
```
In the default setting, the application has to take care of shutting down vsomeip in case these signals are received.
##### Build Instructions for Android
###### Dependencies
- vsomeip uses Boost >= 1.55. The boost libraries (system, thread and log) must be included in the Android source tree and integrated into the build process with an appropriate Android.bp file.
###### Compilation
In general for building the Android source tree the instructions found on the pages from the Android Open Source Project (AOSP) apply (https://source.android.com/setup/build/requirements).
To integrate the vsomeip library into the build process, the source code together with the Android.bp file has to be inserted into the Android source tree (by simply copying or by fetching with a custom platform manifest).
When building the Android source tree, the Android.bp file is automatically found and considered by the build system.
In order that the vsomeip library is also included in the Android image, the library has to be added to the PRODUCT_PACKAGES variable in one of a device/target specific makefile:
```
PRODUCT_PACKAGES += \
libvsomeip \
libvsomeip_cfg \
libvsomeip_sd
```
2.1.安装依赖
由于我的ubuntu版本是18.04,官方文档上的对应boost包的版本过低,因此这里不需要指定对应的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
2.2 编译vsomeip
进入下载的工程源码根目录,因为vsomeip是通过cmake对工程进行管理的,则新建build目录,进行如下操作:
mkdir build
cd build
cmake ..
make
make之后工程结构:
出现如上工程结构,则说明已经成功编译了源码,相关的库文件如上截图所示。
2.3编译源码自带的测试例——hello_world
分析从也是从源码自带的hello_world程序开始,因此先编译对应的helloworld程序。
hello_world程序的编译方法可以查看其自带的readme文件,内容如下:
# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Build instructions for Hello World example
------------------------------------------
1. Build whole project at first:
________________________________
cd <root directory of vSomeIP-Lib>$:
mkdir build
cd build
cmake ..
make
sudo make install
2. Build hello_world target
___________________________
cmake --build . --target hello_world
cd ./examples/hello_world/
make
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
Expected output service
-----------------------
2015-04-01 11:31:13.248437 [info] Using configuration file: ../helloworld-local.json
2015-04-01 11:31:13.248766 [debug] Routing endpoint at /tmp/vsomeip-0
2015-04-01 11:31:13.248913 [info] Service Discovery disabled. Using static routing information.
2015-04-01 11:31:13.248979 [debug] Application(hello_world_service, 4444) is initialized.
2015-04-01 11:31:22.705010 [debug] Application/Client 5555 got registered!
Expected output client
----------------------
2015-04-01 11:31:22.704166 [info] Using configuration file: ../helloworld-local.json
2015-04-01 11:31:22.704417 [debug] Connecting to [0] at /tmp/vsomeip-0
2015-04-01 11:31:22.704630 [debug] Listening at /tmp/vsomeip-5555
2015-04-01 11:31:22.704680 [debug] Application(hello_world_client, 5555) is initialized.
Sending: World
Received: Hello World
相关的编译命令如下:
cmake --build . --target hello_world
cd ./examples/hello_world/
make
3. 测试例运行前准备
通过readme可知,运行程序需要加载指定的配置文件helloworld-local.json, 当前目录下没有该配置文件,需要手动拷贝到当前目录的上一级目录,以当下测试为例:
- 可执行程序所在目录:/home/nvidia/data/xw/vsomeip/build/examples/hello_world
- helloworld-local.json配置文件需要拷贝到可执行程序的上一级目录位置:/home/nvidia/data/xw/vsomeip/build/examples
注意:helloworld-local.json配置文件在工程目录:/home/nvidia/data/xw/vsomeip/examples/hello_world位置处可找到,如下:
4. 运行测试:
//server 端
//测试命令,复制如下全部命令,粘贴到终端,按下enter键运行:
VSOMEIP_CONFIGURATION=../helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_service \
./hello_world_service
//运行结果如下:
[email protected]:~/data/xw/vsomeip/build/examples/hello_world$ VSOMEIP_CONFIGURATION=../helloworld-local.json \
> VSOMEIP_APPLICATION_NAME=hello_world_service \
> ./hello_world_service
2022-05-15 14:19:57.214866 [info] Parsed vsomeip configuration in 1ms
2022-05-15 14:19:57.217071 [info] Using configuration file: "../helloworld-local.json".
2022-05-15 14:19:57.217994 [info] Configuration module loaded.
2022-05-15 14:19:57.218612 [info] Initializing vsomeip application "hello_world_service".
2022-05-15 14:19:57.220857 [info] Instantiating routing manager [Host].
2022-05-15 14:19:57.221919 [info] create_local_server Routing endpoint at /tmp/vsomeip-0
2022-05-15 14:19:57.224044 [info] Application(hello_world_service, 4444) is initialized (11, 100).
2022-05-15 14:19:57.224674 [info] Starting vsomeip application "hello_world_service" (4444) using 2 threads I/O nice 255
2022-05-15 14:19:57.227687 [info] main dispatch thread id from application: 4444 (hello_world_service) is: 7f8eda11d0 TID: 1348
2022-05-15 14:19:57.228521 [info] shutdown thread id from application: 4444 (hello_world_service) is: 7f8e5a01d0 TID: 1349
2022-05-15 14:19:57.232458 [info] Watchdog is disabled!
2022-05-15 14:19:57.238391 [info] OFFER(4444): [1111.2222:0.0] (true)
2022-05-15 14:19:57.238942 [info] io thread id from application: 4444 (hello_world_service) is: 7f8fc90010 TID: 1346
2022-05-15 14:19:57.242660 [info] vSomeIP 3.1.20.3 | (default)
2022-05-15 14:19:57.239282 [info] io thread id from application: 4444 (hello_world_service) is: 7f8d59e1d0 TID: 1351
2022-05-15 14:19:57.243613 [info] Listening at /tmp/vsomeip-4444
2022-05-15 14:19:58.484243 [info] Application/Client 5555 is registering.
2022-05-15 14:19:58.489425 [info] Client [4444] is connecting to [5555] at /tmp/vsomeip-5555
2022-05-15 14:19:58.497555 [info] REGISTERED_ACK(5555)
2022-05-15 14:19:58.601259 [info] REQUEST(5555): [1111.2222:255.4294967295]
2022-05-15 14:19:58.620860 [info] RELEASE(5555): [1111.2222]
2022-05-15 14:19:58.624073 [info] Application/Client 5555 is deregistering.
2022-05-15 14:19:58.729081 [info] Client [4444] is closing connection to [5555]
2022-05-15 14:20:03.618335 [info] STOP OFFER(4444): [1111.2222:0.0] (true)
2022-05-15 14:20:03.623931 [info] Stopping vsomeip application "hello_world_service" (4444).
//截图如下
//client 端
//测试命令,复制如下全部命令,enter运行
VSOMEIP_CONFIGURATION=../helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_client \
./hello_world_client
//运行结果如下:
[email protected]:~/data/xw/vsomeip/build/examples/hello_world$ VSOMEIP_CONFIGURATION=../helloworld-local.json \ > VSOMEIP_APPLICATION_NAME=hello_world_client \ > ./hello_world_client 2022-05-15 14:19:58.453265 [info] Parsed vsomeip configuration in 1ms 2022-05-15 14:19:58.455301 [info] Using configuration file: "../helloworld-local.json". 2022-05-15 14:19:58.456176 [info] Configuration module loaded. 2022-05-15 14:19:58.456714 [info] Initializing vsomeip application "hello_world_client". 2022-05-15 14:19:58.457180 [info] Instantiating routing manager [Proxy]. 2022-05-15 14:19:58.457835 [info] Client [5555] is connecting to [0] at /tmp/vsomeip-0 2022-05-15 14:19:58.458461 [info] Application(hello_world_client, 5555) is initialized (11, 100). 2022-05-15 14:19:58.459481 [info] Starting vsomeip application "hello_world_client" (5555) using 2 threads I/O nice 255 2022-05-15 14:19:58.463607 [info] main dispatch thread id from application: 5555 (hello_world_client) is: 7f8693b1d0 TID: 1353 2022-05-15 14:19:58.463384 [info] shutdown thread id from application: 5555 (hello_world_client) is: 7f8613a1d0 TID: 1354 2022-05-15 14:19:58.474254 [info] io thread id from application: 5555 (hello_world_client) is: 7f87029010 TID: 1352 2022-05-15 14:19:58.474509 [info] io thread id from application: 5555 (hello_world_client) is: 7f7ffff1d0 TID: 1355 2022-05-15 14:19:58.482142 [info] Listening at /tmp/vsomeip-5555 2022-05-15 14:19:58.483037 [info] Client 5555 (hello_world_client) successfully connected to routing ~> registering.. 2022-05-15 14:19:58.495687 [info] Application/Client 5555 (hello_world_client) is registered. 2022-05-15 14:19:58.604220 [info] ON_AVAILABLE(5555): [1111.2222:0.0] Sending: World 2022-05-15 14:19:58.607258 [info] Client [5555] is connecting to [4444] at /tmp/vsomeip-4444 Received: Hello World 2022-05-15 14:19:58.620268 [info] Stopping vsomeip application "hello_world_client" (5555). 2022-05-15 14:19:58.626685 [info] Application/Client 5555 (hello_world_client) is deregistered. 2022-05-15 14:19:58.631236 [info] Client [5555] is closing connection to [4444]
//运行截图
过程中遇到的问题记录:
[email protected]:~/data/xw/vsomeip/build/examples$ ./notify-sample
Configuration module could not be loaded!
解决方法:
[email protected]:~/data/xw/vsomeip/build$ sudo make install
[email protected]:~/data/xw/vsomeip/build/examples$ sudo ldconfig
顺利运行:
边栏推荐
- 哈佛大学砸场子:DALL-E 2只是「粘合怪」,生成正确率只有22%
- Talking about the underlying data structure of Redis
- 【电路基础2】电容
- sample函数—R语言
- 「复盘」面试BAMT回来整理398道高频面试题,助你拿高薪offer
- [Redis] Bitmap and usage scenarios of bitmap (statistics of online people and user online status)
- shell------常用小工具,sort,uniq,tr,cut
- itk中图像2d-3d配准整理
- 6.【opencv鼠标回调事件】
- 看三年的CRUD程序员如何解决数据库死锁的
猜你喜欢
Experience Sharing | Systematic Design and Development of Business Cache
pip install xxx 出现 AttributeError: ‘tuple’ object has no attribute ‘read’ 错误
【os.path】的相关用法(持更)
【Redis】位图以及位图的使用场景(统计在线人数和用户在线状态)
复盘:什么是秋招提前批?什么是普通秋招?都是招聘,为啥要设置这两个招聘时间段
shell正则表达式,三剑客grep命令
直播卖货APP——为何能得到商家和用户的喜欢?
a += 1 += 1为什么是错的?
「复盘」面试BAMT回来整理398道高频面试题,助你拿高薪offer
Implementation of FIR filter based on FPGA (1) - using fir1 function design
随机推荐
线程的状态简介说明
serialize 序列化原生方法
【个人总结】2022.8.7周结
一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
教学习编程,第一步解决自信问题,培养自己的专注力
MapStruct入门使用
路由器——交换机——网络交换机:区别
手把手教你设计一个全局异常处理器
设计一个跨平台的即时通讯系统(采用华为云ECS服务器作为服务端 )【华为云至简致远】
用 Antlr 重构脚本解释器
Pretraining Weekly Issue 56: Long Text Understanding, Instant Question Answering, Mask Self-Supervision
Tsinghua | GLM-130B: An Open Bilingual Pre-training Model
基于QWebassembly的一个数据库监测工具
浅学一下二叉树链式存储结构的遍历
【Rust—LeetCode题解】1.两数之和
【黑马早报】巴菲特罕见巨亏近3000亿;周鸿祎回应360不能卸载;三亚倡议酒店不变相提高房价;首个国产抗新冠口服药定价不超300元...
HackTheBox | Horizontall
作为一个十年卷王,告诫你们年轻人应该如何才能认清自己的价值
Kotlin系列之let、with、run、apply、also函数的使用
【LeetCode】761. 特殊的二进制序列