01-死磕QNX someip
Posted 村里小码农
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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版本
2.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)
上述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进行网络授权:
# io-pkt-v6-hc -i1 -ptcpip 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
2.2
清除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环境运行跟网络配置关系很大。
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版本
SomeIP 协议
SomeIP协议
1.什么是SomeIP
1.1 someip是一种协议
someip是什么协议?
- 宝马公司制定的,是车载以太网和SOA的驱动
- 主要提供车内娱乐信息交互的中间信息传递(例如智能座舱)
- 可以适配各种操作系统QNX Linux等
1.2 someip是一个中间件
- 是操作系统/硬件/和APP之间的服务软件
- 与APP之间使用标准的接口
1.3 协议层
基于TCP/IP的传输,以太网的方式
2.Some/IP的功能
2.1 序列化
- 将数据结果或者对象按照定义的规则转换成二进制的过程,便于在网络上传输
2.2 远程调用
- 基于网络传输方式实现节点间的方法调用
2.3 服务发现
- 特殊的服务:该服务,client 可以查找所需要的服务。server端可以告诉client 自己那些服务可以被使用
- client 端可以和server端动态建立连接
2.4 订阅/发布
- client 端可以想server 订阅相关topic 的数据。server也可以以cycle/event 的方式发布这些数据
3.服务接口
Method -方法
- Property/field - 字段属性
- Event-事件
3.1 Method
- client 向sever 请求报文
- server 响应报文【RR】==>Request/Response
- server 不需要回复响应报文【FF-Method】==> Fire/Forget(当请求为F&F通信的时候,请求的报文类型我REQUEST_NO_RETURN)
3.2 Event
- client 订阅一个服务,server发布服务
- status: on change/cycle
- status value: on change/cycle/事件值变化超过设置范围
3.3 filed -属性/状态
- set/get
- cilent request 获取/设置 某个属性或状态
- notify
- cilent subscribe 某个属性/状态后,server就发布该服务
- 发布条件同Event,有一点不同得是订阅后server会立即发送此field的内容
4.SomeIP报文格式
SomeIP报文一般是由Header 和Payload组成
- Header 部分
- Message ID: 报文的标识符:4个字节的长度,SomeIP有唯一的ID(类似于CAN ID),当定义为Method的时候,Method Id的最高位为0,当定义为Event的时候,Method ID的最高位为0,不同的Method 和Event也有唯一的Method ID和Event ID,对于远程调用RPC的时候(例如从一个ECU到另一个ECU之间的消息传递),指定的sevice 和对应的调用方法.
- 例如,某个ecu需要和Tbox之间的数据交互,获取Tbox上的WAN信息,就需要指定service id 为Tbox对应的service id,method ID 为其中定义获取WAN相关信息的ID
- Length: 4个字节,这里的length 是指的Length字段之后的长度
- Request ID:请求ID
- 区分每一条请求
- Server 端会将这部分copy到response报文中
- client ID: 2个字节,区分请求同一个sevice的不同客户端
- session ID: 2个字节,同一个客户端请求同一个service的次数
- protocol Version:Some/ip的协议版本,1个字节
- Interface Version: service Interface 的主版本
- 用作检测服务的一致性,是否匹配(比如VSP 服务增加功能接口,对应更新了矩阵版本,之前client指定的版本可能就找不到对应的功能)
- Message Type :报文的类型(区分不同的消息类型),一个字节
- Return Code :请求是否被成功处理,1个字节
5.序列化
5.1 序列化和/反序列化
- 序列化:将对象的状态信息转换为可以存储或以二进制的信息在网络中传输
- 序列化根据传输的不同数据有不同的规则
- 基本数据类型的序列化
- 结构体的序列化
- 字符串的序列化(定长/变长)
- 数组的序列化(定长/变长)
- 基本数据的序列化
- 定义传输数据的字节序:例如 uint32 (0x A05C6D4F)
- 字符串类型的序列化
- 字符串由一系列的Unicode字符构成,并且以"\\0" (0x00)结束
- 数组类型的序列化
- 数组是相同类型的集合
- 根据数组的元素的序列排列,并进行序列化
6.Some/IP SD(Service Discovery)
6.1概述
一种特殊的服务,实现服务寻找事件订阅功能
- 服务寻址
- FindService
- OfferService
- StopOffService
- 事件订阅
- subscrbe Eventgroup
- stopSubscribe Eventgroup
- Subscribe EventgroupAck
- Subscribe EventgroupNAck
6.2 SomeIP SD报文格式
- Flags:第一个字节是标志字段,最高三位从高到低依次为重启标志位,单播标志位,初始数据控制标志位,低五位保留
- Reboot Flag
- 重启时置1(或者上电的时候)
- 当sesson ID 完成从0~0xFFFF的一个循环之后,Reboot置0(sesson ID 或从0逐渐增加直到0xFFFF 后又循环)
- 重启检测
- Unicast Flag
- 是否支持单播接收(=1)
- Entry 阵列
- 服务发现是通过SD报文中的Entry阵列字段携带的不同类型Entry来实现的, Entry用来同步服务实例状态和处理事件组的发布和订阅。依据SD 报文中Entry的作用不同将SD的报文类型分为七种,其中Find报文、Offer报文和Stop Offer报文基于不同的机制周期发送,用于同步服务实例的状态;订阅事件组报文、停止订阅事件组报文、订阅ACK报文和订阅NACK报文用于处理事件组的发布和订阅。
- Option 阵列
SD 报文中的Entry通过引用option阵列中携带的其他附件信息,能够更灵活的配置
- entry 的附加信息
- IP 地址
- 传输层协议
- 端口号
- 类型
- EndPoint Option
- Multicast Option
- Configuration Option
- Load Balancing Option
6.3 SD 启动时序 -服务器和事件的处理阶段
- 关闭阶段(Down)
- 可用阶段(Available)
- 初始等待阶段(init wait phase)
- 重复阶段(Repetition phase)
- 主阶段
以上是关于01-死磕QNX someip的主要内容,如果未能解决你的问题,请参考以下文章
[QNX Hypervisor 2.2用户手册]6.2 网络
[QNX Hypervisor 2.2用户手册]10.14 smmu