gitgit.projects.genivi.org / ipc / common-api-dbus-tools.git / blob
? search: re

0544e985b6e4a6c83ddf08969f6475099461bd1e
[ipc/common-api-dbus-tools.git] / docx / CommonAPIDBusCppUserGuide
1 = CommonAPI D-Bus C++ User Guide
2
3 :doctitle: CommonAPI D-Bus C++ User Guide
4 :website: http://projects.genivi.org/commonapi/
5 :version:
6 :date:
7 :toc:
8 :revdate:
9 :imagedir:
10 :cppstr: c++
11
12 == Introduction
13
14 === Aim of this document
15
16 This document complements the CommonAPI tutorial with D-Bus specific information. Please read the base tutorial first.
17
18 == Integration Guide for CommonAPI users
19
20 The following descriptions assume that host and target platform are Linux platforms. However CommonAPI D-Bus supports also Windows as host and target platform. All you need to know for Windows concerning CommonAPI you find in the separate Windows paragraph below at the end of this Integration Guide.
21
22 === Requirements
23
24 CommonAPI was developed for GENIVI and will run on most Linux platforms. Additionally it is possible to run it under Windows for test and development purposes. Please note:
25
26 - CommonAPI uses a lot of C++11 features, as variadic templates, std::bind, std::function and so on. Make sure that the compiler of your target platform is able to compile it (e.g. gcc 4.8).
27 - The build system of CommonAPI is CMake; please make sure that it is installed on your host.
28 - Do not use earlier versions of Eclipse as Luna; it could work but there is no warranty.
29 - The build tool chain for the code generators is Maven; make sure that at least Maven 3 is available. If you use eclipse make sure that the maven plug-in is installed.
30
31 The CommonAPI D-Bus binding requires the D-Bus (_libdbus_ at compile time for linking and the running D-Bus daemon at runtime). The D-Bus version should be at least 1.6.x.
32
33 === Dependencies
34 .CommonAPI-D-Bus Dependencies
35 image::{imagedir}/CommonAPI-DBus-Dependencies.png[CommonAPI D-Bus Dependencies image]
36
37 === Restrictions
38
39 - The signature of D-Bus data must not be longer than 255 characters.
40
41 === Compile Runtime
42
43 ==== Patching libdbus
44
45 CommonAPI-D-Bus needs some API functions of libdbus which are not available in actual libdbus versions. For these additional API functions it is necessary to patch the required libdbus version with all the patches provided in the directory src/dbus-patches.
46
47 [NOTE]
48 Use autotools to build libdbus.
49
50 ----
51 $ wget http://dbus.freedesktop.org/releases/dbus/dbus-<VERSION>.tar.gz
52 $ tar -xzf dbus-<VERSION>.tar.gz
53 $ cd dbus-<VERSION>
54 $ patch -p1 < </path/to/CommonAPI-D-Bus/src/dbus-patches/patch-names>.patch
55 $ ./configure --prefix=</path to your preferred installation folder for patched libdbus>
56 $ make -C dbus
57 $ make -C dbus install
58 $ make install-pkgconfigDATA
59 ----
60
61 You can change the installation directory by the prefix option or you can let it uninstalled (skip the +make install+ commands).
62 WARNING: Installing the patched libdbus to /usr/local can prevent your system from booting correctly at the next reboot.
63
64 ==== Command-line
65
66 In order to build the CommonAPI-D-Bus Runtime library the pkgconfig files of the patched libdbus library must be added to the +PKG_CONFIG_PATH+.
67
68 For example, if the patched libdbus library is available in /usr/local, set the +PKG_CONFIG_PATH+ variable as follows:
69
70 ----
71 $ export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
72 ----
73
74 Now use CMake to build the CommonAPI D-Bus runtime library. We assume that your source directory is +common-api-dbus-runtime+:
75
76 ----
77 $ cd common-api-dbus-runtime
78 $ mkdir build
79 $ cd build
80 $ cmake -DUSE_INSTALLED_COMMONAPI=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..
81 $ make
82 $ make install
83 ----
84
85 You can change the installation directory by the CMake variable +CMAKE_INSTALL_PREFIX+ or you can let it uninstalled (skip the +make install+ command). If you want to use the uninstalled version of CommonAPI set the CMake variable USE_INSTALLED_COMMONAPI to OFF.
86
87 This is the standard procedure and will hopefully create the shared CommonAPI D-Bus runtime library libCommonAPI-DBus.so in the build directory. Note that CMake checks if doxygen and asciidoc are installed. These tools are only necessary if you want to generate the documentation of your own. The unit tests of CommonAPI D-Bus are implemented by using the Google C++ Testing Framework. If you want to build and run the unit tests the environment variable +GTEST_ROOT+ must point to the correct directory (see the contributor's guide below).
88
89 [NOTE]
90 If you prefer to install CommonAPI D-Bus from a tar file you can get the actual tar file from:
91         http://docs.projects.genivi.org/yamaica-update-site/CommonAPI/runtime/
92
93 There are several options for calling CMake and make targets.
94
95 If you do not want to use nor the installed dbus library and neither the installed CommonAPI library:
96 ----
97 $ cmake -DUSE_INSTALLED_DBUS=OFF -DUSE_INSTALLED_COMMONAPI=OFF ..
98 ----
99
100 Generate makefile for building a static CommonAPI library (default is a shared library). The library will be in _/build/src/CommonAPI/DBus_.
101 ----
102 $ cmake -DBUILD_SHARED_LIBS=OFF ..
103 ----
104
105 Generate makefile for building the release version of CommonAPI D-Bus (default is debug).
106 ----
107 $ cmake -DCMAKE_BUILD_TYPE=Release ..
108 ----
109
110 Without any further settings +make install+ will copy CommonAPI D-Bus libraries and header files to _/usr/local_. You can change this destination directory by changing the installation prefix (e.g. to test).
111 ----
112 $ cmake -DCMAKE_INSTALL_PREFIX=/test  ..
113 ----
114
115 Make targets:
116
117 [width="80%",cols="4,10"]
118 |=========================================================
119
120 |+make all+ |
121 Same as make. Will compile and link CommonAPI.
122
123 |+make clean+ |
124 Deletes binaries, but not the files which has been generated by CMake.
125
126 |+make maintainer-clean+ |
127 Deletes everything in the build directory.
128
129 |+make install+ |
130 Copies libraries to _/user/local/lib/commonapiX.X.X_ and header files to _/user/local/include/commonapiX.X.X/CommonAPI_.
131
132 |+make DESTDIR=< install_dir > install+ |
133 The destination directory for the installation can be influenced by +DESTDIR+.
134
135 |=========================================================
136
137 Further make targets will be described in the contributor's guide below.
138
139 ==== Eclipse
140
141 Follow the instructions in the CommonAPI User Guide.
142
143 === Compile tools
144
145 Like the CommonAPI core code generators you can build the D-Bus generator by calling maven from the command-line. Open a console and change in the directory org.genivi.commonapi.dbus.releng of your CommonAPI-D-Bus-Tools directory. Then call:
146
147 ----
148 mvn clean verify –DCOREPATH=<path to your CommonAPI-Tools dir> -Dtarget.id=org.genivi.commonapi.dbus.target
149 ----
150
151 COREPATH is the directory, that contains the target definition folder: org.genivi.commonapi.core.target.
152
153 After the successful build you will find the commond-line generators archived in org.genivi.commonapi.dbus.cli.product/target/products/commonapi_dbus_generator.zip and the update-sites in org.genivi.commonapi.dbus.updatesite/target.
154
155 === Build DBus Glue Code
156
157 The glue code library contains the binding specific, generated code. It depends on your specific project how exactly this library is built (with or without skeleton code, divided up into several libraries, e.g. for services and clients, and so on). The glue code for the verification tests can be built by means of the binding specific verification project (for D-Bus it is _org.genivi.commonapi.dbus.verification_ in CommonAPI-D-Bus-Tools):
158
159 . The cmake call below generates CommonAPI code for all requested fidl files using the CommonAPI- core and DBus code generator. The fidl files for the verification tests can be found in _org.genivi.commonapi.core.verification/fidl_.
160 . Create a build directory for an out of source build.
161 . Call cmake as described below with additional parameters (in eclipse create a make target).
162
163 CMake parameters:
164
165 [width="90%",cols="10,10"]
166 |=========================================================
167
168 |+USE_INSTALLED_COMMONAPI+ |
169 ON or OFF
170
171 |+COMMONAPI_CMAKE_INSTALL_PATH+ |
172 Path to the build directory of CommonAPI (e.g. CommonAPI/build)
173
174 |+COMMONAPI_TOOL_GENERATOR+ |
175 Core code generator executable with path
176
177 |+COMMONAPI_DBUS_TOOL_GENERATOR+ |
178 DBus Code generator executable with path
179
180 |=========================================================
181
182  
183 Example to build DBus glue code for the verification tests:
184
185 ----
186 export PKG_CONFIG_PATH=path/to/patched/libdbus:$PKG_CONFIG_PATH
187
188 cd CommonAPI-D-Bus-Tools/org.genivi.commonapi.dbus.verification/
189 mkdir build
190 cd build
191
192 cmake \
193 -DCOMMONAPI_TOOL_GENERATOR=myworkpath/CommonAPI-Tools/org.genivi.commonapi.core.cli.product/target/products/org.genivi.commonapi.core.cli.product/linux/gtk/MYARCH/commonapi-generator-linux-MYARCH \
194 -DCOMMONAPI_DBUS_TOOL_GENERATOR=myworkpath/CommonAPI-D-Bus-Tools/org.genivi.commonapi.dbus.cli.product/target/products/org.genivi.commonapi.dbus.cli.product/linux/gtk/MYARCH/commonapi-dbus-generator-linux-MYARCH \
195 -DCommonAPI_DIR=myworkpath/CommonAPI/build \
196 -DCommonAPI-DBus_DIR=myworkpath/CommonAPI-D-Bus/build \
197 -DCOMMONAPI_TEST_FIDL_PATH=myworkpath/CommonAPI-Tools/org.genivi.commonapi.core.verification/fidl ..
198
199 make -j4
200 ----
201
202 === Project Setup
203
204 ==== Configuration
205
206 CommonAPI-D-Bus can be configured as CommonAPI itself by an ini-file. The name of this configuration file is +commonapi-dbus.ini+. There are three places where CommonAPI D-Bus Runtime tries to find this file (in the following order):
207
208 1. in the directory of the current executable. If there is a +commonapi-dbus.ini+ file, it has the highest priority.
209 2. in the directory which is specified by the environment variable +COMMONAPI_DBUS_CONFIG+.
210 3. in the global default directory +/etc+.
211
212 The configuration file has 2 possible kinds of sections; all sections are optional.
213
214 ===== Address Translation Sections
215
216 This kind of section determines how CommonAPI addresses are translated into D-Bus addresses (object path, interface name and so on). The name of the section is the CommonAPI address and the parameters are:
217
218 - +service+
219 - +path+
220 - +interface+
221
222 Example:
223
224 ----
225 [local:de.ABC:de.app1]
226 service=de.ABC_de.app1
227 path=/de/app1
228 interface=de.ABC
229 ----
230
231 If there is no address configuration for a certain CommonAPI address available the CommonAPI address will be translated by default as shown in the following picture:
232
233 .D-Bus Addresses
234 image::{imagedir}/DBusAddresses.png[D-Bus Addresses image]
235
236 There might be some confusion concerning the terms and definitions:
237
238 - Franca IDL and CommonAPI define interfaces; these interfaces can be instantiated once or several times in one or several services. The CommonAPI term _interfaceID_ and the D-Bus term _interface name_ are equivalent.
239 - The D-Bus _object path_ is a name used to refer to an object instance. The _object names_ are organized into a filesystem-style hierarchy. The _object path_ corresponds to the CommonAPI _instanceIDs_.
240 - Additionally D-Bus services are "connected" to the bus with an automatically created internal so-called unique bus name (e.g. :1.25). For this bus name one or several well-known names may be defined (here it is called service name). The parameter _service_ in the configuration file defines this well-known name; the default name is _interfaceID___instanceID_.  
241
242 ===== Connections
243
244 Section for assigning a certain D-Bus bus segment (Session, System, Starter) to the connection name.
245
246 ==== Deployment
247
248 The D-Bus code generator can generate code completely without any deployment settings. But for the combination of CommonAPI applications and D-Bus applications which are written without CommonAPI there are some deployment parameters necessary.
249
250 [source,java]
251 ----
252 import "platform:/plugin/org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl"
253
254 specification org.genivi.commonapi.dbus.deployment extends org.genivi.commonapi.core.deployment {
255         for interfaces {
256                 PropertiesType: {CommonAPI, freedesktop} (default: CommonAPI);
257         }
258 }
259 ----
260
261 Use the deployment parameter _PropertiesType_ for the support of implementations of the _org.freedesktop.DBus.Properties_ interface.
262
263 === Windows
264
265 ==== Build D-Bus
266
267 To build the Windows version of D-Bus the following steps have to be done:
268
269 - Download D-Bus from http://www.freedesktop.org/wiki/Software/dbus/ e.g. dbus-1.8.0.tar.gz and unpack the archive into a directory.
270 - For building D-Bus, CMake is needed. Download CMake from http://cmake.org/cmake/resources/software.html. The result of the download is e.g. cmake-2.8.12.2-win32-x86.zip. Unpack the archive into a directory.
271 - Furthermore +expat+ is needed. +Expat+ can be downloaded from http://expat.sourceforge.net. Example: download expat-win32bin-2.1.0.exe from http://sourceforge.net/projects/expat/files/expat_win32/2.1.0 and install it.
272
273
274
275 - Now the Windows D-Bus patch is needed. Download the patch from http://gnuwin32.sourceforge.net/packages/patch.htm e.g. patch-2.5.9-7-setup.exe and install the patch.
276
277 - Apply all the CommonAPI D-Bus patches (located in _CommonAPI-D-Bus/src/dbus-patches_ ) e.g. call
278
279 ----
280 cd dbus-1.8.0
281 find ../CommonAPI-D-Bus/src/dbus-patches/*.patch | xargs -n1 patch -p1 -F3 -i
282 ----
283 (assuming that _CommonAPI-D-Bus_ is on same folder level as _dbus-1.8.0_)
284
285 - Build D-Bus via the CMake command line tool:
286 -- Open the developer command line for VS2013.
287 -- Change into root directory of the unpacked D-Bus archive e.g. dbus-1.8.0.
288 -- Create a new directory dbus-build-dir e.g. +mkdir dbus-build-dir+.
289 -- Change into this new created directory e.g. +cd dbus-build-dir+.
290 -- Create the Visual Studio files for building the D-Bus:
291
292 ----
293 cmake -DEXPAT_INCLUDE_DIR="<expat-path>\Source\lib"
294                 -DEXPAT_LIBRARY="<expat-path>\Bin\libexpat.lib" -G "Visual Studio 12" <DBusSourcenPath>\cmake
295 ----
296
297 Example:
298 ----
299 C:\Work\cmake-2.8.12.2-win32-x86\bin\cmake.exe
300         -DEXPAT_INCLUDE_DIR="C:\Program Files (x86)\Expat 2.1.0\Source\lib"
301         -DEXPAT_LIBRARY="C:\Program Files (x86)\Expat 2.1.0\Bin\libexpat.lib"
302         -G "Visual Studio 12" C:\Work\dbus-1.8.0\cmake
303 ----
304
305 The Visual Studio files are created in the directory dbus-build-dir. Open the solution dbus.sln and build all projects. Info for dbus-1.8.0: In file printf.c the #include "test-utils.h" must be changed to #include "test/test-utils.h".
306
307 ==== Build CommonAPI
308
309 To build now the Windows version with Visual Studio 2013, you can use the solution file CommonAPI-DBus.sln. It is configured to build CommonAPI-D-Bus as a static library.
310
311 Before opening the solution file CommonAPI-DBus.sln the following environment variables must be set:
312
313 - DBUS_DIR: directory containing the patched D-Bus sources e.g. <path_to_folder>\dbus-1.8.0
314 - DBUS_BUILD_DIR: directory containing the build DBus e.g. <path_to_folder>\dbus-1.8.0\dbus-build-dir
315 - COMMONAPI_DIR: directory containing the CommonAPI e.g. <path_to_folder>\CommonAPI
316
317 To run the tests, you need to add the location of your built dbus-1d.dll or dbus-1.dll (depending on Debug or Release built) to the PATH environment variable.
318
319 ==== Restrictions
320
321 - Calling disconnect and later connect on the same DBusConnection somehow damages the libdbus connection. On Linux implementation this all works fine.
322 - The DBusLoadTest revealed that a number of more than about 50 proxies slows down the dbus communication significantly. That's why we run the DBusLoadTest on windows with just 50 instead of 100 proxies.
323
324
325
326
327
328
Common API for Dbus tools
RSS Atom

DBus接口文档的更多相关文章

  1. 【开源】.Net Api开放接口文档网站

    开源地址:http://git.oschina.net/chejiangyi/ApiView 开源QQ群: .net 开源基础服务  238543768 ApiView .net api的接口文档查看 ...

  2. 用Swagger生成接口文档

    Swagger简介 在系统设计的时候,各个应用之间往往是通过接口进行交互的.因此接口的定义在整个团队中就变得尤为重要.我们可以把接口的规范用接口描述语言进行描述,然后Swagger可以根据我们定义的接 ...

  3. Swagger+Spring mvc生成Restful接口文档

    简介 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...

  4. postman-根据接口文档进行测试

    根据接口文档来测试 1.get请求

  5. api(接口)文档管理工具

    api(接口)文档管理工具 欢迎光临:博之阅API管理平台  ,做为一个app开发者,还没有用到api管理工具,你就OUT了 点击进入:程序员精华博客大全  

  6. Markdown写接口文档,自动添加TOC

    上回说到,用Impress.js代替PPT来做项目展示.这回换Markdown来做接口文档好了.(不敢说代替Word,只能说个人感觉更为方便)当然,还要辅之以Git,来方便版本管理. Markdown ...

  7. ShiWangMeSDK Android版接口文档 0.2.0 版

    # ShiWangMeSDK Android版接口文档 0.2.0 版 android 总共有 14 个接口,分别涉及到初始化和对界面的一些细节的控制.下面详细介绍接口,如果没有特殊说明,接口都在 S ...

  8. 使用swagger实现web api在线接口文档

    一.前言 通常我们的项目会包含许多对外的接口,这些接口都需要文档化,标准的接口描述文档需要描述接口的地址.参数.返回值.备注等等:像我们以前的做法是写在word/excel,通常是按模块划分,例如一个 ...

  9. 推荐一款接口文档在线管理系统-MinDoc

    项目简介 MinDoc 是一款针对IT团队开发的简单好用的文档管理系统. MinDoc 的前身是 SmartWiki 文档系统.SmartWiki 是基于 PHP 框架 laravel 开发的一款文档 ...

随机推荐

  1. Linux常用命令之grep

    标题:grep命令的使用 作用:grep可以解析一行文字,取得关键字,若该行存在关键字,就会整行列出.    grep [-acinv] [--color=auto] '查找字符串' filename ...

  2. CF Soldier and Cards (模拟)

    Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  3. Java操作XML的工具类

    import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.Inp ...

  4. 系统磁盘空间/dev/xvda1占满原因分析

    由于项目原因需要定期检查磁盘空间占用情况,常用检查命令如下: 1.查看磁盘空间大小 df -lh 2.查看对应文件大小 du --max-depth=1 -h / 于一日发现在使用Flume + Ka ...

  5. hdu 3966 树链剖分

    思路:树链剖分入门题,我这门入得好苦啊,程序很快写出来了,可是在LCA过程中把update函数里的左右边界位置写反了,一直RE到死. #pragma comment(linker, "/ST ...

  6. hdu 4412 利用单调性的动态规划

    思路: 这题和1227的求法一样,只不过1227是小数据,暴力下,就能进行预处理. 这题的预处理区间期望cost[i][j]需要利用单调性. 即假使以pos位置为安排的点,那么这个区间在其左边的概率为 ...

  7. 转VS快捷键

    “文本操作”快捷键 命令名 快捷键 说明 编辑.折叠到定义 Ctrl + M,Ctrl + O 自动确定在代码中创建区域的逻辑边界(如过程),然后隐藏它们. 编辑.注释选定内容 Ctrl + K,Ct ...

  8. freeCodeCamp:Diff Two Arrays

    比较两个数组,然后返回一个新数组,该数组的元素为两个给定数组中所有独有的数组元素.换言之,返回两个数组的差异. function diff(arr1, arr2) { var newArr = []; ...

  9. jquery简单的图片切换效果,支持pc端、移动端的banner图片切换开发

    详细内容请点击 无意中看见了两年前写的一个图片切换,那会儿刚刚学习网页制作,可以说是我的第一个处女座的jquery图片切换效果.无聊之余对它的宽度稍稍做了一下修改,变成了支持pc端.手机端全屏的ban ...

  10. 考上好大学,然后进入IT行业是穷人孩子晋级中产的唯一出路?

    今天看到一篇不错的文章,内容如下: 这个问题来自于我在知乎上参与的一个热贴讨论,作为一个10年的老码农,创业公司呆过,二.三流的互联网公司混过,BAT也遛了一趟,如今再次回归创业,经历算得上狗血了,看 ...