Commit febe61b2 authored by lubin's avatar lubin 💬

create a init version and project is from The Connected Vehicle Systems Alliance (COVESA)

parents
Pipeline #3946 canceled with stages
Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
\ No newline at end of file
libvsomeip_srcs = [
"implementation/endpoints/**/*.cpp",
"implementation/logging/**/*.cpp",
"implementation/tracing/**/*.cpp",
"implementation/message/**/*.cpp",
"implementation/routing/**/*.cpp",
"implementation/runtime/**/*.cpp",
"implementation/utility/**/*.cpp",
"implementation/plugin/**/*.cpp",
"implementation/security/**/*.cpp",
"implementation/logger/**/*.cpp",
]
libvsomeip_cfg_srcs = [
"implementation/configuration/src/*.cpp",
]
libvsomeip_e2e_srcs = [
"implementation/e2e_protection/src/*.cpp",
]
libvsomeip_sd_srcs = [
"implementation/service_discovery/src/*.cpp",
]
cc_defaults {
name: "vsomeip_defaults",
header_libs: [
"libboost_headers",
],
local_include_dirs: [
"interface",
"implementation/helper/1.70",
],
rtti: true,
cppflags: [
"-std=c++11",
"-fexceptions",
"-Wno-non-virtual-dtor",
"-Wno-unused-const-variable",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-lambda-capture",
"-Wno-unused-variable",
"-Wno-unused-local-typedef",
"-Wno-sign-compare",
"-Wno-format",
"-Wno-header-guard",
"-Wno-overloaded-virtual",
"-Wno-implicit-fallthrough"
]
}
cc_library_shared {
name: "libvsomeip3",
vendor: true,
srcs: libvsomeip_srcs,
defaults: [
"vsomeip_defaults"
],
cflags: [
"-DWITHOUT_SYSTEMD"
],
rtti: true,
local_include_dirs: [
"interface",
"implementation/helper/1.70"
],
export_include_dirs: [
"interface"
],
static_libs: [
"libboost_system",
"libboost_thread",
"libboost_filesystem",
],
shared_libs: [
"liblog",
"libutils"
]
}
cc_library_shared {
name: "libvsomeip3-cfg",
vendor: true,
srcs: libvsomeip_cfg_srcs,
defaults: [
"vsomeip_defaults"
],
rtti: true,
local_include_dirs: [
"interface",
"implementation/helper/1.70"
],
shared_libs: [
"libvsomeip3",
"libboost_system",
"libboost_filesystem"
]
}
cc_library_shared {
name: "libvsomeip3-e2e",
vendor: true,
srcs: libvsomeip_e2e_srcs,
defaults: [
"vsomeip_defaults"
],
rtti: true,
local_include_dirs: [
"interface",
"implementation/helper/1.70"
],
shared_libs: [
"libvsomeip3",
"liblog"
]
}
cc_library_shared {
name: "libvsomeip3-sd",
vendor: true,
srcs: libvsomeip_sd_srcs,
defaults: [
"vsomeip_defaults"
],
rtti: true,
local_include_dirs: [
"interface",
"implementation/helper/1.70"
],
shared_libs: [
"libvsomeip3",
"liblog",
"libboost_thread"
]
}
cc_defaults {
name: "vsomeip_example_defaults",
vendor: true,
owner: "ts",
shared_libs: [
"libvsomeip3"
],
}
cc_binary {
name: "vsomeip-helloworld-client",
defaults: ["vsomeip_example_defaults"],
srcs: [
"examples/hello_world/hello_world_client.cpp",
],
}
cc_binary {
name: "vsomeip-helloworld-service",
defaults: ["vsomeip_example_defaults"],
srcs: [
"examples/hello_world/hello_world_service.cpp",
],
}
cc_binary {
name: "vsomeip-notify-sample",
defaults: ["vsomeip_example_defaults"],
srcs: [
"examples/notify-sample.cpp",
],
}
cc_binary {
name: "vsomeip-request-sample",
defaults: ["vsomeip_example_defaults"],
srcs: [
"examples/request-sample.cpp",
],
}
cc_binary {
name: "vsomeip-response-sample",
defaults: ["vsomeip_example_defaults"],
srcs: [
"examples/response-sample.cpp",
],
}
cc_binary {
name: "vsomeip-subscribe-sample",
defaults: ["vsomeip_example_defaults"],
srcs: [
"examples/subscribe-sample.cpp",
],
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This license applies to all files in directory implementation/helper/boost:
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
### 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
```
\ No newline at end of file
{
"unicast" : "10.0.3.1",
"logging" :
{
"level" : "info",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
},
{
"name" : "client-sample",
"id" : "0x1344"
}
],
"security" :
{
"check_credentials" : "true",
"policies" :
[
{
"client" : "0x1277",
"credentials" : { "uid" : "1000", "gid" : "1000" },
"allow" :
{
"offers":
[
{
"service" : "0x1234",
"instance" : "0x5678"
},
{
"service" : "0x1235",
"instance" : "0x5678"
}
]
}
},
{
"client" : "0x1344",
"credentials" : { "uid" : "1000", "gid" : "1000" },
"allow" :
{
"requests":
[
{
"service" : "0x1234",
"instance" : "0x5678"
}
]
}
}
]
},
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "192.168.56.101",
"netmask" : "255.255.255.0",
"logging" :
{
"level" : "info",
"console" : "true",
"file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" },
"dlt" : "true"
},
"applications" :
[
{
"name" : "client-sample",
"id" : "0x1343"
},
{
"name" : "second-client-sample",
"id" : "0x1344"
},
{
"name" : "third-client-sample",
"id" : "0x1345"
},
{
"name" : "fourth-client-sample",
"id" : "0x1346"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unicast" : "192.168.56.102",
"reliable" : { "port" : "30509", "magic-cookies" : false },
"events" :
[
{
"event" : "0x0777",
"is_field" : "true"
},
{
"event" : "0x0778",
"is_field" : "false"
},
{
"event" : "0x0779",
"is_field" : "true"
}
],
"eventgroups" :
[
{
"eventgroup" : "0x4455",
"events" : [ "0x777", "0x778" ]
},
{
"eventgroup" : "0x4465",
"events" : [ "0x778", "0x779" ]
},
{
"eventgroup" : "0x4555",
"events" : [ "0x777", "0x779" ]
}
]
}
],
"routing" : "client-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.0.0.1",
"port" : "30491",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "192.168.56.102",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"reliable" : { "port" : "30509", "magic-cookies" : "false" },
"events" :
[
{
"event" : "0x0777",
"is_field" : "false",
"is_reliable" : "true",
"update-cycle" : 2000
},
{
"event" : "0x0778",
"is_field" : "true",
"is_reliable" : "true",
"update-cycle" : 0
},
{
"event" : "0x0779",
"is_field" : "false",
"is_reliable" : "true"
}
],
"eventgroups" :
[
{
"eventgroup" : "0x4455",
"events" : [ "0x777", "0x778" ]
},
{
"eventgroup" : "0x4465",
"events" : [ "0x778", "0x779" ]
},
{
"eventgroup" : "0x4555",
"events" : [ "0x777", "0x779" ]
}
]
}
],
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.0.0.1",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "10.0.2.15",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"tracing" :
{
"enable" : "true"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
},
{
"name" : "client-sample",
"id" : "0x1344"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : "30509",
"multicast" :
{
"address" : "224.225.226.233",
"port" : "32344"
},
"events" :
[
{
"event" : "0x0777",
"is_field" : "true",
"update-cycle" : 2000
},
{
"event" : "0x0778",
"is_field" : "true",
"update-cycle" : 0
},
{
"event" : "0x0779",
"is_field" : "true"
}
],
"eventgroups" :
[
{
"eventgroup" : "0x4455",
"events" : [ "0x777", "0x778" ]
},
{
"eventgroup" : "0x4465",
"events" : [ "0x778", "0x779" ],
"is_multicast" : "true"
},
{
"eventgroup" : "0x4555",
"events" : [ "0x777", "0x779" ]
}
]
}
],
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "10.0.2.15",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
},
{
"name" : "client-sample",
"id" : "0x1344"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : "30509",
"multicast" :
{
"address" : "224.225.226.233",
"port" : "32344"
},
"events" :
[
{
"event" : "0x0777",
"is_field" : "true",
"update-cycle" : 2000
},
{
"event" : "0x0778",
"is_field" : "true",
"update-cycle" : 0
},
{
"event" : "0x0779",
"is_field" : "true"
}
],
"eventgroups" :
[
{
"eventgroup" : "0x4455",
"events" : [ "0x777", "0x778" ]
},
{
"eventgroup" : "0x4465",
"events" : [ "0x778", "0x779" ],
"is_multicast" : "true"
},
{
"eventgroup" : "0x4555",
"events" : [ "0x777", "0x779" ]
}
]
}
],
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "10.0.3.28",
"netmask" : "255.255.255.0",
"logging" :
{
"level" : "info",
"console" : "true",
"file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" },
"dlt" : "true"
},
"applications" :
[
{
"name" : "client-sample",
"id" : "0x1343"
},
{
"name" : "second-client-sample",
"id" : "0x1344"
},
{
"name" : "third-client-sample",
"id" : "0x1345"
},
{
"name" : "fourth-client-sample",
"id" : "0x1346"
}
],
"clients" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"reliable" : [ "41234" ]
}
],
"security" :
{
"check_credentials" : "true",
"policies" :
[
{
"client" : { "first" : "0x1343", "last" : "0x1346" },
"credentials" : { "uid" : "0", "gid" : "0" },
"allow" :
{
"requests":
[
{
"service" : "0x1234",
"instance" : "0x5678"
}
]
}
}
]
},
"routing" : "client-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "192.168.56.101",
"netmask" : "255.255.255.0",
"logging" :
{
"level" : "info",
"console" : "true",
"file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" },
"dlt" : "true"
},
"applications" :
[
{
"name" : "client-sample",
"id" : "0x1343"
},
{
"name" : "second-client-sample",
"id" : "0x1344"
},
{
"name" : "third-client-sample",
"id" : "0x1345"
},
{
"name" : "fourth-client-sample",
"id" : "0x1346"
}
],
"clients" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"reliable" : [ "41234" ]
}
],
"routing" : "client-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "10.0.3.1",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }
},
{
"service" : "0x1235",
"instance" : "0x5678",
"unreliable" : "30509",
"multicast" :
{
"address" : "224.225.226.234",
"port" : "32344"
}
}
],
"security" :
{
"check_credentials" : "true",
"policies" :
[
{
"client" : "0x1277",
"credentials" : { "uid" : "1000", "gid" : "1000" },
"allow" :
{
"offers":
[
{
"service" : "0x1234",
"instance" : "0x5678"
},
{
"service" : "0x1235",
"instance" : "0x5678"
}
]
}
},
{
"client" : { "first" : "0x1343", "last" : "0x1346" },
"allow" :
{
"requests":
[
{
"service" : "0x1234",
"instance" : "0x5678"
}
]
}
}
]
},
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "192.168.56.101",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
"events" :
[
{
"event" : "0x8777",
"is_field" : "false",
"is_reliable" : "true",
"update-cycle" : "2000"
},
{
"event" : "0x8778",
"is_field" : "true",
"is_reliable" : "true",
"update-cycle" : "0"
},
{
"event" : "0x8779",
"is_field" : "false",
"is_reliable" : "true"
}
],
"eventgroups" :
[
{
"eventgroup" : "0x4455",
"events" : [ "0x8777", "0x8778" ]
},
{
"eventgroup" : "0x4465",
"events" : [ "0x8778", "0x8779" ]
},
{
"eventgroup" : "0x4555",
"events" : [ "0x8777", "0x8779" ]
}
]
},
{
"service" : "0x1235",
"instance" : "0x5678",
"unreliable" : "30509",
"multicast" :
{
"address" : "224.225.226.234",
"port" : "32344"
}
}
],
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "10.0.3.28",
"netmask" : "255.255.255.0",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" },
"dlt" : "true"
},
"applications" :
[
{
"name" : "client-sample",
"id" : "0x1343"
},
{
"name" : "second-client-sample",
"id" : "0x1344"
},
{
"name" : "third-client-sample",
"id" : "0x1345"
},
{
"name" : "fourth-client-sample",
"id" : "0x1346"
}
],
"clients" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : [ 40000, 40002 ]
}
],
"security" :
{
"check_credentials" : "true",
"policies" :
[
{
"client" : { "first" : "0x1343", "last" : "0x1346" },
"credentials" : { "uid" : "0", "gid" : "0" },
"allow" :
{
"requests":
[
{
"service" : "0x1234",
"instance" : "0x5678"
}
]
}
}
]
},
"routing" : "client-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "192.168.56.101",
"netmask" : "255.255.255.0",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" },
"dlt" : "true"
},
"applications" :
[
{
"name" : "client-sample",
"id" : "0x1343"
},
{
"name" : "second-client-sample",
"id" : "0x1344"
},
{
"name" : "third-client-sample",
"id" : "0x1345"
},
{
"name" : "fourth-client-sample",
"id" : "0x1346"
}
],
"clients" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : [ 40000, 40002 ]
}
],
"routing" : "client-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "10.0.3.1",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : "30509"
},
{
"service" : "0x1235",
"instance" : "0x5678",
"unreliable" : "30509",
"multicast" :
{
"address" : "224.225.226.234",
"port" : "32344"
}
}
],
"security" :
{
"check_credentials" : "true",
"policies" :
[
{
"client" : "0x1277",
"credentials" : { "uid" : "1000", "gid" : "1000" },
"allow" :
{
"offers":
[
{
"service" : "0x1234",
"instance" : "0x5678"
},
{
"service" : "0x1235",
"instance" : "0x5678"
}
]
}
},
{
"client" : { "first" : "0x1343", "last" : "0x1346" },
"allow" :
{
"requests":
[
{
"service" : "0x1234",
"instance" : "0x5678"
}
]
}
}
]
},
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "192.168.56.101",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "service-sample",
"id" : "0x1277"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : "30509",
"events" :
[
{
"event" : "0x8777",
"is_field" : "true",
"update-cycle" : 2000
},
{
"event" : "0x8778",
"is_field" : "true",
"update-cycle" : 0
},
{
"event" : "0x8779",
"is_field" : "true"
}
],
"eventgroups" :
[
{
"eventgroup" : "0x4455",
"events" : [ "0x8777", "0x8778" ]
},
{
"eventgroup" : "0x4465",
"events" : [ "0x8778", "0x8779" ],
"multicast" :
{
"address" : "224.225.226.233",
"port" : "32344"
}
},
{
"eventgroup" : "0x4555",
"events" : [ "0x8777", "0x8779" ]
}
]
},
{
"service" : "0x1235",
"instance" : "0x5678",
"unreliable" : "30509",
"multicast" :
{
"address" : "224.225.226.234",
"port" : "32344"
}
}
],
"routing" : "service-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
{
"unicast" : "192.168.56.101",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "client-sample",
"id" : "0x1343"
},
{
"name" : "other-client-sample",
"id" : "0x1344"
},
{
"name" : "service-sample",
"id" : "0x1277"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
"unreliable" : "31000"
},
{
"service" : "0x1235",
"instance" : "0x5678",
"reliable" : { "port" : "30506", "enable-magic-cookies" : false },
"unreliable" : "31000"
}
],
"routing" : "client-sample",
"service-discovery" :
{
"enable" : "true",
"multicast" : "224.244.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
This diff is collapsed.
To use IP multicast, the route must be added. In Linux this can be done
by:
# route add -net 224.0.0.0/4 dev eth0
Other OSes may have different ways to do this.
TODO:
- update the EA model to match the current implementation
This diff is collapsed.
# 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/.
cmake_minimum_required (VERSION 2.8)
set(EXAMPLE_CONFIG_FILES
"../config/vsomeip.json"
"../config/vsomeip-local.json"
"../config/vsomeip-tcp-client.json"
"../config/vsomeip-tcp-service.json"
"../config/vsomeip-udp-client.json"
"../config/vsomeip-udp-service.json"
)
# Examples
add_executable(request-sample request-sample.cpp ${EXAMPLE_CONFIG_FILES})
target_link_libraries(request-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY})
add_executable(response-sample response-sample.cpp ${EXAMPLE_CONFIG_FILES})
target_link_libraries(response-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY})
add_executable(subscribe-sample subscribe-sample.cpp ${EXAMPLE_CONFIG_FILES})
target_link_libraries(subscribe-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY})
add_executable(notify-sample notify-sample.cpp ${EXAMPLE_CONFIG_FILES})
target_link_libraries(notify-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY})
add_dependencies(examples request-sample response-sample subscribe-sample notify-sample)
install (
TARGETS request-sample response-sample subscribe-sample notify-sample
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
)
###################################################################################################
cc_defaults {
name: "vsomeip_hello_world_defaults",
vendor: true,
cppflags: [
"-std=c++11",
"-Wno-unused-parameter",
],
shared_libs: [
"libvsomeip3",
"libvsomeip3-cfg",
"libvsomeip3-e2e",
"libvsomeip3-sd",
"liblog",
],
}
cc_binary {
name: "vsomeip_hello_world_service",
defaults: ["vsomeip_hello_world_defaults"],
srcs: [
"hello_world_service_main.cpp",
],
}
cc_binary {
name: "vsomeip_hello_world_client",
defaults: ["vsomeip_hello_world_defaults"],
srcs: [
"hello_world_client_main.cpp",
],
}
prebuilt_etc {
name: "helloworld-local.json",
vendor: true,
sub_dir: "vsomeip",
src: "helloworld-local.json",
}
# 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/.
cmake_minimum_required (VERSION 2.8.7)
project (vSomeIPHelloWorld)
find_package(Threads REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(${VSOMEIP_INCLUDE_DIRS})
add_library(vsomeip_hello_world_service INTERFACE)
target_sources(vsomeip_hello_world_service INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/hello_world_service.hpp"
)
target_include_directories(vsomeip_hello_world_service INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}"
)
add_library(vsomeip_hello_world_client INTERFACE)
target_sources(vsomeip_hello_world_client INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/hello_world_client.hpp"
)
target_include_directories(vsomeip_hello_world_client INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}"
)
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
# This will get us acces to
# VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP
# VSOMEIP_LIBRARIES - libraries to link against
find_package(${VSOMEIP_NAME})
if (NOT ${VSOMEIP_NAME}_FOUND)
message("${VSOMEIP_NAME} was not found. Please specify vsomeip_DIR")
endif()
add_executable (hello_world_service hello_world_service_main.cpp)
target_link_libraries(hello_world_service vsomeip_hello_world_service ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
add_executable (hello_world_client hello_world_client_main.cpp)
target_link_libraries(hello_world_client vsomeip_hello_world_client ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()
// 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/.
#include <vsomeip/vsomeip.hpp>
#if defined ANDROID || defined __ANDROID__
#include "android/log.h"
#define LOG_TAG "hello_world_client"
#define LOG_INF(...) fprintf(stdout, __VA_ARGS__), fprintf(stdout, "\n"), (void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, ##__VA_ARGS__)
#define LOG_ERR(...) fprintf(stderr, __VA_ARGS__), fprintf(stderr, "\n"), (void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, ##__VA_ARGS__)
#else
#include <cstdio>
#define LOG_INF(...) fprintf(stdout, __VA_ARGS__), fprintf(stdout, "\n")
#define LOG_ERR(...) fprintf(stderr, __VA_ARGS__), fprintf(stderr, "\n")
#endif
static vsomeip::service_t service_id = 0x1111;
static vsomeip::instance_t service_instance_id = 0x2222;
static vsomeip::method_t service_method_id = 0x3333;
class hello_world_client {
public:
// Get the vSomeIP runtime and
// create a application via the runtime, we could pass the application name
// here otherwise the name supplied via the VSOMEIP_APPLICATION_NAME
// environment variable is used
hello_world_client() :
rtm_(vsomeip::runtime::get()),
app_(rtm_->create_application())
{
}
bool init(){
// init the application
if (!app_->init()) {
LOG_ERR ("Couldn't initialize application");
return false;
}
// register a state handler to get called back after registration at the
// runtime was successful
app_->register_state_handler(
std::bind(&hello_world_client::on_state_cbk, this,
std::placeholders::_1));
// register a callback for responses from the service
app_->register_message_handler(vsomeip::ANY_SERVICE,
service_instance_id, vsomeip::ANY_METHOD,
std::bind(&hello_world_client::on_message_cbk, this,
std::placeholders::_1));
// register a callback which is called as soon as the service is available
app_->register_availability_handler(service_id, service_instance_id,
std::bind(&hello_world_client::on_availability_cbk, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
return true;
}
void start()
{
// start the application and wait for the on_event callback to be called
// this method only returns when app_->stop() is called
app_->start();
}
void on_state_cbk(vsomeip::state_type_e _state)
{
if(_state == vsomeip::state_type_e::ST_REGISTERED)
{
// we are registered at the runtime now we can request the service
// and wait for the on_availability callback to be called
app_->request_service(service_id, service_instance_id);
}
}
void on_availability_cbk(vsomeip::service_t _service,
vsomeip::instance_t _instance, bool _is_available)
{
// Check if the available service is the the hello world service
if(service_id == _service && service_instance_id == _instance
&& _is_available)
{
// The service is available then we send the request
// Create a new request
std::shared_ptr<vsomeip::message> rq = rtm_->create_request();
// Set the hello world service as target of the request
rq->set_service(service_id);
rq->set_instance(service_instance_id);
rq->set_method(service_method_id);
// Create a payload which will be sent to the service
std::shared_ptr<vsomeip::payload> pl = rtm_->create_payload();
std::string str("World");
std::vector<vsomeip::byte_t> pl_data(std::begin(str), std::end(str));
pl->set_data(pl_data);
rq->set_payload(pl);
// Send the request to the service. Response will be delivered to the
// registered message handler
LOG_INF("Sending: %s", str.c_str());
app_->send(rq);
}
}
void on_message_cbk(const std::shared_ptr<vsomeip::message> &_response)
{
if(service_id == _response->get_service()
&& service_instance_id == _response->get_instance()
&& vsomeip::message_type_e::MT_RESPONSE
== _response->get_message_type()
&& vsomeip::return_code_e::E_OK == _response->get_return_code())
{
// Get the payload and print it
std::shared_ptr<vsomeip::payload> pl = _response->get_payload();
std::string resp = std::string(
reinterpret_cast<const char*>(pl->get_data()), 0,
pl->get_length());
LOG_INF("Received: %s", resp.c_str());
stop();
}
}
void stop()
{
// unregister the state handler
app_->unregister_state_handler();
// unregister the message handler
app_->unregister_message_handler(vsomeip::ANY_SERVICE,
service_instance_id, vsomeip::ANY_METHOD);
// alternatively unregister all registered handlers at once
app_->clear_all_handler();
// release the service
app_->release_service(service_id, service_instance_id);
// shutdown the application
app_->stop();
}
private:
std::shared_ptr<vsomeip::runtime> rtm_;
std::shared_ptr<vsomeip::application> app_;
};
// 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/.
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
#include <csignal>
#endif
#include <vsomeip/vsomeip.hpp>
#include "hello_world_client.hpp"
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
hello_world_client *hw_cl_ptr(nullptr);
void handle_signal(int _signal) {
if (hw_cl_ptr != nullptr &&
(_signal == SIGINT || _signal == SIGTERM))
hw_cl_ptr->stop();
}
#endif
int main(int argc, char **argv)
{
(void)argc;
(void)argv;
hello_world_client hw_cl;
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
hw_cl_ptr = &hw_cl;
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);
#endif
if (hw_cl.init()) {
hw_cl.start();
return 0;
} else {
return 1;
}
}
// 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/.
#include <vsomeip/vsomeip.hpp>
#include <chrono>
#include <thread>
#include <condition_variable>
#include <mutex>
#if defined ANDROID || defined __ANDROID__
#include "android/log.h"
#define LOG_TAG "hello_world_service"
#define LOG_INF(...) fprintf(stdout, __VA_ARGS__), fprintf(stdout, "\n"), (void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, ##__VA_ARGS__)
#define LOG_ERR(...) fprintf(stderr, __VA_ARGS__), fprintf(stderr, "\n"), (void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, ##__VA_ARGS__)
#else
#include <cstdio>
#define LOG_INF(...) fprintf(stdout, __VA_ARGS__), fprintf(stdout, "\n")
#define LOG_ERR(...) fprintf(stderr, __VA_ARGS__), fprintf(stderr, "\n")
#endif
static vsomeip::service_t service_id = 0x1111;
static vsomeip::instance_t service_instance_id = 0x2222;
static vsomeip::method_t service_method_id = 0x3333;
class hello_world_service {
public:
// Get the vSomeIP runtime and
// create a application via the runtime, we could pass the application name
// here otherwise the name supplied via the VSOMEIP_APPLICATION_NAME
// environment variable is used
hello_world_service() :
rtm_(vsomeip::runtime::get()),
app_(rtm_->create_application()),
stop_(false),
stop_thread_(std::bind(&hello_world_service::stop, this))
{
}
~hello_world_service()
{
stop_thread_.join();
}
bool init()
{
// init the application
if (!app_->init()) {
LOG_ERR("Couldn't initialize application");
return false;
}
// register a message handler callback for messages sent to our service
app_->register_message_handler(service_id, service_instance_id,
service_method_id,
std::bind(&hello_world_service::on_message_cbk, this,
std::placeholders::_1));
// register a state handler to get called back after registration at the
// runtime was successful
app_->register_state_handler(
std::bind(&hello_world_service::on_state_cbk, this,
std::placeholders::_1));
return true;
}
void start()
{
// start the application and wait for the on_event callback to be called
// this method only returns when app_->stop() is called
app_->start();
}
void stop()
{
std::unique_lock<std::mutex> its_lock(mutex_);
while(!stop_) {
condition_.wait(its_lock);
}
std::this_thread::sleep_for(std::chrono::seconds(5));
// Stop offering the service
app_->stop_offer_service(service_id, service_instance_id);
// unregister the state handler
app_->unregister_state_handler();
// unregister the message handler
app_->unregister_message_handler(service_id, service_instance_id,
service_method_id);
// shutdown the application
app_->stop();
}
void terminate() {
std::lock_guard<std::mutex> its_lock(mutex_);
stop_ = true;
condition_.notify_one();
}
void on_state_cbk(vsomeip::state_type_e _state)
{
if(_state == vsomeip::state_type_e::ST_REGISTERED)
{
// we are registered at the runtime and can offer our service
app_->offer_service(service_id, service_instance_id);
}
}
void on_message_cbk(const std::shared_ptr<vsomeip::message> &_request)
{
// Create a response based upon the request
std::shared_ptr<vsomeip::message> resp = rtm_->create_response(_request);
// Construct string to send back
std::string str("Hello ");
str.append(
reinterpret_cast<const char*>(_request->get_payload()->get_data()),
0, _request->get_payload()->get_length());
// Create a payload which will be sent back to the client
std::shared_ptr<vsomeip::payload> resp_pl = rtm_->create_payload();
std::vector<vsomeip::byte_t> pl_data(str.begin(), str.end());
resp_pl->set_data(pl_data);
resp->set_payload(resp_pl);
// Send the response back
app_->send(resp);
// we have finished
terminate();
}
private:
std::shared_ptr<vsomeip::runtime> rtm_;
std::shared_ptr<vsomeip::application> app_;
bool stop_;
std::mutex mutex_;
std::condition_variable condition_;
std::thread stop_thread_;
};
// 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/.
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
#include <csignal>
#endif
#include <vsomeip/vsomeip.hpp>
#include "hello_world_service.hpp"
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
hello_world_service *hw_srv_ptr(nullptr);
void handle_signal(int _signal) {
if (hw_srv_ptr != nullptr &&
(_signal == SIGINT || _signal == SIGTERM))
hw_srv_ptr->terminate();
}
#endif
int main(int argc, char **argv)
{
(void)argc;
(void)argv;
hello_world_service hw_srv;
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
hw_srv_ptr = &hw_srv;
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);
#endif
if (hw_srv.init()) {
hw_srv.start();
return 0;
} else {
return 1;
}
}
{
"unicast":"134.86.56.94",
"logging":
{
"level":"debug",
"console":"true"
},
"applications":
[
{
"name":"hello_world_service",
"id":"0x4444"
},
{
"name":"hello_world_client",
"id":"0x5555"
}
],
"services":
[
{
"service":"0x1111",
"instance":"0x2222",
"unreliable":"30509"
}
],
"routing":"hello_world_service",
"service-discovery":
{
"enable":"false"
}
}
# 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
AOSP:
1. Apply vsomeip project to AOSP tree and build hello_world example (e.g. via mma build command)
2. Push changes to target
3. Start service and client via different adb shell sessions under root user:
Shell1:
VSOMEIP_CONFIGURATION=/vendor/etc/vsomeip/helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_service \
vsomeip_hello_world_service
Shell2:
VSOMEIP_CONFIGURATION=/vendor/etc/vsomeip/helloworld-local.json \
VSOMEIP_APPLICATION_NAME=hello_world_client \
vsomeip_hello_world_client
NDK:
AndroidStudio example how to use vsomeip like communication mechanism between two Android services:
https://github.com/nkh-lab/ndk-vsomeip-hello-world
Expected Android app Logcat output:
2020-06-05 11:13:06.407 31221-31266/com.example.vsomeiphelloworld I/hello_world_client: Sending: World
2020-06-05 11:13:06.437 31221-31266/com.example.vsomeiphelloworld I/hello_world_client: Received: Hello World
// Copyright (C) 2014-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/.
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
#include <csignal>
#endif
#include <chrono>
#include <condition_variable>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <thread>
#include <mutex>
#include <vsomeip/vsomeip.hpp>
#include "sample-ids.hpp"
class service_sample {
public:
service_sample(bool _use_tcp, uint32_t _cycle) :
app_(vsomeip::runtime::get()->create_application()),
is_registered_(false),
use_tcp_(_use_tcp),
cycle_(_cycle),
blocked_(false),
running_(true),
is_offered_(false),
offer_thread_(std::bind(&service_sample::run, this)),
notify_thread_(std::bind(&service_sample::notify, this)) {
}
bool init() {
std::lock_guard<std::mutex> its_lock(mutex_);
if (!app_->init()) {
std::cerr << "Couldn't initialize application" << std::endl;
return false;
}
app_->register_state_handler(
std::bind(&service_sample::on_state, this,
std::placeholders::_1));
app_->register_message_handler(
SAMPLE_SERVICE_ID,
SAMPLE_INSTANCE_ID,
SAMPLE_GET_METHOD_ID,
std::bind(&service_sample::on_get, this,
std::placeholders::_1));
app_->register_message_handler(
SAMPLE_SERVICE_ID,
SAMPLE_INSTANCE_ID,
SAMPLE_SET_METHOD_ID,
std::bind(&service_sample::on_set, this,
std::placeholders::_1));
std::set<vsomeip::eventgroup_t> its_groups;
its_groups.insert(SAMPLE_EVENTGROUP_ID);
app_->offer_event(
SAMPLE_SERVICE_ID,
SAMPLE_INSTANCE_ID,
SAMPLE_EVENT_ID,
its_groups,
vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(),
false, true, nullptr, vsomeip::reliability_type_e::RT_UNKNOWN);
{
std::lock_guard<std::mutex> its_lock(payload_mutex_);
payload_ = vsomeip::runtime::get()->create_payload();
}
blocked_ = true;
condition_.notify_one();
return true;
}
void start() {
app_->start();
}
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
/*
* Handle signal to shutdown
*/
void stop() {
running_ = false;
blocked_ = true;
condition_.notify_one();
notify_condition_.notify_one();
app_->clear_all_handler();
stop_offer();
offer_thread_.join();
notify_thread_.join();
app_->stop();
}
#endif
void offer() {
std::lock_guard<std::mutex> its_lock(notify_mutex_);
app_->offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
is_offered_ = true;
notify_condition_.notify_one();
}
void stop_offer() {
app_->stop_offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
is_offered_ = false;
}
void on_state(vsomeip::state_type_e _state) {
std::cout << "Application " << app_->get_name() << " is "
<< (_state == vsomeip::state_type_e::ST_REGISTERED ?
"registered." : "deregistered.") << std::endl;
if (_state == vsomeip::state_type_e::ST_REGISTERED) {
if (!is_registered_) {
is_registered_ = true;
}
} else {
is_registered_ = false;
}
}
void on_get(const std::shared_ptr<vsomeip::message> &_message) {
std::shared_ptr<vsomeip::message> its_response
= vsomeip::runtime::get()->create_response(_message);
{
std::lock_guard<std::mutex> its_lock(payload_mutex_);
its_response->set_payload(payload_);
}
app_->send(its_response);
}
void on_set(const std::shared_ptr<vsomeip::message> &_message) {
std::shared_ptr<vsomeip::message> its_response
= vsomeip::runtime::get()->create_response(_message);
{
std::lock_guard<std::mutex> its_lock(payload_mutex_);
payload_ = _message->get_payload();
its_response->set_payload(payload_);
}
app_->send(its_response);
app_->notify(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID,
SAMPLE_EVENT_ID, payload_);
}
void run() {
std::unique_lock<std::mutex> its_lock(mutex_);
while (!blocked_)
condition_.wait(its_lock);
bool is_offer(true);
while (running_) {
if (is_offer)
offer();
else
stop_offer();
for (int i = 0; i < 10 && running_; i++)
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
is_offer = !is_offer;
}
}
void notify() {
std::shared_ptr<vsomeip::message> its_message
= vsomeip::runtime::get()->create_request(use_tcp_);
its_message->set_service(SAMPLE_SERVICE_ID);
its_message->set_instance(SAMPLE_INSTANCE_ID);
its_message->set_method(SAMPLE_SET_METHOD_ID);
vsomeip::byte_t its_data[10];
uint32_t its_size = 1;
while (running_) {
std::unique_lock<std::mutex> its_lock(notify_mutex_);
while (!is_offered_ && running_)
notify_condition_.wait(its_lock);
while (is_offered_ && running_) {
if (its_size == sizeof(its_data))
its_size = 1;
for (uint32_t i = 0; i < its_size; ++i)
its_data[i] = static_cast<uint8_t>(i);
{
std::lock_guard<std::mutex> its_lock(payload_mutex_);
payload_->set_data(its_data, its_size);
std::cout << "Setting event (Length=" << std::dec << its_size << ")." << std::endl;
app_->notify(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENT_ID, payload_);
}
its_size++;
std::this_thread::sleep_for(std::chrono::milliseconds(cycle_));
}
}
}
private:
std::shared_ptr<vsomeip::application> app_;
bool is_registered_;
bool use_tcp_;
uint32_t cycle_;
std::mutex mutex_;
std::condition_variable condition_;
bool blocked_;
bool running_;
std::mutex notify_mutex_;
std::condition_variable notify_condition_;
bool is_offered_;
std::mutex payload_mutex_;
std::shared_ptr<vsomeip::payload> payload_;
// blocked_ / is_offered_ must be initialized before starting the threads!
std::thread offer_thread_;
std::thread notify_thread_;
};
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
service_sample *its_sample_ptr(nullptr);
void handle_signal(int _signal) {
if (its_sample_ptr != nullptr &&
(_signal == SIGINT || _signal == SIGTERM))
its_sample_ptr->stop();
}
#endif
int main(int argc, char **argv) {
bool use_tcp = false;
uint32_t cycle = 1000; // default 1s
std::string tcp_enable("--tcp");
std::string udp_enable("--udp");
std::string cycle_arg("--cycle");
for (int i = 1; i < argc; i++) {
if (tcp_enable == argv[i]) {
use_tcp = true;
break;
}
if (udp_enable == argv[i]) {
use_tcp = false;
break;
}
if (cycle_arg == argv[i] && i + 1 < argc) {
i++;
std::stringstream converter;
converter << argv[i];
converter >> cycle;
}
}
service_sample its_sample(use_tcp, cycle);
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
its_sample_ptr = &its_sample;
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);
#endif
if (its_sample.init()) {
its_sample.start();
return 0;
} else {
return 1;
}
}
# Copyright (C) 2014-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/.
To use the example applications you need two devices on the same network. The network addresses within
the configuration files need to be adapted to match the devices addresses.
To start the request/response-example from the build-directory do:
HOST1: env VSOMEIP_CONFIGURATION=../../config/vsomeip-local.json VSOMEIP_APPLICATION_NAME=client-sample ./request-sample
HOST1: env VSOMEIP_CONFIGURATION=../../config/vsomeip-local.json VSOMEIP_APPLICATION_NAME=service-sample ./response-sample
To start the subscribe/notify-example from the build-directory do:
HOST1: env VSOMEIP_CONFIGURATION=../../config/vsomeip-local.json VSOMEIP_APPLICATION_NAME=client-sample ./subscribe-sample
HOST1: env VSOMEIP_CONFIGURATION=../../config/vsomeip-local.json VSOMEIP_APPLICATION_NAME=service-sample ./notify-sample
// Copyright (C) 2014-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/.
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
#include <csignal>
#endif
#include <chrono>
#include <condition_variable>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <thread>
#include <vsomeip/vsomeip.hpp>
#include "sample-ids.hpp"
class client_sample {
public:
client_sample(bool _use_tcp, bool _be_quiet, uint32_t _cycle)
: app_(vsomeip::runtime::get()->create_application()),
request_(vsomeip::runtime::get()->create_request(_use_tcp)),
use_tcp_(_use_tcp),
be_quiet_(_be_quiet),
cycle_(_cycle),
running_(true),
blocked_(false),
is_available_(false),
sender_(std::bind(&client_sample::run, this)) {
}
bool init() {
if (!app_->init()) {
std::cerr << "Couldn't initialize application" << std::endl;
return false;
}
std::cout << "Client settings [protocol="
<< (use_tcp_ ? "TCP" : "UDP")
<< ":quiet="
<< (be_quiet_ ? "true" : "false")
<< ":cycle="
<< cycle_
<< "]"
<< std::endl;
app_->register_state_handler(
std::bind(
&client_sample::on_state,
this,
std::placeholders::_1));
app_->register_message_handler(
vsomeip::ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD,
std::bind(&client_sample::on_message,
this,
std::placeholders::_1));
request_->set_service(SAMPLE_SERVICE_ID);
request_->set_instance(SAMPLE_INSTANCE_ID);
request_->set_method(SAMPLE_METHOD_ID);
std::shared_ptr< vsomeip::payload > its_payload = vsomeip::runtime::get()->create_payload();
std::vector< vsomeip::byte_t > its_payload_data;
for (std::size_t i = 0; i < 10; ++i) its_payload_data.push_back(i % 256);
its_payload->set_data(its_payload_data);
request_->set_payload(its_payload);
app_->register_availability_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID,
std::bind(&client_sample::on_availability,
this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
app_->register_availability_handler(SAMPLE_SERVICE_ID + 1, SAMPLE_INSTANCE_ID,
std::bind(&client_sample::on_availability,
this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
return true;
}
void start() {
app_->start();
}
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
/*
* Handle signal to shutdown
*/
void stop() {
running_ = false;
blocked_ = true;
app_->clear_all_handler();
app_->release_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
condition_.notify_one();
sender_.join();
app_->stop();
}
#endif
void on_state(vsomeip::state_type_e _state) {
if (_state == vsomeip::state_type_e::ST_REGISTERED) {
app_->request_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
}
}
void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) {
std::cout << "Service ["
<< std::setw(4) << std::setfill('0') << std::hex << _service << "." << _instance
<< "] is "
<< (_is_available ? "available." : "NOT available.")
<< std::endl;
if (SAMPLE_SERVICE_ID == _service && SAMPLE_INSTANCE_ID == _instance) {
if (is_available_ && !_is_available) {
is_available_ = false;
} else if (_is_available && !is_available_) {
is_available_ = true;
send();
}
}
}
void on_message(const std::shared_ptr< vsomeip::message > &_response) {
std::cout << "Received a response from Service ["
<< std::setw(4) << std::setfill('0') << std::hex << _response->get_service()
<< "."
<< std::setw(4) << std::setfill('0') << std::hex << _response->get_instance()
<< "] to Client/Session ["
<< std::setw(4) << std::setfill('0') << std::hex << _response->get_client()
<< "/"
<< std::setw(4) << std::setfill('0') << std::hex << _response->get_session()
<< "]"
<< std::endl;
if (is_available_)
send();
}
void send() {
if (!be_quiet_)
{
std::lock_guard< std::mutex > its_lock(mutex_);
blocked_ = true;
condition_.notify_one();
}
}
void run() {
while (running_) {
{
std::unique_lock<std::mutex> its_lock(mutex_);
while (!blocked_) condition_.wait(its_lock);
if (is_available_) {
app_->send(request_);
std::cout << "Client/Session ["
<< std::setw(4) << std::setfill('0') << std::hex << request_->get_client()
<< "/"
<< std::setw(4) << std::setfill('0') << std::hex << request_->get_session()
<< "] sent a request to Service ["
<< std::setw(4) << std::setfill('0') << std::hex << request_->get_service()
<< "."
<< std::setw(4) << std::setfill('0') << std::hex << request_->get_instance()
<< "]"
<< std::endl;
blocked_ = false;
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(cycle_));
}
}
private:
std::shared_ptr< vsomeip::application > app_;
std::shared_ptr< vsomeip::message > request_;
bool use_tcp_;
bool be_quiet_;
uint32_t cycle_;
vsomeip::session_t session_;
std::mutex mutex_;
std::condition_variable condition_;
bool running_;
bool blocked_;
bool is_available_;
std::thread sender_;
};
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
client_sample *its_sample_ptr(nullptr);
void handle_signal(int _signal) {
if (its_sample_ptr != nullptr &&
(_signal == SIGINT || _signal == SIGTERM))
its_sample_ptr->stop();
}
#endif
int main(int argc, char **argv) {
bool use_tcp = false;
bool be_quiet = false;
uint32_t cycle = 1000; // Default: 1s
std::string tcp_enable("--tcp");
std::string udp_enable("--udp");
std::string quiet_enable("--quiet");
std::string cycle_arg("--cycle");
int i = 1;
while (i < argc) {
if (tcp_enable == argv[i]) {
use_tcp = true;
} else if (udp_enable == argv[i]) {
use_tcp = false;
} else if (quiet_enable == argv[i]) {
be_quiet = true;
} else if (cycle_arg == argv[i] && i+1 < argc) {
i++;
std::stringstream converter;
converter << argv[i];
converter >> cycle;
}
i++;
}
client_sample its_sample(use_tcp, be_quiet, cycle);
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
its_sample_ptr = &its_sample;
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);
#endif
if (its_sample.init()) {
its_sample.start();
return 0;
} else {
return 1;
}
}
// Copyright (C) 2014-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/.
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
#include <csignal>
#endif
#include <chrono>
#include <condition_variable>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <thread>
#include <vsomeip/vsomeip.hpp>
#include "sample-ids.hpp"
class service_sample {
public:
service_sample(bool _use_static_routing) :
app_(vsomeip::runtime::get()->create_application()),
is_registered_(false),
use_static_routing_(_use_static_routing),
blocked_(false),
running_(true),
offer_thread_(std::bind(&service_sample::run, this)) {
}
bool init() {
std::lock_guard<std::mutex> its_lock(mutex_);
if (!app_->init()) {
std::cerr << "Couldn't initialize application" << std::endl;
return false;
}
app_->register_state_handler(
std::bind(&service_sample::on_state, this,
std::placeholders::_1));
app_->register_message_handler(
SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_METHOD_ID,
std::bind(&service_sample::on_message, this,
std::placeholders::_1));
std::cout << "Static routing " << (use_static_routing_ ? "ON" : "OFF")
<< std::endl;
return true;
}
void start() {
app_->start();
}
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
/*
* Handle signal to shutdown
*/
void stop() {
running_ = false;
blocked_ = true;
app_->clear_all_handler();
stop_offer();
condition_.notify_one();
offer_thread_.join();
app_->stop();
}
#endif
void offer() {
app_->offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
app_->offer_service(SAMPLE_SERVICE_ID + 1, SAMPLE_INSTANCE_ID);
}
void stop_offer() {
app_->stop_offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
app_->stop_offer_service(SAMPLE_SERVICE_ID + 1, SAMPLE_INSTANCE_ID);
}
void on_state(vsomeip::state_type_e _state) {
std::cout << "Application " << app_->get_name() << " is "
<< (_state == vsomeip::state_type_e::ST_REGISTERED ?
"registered." : "deregistered.")
<< std::endl;
if (_state == vsomeip::state_type_e::ST_REGISTERED) {
if (!is_registered_) {
is_registered_ = true;
blocked_ = true;
condition_.notify_one();
}
} else {
is_registered_ = false;
}
}
void on_message(const std::shared_ptr<vsomeip::message> &_request) {
std::cout << "Received a message with Client/Session [" << std::setw(4)
<< std::setfill('0') << std::hex << _request->get_client() << "/"
<< std::setw(4) << std::setfill('0') << std::hex
<< _request->get_session() << "]"
<< std::endl;
std::shared_ptr<vsomeip::message> its_response
= vsomeip::runtime::get()->create_response(_request);
std::shared_ptr<vsomeip::payload> its_payload
= vsomeip::runtime::get()->create_payload();
std::vector<vsomeip::byte_t> its_payload_data;
for (std::size_t i = 0; i < 120; ++i)
its_payload_data.push_back(i % 256);
its_payload->set_data(its_payload_data);
its_response->set_payload(its_payload);
app_->send(its_response);
}
void run() {
std::unique_lock<std::mutex> its_lock(mutex_);
while (!blocked_)
condition_.wait(its_lock);
bool is_offer(true);
if (use_static_routing_) {
offer();
while (running_);
} else {
while (running_) {
if (is_offer)
offer();
else
stop_offer();
for (int i = 0; i < 10 && running_; i++)
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
is_offer = !is_offer;
}
}
}
private:
std::shared_ptr<vsomeip::application> app_;
bool is_registered_;
bool use_static_routing_;
std::mutex mutex_;
std::condition_variable condition_;
bool blocked_;
bool running_;
// blocked_ must be initialized before the thread is started.
std::thread offer_thread_;
};
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
service_sample *its_sample_ptr(nullptr);
void handle_signal(int _signal) {
if (its_sample_ptr != nullptr &&
(_signal == SIGINT || _signal == SIGTERM))
its_sample_ptr->stop();
}
#endif
int main(int argc, char **argv) {
bool use_static_routing(false);
std::string static_routing_enable("--static-routing");
for (int i = 1; i < argc; i++) {
if (static_routing_enable == argv[i]) {
use_static_routing = true;
}
}
service_sample its_sample(use_static_routing);
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
its_sample_ptr = &its_sample;
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);
#endif
if (its_sample.init()) {
its_sample.start();
return 0;
} else {
return 1;
}
}
# 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/.
cmake_minimum_required (VERSION 2.8)
# Daemon
add_executable(routingmanagerd routingmanagerd.cpp)
target_link_libraries(routingmanagerd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY} ${DLT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
add_dependencies(routingmanagerd ${VSOMEIP_NAME})
option(VSOMEIP_INSTALL_ROUTINGMANAGERD "Whether or not to install the routing manager daemon.")
if (VSOMEIP_INSTALL_ROUTINGMANAGERD)
install (
TARGETS routingmanagerd
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
)
endif()
###################################################################################################
// 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/.
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <unistd.h>
#include <thread>
#include <condition_variable>
#include <mutex>
#include <iostream>
#include <vsomeip/vsomeip.hpp>
#include <vsomeip/internal/logger.hpp>
#ifdef USE_DLT
#include <dlt/dlt.h>
#endif
static std::shared_ptr<vsomeip::application> its_application;
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
static bool stop_application = false;
static bool stop_sighandler = false;
static std::condition_variable_any sighandler_condition;
static std::recursive_mutex sighandler_mutex;
#endif
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
/*
* Handle signal to stop the daemon
*/
void routingmanagerd_stop(int _signal) {
// Do not log messages in signal handler as this can cause deadlock in boost logger
if (_signal == SIGINT || _signal == SIGTERM) {
stop_application = true;
}
std::unique_lock<std::recursive_mutex> its_lock(sighandler_mutex);
sighandler_condition.notify_one();
}
#endif
/*
* Create a vsomeip application object and start it.
*/
int routingmanagerd_process(bool _is_quiet) {
#ifdef USE_DLT
if (!_is_quiet)
DLT_REGISTER_APP(VSOMEIP_LOG_DEFAULT_APPLICATION_ID, VSOMEIP_LOG_DEFAULT_APPLICATION_NAME);
#else
(void)_is_quiet;
#endif
std::shared_ptr<vsomeip::runtime> its_runtime
= vsomeip::runtime::get();
if (!its_runtime) {
return -1;
}
// Create the application object
its_application = its_runtime->create_application("routingmanagerd");
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
std::thread sighandler_thread([]() {
// Unblock signals for this thread only
sigset_t handler_mask;
sigemptyset(&handler_mask);
sigaddset(&handler_mask, SIGTERM);
sigaddset(&handler_mask, SIGINT);
sigaddset(&handler_mask, SIGSEGV);
sigaddset(&handler_mask, SIGABRT);
pthread_sigmask(SIG_UNBLOCK, &handler_mask, NULL);
// Handle the following signals
signal(SIGINT, routingmanagerd_stop);
signal(SIGTERM, routingmanagerd_stop);
while (!stop_sighandler) {
std::unique_lock<std::recursive_mutex> its_lock(sighandler_mutex);
sighandler_condition.wait(its_lock);
if (stop_application) {
its_application->stop();
return;
}
}
});
#endif
if (its_application->init()) {
if (its_application->is_routing()) {
its_application->start();
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
sighandler_thread.join();
#endif
return 0;
}
VSOMEIP_ERROR << "routingmanagerd has not been configured as routing - abort";
}
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
std::unique_lock<std::recursive_mutex> its_lock(sighandler_mutex);
stop_sighandler = true;
sighandler_condition.notify_one();
sighandler_thread.join();
#endif
return -1;
}
/*
* Parse command line options
* -h | --help print usage information
* -d | --daemonize start background processing by forking the process
* -q | --quiet do _not_ use dlt logging
*
* and start processing.
*/
int main(int argc, char **argv) {
#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
// Block all signals
sigset_t mask;
sigfillset(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL);
#endif
bool must_daemonize(false);
bool is_quiet(false);
if (argc > 1) {
for (int i = 0; i < argc; i++) {
std::string its_argument(argv[i]);
if (its_argument == "-d" || its_argument == "--daemonize") {
must_daemonize = true;
} else if (its_argument == "-q" || its_argument == "--quiet") {
is_quiet = true;
} else if (its_argument == "-h" || its_argument == "--help") {
std::cout << "usage: "
<< argv[0] << " [-h|--help][-d|--daemonize][-q|--quiet]"
<< std::endl;
return 0;
}
}
}
/* Fork the process if processing shall be done in the background */
if (must_daemonize) {
pid_t its_process, its_signature;
its_process = fork();
if (its_process < 0) {
return EXIT_FAILURE;
}
if (its_process > 0) {
return EXIT_SUCCESS;
}
umask(0111);
its_signature = setsid();
if (its_signature < 0) {
return EXIT_FAILURE;
}
}
return routingmanagerd_process(is_quiet);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment