c++ 客户端和服务器的vsomeip配置文件

mwkjh3gx  于 2022-11-27  发布在  其他
关注(0)|答案(2)|浏览(849)

当客户端和服务器使用不同的JSON配置文件时,我无法在服务器和客户端之间建立通信。我的要求是使用vsomeip框架传输SOME/IP数据。我在同一个系统上传输数据。但是,当发送器和接收器使用同一个JSON文件时,我可以传输数据。下面是使用的JSON文件。

{
    "unicast" : "160.48.199.102",
    "logging" :
    { 
        "level" : "trace",
        "console" : "true",
        "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
        "dlt" : "false"
    },
    "applications" : 
    [
        {
            "name" : "master_tx",
            "id" : "0x1277"
        },
        {    
            "name" : "master_rx",
            "id" : "0x1344"
        }
    ],
    "services" :
    [
        {
            "service" : "0x3556",
            "instance" : "0x0001",
            "reliable" : { "port" : "30490", "magic-cookies" : "false" },
            "events" : 
            [
                {
                    "event" : "0x8001",
                    "is_field" : "true",
                    "is_reliable" : "false"
                }
            ]
        }
    ]
    "max-payload-size" : "5000",
    "max-payload-size-unreliable" : "5000",
    "routing" : "master_tx",
    "service-discovery" :
    {
        "enable" : "true",
        "port" : "30490",
        "protocol" : "_udp_",
        "initial_delay_min" : "100",
        "initial_delay_max" : "200",
        "repetitions_base_delay" : "200",
        "repetitions_max" : "15",
        "ttl" : "100",
        "cyclic_offer_delay" : "2000",
        "request_response_delay" : "1500"
    }
}

但是,当发送方和接收方使用不同的JSON文件时,我无法建立任何连接。
server.json

{
    "unicast" : "192.168.0.178",
    "logging" :
    { 
        "level" : "trace",
        "console" : "true",
        "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
        "dlt" : "false"
    },
    "applications" : 
    [
        {
            "name" : "master_tx",
            "id" : "0x1277"
        }
    ],
    "services" :
    [
        {
            "service" : "0x3556",
            "instance" : "0x0001",
            "reliable" : { "port" : "30490", "magic-cookies" : "false" },
            "events" : 
            [
                {
                    "event" : "0x8001",
                    "is_field" : "true",
                    "is_reliable" : "false"
                }
            ],
            "eventgroups" :
            [
                {
                    "eventgroup" : "0x001",
                    "events" : [ "0x8001" ]
                }
            ]
        }
    ],
    "max-payload-size" : "5000",
    "max-payload-size-unreliable" : "5000",
    "routing" : "master_tx",
    "service-discovery" :
    {
        "enable" : "true",
        "port" : "30490",
        "protocol" : "_udp_",
        "initial_delay_min" : "100",
        "initial_delay_max" : "200",
        "repetitions_base_delay" : "200",
        "repetitions_max" : "15",
        "ttl" : "100",
        "cyclic_offer_delay" : "2000",
        "request_response_delay" : "1500"
    }
}

client.json

{
    "unicast" : "192.168.0.178",
    "network" : "vsomeip-rx",
    "logging" :
    { 
        "level" : "trace",
        "console" : "true",
        "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
        "dlt" : "true"
    },
    "applications" : 
    [
        {    
            "name" : "master_rx",
            "id" : "0x1344"
        }
    ],
    "clients" :
    [
        {
            "service" : "0x3556",
            "instance" : "0x0001",
            "unreliable" : [ "30490" ]
        }
    ],
    "max-payload-size" : "5000",
    "max-payload-size-unreliable" : "5000",
    "routing" : "master_rx",
    "service-discovery" :
    {
        "enable" : "true",
        "port" : "30490",
        "protocol" : "_udp_",
        "initial_delay_min" : "100",
        "initial_delay_max" : "200",
        "repetitions_base_delay" : "200",
        "repetitions_max" : "15",
        "ttl" : "100",
        "cyclic_offer_delay" : "2000",
        "request_response_delay" : "1500"
    }
}

如果JSON文件中有错误或者我遗漏了其他东西,有人能帮助我吗?

3yhwsihp

3yhwsihp1#

服务器.json

1.端口30490被定义为可靠端口,但它被用作服务发现端口(不可靠)。请使用其他端口,如30500。
1.我不确定**"udp"是否是允许的值-“udp”**肯定是。

客户端.json

1.“clients”标记指定用于连接特定服务的端口。在这种情况下,同样只使用一个端口30490,该端口已定义用于服务发现。此外,在客户端中,该端口被指定为不可靠,而在服务器中,该端口是可靠的。除文档中指定的端口外:vsomeip将使用列表中的第一个可用端口。如果找不到可用端口,连接将失败。 请尝试使用其他端口或删除“clients”标记进行测试。
1.我不确定**"udp"是否是允许的值-“udp”**肯定是。

f0ofjuux

f0ofjuux2#

嗯,很难。我认为端口30490是为ServiceDiscovery保留的(由vsomeip守护进程使用)。因此,重用应用程序可能会导致问题。
但我认为这里的主要问题是您在server.json中为服务“0x3556”使用了一个可靠的端口(即TCP),而在client.json中使用了一个不可靠的端口(UDP)。

相关问题