文章目录
前言
验证vsomeip可以在Host Linux和LXC 里面的Guest Linux之间进行通信。
- 验证vsomeip自带helloworld例程
- 创建helloworld的Service和client的配置文件
- 验证双机情况下vsomeip通信
- 验证LXC 内外系统的vsomeip通信
一、验证vsomeip自带helloworld例程
{
"unicast":"127.0.0.1",
"logging":
{
"level":"debug",
"console":"true"
},
"applications":
[
{
"name":"hello_world_service",
"id":"0x4444"
},
{
"name":"hello_world_client",
"id":"0x5555"
}
],
"services":
[
{
"service":"0x1111",
"instance":"0x2222",
"unreliable":"30509"
}
],
"routing":"hello_world_service",
"service-discovery":
{
"enable":"false"
}
}
unicast的地址要更换成127.0.0.1,说明是在本机内部运行。
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ VSOMEIP_CONFIGURATION=../helloworld-local.json \
> VSOMEIP_APPLICATION_NAME=hello_world_client \
> ./hello_world_client
1 Configuration module could not be loaded!
Error fix:
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ sudo ldconfig
按照readme的说明,直接copy执行命令来运行,要说明的是
1.vsomeip的配置需要import自己的JSON文件,否则会用到系统自带的default配置;
2.第一执行的时候会遇到配置模块无法加载的问题,执行一下 sudo ldconfig就能解决
1. 先运行服务端的APP
Run vsompip server side first:
will@will-OptiPlex-7050:~/work/vsomeip/examples/hello_world/build$ VSOMEIP_CONFIGURATION=../helloworld-local.json \
> VSOMEIP_APPLICATION_NAME=hello_world_service \
> ./hello_world_service
log会有 如下打印
2023-11-01 11:11:42.288696 [info] Using configuration file: "../helloworld-local.json".
2023-11-01 11:11:42.289278 [info] Parsed vsomeip configuration in 0ms
2023-11-01 11:11:42.289336 [info] Configuration module loaded.
2023-11-01 11:11:42.289392 [info] Security disabled!
2023-11-01 11:11:42.289424 [info] Initializing vsomeip (3.4.9.1) application "hello_world_service".
2023-11-01 11:11:42.289804 [info] Instantiating routing manager [Host].
2023-11-01 11:11:42.290299 [info] create_routing_root: Routing root @ /tmp/vsomeip-0
2023-11-01 11:11:42.290997 [info] Application(hello_world_service, 4444) is initialized (11, 100).
2023-11-01 11:11:42.291277 [info] Starting vsomeip application "hello_world_service" (4444) using 2 threads I/O nice 255
2023-11-01 11:11:42.291740 [info] Client [4444] routes unicast:134.86.56.94, netmask:255.255.255.0
2023-11-01 11:11:42.291761