vsomeip双机通信

VSOMEIP双机通信

环境:两台虚拟机配置的Ubuntu20.04 (默认部署好vsomeip并且编译过)

  • 编译helloworld程序
    在这里插入图片描述
    按照上图helloworld 文件里的readme步骤来
  • 配置hello world服务端配置文件
{
    "unicast":"192.168.52.129",
    "logging":
    {
        "level":"debug",
        "console":"true",
        "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
        "dlt" : "false"
    },

    "applications":
    [
        {
            "name":"hello_world_service",
            "id":"0x4444"
        },
    ],

    "services":
    [
        {
            "service":"0x1111",
            "instance":"0x2222",
            "unreliable":"30509"
        }
    ],

    "routing":"hello_world_service",
    "service-discovery":
    {
        "enable":"false",
        "enable" : "true",
        "multicast" : "224.224.224.245",
        "port" : "30490",
        "protocol" : "udp",
        "initial_delay_min" : "10",
        "initial_delay_max" : "100",
        "repetitions_base_delay" : "200",
        "repetitions_max" : "3",
        "ttl" : "3",
        "cyclic_offer_delay" : "2000",
        "request_response_delay" : "1500"
    }
}
  • 配置端口并且运行服务端
route add -host 224.224.224.245 dev <interface>

运行服务端指令:
先把helloworld-local.json文件复制到build文件下。
如图:
在这里插入图片描述
再运行以下指令:

env VSOMEIP_CONFIGURATION=./helloworld-local.json  VSOMEIP_APPLICATION_NAME=hello_world_service 
./hello_world_service

在这里插入图片描述

  • 将make出来的客户端可执行文件复制到另一台虚拟机上,再配置配置文件如图:
    在这里插入图片描述
    配置文件内容如图:
{
    "unicast":"192.168.52.128",
    "logging":
    {
        "level":"debug",
        "console":"true",
        "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
        "dlt" : "false"
    },

    "applications":
    [
        {
            "name":"hello_world_client",
            "id":"0x5555"
        }
    ],
    "routing":"hello_world_client",
    "service-discovery":
    {

        "enable" : "true",
        "multicast" : "224.224.224.245",
        "port" : "30490",
        "protocol" : "udp",
        "initial_delay_min" : "10",
        "initial_delay_max" : "100",
        "repetitions_base_delay" : "200",
        "repetitions_max" : "3",
        "ttl" : "3",
        "cyclic_offer_delay" : "2000",
        "request_response_delay" : "1500"
    }
}

然后再进行如下指令

export LD_LIBRARY_PATH=/home/zyf/vsomeip-master/build
route add -host 224.224.224.245 dev <interface>
env VSOMEIP_CONFIGURATION=./helloworld-local.json  VSOMEIP_APPLICATION_NAME=hello_world_client 
./hello_world_client

终端显示如图:
在这里插入图片描述

代码都是vsomeip/examples/hello_world下的代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值