summaryrefslogtreecommitdiff
path: root/CommonAPI-Examples
diff options
context:
space:
mode:
authorJürgen Gehring <juergen.gehring@bmw.de>2015-06-17 03:35:44 -0700
committerJürgen Gehring <juergen.gehring@bmw.de>2015-06-17 03:51:23 -0700
commit9b91fba4b4008007847f32630cbe160287f291fd (patch)
treec9f7b77ea4255b30ec3b2683fb9c98840bcdbae2 /CommonAPI-Examples
parent1d9ae05afdc4341622d1720138d2bc781ee78144 (diff)
downloadgenivi-common-api-runtime-3.1.2.tar.gz
CommonAPI 3.1.23.1.2
Diffstat (limited to 'CommonAPI-Examples')
-rw-r--r--CommonAPI-Examples/E01HelloWorld/CMakeLists.txt13
-rw-r--r--CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl4
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp10
-rw-r--r--CommonAPI-Examples/E01HelloWorld/vsomeip-client.json26
-rw-r--r--CommonAPI-Examples/E01HelloWorld/vsomeip-local.json52
-rw-r--r--CommonAPI-Examples/E01HelloWorld/vsomeip-service.json48
-rw-r--r--CommonAPI-Examples/E02Attributes/CMakeLists.txt74
-rw-r--r--CommonAPI-Examples/E02Attributes/commonapi4someip.ini8
-rw-r--r--CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl11
-rw-r--r--CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl54
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp12
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp11
-rw-r--r--CommonAPI-Examples/E02Attributes/vsomeip-client.json26
-rw-r--r--CommonAPI-Examples/E02Attributes/vsomeip-local.json52
-rw-r--r--CommonAPI-Examples/E02Attributes/vsomeip-service.json77
-rw-r--r--CommonAPI-Examples/E03Methods/CMakeLists.txt75
-rw-r--r--CommonAPI-Examples/E03Methods/commonapi4someip.ini8
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl8
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl54
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl4
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp15
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp9
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp2
-rw-r--r--CommonAPI-Examples/E03Methods/vsomeip-client.json26
-rw-r--r--CommonAPI-Examples/E03Methods/vsomeip-local.json52
-rw-r--r--CommonAPI-Examples/E03Methods/vsomeip-service.json77
-rw-r--r--CommonAPI-Examples/E04PhoneBook/CMakeLists.txt89
-rw-r--r--CommonAPI-Examples/E04PhoneBook/commonapi4dbus.ini8
-rw-r--r--CommonAPI-Examples/E04PhoneBook/commonapi4someip.ini8
-rw-r--r--CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-DBus.fdepl6
-rw-r--r--CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl113
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp9
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp14
-rw-r--r--CommonAPI-Examples/E05Manager/CMakeLists.txt84
-rw-r--r--CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl50
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp7
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp16
-rw-r--r--CommonAPI-Examples/E06Unions/CMakeLists.txt89
-rw-r--r--CommonAPI-Examples/E06Unions/commonapi4dbus.ini8
-rw-r--r--CommonAPI-Examples/E06Unions/commonapi4someip.ini8
-rw-r--r--CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl73
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp17
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp38
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp2
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h2
-rw-r--r--CommonAPI-Examples/E06Unions/vsomeip-client.json26
-rw-r--r--CommonAPI-Examples/E06Unions/vsomeip-local.json52
-rw-r--r--CommonAPI-Examples/E06Unions/vsomeip-service.json48
-rw-r--r--CommonAPI-Examples/E07Mainloop/CMakeLists.txt87
-rw-r--r--CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini10
-rw-r--r--CommonAPI-Examples/E07Mainloop/commonapi4someip.ini10
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp37
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp35
53 files changed, 1577 insertions, 177 deletions
diff --git a/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt b/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt
index b250e4d..9971079 100644
--- a/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt
+++ b/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt
@@ -29,11 +29,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version
message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -61,8 +61,8 @@ else()
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.1 REQUIRED)
-find_package (vsomeip 1.1.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.2 REQUIRED)
+find_package (vsomeip 1.2.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
@@ -119,6 +119,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
index 4872a22..6d43ef0 100644
--- a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
+++ b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
@@ -11,6 +11,7 @@ define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E
method sayHello {
SomeIpMethodID = 33000
+ SomeIpReliable = true
in {
name {
@@ -27,6 +28,7 @@ define org.genivi.commonapi.someip.deployment for provider Service {
SomeIpInstanceID = 22136
SomeIpUnicastAddress = "192.168.0.2"
- SomeIpUnicastPort = 30499
+ SomeIpReliableUnicastPort = 30499
+ SomeIpUneliableUnicastPort = 30499
}
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
index f92ae81..2fb7918 100644
--- a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
@@ -22,7 +22,15 @@ int main() {
std::string connection = "service-sample";
std::shared_ptr<E01HelloWorldStubImpl> myService = std::make_shared<E01HelloWorldStubImpl>();
- runtime->registerService(domain, instance, myService, connection);
+ bool successfullyRegistered = runtime->registerService(domain, instance, myService, connection);
+
+ while (!successfullyRegistered) {
+ std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ successfullyRegistered = runtime->registerService(domain, instance, myService, connection);
+ }
+
+ std::cout << "Successfully Registered Service!" << std::endl;
while (true) {
std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json b/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json
new file mode 100644
index 0000000..731852a
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json
@@ -0,0 +1,26 @@
+{
+ "unicast" : "192.168.56.102",
+ "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"
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json b/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json
new file mode 100644
index 0000000..2f4c823
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json
@@ -0,0 +1,52 @@
+{
+ "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" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "unreliable" : "31000"
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json b/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json
new file mode 100644
index 0000000..371ecf7
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json
@@ -0,0 +1,48 @@
+{
+ "unicast" : "192.168.56.101",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "unreliable" : "31000"
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E02Attributes/CMakeLists.txt b/CommonAPI-Examples/E02Attributes/CMakeLists.txt
index 7da893e..fccec2c 100644
--- a/CommonAPI-Examples/E02Attributes/CMakeLists.txt
+++ b/CommonAPI-Examples/E02Attributes/CMakeLists.txt
@@ -8,7 +8,14 @@ cmake_minimum_required(VERSION 2.8)
set(PRJ_NAME E02Attributes)
set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+if (MSVC)
+# Visual C++ is not always sure whether he is really C++
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"")
+else()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -pthread -D_GLIBCXX_USE_NANOSLEEP")
+endif()
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
@@ -22,11 +29,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version
message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -42,7 +49,7 @@ if (MSVC)
#Not beautiful, but it works
if (DBus_DIR)
if (DBus_BUILD_DIR)
- set(DBUS_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
else ()
message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
endif ()
@@ -53,46 +60,71 @@ else()
pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
+# SOME/IP
+find_package (CommonAPI-SomeIP 3.1.2 REQUIRED)
+find_package (vsomeip 1.2.0 REQUIRED)
+
# Source Files
set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_PATH src-gen)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1_0/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
+# Application
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/CommonTypes.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp)
set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS})
+
+# Boost
+find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
+include_directories( ${Boost_INCLUDE_DIR} )
+
+# DBus library
+FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp)
+
+# SOME/IP library
+FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp)
# Paths
OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
- src-gen
+ src-gen/core
+ src-gen/dbus
+ src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${DBus_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
)
if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_INCLUDE_DIRS}/dbus/.libs
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${DBus_INCLUDE_DIRS}/dbus/.libs
+ ${Boost_LIBRARY_DIR}
)
endif()
-set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+set(LINK_LIBRARIES -Wl,--as-needed CommonAPI)
# Build Client
add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
@@ -101,3 +133,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
# Build service
add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
+
+# Build DBus library
+add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus)
+
+# Build SOME/IP library
+add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP)
diff --git a/CommonAPI-Examples/E02Attributes/commonapi4someip.ini b/CommonAPI-Examples/E02Attributes/commonapi4someip.ini
new file mode 100644
index 0000000..9d2e519
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/commonapi4someip.ini
@@ -0,0 +1,8 @@
+[default]
+binding=someip
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl
new file mode 100644
index 0000000..9cadf7d
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl
@@ -0,0 +1,11 @@
+/* Copyright (C) 2015 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/. */
+
+import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment_spec.fdepl"
+import "E02Attributes.fidl"
+
+define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E02Attributes {
+ DBusDefaultAttributeType = freedesktop
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl
new file mode 100644
index 0000000..0afbaf0
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl
@@ -0,0 +1,54 @@
+/* Copyright (C) 2015 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/. */
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E02Attributes.fidl"
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E02Attributes {
+ SomeIpServiceID = 4660
+
+ attribute x {
+ SomeIpGetterID = 3000
+ SomeIpSetterID = 3001
+ SomeIpNotifierID = 33010
+ SomeIpEventGroups = { 33010 }
+
+ SomeIpGetterReliable = true
+ SomeIpSetterReliable = true
+ SomeIpNotifierReliable = true
+ }
+
+ attribute a1 {
+ SomeIpGetterID = 3002
+ SomeIpSetterID = 3003
+ SomeIpNotifierID = 33011
+ SomeIpEventGroups = { 33011 }
+
+ SomeIpGetterReliable = true
+ SomeIpSetterReliable = true
+ SomeIpNotifierReliable = true
+ }
+}
+
+define org.genivi.commonapi.someip.deployment for typeCollection commonapi.examples.CommonTypes {
+ struct a1Struct {
+ }
+
+ struct a2Struct {
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E02Attributes {
+ InstanceId = "commonapi.examples.Attributes"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30499
+ SomeIpUnreliableUnicastPort = 30500
+ }
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
index e51eea7..0ecaa7b 100644
--- a/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
@@ -4,7 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <iostream>
+
+#ifndef WIN32
#include <unistd.h>
+#endif
#include <CommonAPI/CommonAPI.hpp>
#include <v1_0/commonapi/examples/E02AttributesProxy.hpp>
@@ -25,14 +28,19 @@ void recv_cb_s(const CommonAPI::CallStatus& callStatus, const CommonTypes::a1Str
}
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E02C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E02Attributes");
+
std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
std::string domain = "local";
- std::string instance = "commonapi.examples.Attributes";
+ std::string instance = "commonapi.examples.Attributes";
+ std::string connection = "client-sample";
std::shared_ptr<CommonAPI::DefaultAttributeProxyHelper<E02AttributesProxy, AttributeCacheExtension>::class_t> myProxy =
- runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttributeCacheExtension>(domain, instance);
+ runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttributeCacheExtension>(domain, instance, connection);
+ std::cout << "Waiting for service to become available." << std::endl;
while (!myProxy->isAvailable()) {
usleep(10);
}
diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
index 60c743d..8947414 100644
--- a/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
@@ -10,13 +10,22 @@
#include "E02AttributesStubImpl.hpp"
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E02S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E02Attributes");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
std::string instance = "commonapi.examples.Attributes";
+ std::string connection = "service-sample";
std::shared_ptr<E02AttributesStubImpl> myService = std::make_shared<E02AttributesStubImpl>();
- runtime->registerService(domain, instance, myService);
+ while (!runtime->registerService(domain, instance, myService, connection)) {
+ std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+
+ std::cout << "Successfully Registered Service!" << std::endl;
while (true) {
myService->incCounter(); // Change value of attribute, see stub implementation
diff --git a/CommonAPI-Examples/E02Attributes/vsomeip-client.json b/CommonAPI-Examples/E02Attributes/vsomeip-client.json
new file mode 100644
index 0000000..731852a
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/vsomeip-client.json
@@ -0,0 +1,26 @@
+{
+ "unicast" : "192.168.56.102",
+ "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"
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E02Attributes/vsomeip-local.json b/CommonAPI-Examples/E02Attributes/vsomeip-local.json
new file mode 100644
index 0000000..2f4c823
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/vsomeip-local.json
@@ -0,0 +1,52 @@
+{
+ "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" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "unreliable" : "31000"
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E02Attributes/vsomeip-service.json b/CommonAPI-Examples/E02Attributes/vsomeip-service.json
new file mode 100644
index 0000000..03d8979
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/vsomeip-service.json
@@ -0,0 +1,77 @@
+{
+ "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"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" :
+ {
+ "minimum" : "10",
+ "maximum" : 100
+ },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "events" :
+ [
+ {
+ "event" : "0x80F2",
+ "is_field" : "false",
+ "is_reliable" : "true",
+ "update-cycle" : 2000
+ },
+ {
+ "event" : "0x80F3",
+ "is_field" : "true",
+ "is_reliable" : "true",
+ "update-cycle" : 0
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x80F2",
+ "events" : [ "0x80F2" ]
+ },
+ {
+ "eventgroup" : "0x80F3",
+ "events" : [ "0x80F3" ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E03Methods/CMakeLists.txt b/CommonAPI-Examples/E03Methods/CMakeLists.txt
index 5640fea..30d1eb2 100644
--- a/CommonAPI-Examples/E03Methods/CMakeLists.txt
+++ b/CommonAPI-Examples/E03Methods/CMakeLists.txt
@@ -1,4 +1,6 @@
# Copyright (C) 2014, 2015 BMW Group
+# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+# Author: Juergen Gehring (juergen.gehring@bmw.de)
# 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/.
@@ -8,7 +10,14 @@ cmake_minimum_required(VERSION 2.8)
set(PRJ_NAME E03Methods)
set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+if (MSVC)
+# Visual C++ is not always sure whether he is really C++
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"")
+else()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+endif()
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
@@ -22,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version
message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -42,7 +51,7 @@ if (MSVC)
#Not beautiful, but it works
if (DBus_DIR)
if (DBus_BUILD_DIR)
- set(DBUS_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
else ()
message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
endif ()
@@ -53,20 +62,37 @@ else()
pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
+# SOME/IP
+find_package (CommonAPI-SomeIP 3.1.2 REQUIRED)
+find_package (vsomeip 1.2.0 REQUIRED)
+
# Source Files
set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/core/v1_2/commonapi/examples)
-set(PRJ_DBUS_SRC_GEN_PATH src-gen/dbus/v1_2/commonapi/examples)
+set(PRJ_SRC_GEN_PATH src-gen)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1_2/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1_2/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1_2/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_DBUS_SRC_GEN_PATH}/*Proxy.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_DBUS_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
+# Application
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/E03Methods.cpp)
set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS})
+
+# Boost
+find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
+include_directories( ${Boost_INCLUDE_DIR} )
+
+# DBus library
+FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS})
+
+# SOME/IP library
+FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp)
# Paths
OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
@@ -75,26 +101,32 @@ message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
src-gen/core
src-gen/dbus
+ src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${DBus_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
)
if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_INCLUDE_DIRS}/dbus/.libs
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${DBus_INCLUDE_DIRS}/dbus/.libs
+ ${Boost_LIBRARY_DIR}
)
endif()
-set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+set(LINK_LIBRARIES -Wl,--as-needed CommonAPI)
# Build Client
add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
@@ -103,3 +135,12 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
# Build service
add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
+
+# Build DBus library
+add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus)
+
+# Build SOME/IP library
+add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP)
+
diff --git a/CommonAPI-Examples/E03Methods/commonapi4someip.ini b/CommonAPI-Examples/E03Methods/commonapi4someip.ini
new file mode 100644
index 0000000..9d2e519
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/commonapi4someip.ini
@@ -0,0 +1,8 @@
+[default]
+binding=someip
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl b/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl
new file mode 100644
index 0000000..560f1a9
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl
@@ -0,0 +1,8 @@
+import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment_spec.fdepl"
+import "E03Methods.fidl"
+
+define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E03Methods {
+ method foo {
+ Timeout = 1234
+ }
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl b/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl
new file mode 100644
index 0000000..6782105
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl
@@ -0,0 +1,54 @@
+/* Copyright (C) 2015 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/. */
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E03Methods.fidl"
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E03Methods {
+ SomeIpServiceID = 4660
+
+ method foo {
+ SomeIpMethodID = 33000
+ SomeIpReliable = false
+
+ in {
+ x2 {
+ SomeIpStringEncoding = utf16le
+ }
+ }
+ out {
+ y2 {
+ SomeIpStringEncoding = utf16le
+ }
+ }
+ }
+
+ broadcast myStatus {
+ SomeIpEventID = 33010
+ SomeIpEventGroups = { 33010 }
+
+ out {
+ }
+ }
+
+ enumeration stdErrorTypeEnum {
+ NO_FAULT {
+ }
+ MY_FAULT {
+ }
+ }
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E03Methods {
+ InstanceId = "commonapi.examples.Methods"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30500
+ SomeIpUnreliableUnicastPort = 30501
+}
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
index edf8dc6..f0963cd 100644
--- a/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
@@ -20,9 +20,7 @@ interface E03Methods {
Int32 y1
String y2
}
- error {
- stdErrorTypeEnum
- }
+ error stdErrorTypeEnum
}
broadcast myStatus {
diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
index 0c6bc56..8d58060 100644
--- a/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
@@ -17,25 +17,28 @@
using namespace v1_2::commonapi::examples;
void recv_cb(const CommonAPI::CallStatus& callStatus,
- const E03Methods::fooError& methodError,
+ const E03Methods::stdErrorTypeEnum& methodError,
const int32_t& y1,
const std::string& y2) {
std::cout << "Result of asynchronous call of foo: " << std::endl;
std::cout << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS")
<< std::endl;
std::cout << " error: "
- << ((methodError.stdErrorTypeEnum == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" :
+ << ((methodError == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" :
"MY_FAULT") << std::endl;
std::cout << " Output values: y1 = " << y1 << ", y2 = " << y2 << std::endl;
}
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E03C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E03Methods");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
std::string instance = "commonapi.examples.Methods";
- std::shared_ptr<E03MethodsProxy<>> myProxy = runtime->buildProxy < E03MethodsProxy > (domain, instance);
+ std::shared_ptr<E03MethodsProxy<>> myProxy = runtime->buildProxy < E03MethodsProxy > (domain, instance, "client-sample");
while (!myProxy->isAvailable()) {
usleep(10);
@@ -50,7 +53,7 @@ int main() {
int32_t inX1 = 5;
std::string inX2 = "abc";
CommonAPI::CallStatus callStatus;
- E03Methods::fooError methodError;
+ E03Methods::stdErrorTypeEnum methodError;
int32_t outY1;
std::string outY2;
@@ -62,7 +65,7 @@ int main() {
std::cout << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS")
<< std::endl;
std::cout << " error: "
- << ((methodError.stdErrorTypeEnum == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT")
+ << ((methodError == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT")
<< std::endl;
std::cout << " Input values: x1 = " << inX1 << ", x2 = " << inX2 << std::endl;
std::cout << " Output values: y1 = " << outY1 << ", y2 = " << outY2 << std::endl;
@@ -72,7 +75,7 @@ int main() {
std::function<
void(const CommonAPI::CallStatus&,
- const E03Methods::fooError&,
+ const E03Methods::stdErrorTypeEnum&,
const int32_t&,
const std::string&)> fcb = recv_cb;
myProxy->fooAsync(inX1, inX2, recv_cb);
diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
index 7c9528c..a57e46b 100644
--- a/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
@@ -12,13 +12,20 @@
#include "E03MethodsStubImpl.hpp"
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E03S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E03Methods");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
std::string instance = "commonapi.examples.Methods";
std::shared_ptr<E03MethodsStubImpl> myService = std::make_shared<E03MethodsStubImpl>();
- runtime->registerService(domain, instance, myService);
+ while (!runtime->registerService(domain, instance, myService, "service-sample")) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+
+ std::cout << "Successfully Registered Service!" << std::endl;
while (true) {
myService->incCounter(); // Change value of attribute, see stub implementation
diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp
index d2856d2..b3b0afa 100644
--- a/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp
@@ -30,7 +30,7 @@ void E03MethodsStubImpl::foo(const std::shared_ptr<CommonAPI::ClientId> _client,
std::cout << "foo called, setting new values." << std::endl;
- E03Methods::fooError methodError = (E03Methods::fooError) E03Methods::stdErrorTypeEnum::MY_FAULT;
+ E03Methods::stdErrorTypeEnum methodError = E03Methods::stdErrorTypeEnum::MY_FAULT;
int32_t y1 = 42;
std::string y2 = "xyz";
_reply(methodError, y1, y2);
diff --git a/CommonAPI-Examples/E03Methods/vsomeip-client.json b/CommonAPI-Examples/E03Methods/vsomeip-client.json
new file mode 100644
index 0000000..f6d7414
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/vsomeip-client.json
@@ -0,0 +1,26 @@
+{
+ "unicast" : "192.168.56.102",
+ "netmask" : "255.255.255.0",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "true", "path" : "/var/log/E03MethodsClient.log" },
+ "dlt" : "true"
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : "0x1343"
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E03Methods/vsomeip-local.json b/CommonAPI-Examples/E03Methods/vsomeip-local.json
new file mode 100644
index 0000000..2f4c823
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/vsomeip-local.json
@@ -0,0 +1,52 @@
+{
+ "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" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "unreliable" : "31000"
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E03Methods/vsomeip-service.json b/CommonAPI-Examples/E03Methods/vsomeip-service.json
new file mode 100644
index 0000000..2ab32df
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/vsomeip-service.json
@@ -0,0 +1,77 @@
+{
+ "unicast" : "192.168.56.101",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/E03MethodsService.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" :
+ {
+ "minimum" : "10",
+ "maximum" : 100
+ },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "unreliable" : "30509",
+ "events" :
+ [
+ {
+ "event" : "0x80F2",
+ "is_field" : "false",
+ "is_reliable" : "false",
+ "update-cycle" : 2000
+ },
+ {
+ "event" : "0x80F3",
+ "is_field" : "true",
+ "is_reliable" : "false",
+ "update-cycle" : 0
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x80F2",
+ "events" : [ "0x80F2" ]
+ },
+ {
+ "eventgroup" : "0x80F3",
+ "events" : [ "0x80F3" ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt b/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt
index ed9840a..81cafd7 100644
--- a/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt
+++ b/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt
@@ -10,7 +10,14 @@ cmake_minimum_required(VERSION 2.8)
set(PRJ_NAME E04PhoneBook)
set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+if (MSVC)
+# Visual C++ is not always sure whether he is really C++
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"")
+else()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -pthread -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+endif()
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
@@ -24,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version
message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -38,48 +45,88 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
# CommonAPI
include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
+###############################################################################
+# find DBus by using the 'pkg-config' tool
+if (MSVC)
+ #Not beautiful, but it works
+ if (DBus_DIR)
+ if (DBus_BUILD_DIR)
+ set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ else ()
+ message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "DBus_DIR not set! Cannot continue.")
+ endif ()
+else()
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
+endif()
+
+# SOME/IP
+find_package (CommonAPI-SomeIP 3.1.2 REQUIRED)
+find_package (vsomeip 1.2.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
+set(PRJ_SRC_GEN_PATH src-gen)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
+# Application
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/E04PhoneBook.cpp)
set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS})
+
+# Boost
+find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
+include_directories( ${Boost_INCLUDE_DIR} )
+
+# DBus library
+FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS})
+
+# SOME/IP library
+FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp)
# Paths
OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
- src-gen
+ src-gen/core
+ src-gen/dbus
+ src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${DBus_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
)
if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_INCLUDE_DIRS}/dbus/.libs
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${DBus_INCLUDE_DIRS}/dbus/.libs
+ ${Boost_LIBRARY_DIR}
)
endif()
-set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+set(LINK_LIBRARIES -Wl,--as-needed CommonAPI)
# Build Client
add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
@@ -88,3 +135,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
# Build service
add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
+
+# Build DBus library
+add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus)
+
+# Build SOME/IP library
+#add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS})
+#target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP)
diff --git a/CommonAPI-Examples/E04PhoneBook/commonapi4dbus.ini b/CommonAPI-Examples/E04PhoneBook/commonapi4dbus.ini
new file mode 100644
index 0000000..ba5224f
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/commonapi4dbus.ini
@@ -0,0 +1,8 @@
+[default]
+binding=dbus
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E04PhoneBook/commonapi4someip.ini b/CommonAPI-Examples/E04PhoneBook/commonapi4someip.ini
new file mode 100644
index 0000000..9d2e519
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/commonapi4someip.ini
@@ -0,0 +1,8 @@
+[default]
+binding=someip
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-DBus.fdepl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-DBus.fdepl
new file mode 100644
index 0000000..0ad898b
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-DBus.fdepl
@@ -0,0 +1,6 @@
+import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment_spec.fdepl"
+import "E04PhoneBook.fidl"
+
+define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E04PhoneBook {
+ DBusDefaultAttributeType = freedesktop
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl
new file mode 100644
index 0000000..af57abc
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl
@@ -0,0 +1,113 @@
+/* Copyright (C) 2014 BMW Group
+ * 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/. */
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E04PhoneBook.fidl"
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E04PhoneBook {
+ SomeIpServiceID = 4660
+ SomeIpEventGroups = { 7000, 7001 }
+
+ attribute phoneBook {
+ SomeIpGetterID = 7000
+ }
+
+ method setPhoneBookDataFilter {
+ SomeIpMethodID = 33000
+ }
+
+ broadcast phoneBookDataSet {
+ SomeIpEventID = 8000
+ }
+
+ enumeration phoneNumberEnum {
+ WORK {
+ }
+ HOME {
+ }
+ MOBILE1 {
+ }
+ MOBILE2 {
+ }
+ }
+
+ struct phoneBookStruct {
+ name {
+ }
+ forename {
+ }
+ organisation {
+ }
+ address {
+ }
+ email {
+ }
+ phoneNumber {
+ }
+ }
+
+ struct elementFilterStruct {
+ addName {
+ }
+ addForename {
+ }
+ addOrganisation {
+ }
+ addAddress {
+ }
+ addEmail {
+ }
+ addPhoneNumber {
+ }
+ }
+
+ struct contentFilterStruct {
+ element {
+ }
+ expression {
+ }
+ }
+
+ enumeration phoneBookDataElementEnum {
+ NAME {
+ }
+ FORENAME {
+ }
+ ORGANISATION {
+ }
+ ADDRESS {
+ }
+ EMAIL {
+ }
+ PHONENUMBER {
+ }
+ }
+
+ struct phoneBookDataElement {
+ }
+
+ struct phoneBookDataElementString {
+ content {
+ }
+ }
+
+ struct phoneBookDataElementPhoneNumber {
+ content {
+ }
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E04PhoneBook {
+ InstanceId = "commonapi.examples.PhoneBook"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30491
+ SomeIpUnreliableUnicastPort = 30492
+}
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
index 8250762..d1b9d84 100644
--- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
@@ -5,7 +5,9 @@
* 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 WIN32
#include <unistd.h>
+#endif
#include <map>
#include <iostream>
@@ -128,19 +130,22 @@ void printFilterResult(const std::vector<E04PhoneBook::phoneBookDataElementMap>&
}
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E04C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E04PhoneBook");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
const std::string &domain = "local";
const std::string &instance = "commonapi.examples.PhoneBook";
- std::shared_ptr < E04PhoneBookProxyDefault > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance);
+ std::shared_ptr < E04PhoneBookProxy<> > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance);
while (!myProxyA->isAvailable()) {
usleep(10);
}
const CommonAPI::ConnectionId_t otherConnectionId = "42";
- std::shared_ptr < E04PhoneBookProxyDefault > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId);
+ std::shared_ptr < E04PhoneBookProxy<> > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId);
while (!myProxyB->isAvailable()) {
usleep(10);
}
diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
index 03da5d8..bece39c 100644
--- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
@@ -12,6 +12,9 @@
#include "E04PhoneBookStubImpl.h"
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E04S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E04PhoneBook");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
const std::string &domain = "local";
@@ -19,7 +22,16 @@ int main() {
std::shared_ptr<E04PhoneBookStubImpl> myService = std::make_shared<E04PhoneBookStubImpl>();
myService->setPhoneBookAttribute(myService->createTestPhoneBook());
- runtime->registerService(domain, instance, myService);
+ bool successfullyRegistered = runtime->registerService(domain, instance, myService);
+
+ while (!successfullyRegistered) {
+ std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ successfullyRegistered = runtime->registerService(domain, instance, myService);
+ }
+
+ std::cout << "Successfully Registered Service!" << std::endl;
+
while (true) {
std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(2));
diff --git a/CommonAPI-Examples/E05Manager/CMakeLists.txt b/CommonAPI-Examples/E05Manager/CMakeLists.txt
index db10047..ba18ba5 100644
--- a/CommonAPI-Examples/E05Manager/CMakeLists.txt
+++ b/CommonAPI-Examples/E05Manager/CMakeLists.txt
@@ -10,7 +10,14 @@ cmake_minimum_required(VERSION 2.8)
set(PRJ_NAME E05Manager)
set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+if (MSVC)
+# Visual C++ is not always sure whether he is really C++
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"")
+else()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+endif()
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
@@ -24,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version
message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -38,44 +45,83 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
# CommonAPI
include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
+###############################################################################
+# find DBus by using the 'pkg-config' tool
+if (MSVC)
+ #Not beautiful, but it works
+ if (DBus_DIR)
+ if (DBus_BUILD_DIR)
+ set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ else ()
+ message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "DBus_DIR not set! Cannot continue.")
+ endif ()
+else()
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
+endif()
+
+# SOME/IP
+find_package (CommonAPI-SomeIP 3.1.2 REQUIRED)
+find_package (vsomeip 1.2.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_PATH src-gen)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1_0/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
+# Application
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS})
+
+# Boost
+find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
+include_directories( ${Boost_INCLUDE_DIR} )
+
+# DBus library
+FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp)
+
+# SOME/IP library
+FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp)
# Paths
OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
- src-gen
+ src-gen/core
+ src-gen/dbus
+ src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${DBus_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
)
if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_INCLUDE_DIRS}/dbus/.libs
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${DBus_INCLUDE_DIRS}/dbus/.libs
+ ${Boost_LIBRARY_DIR}
)
endif()
@@ -88,3 +134,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
# Build service
add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
+
+# Build DBus library
+add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus)
+
+# Build SOME/IP library
+#add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS})
+#target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP)
diff --git a/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl
new file mode 100644
index 0000000..5befa32
--- /dev/null
+++ b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl
@@ -0,0 +1,50 @@
+/* Copyright (C) 2014 BMW Group
+ * 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/. */
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E05Manager.fidl"
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05Manager {
+ SomeIpServiceID = 4660
+ SomeIpEventGroups = { 7000, 7001 }
+
+ attribute myDevices {
+ SomeIpGetterID = 7000
+ SomeIpSetterID = 7004
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05Device {
+ SomeIpServiceID = 4661
+ SomeIpEventGroups = { 7000, 7001 }
+
+ method doSomething {
+ SomeIpMethodID = 7001
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05SpecialDevice {
+ SomeIpServiceID = 4662
+ SomeIpEventGroups = { 7000, 7001 }
+
+ method doSomethingSpecial {
+ SomeIpMethodID = 7002
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E04PhoneBook {
+ InstanceId = "commonapi.examples.PhoneBook"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30500
+ SomeIpUnreliableUnicastPort = 30501
+}
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
index d43fb3d..983601c 100644
--- a/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
@@ -5,7 +5,9 @@
* 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 WIN32
#include <unistd.h>
+#endif
#include <iostream>
@@ -25,11 +27,14 @@ void newDeviceAvailable(const std::string address, const CommonAPI::Availability
}
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E05C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E05Manager");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
const std::string &domain = "local";
const std::string &instance = "commonapi.examples.Manager";
- std::shared_ptr<E05ManagerProxyDefault> myProxy = runtime->buildProxy<E05ManagerProxy>(domain, instance);
+ std::shared_ptr<E05ManagerProxy<>> myProxy = runtime->buildProxy<E05ManagerProxy>(domain, instance);
while (!myProxy->isAvailable()) {
usleep(10);
}
diff --git a/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
index 188d46c..c32faa0 100644
--- a/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
@@ -18,13 +18,21 @@ const static unsigned int maxDeviceNumber = 3;
const static std::string managerInstanceName = "commonapi.examples.Manager";
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E05S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E05Manager");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::shared_ptr<E05ManagerStubImpl> myService = std::make_shared < E05ManagerStubImpl > (managerInstanceName);
- const bool serviceRegistered = runtime->registerService("local", managerInstanceName, myService);
- if (!serviceRegistered) {
- std::cout << "Error: Unable to register service." << std::endl;
- }
+ bool successfullyRegistered = runtime->registerService("local", managerInstanceName, myService);
+
+ while (!successfullyRegistered) {
+ std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ successfullyRegistered = runtime->registerService("local", managerInstanceName, myService);
+ }
+
+ std::cout << "Successfully Registered Service!" << std::endl;
while (true) {
// Simulate external events
diff --git a/CommonAPI-Examples/E06Unions/CMakeLists.txt b/CommonAPI-Examples/E06Unions/CMakeLists.txt
index 641fd78..1b342a3 100644
--- a/CommonAPI-Examples/E06Unions/CMakeLists.txt
+++ b/CommonAPI-Examples/E06Unions/CMakeLists.txt
@@ -10,7 +10,14 @@ cmake_minimum_required(VERSION 2.8)
set(PRJ_NAME E06Unions)
set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+if (MSVC)
+# Visual C++ is not always sure whether he is really C++
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"")
+else()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+endif()
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
@@ -24,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version
message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -38,48 +45,88 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
# CommonAPI
include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
+###############################################################################
+# find DBus by using the 'pkg-config' tool
+if (MSVC)
+ #Not beautiful, but it works
+ if (DBus_DIR)
+ if (DBus_BUILD_DIR)
+ set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ else ()
+ message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "DBus_DIR not set! Cannot continue.")
+ endif ()
+else()
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
+endif()
+
+# SOME/IP
+find_package (CommonAPI-SomeIP 3.1.2 REQUIRED)
+find_package (vsomeip 1.2.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
+set(PRJ_SRC_GEN_PATH src-gen)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
+# Application
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/CommonTypes.cpp)
set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS})
+
+# Boost
+find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
+include_directories( ${Boost_INCLUDE_DIR} )
+
+# DBus library
+FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS})
+
+# SOME/IP library
+FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS})
# Paths
OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
- src-gen
+ src-gen/core
+ src-gen/dbus
+ src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${DBus_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
)
if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
- ${DBUS_INCLUDE_DIRS}/dbus/.libs
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${DBus_INCLUDE_DIRS}/dbus/.libs
+ ${Boost_LIBRARY_DIR}
)
endif()
-set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+set(LINK_LIBRARIES -Wl,--as-needed CommonAPI)
# Build Client
add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
@@ -88,3 +135,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
# Build service
add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
+
+# Build DBus library
+add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus)
+
+# Build SOME/IP library
+add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP)
diff --git a/CommonAPI-Examples/E06Unions/commonapi4dbus.ini b/CommonAPI-Examples/E06Unions/commonapi4dbus.ini
new file mode 100644
index 0000000..ba5224f
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/commonapi4dbus.ini
@@ -0,0 +1,8 @@
+[default]
+binding=dbus
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E06Unions/commonapi4someip.ini b/CommonAPI-Examples/E06Unions/commonapi4someip.ini
new file mode 100644
index 0000000..9d2e519
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/commonapi4someip.ini
@@ -0,0 +1,8 @@
+[default]
+binding=someip
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl
new file mode 100644
index 0000000..67f27ed
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl
@@ -0,0 +1,73 @@
+/* Copyright (C) 2014 BMW Group
+ * 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/. */
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E06Unions.fidl"
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E06Unions {
+ SomeIpServiceID = 4660
+ SomeIpEventGroups = { 7000, 7001 }
+
+ attribute u {
+ SomeIpGetterID = 3000
+ SomeIpSetterID = 3001
+ SomeIpNotifierID = 33010
+ SomeIpEventGroups = { 33010 }
+ }
+
+ attribute x {
+ SomeIpGetterID = 3002
+ SomeIpSetterID = 3003
+ SomeIpNotifierID = 33011
+ SomeIpEventGroups = { 33011 }
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for typeCollection commonapi.examples.CommonTypes {
+
+ union SettingsUnion {
+ id {
+ }
+ status {
+ }
+ channel {
+ }
+ name {
+ }
+ }
+
+ struct SettingsStructMyTypedef {
+ id {
+ }
+ }
+
+ struct SettingsStructMyEnum {
+ status {
+ }
+ }
+
+ struct SettingsStructUInt8 {
+ channel {
+ }
+ }
+
+ struct SettingsStructString {
+ name {
+ }
+ }
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E06Unions {
+ InstanceId = "commonapi.examples.Unions"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30490
+ SomeIpUnreliableUnicastPort = 30491
+}
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
index 2fa2527..ea6618a 100644
--- a/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
@@ -4,15 +4,15 @@
* 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 WIN32
#include <unistd.h>
-
+#endif
#include <iostream>
#include <CommonAPI/CommonAPI.hpp>
-#include "../src-gen/commonapi/examples/CommonTypes.hpp"
-#include "../src-gen/commonapi/examples/E06UnionsProxy.hpp"
+#include "commonapi/examples/CommonTypes.hpp"
+#include "commonapi/examples/E06UnionsProxy.hpp"
#include "typeUtils.hpp"
using namespace commonapi::examples;
@@ -155,11 +155,16 @@ void recv_msg1(std::shared_ptr<CommonTypes::SettingsStruct> x) {
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E06C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E06Unions");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
const std::string &domain = "local";
- const std::string &instance = "commonapi.examples.Unions";
- std::shared_ptr<E06UnionsProxyDefault> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance);
+ const std::string &instance = "commonapi.examples.Unions";
+ std::string connection = "client-sample";
+
+ std::shared_ptr<E06UnionsProxy<>> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance, connection);
while (!myProxy->isAvailable()) {
usleep(10);
diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
index 0e1cf02..9fa72b6 100644
--- a/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
@@ -12,23 +12,37 @@
#include "E06UnionsStubImpl.h"
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E06S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E06Unions");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
const std::string &domain = "local";
- const std::string &instance = "commonapi.examples.Unions";
+ const std::string &instance = "commonapi.examples.Unions";
+ std::string connection = "service-sample";
+
std::shared_ptr<E06UnionsStubImpl> myService = std::make_shared<E06UnionsStubImpl>();
- if (runtime->registerService(domain, instance, myService)) {
- int n = 0;
- while (true) {
- std::cout << "Set value " << n << " for union u." << std::endl;
- myService->setMyValue(n);
- n++;
- if (n == 4) {
- n = 0;
- }
- std::this_thread::sleep_for(std::chrono::seconds(2));
+ bool successfullyRegistered = runtime->registerService(domain, instance, myService, connection);
+
+ while (!successfullyRegistered) {
+ std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ successfullyRegistered = runtime->registerService(domain, instance, myService);
+ }
+
+ std::cout << "Successfully Registered Service!" << std::endl;
+
+ int n = 0;
+ while (true) {
+ std::cout << "Set value " << n << " for union u." << std::endl;
+ myService->setMyValue(n);
+ n++;
+ if (n == 4) {
+ n = 0;
}
- }
+ std::this_thread::sleep_for(std::chrono::seconds(2));
+ }
+
return 0;
}
diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp
index 58e9f82..1cee610 100644
--- a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp
@@ -7,7 +7,7 @@
#include "E06UnionsStubImpl.h"
-#include "../src-gen/commonapi/examples/CommonTypes.hpp"
+#include "commonapi/examples/CommonTypes.hpp"
using namespace commonapi::examples;
diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h
index cc3b0bf..3f7058e 100644
--- a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h
@@ -10,7 +10,7 @@
#include <CommonAPI/CommonAPI.hpp>
-#include "../src-gen/commonapi/examples/E06UnionsStubDefault.hpp"
+#include "commonapi/examples/E06UnionsStubDefault.hpp"
class E06UnionsStubImpl: public commonapi::examples::E06UnionsStubDefault {
diff --git a/CommonAPI-Examples/E06Unions/vsomeip-client.json b/CommonAPI-Examples/E06Unions/vsomeip-client.json
new file mode 100644
index 0000000..731852a
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/vsomeip-client.json
@@ -0,0 +1,26 @@
+{
+ "unicast" : "192.168.56.102",
+ "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"
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E06Unions/vsomeip-local.json b/CommonAPI-Examples/E06Unions/vsomeip-local.json
new file mode 100644
index 0000000..2f4c823
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/vsomeip-local.json
@@ -0,0 +1,52 @@
+{
+ "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" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "unreliable" : "31000"
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E06Unions/vsomeip-service.json b/CommonAPI-Examples/E06Unions/vsomeip-service.json
new file mode 100644
index 0000000..371ecf7
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/vsomeip-service.json
@@ -0,0 +1,48 @@
+{
+ "unicast" : "192.168.56.101",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "unreliable" : "31000"
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E07Mainloop/CMakeLists.txt b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
index 2642156..0f54006 100644
--- a/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
+++ b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
@@ -9,7 +9,14 @@ cmake_minimum_required(VERSION 2.8)
set(PRJ_NAME E07Mainloop)
set(CMAKE_VERBOSE_MAKEFILE on)
+
+if (MSVC)
+# Visual C++ is not always sure whether he is really C++
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"")
+else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP -DLINUX")
+endif()
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
@@ -23,11 +30,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version
message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -37,21 +44,53 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
# CommonAPI
include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
+###############################################################################
+# find DBus by using the 'pkg-config' tool
+if (MSVC)
+ #Not beautiful, but it works
+ if (DBus_DIR)
+ if (DBus_BUILD_DIR)
+ set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ else ()
+ message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "DBus_DIR not set! Cannot continue.")
+ endif ()
+else()
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
+endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.1 REQUIRED)
-find_package (vsomeip 1.1.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.2 REQUIRED)
+find_package (vsomeip 1.2.0 REQUIRED)
# GLib
-FIND_PACKAGE(glib-2.0)
-if (GLIB_FOUND)
- message ( STATUS "Glib found: " ${GLIB_INCLUDE_DIRS} " " ${_GLIB_LIBRARY_DIR} " " ${GLIBCONFIG_INCLUDE_DIR} )
- include_directories(${GLIB_INCLUDE_DIRS} ${GLIBCONFIG_INCLUDE_DIR})
- #link_directories(${_GLIB_LIBRARY_DIR})
-else (GLIB_FOUND)
- message ( WARNING "Glib not found.")
-endif (GLIB_FOUND)
+if (MSVC)
+ if (GLIB_INCLUDE_DIRS)
+ if (GLIBCONFIG_INCLUDE_DIR)
+ if (_GLIB_LIBRARY_DIR)
+ include_directories(${GLIB_INCLUDE_DIRS} ${GLIBCONFIG_INCLUDE_DIR})
+ link_directories(${_GLIB_LIBRARY_DIR})
+ else ()
+ message (FATAL_ERROR "_GLIB_LIBRARY_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "GLIBCONFIG_INCLUDE_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "GLIB_INCLUDE_DIRS not set! Cannot continue.")
+ endif ()
+else()
+ FIND_PACKAGE(glib-2.0)
+ if (GLIB_FOUND)
+ message ( STATUS "Glib found: " ${GLIB_INCLUDE_DIRS} " " ${_GLIB_LIBRARY_DIR} " " ${GLIBCONFIG_INCLUDE_DIR} )
+ include_directories(${GLIB_INCLUDE_DIRS} ${GLIBCONFIG_INCLUDE_DIR})
+ #link_directories(${_GLIB_LIBRARY_DIR})
+ else (GLIB_FOUND)
+ message ( WARNING "Glib not found.")
+ endif (GLIB_FOUND)
+endif()
# Source Files
set(PRJ_SRC_PATH src)
@@ -70,6 +109,10 @@ FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp)
set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+# Boost
+find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
+include_directories( ${Boost_INCLUDE_DIR} )
+
# DBus library
FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp)
@@ -87,7 +130,7 @@ include_directories(
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
${COMMONAPI_SOMEIP_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIRS}
+ ${DBus_INCLUDE_DIRS}
${VSOMEIP_INCLUDE_DIRS}
)
@@ -96,13 +139,15 @@ link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
- ${DBUS_INCLUDE_DIRS}/dbus/.libs
+ ${DBus_INCLUDE_DIRS}/dbus/.libs
+ ${Boost_LIBRARY_DIR}
)
endif()
@@ -117,9 +162,9 @@ add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
# Build DBus library
-add_library (${PRJ_NAME}-DBus SHARED ${PRJ_DBUS_LIB_SRCS})
-target_link_libraries(${PRJ_NAME}-DBus CommonAPI-DBus)
+add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus)
# Build SOME/IP library
-add_library (${PRJ_NAME}-SomeIP SHARED ${PRJ_SOMEIP_LIB_SRCS})
-target_link_libraries(${PRJ_NAME}-SomeIP CommonAPI-SomeIP) \ No newline at end of file
+add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP)
diff --git a/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini b/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini
index 39a52b7..ba5224f 100644
--- a/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini
+++ b/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini
@@ -1,8 +1,8 @@
[default]
binding=dbus
-[proxy]
-local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-DBus.so
-
-[stub]
-local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-DBus.so
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini b/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini
index 0c68943..9d2e519 100644
--- a/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini
+++ b/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini
@@ -1,8 +1,8 @@
[default]
binding=someip
-[proxy]
-local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-SomeIP.so
-
-[stub]
-local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-SomeIP.so
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
index 02954be..304255f 100644
--- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
@@ -5,10 +5,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <iostream>
+
+#ifndef WIN32
#include <unistd.h>
+#endif
+
#include <sstream>
#include <glib.h>
+#include <gio/gio.h>
#include <CommonAPI/CommonAPI.hpp>
#include <v1_0/commonapi/examples/E07MainloopProxy.hpp>
@@ -114,7 +119,12 @@ static GSourceFuncs standardGLibSourceCallbackFuncs = {
gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) {
CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
- watch->dispatch(condition);
+
+#ifdef WIN32
+ condition = static_cast<GIOCondition>(7);
+#endif
+
+ watch->dispatch(condition);
return true;
}
@@ -124,11 +134,16 @@ gboolean gTimeoutDispatcher ( void* userData ) {
}
void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) {
-
const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
- channel = g_io_channel_unix_new(fileDesc.fd);
- GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events));
+#ifdef WIN32
+ channel = g_io_channel_win32_new_socket(fileDesc.fd);
+ GSource* gWatch = g_io_create_watch(channel, GIOCondition::G_IO_IN);
+#else
+ channel = g_io_channel_unix_new(fileDesc.fd);
+ GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events));
+#endif
+
g_source_set_callback(gWatch, reinterpret_cast<GSourceFunc>(&gWatchDispatcher), watch, NULL);
const auto& dependentSources = watch->getDependentDispatchSources();
@@ -141,7 +156,7 @@ void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPrio
g_source_add_child_source(gWatch, gDispatchSource);
}
- g_source_attach(gWatch, NULL);
+ int source = g_source_attach(gWatch, NULL);
}
void watchRemovedCallback ( CommonAPI::Watch* watch ) {
@@ -155,6 +170,9 @@ void watchRemovedCallback ( CommonAPI::Watch* watch ) {
}
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E07C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop");
+
std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
std::string domain = "local";
@@ -167,11 +185,16 @@ int main() {
std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback;
mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
- std::shared_ptr<E07MainloopProxyDefault> myProxy = runtime->buildProxy<E07MainloopProxy>(domain,
+ std::shared_ptr<E07MainloopProxy<>> myProxy = runtime->buildProxy<E07MainloopProxy>(domain,
instance, mainloopContext);
std::cout << "Checking availability" << std::flush;
- static constexpr bool mayBlock = false;
+ static
+ #ifndef WIN32
+ constexpr
+ #endif
+ bool mayBlock = false;
+
int count = 0;
while (!myProxy->isAvailable()) {
if (count % 10 == 0)
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
index e57f192..17e7eb7 100644
--- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
@@ -8,6 +8,7 @@
#include <thread>
#include <glib.h>
+#include <gio/gio.h>
#include <CommonAPI/CommonAPI.hpp>
#include "E07MainloopStubImpl.hpp"
@@ -69,7 +70,12 @@ static GSourceFuncs standardGLibSourceCallbackFuncs = {
gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) {
CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
- watch->dispatch(condition);
+
+#ifdef WIN32
+ condition = static_cast<GIOCondition>(7);
+#endif
+
+ watch->dispatch(condition);
return true;
}
@@ -79,11 +85,16 @@ gboolean gTimeoutDispatcher ( void* userData ) {
}
void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) {
-
const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
- channel = g_io_channel_unix_new(fileDesc.fd);
- GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events));
+#ifdef WIN32
+ channel = g_io_channel_win32_new_socket(fileDesc.fd);
+ GSource* gWatch = g_io_create_watch(channel, GIOCondition::G_IO_IN);
+#else
+ channel = g_io_channel_unix_new(fileDesc.fd);
+ GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events));
+#endif
+
g_source_set_callback(gWatch, reinterpret_cast<GSourceFunc>(&gWatchDispatcher), watch, NULL);
const auto& dependentSources = watch->getDependentDispatchSources();
@@ -96,7 +107,7 @@ void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPrio
g_source_add_child_source(gWatch, gDispatchSource);
}
- g_source_attach(gWatch, NULL);
+ int source = g_source_attach(gWatch, NULL);
}
void watchRemovedCallback ( CommonAPI::Watch* watch ) {
@@ -110,6 +121,9 @@ void watchRemovedCallback ( CommonAPI::Watch* watch ) {
}
int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E07S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop");
+
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
@@ -123,7 +137,16 @@ int main() {
mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
std::shared_ptr<E07MainloopStubImpl> myService = std::make_shared<E07MainloopStubImpl>();
- runtime->registerService(domain, instance, myService, mainloopContext);
+
+ bool successfullyRegistered = runtime->registerService(domain, instance, myService, mainloopContext);
+
+ while (!successfullyRegistered) {
+ std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ successfullyRegistered = runtime->registerService(domain, instance, myService, mainloopContext);
+ }
+
+ std::cout << "Successfully Registered Service!" << std::endl;
GMainLoop* mainloop = NULL;
mainloop = g_main_loop_new(NULL, FALSE);