01-死磕QNX someip

1. vsomeip3.1.20版本 

环境配置

export COMMONAPI_CONFIG=/etc/commonapi.ini
export LD_LIBRARY_PATH=/sdcard/someip:$LD_LIBRARY_PATH
export VSOMEIP_CONFIGURATION=/etc/vsomeip-service.json
export VSOMEIP_APPLICATION_NAME=HelloWorldSomeIPService

sysctl -w net.inet.ip.forwarding=1

route -n add 224.244.224.245 192.168.1.1

测试问题:

# ./HelloWorldSomeIPService
[CAPI][INFO] Loading configuration file '/etc/commonapi.ini'
[CAPI][INFO] Using default binding 'someip'
[CAPI][INFO] Using default shared library folder '/usr/local/lib/commonapi'
[CAPI][INFO] Registering function for creating "commonapi.HelloWorld:v1_0" stub adapter.
[CAPI][INFO] Registering stub for "local:commonapi.HelloWorld:v1_0:mid.someip.helloword"
1970-00-01 03:25:22.226275 [info] Parsed vsomeip configuration in 23ms
1970-00-01 03:25:22.226285 [info] Using configuration file: "/etc/vsomeip-service.json".
1970-00-01 03:25:22.226295 [info] Configuration module loaded.
1970-00-01 03:25:22.226295 [info] Initializing vsomeip application "HelloWorldSomeIPServiceA".
1970-00-01 03:25:22.226295 [info] Instantiating routing manager [Proxy].
1970-00-01 03:25:22.226295 [info] Client [ffff] is connecting to [0] at /tmp/vsomeip-0
1970-00-01 03:25:22.226305 [info] Application(HelloWorldSomeIPServiceA, ffff) is initialized (11, 100).
1970-00-Successfully Registered Service!1
03Waiting for calls... (Abort with CTRL+C):
25:22.226305 [info] Starting vsomeip application "HelloWorldSomeIPServiceA" (ffff) using 2 threads I/O nice 255
1970-00-01 03:25:22.226315 [info] main dispatch thread id from application: ffff (HelloWorldSomeIPServiceA) is: 4
1970-00-01 03:25:22.226315 [info] shutdown thread id from application: ffff (HelloWorldSomeIPServiceA) is: 5
1970-00-01 03:25:22.226315 [info] io thread id from application: ffff (HelloWorldSomeIPServiceA) is: 3
1970-00-01 03:25:22.226315 [info] io thread id from application: ffff (HelloWorldSomeIPServiceA) is: 6
1970-00-01 03:25:22.226325 [info] routing_manager_proxy::on_disconnect: Client 0xffff calling host_->on_state with DEREGISTERED
1970-00-01 03:25:22.227335 [info] routing_manager_proxy::on_disconnect: Client 0xffff calling host_->on_state with DEREGISTERED
1970-00-01 03:25:22.229346 [info] routing_manager_proxy::on_disconnect: Client 0xffff calling host_->on_state with DEREGISTERED
1970-00-01 03:25:23.233358 [info] routing_manager_proxy::on_disconnect: Client 0xffff calling host_->on_state with DEREGISTERED
1970-00-01 03:25:24.241375 [info] routing_manager_proxy::on_disconnect: Client 0xffff calling host_->on_state with DEREGISTERED
1970-00-01 03:25:25.257385 [info] routing_manager_proxy::on_disconnect: Client 0xffff calling host_->on_state with DEREGISTERED
1970-00-01 03:25:27.273403 [info] routing_manager_proxy::on_disconnect: Client 0xffff calling host_->on_state with DEREGISTERED

困扰了好久~~~~~~~~ 

2. vsomeip 2.10.21版本  

export COMMONAPI_CONFIG=/etc/commonapi.ini
export LD_LIBRARY_PATH=/sdcard/someip:$LD_LIBRARY_PATH
export PATH=/sdcard/someip:$PATH
export VSOMEIP_CONFIGURATION=/etc/vsomeip-service.json
export VSOMEIP_APPLICATION_NAME=hello_world_service

2.1 192.168.1.1网段

export VSOMEIP_APPLICATION_NAME=hello_world_service

# ./hello_world_service
1970-01-01 01:42:17.065471 [info] Parsed vsomeip configuration in 15ms
1970-01-01 01:42:17.067471 [info] Using configuration file: "/etc/vsomeip-service.json".
1970-01-01 01:42:17.068471 [info] Default configuration module loaded.
1970-01-01 01:42:17.068471 [info] Initializing vsomeip application "hello_world_service".
1970-01-01 01:42:17.069471 [warning] Routing Manager seems to be inactive. Taking over...
1970-01-01 01:42:17.073471 [info] SOME/IP client identifier configured. Using 100b (was: 1000)
1970-01-01 01:42:17.074471 [info] Instantiating routing manager [Host].
1970-01-01 01:42:17.075471 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 01:42:17.079471 [error] Server endpoint creation failed (3)
1970-01-01 01:42:17.079471 [error] routing_manager_stub::init_routing_endpoint Client ID: 0 Path: /tmp/vsomeip-0 Reason: acceptor bind: Permission denied
1970-01-01 01:42:17.079471 [info] Client [100b] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 01:42:17.079471 [info] Service Discovery enabled. Trying to load module.
1970-01-01 01:42:17.087471 [info] Service Discovery module loaded.
1970-01-01 01:42:17.087471 [info] Application(hello_world_service, 100b) is initialized (11, 100).
Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)
1970-01-01 01:42:17.088471 [info] Starting vsomeip application "hello_world_service" using 2 threads
1970-01-01 01:42:17.088471 [info] main dispatch thread id from application: 100b (hello_world_service) is: 4
1970-01-01 01:42:17.088471 [info] shutdown thread id from application: 100b (hello_world_service) is: 5
1970-01-01 01:42:17.089471 [info] SOME/IP routing ready.
1970-01-01 01:42:17.089471 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 01:42:17.091471 [error] Server endpoint creation failed (3)
1970-01-01 01:42:17.091471 [error] routing_manager_stub::init_routing_endpoint Client ID: 0 Path: /tmp/vsomeip-0 Reason: acceptor bind: Permission denied
1970-01-01 01:42:17.091471 [info] Watchdog is disabled!
1970-01-01 01:42:17.091471 [info] io thread id from application: 100b (hello_world_service) is: 3
1970-01-01 01:42:17.091471 [info] io thread id from application: 100b (hello_world_service) is: 7
1970-01-01 01:42:17.091471 [info] vSomeIP 2.10.21 | (default)
1970-01-01 01:42:20.291480 [warning] Releasing client identifier 100a. Its corresponding application went offline while no routing manager was running.
1970-01-01 01:42:20.291480 [info] Application/Client 100a is deregistering.
1970-01-01 01:42:27.094179 [info] vSomeIP 2.10.21 | (default)
1970-01-01 01:42:37.095811 [info] vSomeIP 2.10.21 | (default)
Waiting for calls... (Abort with CTRL+C)
1970-01-01 01:42:47.097257 [info] vSomeIP 2.10.21 | (default)
1970-01-01 01:42:57.098566 [info] vSomeIP 2.10.21 | (default)

扫描二维码关注公众号,回复: 15360442 查看本文章

上述LOG可以看出,socket bind 权限问题。那么怎么处理?

QNX LOG:

Jan 01 04:28:02.308              io_service.577610              default  14814  io_service[sensors_manager.c:618]: [39]Sensor:PMIC_THERM:43929 mC


Jan 01 04:28:02.704                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_drv.c:214] io_write: pid=45101, tid=2, ufs_drv:persistent /pmic/client/ufs 2
Jan 01 04:28:02.704                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_utils.c:282] NPA_CLIENT_REQUIRED 0x23177a2924 2
Jan 01 04:28:02.705                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_utils.c:284] NPA_CLIENT_REQUIRED 0x23177a2924 DONE
Jan 01 04:28:02.822           devnp_emac_eth.45081                 emac*     2  emac_start: Link is not UP
Jan 01 04:28:02.825                  dumper.680003                 slog*     0  run fault pid 2977857 tid 1 signal 11 code 1 ip 0x155ccca794 ./hello_world_service
Jan 01 04:28:02.542           secpolgenerate.20487                 info*     0  io-pkt-v6-hc (pid:45081 type:io_pkt_v6_hc_t) failed to attach to path /tmp/vsomeip-0: no rule
Jan 01 04:28:02.564           secpolgenerate.20487                 info      0  io-pkt-v6-hc (pid:45081 type:io_pkt_v6_hc_t) failed to attach to path /tmp/vsomeip-1003: no rule
Jan 01 04:28:02.565           secpolgenerate.20487                 info      0  io-pkt-v6-hc (pid:45081 type:io_pkt_v6_hc_t) failed to attach to path /tmp/vsomeip-0: no rule
Jan 01 04:28:03.213              io_service.577610              default  14814  io_service[sensors_manager.c:618]: [40]Sensor:PMIC_THERM2:44190 mC


Jan 01 04:28:03.218               display.45084..0                   HI  10256  [20][wfdSetPipelineAttribiv:2111] DESTINATION_RECTANGLE (x=960 y=0 w=128 h=128), layer_id=8
Jan 01 04:28:03.311              io_service.577610              default  14814  io_service[sensors_manager.c:618]: [39]Sensor:PMIC_THERM:44321 mC


Jan 01 04:28:03.400                  dumper.680003                 slog      0  pid 2977857 core file created at /var/log/hello_world_service.core
Jan 01 04:28:04.071                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_drv.c:428] DCMD_NPA_ISSUE_REQUIRED_REQUEST client=0x2317732154, pid=32781, tid=1
Jan 01 04:28:04.135                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_drv.c:428] DCMD_NPA_ISSUE_REQUIRED_REQUEST client=0x2317732154, pid=32781, tid=7
Jan 01 04:28:04.216              io_service.577610              default  14814  io_service[sensors_manager.c:618]: [40]Sensor:PMIC_THERM2:44287 mC


Jan 01 04:28:04.265           devnp_emac_eth.45081                 emac      2  emac_start: Link is not UP
Jan 01 04:28:04.314              io_service.577610              default  14814  io_service[sensors_manager.c:618]: [39]Sensor:PMIC_THERM:44223 mC


Jan 01 04:28:04.826                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_drv.c:214] io_write: pid=45101, tid=2, ufs_drv:persistent /pmic/client/ufs 1
Jan 01 04:28:04.826                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_utils.c:282] NPA_CLIENT_REQUIRED 0x23177a2924 1
Jan 01 04:28:04.826                  npa_drv.32784  npa_hi_rate_logging  16103  qcore:[npa_utils.c:284] NPA_CLIENT_REQUIRED 0x23177a2924 DONE
Jan 01 04:28:05.218              io_service.577610              default  14814  io_service[sensors_manager.c:618]: [40]Sensor:PMIC_THERM2:44385 mC


Jan 01 04:28:05.252               display.45084..0                   HI  10256  [20][wfdSetPipelineAttribiv:2111] DESTINATION_RECTANGLE (x=896 y=0 w=128 h=128), layer_id=8
Jan 01 04:28:05.317              io_service.577610              default  14814  io_service[sensors_manager.c:618]: [39]Sensor:PMIC_THERM:44158 mC


Jan 01 04:28:05.392                 watchdog.32777              default  16024  watchdog[watchdog.c:427]: lowpriowd alive

通过io-pkt-v6-hc 对hello_world_service进行网络授权://192.168.1.1 

#io-pkt-v6-hc -ptcpip stacksize=8192,prefix=/alt
#SOCK=/alt /sdcard/someip/hello_world_service

1970-01-01 00:03:05.034710 [info] Parsed vsomeip configuration in 13ms
1970-01-01 00:03:05.036710 [info] Using configuration file: "/etc/vsomeip-service-ip.json".
1970-01-01 00:03:05.037710 [info] Default configuration module loaded.
1970-01-01 00:03:05.037710 [info] Initializing vsomeip application "hello_world_service".
1970-01-01 00:03:05.038710 [info] SOME/IP client identifier configured. Using 1001 (was: 1000)
1970-01-01 00:03:05.038710 [info] Instantiating routing manager [Host].
1970-01-01 00:03:05.039710 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 00:03:05.040710 [info] Listening at /tmp/vsomeip-0
1970-01-01 00:03:05.040710 [info] Client [1001] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 00:03:05.040710 [info] Service Discovery enabled. Trying to load module.
1970-01-01 00:03:05.049710 [info] Service Discovery module loaded.
1970-01-01 00:03:05.049710 [info] Application(hello_world_service, 1001) is initialized (11, 100).
1970-01-01 00:03:05.050710 [info] OFFER(1001): [3adc.65d4:1.0]
1970-01-01 00:03:05.050710 [info] Starting vsomeip application "hello_world_service" using 2 threads
1970-01-01 00:03:05.050710 [info] main dispatch thread id from application: 1001 (hello_world_service) is: 4
1970-01-01 00:03:05.051710 [info] shutdown thread id from application: 1001 (hello_world_service) is: 5
Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)
1970-01-01 00:03:05.067710 [error] Server endpoint creation failed (3)
1970-01-01 00:03:05.067710 [error] outbound interface option IPv4: Can't assign requested address
1970-01-01 00:03:05.067710 [error] Service Discovery endpoint could not be created. Please check your network configuration.
1970-01-01 00:03:05.067710 [error] Couldn't start service discovery
1970-01-01 00:03:05.068710 [error] Server endpoint creation failed (3)
1970-01-01 00:03:05.068710 [error] acceptor bind: Can't assign requested address
1970-01-01 00:03:05.069710 [error] Server endpoint creation failed (3)
1970-01-01 00:03:05.069710 [error] outbound interface option IPv4: Can't assign requested address
1970-01-01 00:03:05.069710 [info] SOME/IP routing ready.
1970-01-01 00:03:05.069710 [info] Watchdog is disabled!
1970-01-01 00:03:05.070710 [info] io thread id from application: 1001 (hello_world_service) is: 3
1970-01-01 00:03:05.070710 [info] vSomeIP 2.10.21 | (default)
1970-01-01 00:03:05.070710 [info] io thread id from application: 1001 (hello_world_service) is: 7

1). outbound interface option IPv4: Can't assign requested address  错误提示修改:

routing_manager_impl.cpp 中

#if defined(_WIN32) 
                if (its_unicast.is_v4()) {
                    its_unicast = boost::asio::ip::address_v4::any();
                } else if (its_unicast.is_v6()) {
                    its_unicast = boost::asio::ip::address_v6::any();
                }
#endif

该段代码在QNX运行存在问题,192.168.1.1 最后得到的its_unicast 为0.0.0.0

所以改为:

#if !defined(_WIN32) && !defined(__QNX__)
                if (its_unicast.is_v4()) {
                    its_unicast = boost::asio::ip::address_v4::any();
                } else if (its_unicast.is_v6()) {
                    its_unicast = boost::asio::ip::address_v6::any();
                }
#endif

修改后运行

Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)
1970-01-01 00:37:09.920177 [error] Server endpoint creation failed (3)
1970-01-01 00:37:09.920177 [error] bind: Can't assign requested address
1970-01-01 00:37:09.921177 [error] Service Discovery endpoint could not be created. Please check your network configuration.
1970-01-01 00:37:09.921177 [error] Couldn't start service discovery
1970-01-01 00:37:09.921177 [info] create_server_endpoint:  _port:30509 _reliable:false _start:true
1970-01-01 00:37:09.921177 [info] create_server_endpoint:  its_unicast:192.168.1.1
1970-01-01 00:37:09.921177 [info] create_server_endpoint:  new its_unicast:192.168.1.1
1970-01-01 00:37:09.921177 [info] enter -> server_endpoint_impl
1970-01-01 00:37:09.922177 [info] enter -> udp_server_endpoint_impl
1970-01-01 00:37:09.922177 [error] Server endpoint creation failed (3)
1970-01-01 00:37:09.923177 [error] bind: Can't assign requested address

bind 失败怎么处理?

测试指定网卡bind://emac0,lo0,vp0

添加code

	struct ifreq nif;
    std::string its_device = "emac0";
	strcpy(nif.ifr_name, its_device.c_str());
    if (its_device != "") {
        if (setsockopt(socket_.native_handle(),
                SOL_SOCKET, SO_BINDTODEVICE, (char *)&nif, (int)sizeof(nif)) == -1) {
            VSOMEIP_WARNING << "UDP Server: Could not bind to device \"" << its_device << "\"";
        }
    }
	std::string its_device2 = "lo0";
	strcpy(nif.ifr_name, its_device2.c_str());
    if (its_device2 != "") {
        if (setsockopt(socket_.native_handle(),
                SOL_SOCKET, SO_BINDTODEVICE, (char *)&nif, (int)sizeof(nif)) == -1) {
            VSOMEIP_WARNING << "UDP Server: Could not bind to device2 \"" << its_device2 << "\"";
        }
    }

	std::string its_device3 = "vp0";
	strcpy(nif.ifr_name, its_device3.c_str());
    if (its_device3 != "") {
        if (setsockopt(socket_.native_handle(),
                SOL_SOCKET, SO_BINDTODEVICE, (char *)&nif, (int)sizeof(nif)) == -1) {
            VSOMEIP_WARNING << "UDP Server: Could not bind to device3 \"" << its_device3 << "\"";
        }
    }

测试结果: lo0 本地127.0.0.1 可以bind

1970-01-01 03:01:05.374723 [warning] UDP Server: Could not bind to device "emac0"
1970-01-01 03:01:05.374723 [warning] UDP Server: Could not bind to device3 "vp0"
Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)
1970-01-01 03:01:05.395723 [error] Server endpoint creation failed (3)
1970-01-01 03:01:05.395723 [error] bind: Can't assign requested address

那么为什么emac0 以及 vp0网络不行?

查看netstat

# SOCK=/alt ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33136
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1

原来/alt 网络只有lo0,是这么个原因。

那么怎么添加emac0 以及 vp0网络呢?

答案

添加vp0网卡到 /alt

SOCK=/alt mount -T io-pkt -o peer=/dev/qvm/la/la_to_host,bind=/dev/vdevpeer/vp0,mac=aaaaaaaaaaaa,mode=0660 /lib/dll/devnp-vdevpeer-net.so

添加后,查看 SOCK=/alt网络信息

# SOCK=/alt ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33136
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
vp0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        capabilities rx=1f<IP4CSUM,TCP4CSUM,UDP4CSUM,TCP6CSUM,UDP6CSUM>
        capabilities tx=7e<TCP4CSUM,UDP4CSUM,TCP6CSUM,UDP6CSUM,TSO4,TSO6>
        enabled rx=1f<IP4CSUM,TCP4CSUM,UDP4CSUM,TCP6CSUM,UDP6CSUM>
        enabled tx=0
        address: aa:aa:aa:aa:aa:aa
        media: Ethernet autoselect
        status: active

修改VP0 IP地址,添加route 然后重新测试

# SOCK=/alt ifconfig vp0 192.168.1.1

# SOCK=/alt route -n add 224.244.224.245 192.168.1.255

# SOCK=/alt hello_world_service
1970-01-01 00:05:26.248831 [info] Parsed vsomeip configuration in 16ms
1970-01-01 00:05:26.249831 [info] Using configuration file: "/etc/vsomeip-service-ip.json".
1970-01-01 00:05:26.250831 [info] Default configuration module loaded.
1970-01-01 00:05:26.250831 [info] Initializing vsomeip application "hello_world_service".
1970-01-01 00:05:26.252831 [info] SOME/IP client identifier configured. Using 1003 (was: 1000)
1970-01-01 00:05:26.252831 [info] Instantiating routing manager [Host].
1970-01-01 00:05:26.252831 [info] enter -> routing_manager_stub
1970-01-01 00:05:26.253831 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 00:05:26.253831 [info] enter -> server_endpoint_impl
1970-01-01 00:05:26.253831 [info] local_server_endpoint_impl: path:/tmp/vsomeip-0
1970-01-01 00:05:26.254831 [info] Listening at /tmp/vsomeip-0
1970-01-01 00:05:26.254831 [info] Client [1003] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 00:05:26.254831 [info] Service Discovery enabled. Trying to load module.
1970-01-01 00:05:26.263831 [info] Service Discovery module loaded.
1970-01-01 00:05:26.263831 [info] Application(hello_world_service, 1003) is initialized (11, 100).
1970-01-01 00:05:26.264831 [info] OFFER(1003): [3adc.65d4:1.0]
1970-01-01 00:05:26.264831 [info] Starting vsomeip application "hello_world_service" using 2 threads
1970-01-01 00:05:26.264831 [info] main dispatch thread id from application: 1003 (hello_world_service) is: 4
1970-01-01 00:05:26.265831 [info] create_server_endpoint:  _port:30490 _reliable:false _start:true
1970-01-01 00:05:26.265831 [info] shutdown thread id from application: 1003 (hello_world_service) is: 5
1970-01-01 00:05:26.265831 [info] create_server_endpoint:  its_unicast:192.168.1.1
1970-01-01 00:05:26.265831 [info] enter -> server_endpoint_impl
1970-01-01 00:05:26.265831 [info] create_server_endpoint:  target its_unicast:192.168.1.1
1970-01-01 00:05:26.265831 [info] local_server_endpoint_impl: path:/tmp/vsomeip-1003
1970-01-01 00:05:26.265831 [info] enter -> server_endpoint_impl
1970-01-01 00:05:26.266831 [info] enter -> udp_server_endpoint_impl
1970-01-01 00:05:26.266831 [info] udp_server_endpoint_impl: address:192.168.1.1 port:30490
1970-01-01 00:05:26.267831 [info] udp_server_endpoint_impl: its_unicast_address:192.168.1.1
Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)
1970-01-01 00:05:26.267831 [info] address:192.168.1.1 _address:224.244.224.245  _address.to_v4():224.244.224.245
1970-01-01 00:05:26.268831 [info] create_server_endpoint:  _port:30509 _reliable:false _start:true
1970-01-01 00:05:26.268831 [info] create_server_endpoint:  its_unicast:192.168.1.1
1970-01-01 00:05:26.269831 [info] create_server_endpoint:  target its_unicast:192.168.1.1
1970-01-01 00:05:26.269831 [info] enter -> server_endpoint_impl
1970-01-01 00:05:26.269831 [info] enter -> udp_server_endpoint_impl
1970-01-01 00:05:26.269831 [info] udp_server_endpoint_impl: address:192.168.1.1 port:30509
1970-01-01 00:05:26.269831 [info] udp_server_endpoint_impl: its_unicast_address:192.168.1.1
1970-01-01 00:05:26.269831 [info] SOME/IP routing ready.
1970-01-01 00:05:26.269831 [info] Watchdog is disabled!
1970-01-01 00:05:26.270831 [info] io thread id from application: 1003 (hello_world_service) is: 3
1970-01-01 00:05:26.270831 [info] io thread id from application: 1003 (hello_world_service) is: 7
1970-01-01 00:05:26.270831 [info] vSomeIP 2.10.21 | (default)

如上LOG,运行OK!!!!! 

2.2 本地127.0.0.1网络

切换本地127.0.0.1网络,运行:

# route -n add 224.244.224.245 127.0.0.255
add host 224.244.224.245: gateway 127.0.0.255
#
#
#
# SOCK=/tmp/somip-tcp hello_world_service
1970-01-01 01:07:55.697700 [info] Parsed vsomeip configuration in 12ms
1970-01-01 01:07:55.698700 [info] Using configuration file: "/etc/vsomeip-service.json".
1970-01-01 01:07:55.699700 [info] Default configuration module loaded.
1970-01-01 01:07:55.699700 [info] Initializing vsomeip application "hello_world_service".
1970-01-01 01:07:55.700700 [info] SOME/IP client identifier configured. Using 1001 (was: 1000)
1970-01-01 01:07:55.700700 [info] Instantiating routing manager [Host].
1970-01-01 01:07:55.701700 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 01:07:55.703700 [info] Listening at /tmp/vsomeip-0
1970-01-01 01:07:55.703700 [info] Client [1001] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 01:07:55.703700 [info] Service Discovery enabled. Trying to load module.
1970-01-01 01:07:55.711700 [info] Service Discovery module loaded.
1970-01-01 01:07:55.711700 [info] Application(hello_world_service, 1001) is initialized (11, 100).
1970-01-01 01:07:55.711700 [info] Starting vsomeip application "hello_world_service" using 2 threads
1970-01-01 01:07:55.712700 [info] main dispatch thread id from application: 1001 (hello_world_service) is: 4
1970-01-01 01:07:55.712700 [info] OFFER(1001): [3adc.65d4:1.0]
1970-01-01 01:07:55.712700 [info] shutdown thread id from application: 1001 (hello_world_service) is: 5
1970-01-01 01:07:55.726700 [error] udp_server_endpoint_impl::join:set_option: Can't assign requested address
1970-01-01 01:07:55.726700 [info] SOME/IP routing ready.
1970-01-01 01:07:55.726700 [info] Watchdog is disabled!
1970-01-01 01:07:55.727700 [info] io thread id from application: 1001 (hello_world_service) is: 3
1970-01-01 01:07:55.727700 [info] io thread id from application: 1001 (hello_world_service) is: 7
1970-01-01 01:07:55.727700 [info] vSomeIP 2.10.21 | (default)
Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)

提示错误原因是没有设置route [SCCK route]

# SOCK=/alt netstat -r
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use    Mtu  Interface
127.0.0.1          127.0.0.1          UH          0        0  33136  lo0

Internet6:
Destination        Gateway            Flags    Refs      Use    Mtu  Interface
::1                ::1                UH          0        0  33136  lo0
fe80::%lo0/64      fe80::1%lo0        U           0        0      -  lo0
fe80::1%lo0        link#1             UHL         0        0      -  lo0
ff01:1::/32        ::1                UC          0        0  33136  lo0
ff02::%lo0/32      ::1                UC          0        0  33136  lo0

添加SOCK=/alt route支持

# SOCK=/alt route -n add 224.244.224.245 127.0.0.255
add host 224.244.224.245: gateway 127.0.0.255
#
#
# SOCK=/alt netstat -r
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use    Mtu  Interface
127.0.0.1          127.0.0.1          UH          0       48  33136  lo0
224.244.224.245    127.0.0.255        UGHS        0        0  33136  lo0

Internet6:
Destination        Gateway            Flags    Refs      Use    Mtu  Interface
::1                ::1                UH          0        0  33136  lo0
fe80::%lo0/64      fe80::1%lo0        U           0        0      -  lo0
fe80::1%lo0        link#1             UHL         0        0      -  lo0
ff01:1::/32        ::1                UC          0        0  33136  lo0
ff02::%lo0/32      ::1                UC          0        0  33136  lo0
#

 >>>>继续在127.0.0.1网段测试

LOG信息如下:

# SOCK=/alt hello_world_service
1970-01-01 01:01:55.710750 [info] Parsed vsomeip configuration in 9ms
1970-01-01 01:01:55.711750 [info] Using configuration file: "/etc/vsomeip-service.json".
1970-01-01 01:01:55.712750 [info] Default configuration module loaded.
1970-01-01 01:01:55.712750 [info] Initializing vsomeip application "hello_world_service".
1970-01-01 01:01:55.713750 [info] SOME/IP client identifier configured. Using 1001 (was: 1000)
1970-01-01 01:01:55.713750 [info] Instantiating routing manager [Host].
1970-01-01 01:01:55.713750 [info] enter -> routing_manager_stub
1970-01-01 01:01:55.713750 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 01:01:55.714750 [info] enter -> server_endpoint_impl
1970-01-01 01:01:55.714750 [info] local_server_endpoint_impl: path:/tmp/vsomeip-0
1970-01-01 01:01:55.715750 [info] Listening at /tmp/vsomeip-0
1970-01-01 01:01:55.715750 [info] Client [1001] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 01:01:55.715750 [info] Service Discovery enabled. Trying to load module.
1970-01-01 01:01:55.727750 [info] Service Discovery module loaded.
1970-01-01 01:01:55.727750 [info] Application(hello_world_service, 1001) is initialized (11, 100).
1970-01-01 01:01:55.728750 [info] Starting vsomeip application "hello_world_service" using 2 threads
1970-01-01 01:01:55.728750 [info] OFFER(1001): [3adc.65d4:1.0]
1970-01-01 01:01:55.728750 [info] main dispatch thread id from application: 1001 (hello_world_service) is: 4
1970-01-01 01:01:55.728750 [info] create_server_endpoint:  _port:30490 _reliable:false _start:true
1970-01-01 01:01:55.728750 [info] shutdown thread id from application: 1001 (hello_world_service) is: 5
1970-01-01 01:01:55.728750 [info] create_server_endpoint:  its_unicast:127.0.0.1
1970-01-01 01:01:55.729750 [info] create_server_endpoint:  target its_unicast:127.0.0.1
1970-01-01 01:01:55.729750 [info] enter -> server_endpoint_impl
1970-01-01 01:01:55.729750 [info] enter -> server_endpoint_impl
1970-01-01 01:01:55.729750 [info] enter -> udp_server_endpoint_impl
1970-01-01 01:01:55.729750 [info] local_server_endpoint_impl: path:/tmp/vsomeip-1001
1970-01-01 01:01:55.729750 [info] udp_server_endpoint_impl: address:127.0.0.1 port:30490
1970-01-01 01:01:55.730750 [info] udp_server_endpoint_impl: its_unicast_address:127.0.0.1
1970-01-01 01:01:55.730750 [info] address:127.0.0.1 _address:224.244.224.245  _address.to_v4():224.244.224.245
1970-01-01 01:01:55.730750 [info] create_server_endpoint:  _port:30509 _reliable:false _start:true
1970-01-01 01:01:55.730750 [info] create_server_endpoint:  its_unicast:127.0.0.1
Successfully Registered Service!
1970-01-01 01:01:55.731750 [info] create_server_endpoint:  target its_unicast:127.0.0.1Waiting for calls... (Abort with CTRL+C)

1970-01-01 01:01:55.731750 [info] enter -> server_endpoint_impl
1970-01-01 01:01:55.731750 [info] enter -> udp_server_endpoint_impl
1970-01-01 01:01:55.731750 [info] udp_server_endpoint_impl: address:127.0.0.1 port:30509
1970-01-01 01:01:55.731750 [info] udp_server_endpoint_impl: its_unicast_address:127.0.0.1
1970-01-01 01:01:55.731750 [info] SOME/IP routing ready.
1970-01-01 01:01:55.731750 [info] Watchdog is disabled!
1970-01-01 01:01:55.732750 [info] io thread id from application: 1001 (hello_world_service) is: 3
1970-01-01 01:01:55.732750 [info] io thread id from application: 1001 (hello_world_service) is: 7
1970-01-01 01:01:55.732750 [info] vSomeIP 2.10.21 | (default)

如上log可以看出,someip测试服务运行OK。

2.3  仅127.0.0.1网段

清除emac网卡

io-pkt-v6-hc -i1 -ptcpip

添加本地route

route -n add 224.244.224.245 127.0.0.255

修改vsomeip-service.json 配置 

运行QNX测试程序: 

# ./hello_world_service &
[1] 1077288
# 1970-01-01 00:06:53.924619 [info] Parsed vsomeip configuration in 14ms
1970-01-01 00:06:53.925619 [info] Using configuration file: "/etc/vsomeip-service.json".
1970-01-01 00:06:53.926619 [info] Default configuration module loaded.
1970-01-01 00:06:53.926619 [info] Initializing vsomeip application "hello_world_service".
1970-01-01 00:06:53.927619 [info] SOME/IP client identifier configured. Using 1001 (was: 1000)
1970-01-01 00:06:53.927619 [info] Instantiating routing manager [Host].
1970-01-01 00:06:53.928619 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 00:06:53.931619 [info] Listening at /tmp/vsomeip-0
1970-01-01 00:06:53.931619 [info] Client [1001] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 00:06:53.931619 [info] Service Discovery enabled. Trying to load module.
1970-01-01 00:06:53.942619 [info] Service Discovery module loaded.
1970-01-01 00:06:53.942619 [info] Application(hello_world_service, 1001) is initialized (11, 100).
1970-01-01 00:06:53.943619 [info] Starting vsomeip application "hello_world_service" using 2 threads
1970-01-01 00:06:53.943619 [info] main dispatch thread id from application: 1001 (hello_world_service) is: 4
1970-01-01 00:06:53.943619 [info] OFFER(1001): [3adc.65d4:1.0]
1970-01-01 00:06:53.943619 [info] shutdown thread id from application: 1001 (hello_world_service) is: 5
1970-01-01 00:06:53.944619 [info] SOME/IP routing ready.
1970-01-01 00:06:53.944619 [info] Watchdog is disabled!
1970-01-01 00:06:53.945619 [info] io thread id from application: 1001 (hello_world_service) is: 7
1970-01-01 00:06:53.945619 [info] io thread id from application: 1001 (hello_world_service) is: 3
1970-01-01 00:06:53.945619 [info] vSomeIP 2.10.21 | (default)
Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)

#
#
#
#
# 1970-01-01 00:07:03.947413 [info] vSomeIP 2.10.21 | (default)

#
#
# export VSOMEIP_APPLICATION_NAME=hello_world_client
#
#
# 1970-01-01 00:07:13.948714 [info] vSomeIP 2.10.21 | (default)
./hello_world_client
1970-01-01 00:07:16.782683 [info] Parsed vsomeip configuration in 11ms
1970-01-01 00:07:16.783683 [info] Using configuration file: "/etc/vsomeip-service.json".
1970-01-01 00:07:16.784683 [info] Default configuration module loaded.
1970-01-01 00:07:16.784683 [info] Initializing vsomeip application "hello_world_client".
1970-01-01 00:07:16.785683 [info] SOME/IP client identifier configured. Using 2000 (was: 2000)
1970-01-01 00:07:16.785683 [info] Instantiating routing manager [Proxy].
1970-01-01 00:07:16.785683 [info] Client [2000] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 00:07:16.787683 [info] Listening at /tmp/vsomeip-2000
1970-01-01 00:07:16.787683 [info] Application(hello_world_client, 2000) is initialized (11, 100).
1970-01-01 00:07:16.788683 [info] Starting vsomeip application "hello_world_client" using 2 threads
Checking availability!
1970-01-01 00:07:16.789683 [info] main dispatch thread id from application: 2000 (hello_world_client) is: 4
1970-01-01 00:07:16.789683 [info] shutdown thread id from application: 2000 (hello_world_client) is: 5
1970-01-01 00:07:16.789683 [info] io thread id from application: 2000 (hello_world_client) is: 3
1970-01-01 00:07:16.790683 [info] io thread id from application: 2000 (hello_world_client) is: 6
1970-01-01 00:07:16.790683 [info] Client 2000 successfully connected to routing  ~> registering..
1970-01-01 00:07:16.791683 [info] Application/Client 2000 is registering.
1970-01-01 00:07:16.791683 [info] Client [1001] is connecting to [2000] at /tmp/vsomeip-2000
1970-01-01 00:07:16.793683 [info] Application/Client 2000 is registered.
1970-01-01 00:07:16.794683 [info] REGISTERED_ACK(2000)
1970-01-01 00:07:16.799683 [info] REQUEST(2000): [3adc.65d4:1.4294967295]
1970-01-01 00:07:16.800683 [info] ON_AVAILABLE(2000): [3adc.65d4:1.0]
Available...
Enter number 1: Waiting for calls... (Abort with CTRL+C)

综上,未发现routing 错误,以及socket bind问题; 可以判断,上述2.1 someip 在QNX环境运行跟网络配置关系很大。

※错误信息及解决:

1970-01-01 00:14:11.374271 [error] udp_server_endpoint_impl::join:set_option: Can't assign requested address
※解决:添加route:  route -n add 224.244.224.245 127.0.0.255

                               SOCK=/alt route -n add 224.244.224.245 127.0.0.255

2.3 程序名称与配置文件名称匹配问题

2.10.21 版本,配置文件service 以及 route name 与实际运行的程序名称不一致时会出现与3.1.20类似的问题:routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED

export VSOMEIP_APPLICATION_NAME=HelloWorldSomeIPService

# ./HelloWorldSomeIPService
1970-01-01 01:15:59.927933 [info] Parsed vsomeip configuration in 14ms
1970-01-01 01:15:59.928933 [info] Using configuration file: "/etc/vsomeip-service.json".
1970-01-01 01:15:59.929933 [info] Default configuration module loaded.
1970-01-01 01:15:59.930933 [info] Initializing vsomeip application "HelloWorldSomeIPService".
1970-01-01 01:15:59.931933 [info] SOME/IP client identifier configured. Using 1007 (was: 0000)
1970-01-01 01:15:59.931933 [info] Instantiating routing manager [Proxy].
1970-01-01 01:15:59.931933 [info] Client [1007] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 01:15:59.937933 [error] Server endpoint creation failed (3)
1970-01-01 01:15:59.937933 [error] Client ID: 1007: acceptor bind: Permission denied
1970-01-01 01:15:59.937933 [info] Application(HelloWorldSomeIPService, 1007) is initialized (11, 100).
Successfully Registered Service!
1970-01-01 01:15:59.937933 [info] Starting vsomeip application "HelloWorldSomeIPService" using 2 threadsWaiting for calls... (Abort with CTRL+C)

1970-01-01 01:15:59.937933 [info] main dispatch thread id from application: 1007 (HelloWorldSomeIPService) is: 4
1970-01-01 01:15:59.937933 [info] shutdown thread id from application: 1007 (HelloWorldSomeIPService) is: 5
1970-01-01 01:15:59.940933 [error] Server endpoint creation failed (3)
1970-01-01 01:15:59.940933 [error] Client ID: 1007: acceptor bind: Permission denied
1970-01-01 01:15:59.940933 [info] io thread id from application: 1007 (HelloWorldSomeIPService) is: 6
1970-01-01 01:15:59.940933 [info] io thread id from application: 1007 (HelloWorldSomeIPService) is: 3
1970-01-01 01:15:59.941933 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:00.043602 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:00.245036 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:00.646979 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:01.447985 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:03.048993 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:04.650002 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:06.251906 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:07.853345 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:09.454760 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:11.055769 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:12.657247 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:14.258393 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED
1970-01-01 01:16:15.859996 [info] routing_manager_proxy::on_disconnect: Client 0x1007 calling host_->on_state with DEREGISTERED

 

3. vsomeip 2.5.2版本  

环境配置:

export COMMONAPI_CONFIG=/etc/commonapi.ini
export LD_LIBRARY_PATH=/sdcard/someip:$LD_LIBRARY_PATH
export PATH=/sdcard/someip:$PATH
export VSOMEIP_CONFIGURATION=/etc/vsomeip-service.json
export VSOMEIP_APPLICATION_NAME=hello_world_service

route add -net 224.0.0.0/4 default

3.1 本地local  127.0.0.1

vsomeip-service.json:

{
        "unicast" : "127.0.0.1",
        "logging" :
        {
                "level" : "debug",
                "console" : "true",
                "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
                "dlt" : "false"
        },
        "applications" :
        [
                {
                        "name" : "hello_world_service",
                        "id" : "0x1000"
                },

                {
                        "name" : "hello_world_client",
                        "id" : "0x2000"
                }
        ],
        "services" :
        [
                {
                        "service" : "15068",
                        "instance" : "26068",
                        "unreliable" : "30509"
                }
        ],
        "routing" : "hello_world_service",
        "service-discovery" :
        {
                "enable" : "true",
                "multicast" : "224.244.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"
        }
}

net授权运行server:

io-pkt-v6-hc -i1 -ptcpip prefix=/tmp/somip-tcp
SOCK=/tmp/somip-tcp hello_world_service

# SOCK=/tmp/somip-tcp /sdcard/someip/hello_world_service &
[1] 1470504
# 1970-01-01 00:47:05.235784 [info] Default configuration module loaded.
1970-01-01 00:47:05.236784 [info] Initializing vsomeip application "hello_world_service".
1970-01-01 00:47:05.237784 [info] SOME/IP client identifier configured. Using 1001 (was: 1000)
1970-01-01 00:47:05.237784 [info] Instantiating routing manager [Host].
1970-01-01 00:47:05.237784 [info] init_routing_endpoint Routing endpoint at /tmp/vsomeip-0
1970-01-01 00:47:05.238784 [info] Client [1001] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 00:47:05.239784 [info] enter -> local_client_endpoint_impl
1970-01-01 00:47:05.239784 [info] Service Discovery enabled. Trying to load module.
1970-01-01 00:47:05.243784 [info] Service Discovery module loaded.
1970-01-01 00:47:05.243784 [info] Application(hello_world_service, 1001) is initialized (11, 100).
1970-01-01 00:47:05.244784 [info] OFFER(1001): [3adc.65d4:1.0]
1970-01-01 00:47:05.244784 [info] Starting vsomeip application "hello_world_service" using 2 threads
1970-01-01 00:47:05.244784 [info] enter -> udp_server_endpoint_impl
Successfully Registered Service!
Waiting for calls... (Abort with CTRL+C)
1970-01-01 00:47:05.253784 [error] set_option: Can't assign requested address
1970-01-01 00:47:05.254784 [info] enter -> udp_server_endpoint_impl
1970-01-01 00:47:05.254784 [info] Watchdog is disabled!
1970-01-01 00:47:05.254784 [info] vSomeIP 2.5.2

第一次 udp_server_endpoint_impl set_option 错误,第二次udp_server_endpoint_impl 未有异常。

运行client:

export VSOMEIP_APPLICATION_NAME=hello_world_client

 
# export VSOMEIP_APPLICATION_NAME=hello_world_client
#
# SOCK=/tmp/somip-tcp /sdcard/someip/hello_world_client
1970-01-01 00:49:04.101359 [info] Default configuration module loaded.
1970-01-01 00:49:04.101359 [info] Initializing vsomeip application "hello_world_client".
1970-01-01 00:49:04.102359 [info] SOME/IP client identifier configured. Using 2000 (was: 2000)
1970-01-01 00:49:04.102359 [info] Instantiating routing manager [Proxy].
1970-01-01 00:49:04.102359 [info] Client [2000] is connecting to [0] at /tmp/vsomeip-0
1970-01-01 00:49:04.102359 [info] enter -> local_client_endpoint_impl
1970-01-01 00:49:04.104359 [info] Listening at /tmp/vsomeip-2000
1970-01-01 00:49:04.104359 [info] Application(hello_world_client, 2000) is initialized (11, 100).
1970-01-01 00:49:04.105359 [info] Starting vsomeip application "hello_world_client" using 2 threads
Checking availability!
1970-01-01 00:49:04.106359 [info] Client 2000 successfully connected to routing  ~> registering..
1970-01-01 00:49:04.107359 [info] Application/Client 2000 is registering.
1970-01-01 00:49:04.107359 [info] Client [1001] is connecting to [2000] at /tmp/vsomeip-2000
1970-01-01 00:49:04.107359 [info] enter -> local_client_endpoint_impl
1970-01-01 00:49:04.108359 [info] Application/Client 2000 is registered.
1970-01-01 00:49:04.109359 [info] REGISTERED_ACK(2000)
1970-01-01 00:49:04.110359 [info] REQUEST(2000): [3adc.65d4:1.4294967295]
Available...
Enter number 1: Waiting for calls... (Abort with CTRL+C)
1970-01-01 00:49:05.271088 [info] vSomeIP 2.5.2
3
Enter number 2: 2
1970-01-01 00:49:08.211727 [info] Client [2000] is connecting to [1001] at /tmp/vsomeip-1001
1970-01-01 00:49:08.211727 [info] enter -> local_client_endpoint_impl
HelloWorldStubImpl: Service called by ID: 8192
Got average value: '2.5'
Enter number 1: 4
Enter number 2: 2
HelloWorldStubImpl: Service called by ID: 8192
Got average value: '3'

client 跟 service 通讯正常。接口调用OK

猜你喜欢

转载自blog.csdn.net/liaochaoyun/article/details/129801181