前言
SOME/IP协议越来越多的用于汽车电子行业中,关于协议详细完全的中文资料却没有,所以我将结合工作经验并对照英文原版协议做一系列的文章。基本分三大块:
1. SOME/IP协议讲解
2. SOME/IP-SD协议讲解
3. python/C++举例调试讲解
4.2.2 Request/Response Communication
One of the most common communication patterns is the request/response pattern.
One communication partner (Client) sends a request message, which is answered by
another communication partner (Server).
最常用的通信模型 就是 请求/响应模型,client请求 server回复响应.
[PRS_SOMEIP_00920]发送请求包 按照下面的步骤 就没错
Upstream requirements: RS_SOMEIP_00007
For the SOME/IP request message the client has to do the following for payload and
header:
• Construct the payload
• Set the Message ID based on the method the client wants to call
• Set the Length field to 8 bytes (for the part of the SOME/IP header after the length
field) + length of the serialized payload
8个字节是header length字段 后面的长度
+
payload的长度
• Optionally set the Request ID to a unique number (shall be unique for client only)
• Set the Protocol Version according [PRS_SOMEIP_00052]
• Set the Interface Version according to the interface definition
• Set the Message Type to REQUEST (i.e. 0x00)
• Set the Return Code to 0x00
[PRS_SOMEIP_00921]
Upstream requirements: RS_SOMEIP_00028, RS_SOMEIP_00007
To construct the payload of a request message, all input or inout arguments of the
method shall be serialized according to the order of the arguments within the signature
of the method.
不管是请求还是响应的参数列表 ,在序列化payload的时必须要按照规范的参数顺序进行序列化。
[PRS_SOMEIP_00922]
Upstream requirements: RS_SOMEIP_00007
The server builds the header of the response based on the header of the client’s
request and does in addition:
• Construct the payload
• take over the Message ID from the corresponding request
• Set the length to the 8 Bytes + new payload size
8个字节是header length字段 后面的长度
+
payload的长度
• take over the Request ID from the corresponding request
• Set the Message Type to RESPONSE (i.e. 0x80) or ERROR (i.e. 0x81)
• set Return Code to a return code according to [PRS_SOMEIP_00191].
[PRS_S