一、步骤
Step 1 & 2: Preparation / Prerequisites
Step 3: Build the CommonAPI SOME/IP Runtime Library
Step 4: Write the Franca file and generate code
Step 5: Write the client and the service application
Step 6: Build and run
二、或去CommonAPi、vSomeip源码
git clone https:
//github
.com
/GENIVI/capicxx-someip-runtime
.git
git clone https:
//github
.com
/GENIVI/capicxx-core-runtime
.git
git clone http:
//github
.com
/GENIVI/vSomeIP
.git
三、安装依赖
sudo apt-get install libboost-system1.54-dev libboost-thread1.54-dev libboost-log1.54-dev
sudo apt-get install openjdk-7-jdk
四、编译
1、编译vSomeIP:
a、cd
vSomeIP b、
mkdir
build c、
cd
build d、cmake .. e、make install
2、编译CommonAPI
a、cd
capicxx-someip-runtime b、
mkdir
build c、cd build d、cmake -DUSE_INSTALLED_COMMONAPI=OFF .. e、make install
3、编译CommonAPI-someip
a、cd capicxx-core-runtime b、mkdir build c、cd build d、cmake .. e、make install
五、使用
1、在work目录下新建project目录
2、mkdir cgen && cd cgen
3、wget http:
//docs
.projects.genivi.org
/yamaica-update-site/CommonAPI/generator/3
.1
/3
.1.3
/commonapi_someip_generator
.zip
4、unzip commonapi_someip_generator.zip -d commonapi_someip_generator
5、chmod +x ./commonapi_someip_generator/commonapi-someip-generator-linux-x86
6、在project目录下mkdir fidl
7、在fidl下添加HelloWorld.fdepl, 内容如下:
import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
import "HelloWorld.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.HelloWorld {
SomeIpServiceID = 4660
method sayHello {
SomeIpMethodID = 33000
}
}
define org.genivi.commonapi.someip.deployment for provider MyService {
instance commonapi.HelloWorld {
InstanceId = "test"
SomeIpInstanceID = 22136
}
}
8、进入project 目录,./cgen/commonapi_someip_generator/commonapi-someip-generator-linux-x86 -ll verbose ./fidl/HelloWorld.fdepl
9、添加cmakefileLists.txt,内容如下:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++0x")
include_directories(
src-gen
../capicxx-core-runtime/include
../capicxx-someip-runtime/include
../vSomeIP/interface
)
link_directories(
/home/x/work/capicxx-core-runtime/build
/home/x/work/capicxx-someip-runtime/build
/home/x/work/vSomeIP/build
)
add_executable(HelloWorldClient
src/HelloWorldClient.cpp
src-gen/v1_0/commonapi/HelloWorldSomeIPProxy.cpp
src-gen/v1_0/commonapi/HelloWorldSomeIPDeployment.cpp
)
target_link_libraries(HelloWorldClient CommonAPI CommonAPI-SomeIP vsomeip)
add_executable(HelloWorldService
src/HelloWorldService.cpp
src/HelloWorldStubImpl.cpp
src-gen/v1_0/commonapi/HelloWorldSomeIPStubAdapter.cpp
src-gen/v1_0/commonapi/HelloWorldStubDefault.cpp
src-gen/v1_0/commonapi/HelloWorldSomeIPDeployment.cpp
)
target_link_libraries(HelloWorldService CommonAPI CommonAPI-SomeIP vsomeip)
10、mkdir build && cd build && cmake ..