前言
SOME/IP协议越来越多的用于汽车电子行业中,关于协议详细完全的中文资料却没有,所以我将结合工作经验并对照英文原版协议做一系列的文章。基本分三大块:
1. SOME/IP协议讲解
2. SOME/IP-SD协议讲解
3. python/C++举例调试讲解
4.1.5 De-serialization of Data Structures
The de-serialization process need to inspect the payload (serialized byte stream) of
the received SOME/IP message. Thereby the de-serialization process need to identify
the elements within the received byte stream and compare the identified elements with
the configured data type(s) of the corresponding service interface (please note, the
data type is derived from the interface specification, which defines the exact position
of all data structures in a SOME/IP message). The possibility to identify elements in a
dedicated SOME/IP serialized byte stream depend on the interface specification and
the serialization properties. The serialization properties define among others:
• if structured data types are serialized with a length field in front
• if tag-length-value are used for encoding, which include data ids and the possibility specify optional data members
The de-serialization process of a SOME/IP messages need to consider the received
message length and deal with a message length which may be larger or less then expected according the interface specification. This is needed to support backward compatible communication, where ECUs of a heterogeneous in-vehicle network (re-used
ECUs and new developed ECUs) communicate via SOME/IP serialized byte streams.
The subsequential chapters describe the expected behavior of the de-serialization process.
4.1.5 数据结构的反序列化
SOME/IP(Scalable service-Oriented MiddlewarE over IP)消息的反序列化过程需要检查接收到的消息的有效载荷(序列化的字节流)。在此过程中,反序列化需要识别接收到的字节流中的元素,并将这些已识别的元素与相应服务接口配置的数据类型进行比较(请注意,数据类型是从接口规范中派生的,该规范定义了SOME/IP消息中所有数据结构的精确位置)。在专用的SOME/IP序列化字节流中识别元素的可能性取决于接口规范和序列化属性。
序列化属性定义了多种内容,其中包括:
结构化数据类型是否在前面有一个长度字段进行序列化。
是否使用标签-长度-值(TLV)进行编码,这包括数据标识符以及指定可选数据成员的可能性。
SOME/IP消息的反序列化过程需要考虑接收到的消息长度,并处理可能大于或小于接口规范所预期的消息长度。这是为了支持向后兼容的通信,在这种通信中,异构车载网络(包括重新使用的电子控制单元ECU和新开发的ECU)通过SOME/IP序列化的字节流进行通信。
后续的章节将描述反序列化过程的预期行为。这包括但不限于如何处理不同长度的消息、如何根据TLV编码解析数据、以及如何确保数据类型的正确匹配,以确保在异构车辆网络中实现可靠和兼容的通信。
总结:了解前面章节描述序列化的规则,则就可以反向解析出数据了。
4.1.5.1 Structured DataTypes (structs)
If more data then expected was received, then the de-serialization process should accept all received elements of the SOME/IP message payload which correspond to the
configured service interface data type and skip the unknown identified elements of the
de-serialized SOME/IP message payloa