vsomeip环境搭建及helloworld测试例跑通

这篇具有很好参考价值的文章主要介绍了vsomeip环境搭建及helloworld测试例跑通。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

SOME/IP开源库vsomeip系列分析

1. 代码拉取

vsomeip相关代码可以直接从github上获取,如下:

git clone https://github.com/COVESA/vsomeip.git

vsomeip环境搭建及helloworld测试例跑通

vsomeip环境搭建及helloworld测试例跑通

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
```

vsomeip环境搭建及helloworld测试例跑通

 

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之后工程结构:

vsomeip环境搭建及helloworld测试例跑通

出现如上工程结构,则说明已经成功编译了源码,相关的库文件如上截图所示。

2.3编译源码自带的测试例——hello_world

分析从也是从源码自带的hello_world程序开始,因此先编译对应的helloworld程序。

hello_world程序的编译方法可以查看其自带的readme文件vsomeip环境搭建及helloworld测试例跑通,内容如下:

# 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

vsomeip环境搭建及helloworld测试例跑通

3. 测试例运行前准备

通过readme可知,运行程序需要加载指定的配置文件helloworld-local.json, 当前目录下没有该配置文件,需要手动拷贝到当前目录的上一级目录,以当下测试为例:

  • 可执行程序所在目录:/home/nvidia/data/xw/vsomeip/build/examples/hello_world

vsomeip环境搭建及helloworld测试例跑通

  • helloworld-local.json配置文件需要拷贝到可执行程序的上一级目录位置:/home/nvidia/data/xw/vsomeip/build/examples

    vsomeip环境搭建及helloworld测试例跑通

注意:helloworld-local.json配置文件在工程目录:/home/nvidia/data/xw/vsomeip/examples/hello_world位置处可找到,如下:

vsomeip环境搭建及helloworld测试例跑通

4. 运行测试:

//server 端

//测试命令,复制如下全部命令,粘贴到终端,按下enter键运行:
VSOMEIP_CONFIGURATION=../helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_service \
./hello_world_service

//运行结果如下:

nvidia@nvidia-master:~/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).

//截图如下

vsomeip环境搭建及helloworld测试例跑通

//client 端

//测试命令,复制如下全部命令,enter运行
VSOMEIP_CONFIGURATION=../helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_client \
./hello_world_client

//运行结果如下:

nvidia@nvidia-master:~/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]

//运行截图

vsomeip环境搭建及helloworld测试例跑通


过程中遇到的问题记录:

nvidia@nvidia-master:~/data/xw/vsomeip/build/examples$ ./notify-sample
Configuration module could not be loaded!

vsomeip环境搭建及helloworld测试例跑通

解决方法:

nvidia@nvidia-master:~/data/xw/vsomeip/build$ sudo make install
nvidia@nvidia-master:~/data/xw/vsomeip/build/examples$ sudo ldconfig

vsomeip环境搭建及helloworld测试例跑通

顺利运行:

vsomeip环境搭建及helloworld测试例跑通文章来源地址https://www.toymoban.com/news/detail-405434.html

到了这里,关于vsomeip环境搭建及helloworld测试例跑通的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 《一个操作系统的实现》windows用vm安装CentOS——从bochs环境搭建到第一个demo跑通

    vm安装CentOS虚拟机带有桌面的版本。 su 输入密码 123456 。更新 yum -y update 。一般已经安装好后面这2个工具: yum install -y net-tools wget 。 看下ip地址 ifconfig ,然后本地终端连接 ssh root@192.168.249.132 输入密码即可,主要是为了复制网址方便些。大概率 wget https://nchc.dl.sourceforge.net/

    2024年02月11日
    浏览(44)
  • 小米便签开源项目本地环境搭建

    基于Android Studio、和Gradle 的小米便签配置和安装 一、Android Studio的中文社区(官网)下载最新的Android Studio 点击开始传送 http://www.android-studio.org/ 可参考下文安装配置Android StudioAndroid Studio 和 SDK 下载、安装和环境变量配置_siwuxie095的博客-CSDN博客_androidstudio配置sdk 根据指引把

    2023年04月25日
    浏览(44)
  • MIT Cheetah开源代码仿真环境搭建

    参考文章:长乐未央https://zhuanlan.zhihu.com/p/537013183 电脑系统:Ubuntu18.04 ROS版本: ROS Melodic 首先更新一下 安装依赖项 首先是QT5.14.2,下载地址友情链接:QT5.14.2 下载完成后选中下载的QT5文件,右键点击属性,点击权限,勾选允许作为程序执行文件,如下图所示: 然后在该文件

    2023年04月17日
    浏览(45)
  • 跑通GICI-LIB——上海交通大学开源GNSS/INS/Camera组合导航库

    GICI-LIB是由上海交通大学池澄博士开源的GNSS/INS/Camera组合导航库 GICI-LIB原文链接:C. Chi, X. Zhang, J. Liu, Y. Sun, Z. Zhang, and X. Zhan, \\\"GICI-LIB: A GNSS/INS/Camera Integrated Navigation Library,\\\" arXiv preprint, arXiv:2306.13268.  https://doi.org/10.48550/arXiv.2306.13268. GICI-LIB有以下几个特点: 基于 因子图优化(

    2024年02月08日
    浏览(67)
  • 开源元数据管理平台OpenMetadata开发环境搭建

    开源的元数据管理平台很多。开源元数据管理平台是一种用于收集、存储和管理数据的工具,它们提供了一种可扩展的方式来组织和维护数据的元数据信息。以下是一些常见的开源元数据管理平台: Apache Atlas:Apache Atlas是一个开源的大数据元数据管理和数据治理平台,旨在帮

    2024年02月20日
    浏览(40)
  • selenium 自动化测试:如何搭建自动化测试环境,搭建环境过程应该注意的问题

    最近也有很多人私下问我,selenium学习难吗,基础入门的学习内容很多是3以前的版本资料,对于有基础的人来说,3到4的差别虽然有,但是不足以影响自己,但是对于没有学过的人来说,通过资料再到自己写的代码,发现有些东西没有,有些方法又不相同,导致脚本不能运行

    2024年02月10日
    浏览(53)
  • 【前后端的那些事】开源!前后端环境搭建+树形结构表格实现

    前言 :最近写项目,发现了一些很有意思的功能,想写文章,录视频把这些内容记录下。但这些功能太零碎,如果为每个功能都单独搭建一个项目,这明显不合适。于是我想,就搭建一个项目,把那些我想将的小功能全部整合到一起。实现搭一次环境,处处使用。 本文主要

    2024年02月01日
    浏览(50)
  • EtherCat--主站开源的C语言库SOEM-环境搭建

    (一)安装VS; (二)下载SOEM 1.3.1 源代码:链接地址 http://openethercatsociety.github.io/ (三)安装WinPcap_4_1_3.exe:链接地址 https://www.winpcap.org/install/default.htm (一)soem目录:实现主从站功能的主要文件和源文件(头文件和源文件) ethercatbase.c : 基于ether功能函数,将数据封装成

    2024年02月05日
    浏览(42)
  • ❤ React18 环境搭建项目与运行(地址已经放Gitee开源--新体系为webpack搭建)

    记得给个star呀伙伴 Github(https://github.com/NexusLin/NexusReact) Gitee(https://gitee.com/NexusLinNoa/NexusReact) 环境介绍 1、检查本地环境 node版本 18.17.0 检查node和npm环境 node -v npm -v 2、安装yarn npm install -g yarn yarn --version 3、创建一个新的React项目 npx create-react-app ltbreact 4、进入并运行项目

    2024年04月13日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包