VSOMEIP - 2 台设备之间的通信 (TCP/UDP) 不工作
VSOMEIP - Communication between 2 devices (TCP/UDP) Not working
正在学习 VSOMEIP 教程 Vsomeip in 10 minutes everything works up to the point of Communication between 2 devices。
当前设置:
- Ubuntu 16.04(两台机器 - 服务器和客户端)
- 两台机器通过以太网连接
使用的文件:
- server.cpp
- client.cpp
- client_config.json
- server_config.json
服务器输出
[info] Parsed vsomeip configuration in 1ms
[info] Using configuration file: "../clie_prop.json".
[info] Default configuration module loaded.
[info] Initializing vsomeip application "Hello".
[info] SOME/IP client identifier configured. Using 0033 (was: 1313)
[info] Instantiating routing manager [Proxy].
[info] Client [33] is connecting to [0] at /tmp/vsomeip-0
[info] Listening at /tmp/vsomeip-33
[info] Application(Hello, 33) is initialized (11, 100).
[info] Starting vsomeip application "Hello" using 2 threads
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] io thread id from application: 0033 (Hello) is: 7f80f5cd88c0 TID: 1497
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[info] io thread id from application: 0033 (Hello) is: 7f80f15e7700 TID: 1501
[info] shutdown thread id from application: 0033 (Hello) is: 7f80f1de8700 TID: 1500
[info] main dispatch thread id from application: 0033 (Hello) is: 7f80f25e9700 TID: 1499
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
客户端输出
[info] Parsed vsomeip configuration in 0ms
[info] Using configuration file: "../serv_prop.json".
[info] Default configuration module loaded.
[info] Initializing vsomeip application "World".
[warning] Routing Manager seems to be inactive. Taking over...
[info] SOME/IP client identifier configured. Using 1212 (was: 1212)
[info] Instantiating routing manager [Host].
[info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
[info] Client [1212] is connecting to [0] at /tmp/vsomeip-0
[info] Service Discovery enabled. Trying to load module.
[info] Service Discovery module loaded.
[info] Application(World, 1212) is initialized (11, 100).
[info] OFFER(1212): [1234.5678:0.0]
[info] Starting vsomeip application "World" using 2 threads
[info] Watchdog is disabled!
[info] io thread id from application: 1212 (World) is: 7fa68723d8c0 TID: 5370
[info] Network interface "enp0s3" state changed: up
[info] vSomeIP 2.10.21 | (default)
[info] Sent READY to systemd watchdog
[info] io thread id from application: 1212 (World) is: 7fa6828f3700 TID: 5374
[info] shutdown thread id from application: 1212 (World) is: 7fa6838f5700 TID: 5372
[info] main dispatch thread id from application: 1212 (World) is: 7fa6840f6700 TID: 5371
[warning] Releasing client identifier 0003. Its corresponding application went offline while no routing manager was running.
[info] Application/Client 0003 is deregistering.
使用的所有代码与 Request/Response in the vsomeip tutorial. The config files are the same as the config file specified in the communication between 2 devices 部分中使用的代码相同 IP 地址已更改以匹配我的机器地址。
非常感谢任何帮助,谢谢。
我找到了解决办法!!
如果您导航到 vsomeip 或 vsomeip-master 目录中的 /build/examples 文件夹,您会发现可执行文件(响应样本、订阅样本等)。如果您 运行 他们使用与 vsomeip 中使用的配置文件相同的配置文件,在 10 分钟后 (更改单播地址等),它应该可以完美运行。
这是我使用的配置文件。
{
"unicast" : "192.168.43.6",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "World",
"id" : "0x1212"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : "30509"
}
],
"routing" : "World",
"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"
}
}
我使用 shell 脚本来做到这一点。
#!/bin/bash
route add -host 224.224.224.245 dev <interface>
export VSOMEIP_CONFIGURATION=<config_file>
export VSOMEIP_APPLICATION_NAME=<application_name>
./<executable>
无论如何它对我有用!希望这可以帮助! :)
为了澄清 Rob Crowley 的回答,我使用 "vsomeip in 10 minutes" 教程中包含的两个独特的 .json 配置文件让它工作。我在提供服务的主机上使用 "World" 配置,在客户端 运行 主机上使用 "Hello" 配置文件。在这些文件中,我唯一需要修改的是 "unicast" 地址。我更改了它以匹配各个主机的 IP 地址。
我还修改了脚本以在 "route add -host" 命令之前使用 "sudo",因为我发现没有它实际上不会添加路由。
我在 "vsomeip/build/examples/" 文件夹中调用了 make 来构建示例。我在服务脚本上指向的是 "notify-sample" 可执行文件 (vsomeip/build/examples/)。我在服务脚本上指向的是 "subscribe-sample" 可执行文件 (vsomeip/build/examples/).
在通过以太网连接我的两台主机并确保它们的 IP 地址与各自配置文件的 "unicast" 字段中的 IP 地址相匹配后,这种组合对我有效。
正在学习 VSOMEIP 教程 Vsomeip in 10 minutes everything works up to the point of Communication between 2 devices。
当前设置:
- Ubuntu 16.04(两台机器 - 服务器和客户端)
- 两台机器通过以太网连接
使用的文件:
- server.cpp
- client.cpp
- client_config.json
- server_config.json
服务器输出
[info] Parsed vsomeip configuration in 1ms
[info] Using configuration file: "../clie_prop.json".
[info] Default configuration module loaded.
[info] Initializing vsomeip application "Hello".
[info] SOME/IP client identifier configured. Using 0033 (was: 1313)
[info] Instantiating routing manager [Proxy].
[info] Client [33] is connecting to [0] at /tmp/vsomeip-0
[info] Listening at /tmp/vsomeip-33
[info] Application(Hello, 33) is initialized (11, 100).
[info] Starting vsomeip application "Hello" using 2 threads
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] io thread id from application: 0033 (Hello) is: 7f80f5cd88c0 TID: 1497
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[info] io thread id from application: 0033 (Hello) is: 7f80f15e7700 TID: 1501
[info] shutdown thread id from application: 0033 (Hello) is: 7f80f1de8700 TID: 1500
[info] main dispatch thread id from application: 0033 (Hello) is: 7f80f25e9700 TID: 1499
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
[warning] local_client_endpoint::connect: Couldn't connect to: /tmp/vsomeip-0 (Connection refused / 111)
[info] routing_manager_proxy::on_disconnect: Client 0x33 calling host_->on_state with DEREGISTERED
客户端输出
[info] Parsed vsomeip configuration in 0ms
[info] Using configuration file: "../serv_prop.json".
[info] Default configuration module loaded.
[info] Initializing vsomeip application "World".
[warning] Routing Manager seems to be inactive. Taking over...
[info] SOME/IP client identifier configured. Using 1212 (was: 1212)
[info] Instantiating routing manager [Host].
[info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
[info] Client [1212] is connecting to [0] at /tmp/vsomeip-0
[info] Service Discovery enabled. Trying to load module.
[info] Service Discovery module loaded.
[info] Application(World, 1212) is initialized (11, 100).
[info] OFFER(1212): [1234.5678:0.0]
[info] Starting vsomeip application "World" using 2 threads
[info] Watchdog is disabled!
[info] io thread id from application: 1212 (World) is: 7fa68723d8c0 TID: 5370
[info] Network interface "enp0s3" state changed: up
[info] vSomeIP 2.10.21 | (default)
[info] Sent READY to systemd watchdog
[info] io thread id from application: 1212 (World) is: 7fa6828f3700 TID: 5374
[info] shutdown thread id from application: 1212 (World) is: 7fa6838f5700 TID: 5372
[info] main dispatch thread id from application: 1212 (World) is: 7fa6840f6700 TID: 5371
[warning] Releasing client identifier 0003. Its corresponding application went offline while no routing manager was running.
[info] Application/Client 0003 is deregistering.
使用的所有代码与 Request/Response in the vsomeip tutorial. The config files are the same as the config file specified in the communication between 2 devices 部分中使用的代码相同 IP 地址已更改以匹配我的机器地址。
非常感谢任何帮助,谢谢。
我找到了解决办法!!
如果您导航到 vsomeip 或 vsomeip-master 目录中的 /build/examples 文件夹,您会发现可执行文件(响应样本、订阅样本等)。如果您 运行 他们使用与 vsomeip 中使用的配置文件相同的配置文件,在 10 分钟后 (更改单播地址等),它应该可以完美运行。 这是我使用的配置文件。
{
"unicast" : "192.168.43.6",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" :
[
{
"name" : "World",
"id" : "0x1212"
}
],
"services" :
[
{
"service" : "0x1234",
"instance" : "0x5678",
"unreliable" : "30509"
}
],
"routing" : "World",
"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"
}
}
我使用 shell 脚本来做到这一点。
#!/bin/bash
route add -host 224.224.224.245 dev <interface>
export VSOMEIP_CONFIGURATION=<config_file>
export VSOMEIP_APPLICATION_NAME=<application_name>
./<executable>
无论如何它对我有用!希望这可以帮助! :)
为了澄清 Rob Crowley 的回答,我使用 "vsomeip in 10 minutes" 教程中包含的两个独特的 .json 配置文件让它工作。我在提供服务的主机上使用 "World" 配置,在客户端 运行 主机上使用 "Hello" 配置文件。在这些文件中,我唯一需要修改的是 "unicast" 地址。我更改了它以匹配各个主机的 IP 地址。
我还修改了脚本以在 "route add -host" 命令之前使用 "sudo",因为我发现没有它实际上不会添加路由。
我在 "vsomeip/build/examples/" 文件夹中调用了 make 来构建示例。我在服务脚本上指向的是 "notify-sample" 可执行文件 (vsomeip/build/examples/)。我在服务脚本上指向的是 "subscribe-sample" 可执行文件 (vsomeip/build/examples/).
在通过以太网连接我的两台主机并确保它们的 IP 地址与各自配置文件的 "unicast" 字段中的 IP 地址相匹配后,这种组合对我有效。