SOME/IP--协议英文原文讲解7

打印 上一主题 下一主题

主题 866|帖子 866|积分 2598

前言
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 payload. If less data then expected was received,
then the de-serialization should accept all know elements of the SOME/IP message
payload which correspond to the configured service interface data type and fill the
missing elements of the configured service interface data type with an specified complementary default value (e.g. initial value).
4.1.5.1 布局化数据范例(布局体)
如果接收到的数据比预期的多,那么反序列化过程应该接受SOME/IP消息有效载荷中所有与设置的服务接口数据范例相对应的元素,并跳过反序列化后的SOME/IP消息有效载荷中未知的已识别元素。如果接收到的数据比预期的少,那么反序列化过程应该接受SOME/IP消息有效载荷中所有与设置的服务接口数据范例相对应的已知元素,并用指定的补充默认值(例如初始值)添补设置的服务接口数据范例中缺失的元素。
在处理这种情况时,告急的是要确保系统的稳固性和向后兼容性。当接收到比预期更多的数据时,跳过未知元素可以防止剖析错误或数据损坏,同时仍然能够使用可用的有效数据。当接收到比预期更少的数据时,使用默认值添补缺失的元素可以确保服务能够继续运行,尽管大概以某种受限或降级模式运行。
这种处理战略是计划用于在异构和不断演变的车辆网络中实现机动的通信。在如许的情况中,不同的电子控制单位(ECU)大概具有不同的软件版本和功能集,因此它们之间的通信大概会碰到数据不匹配的情况。通过采用上述战略,可以确保即使在这种情况下,系统也能够以尽大概高的可靠性和效率运行。
[PRS_SOMEIP_00371]
Upstream requirements: RS_SOMEIP_00033
If the length is greater than the length of the struct as specified in the data type definition only the bytes specified in the data type shall be interpreted and the other bytes shall be skipped based on the length field.
如果⻓度⼤于数据范例定义中指定的布局⻓度,则仅应解释数据范例中指定的字节,并根
据⻓度字段跳过其他字节
[PRS_SOMEIP_00900]
Upstream requirements: RS_SOMEIP_00033
If the length is less than the sum of the lengths of all struct members and no complementary 
default value for the missing data can be provided locally by the receiver, the
deserialization shall be aborted and the message shall be treated as malformed.
如果⻓度⼩于所有布局成员的⻓度之和,而且接收器⽆法在本地提供缺失数据的补充默认
值,则应中⽌反序列化并将消息视为格式错误
4.1.5.2 Structured Datatypes and Arguments with Identifier and optional members (’TLV’)
If the de-serialization process detect an unkown optional member according the configured
service interface data type, then the de-serialization process should ignore this
member. If the de-serialization process detect a missing member/argument, which is
required according the configured service interface data type and a complementary
default value (e.g. initial value) is available, then the de-serialization process should
use the complementary default value for this missing member/argument. Otherwise
the SOME/IP message is treated as malformed.
4.1.5.2 带有标识符和可选成员的布局化数据范例和参数(’TLV’)
在反序列化过程中,如果检测到根据设置的服务接口数据范例未知的可选成员,则反序列化过程应忽略该成员。如果反序列化过程检测到根据设置的服务接口数据范例必需的成员/参数缺失,但存在补充默认值(例如初始值),则反序列化过程应使用此补充默认值来添补缺失的成员/参数。否则,该SOME/IP消息将被视为格式错误。
[PRS_SOMEIP_00223]
Upstream requirements: RS_SOMEIP_00050
The deserializer shall ignore optional members/arguments which are not available in
the serialized byte stream.
反序列化器应忽略序列化字节省中不存在的可选成员/参数。

[PRS_SOMEIP_00217]
Upstream requirements: RS_SOMEIP_00050
If the deserializer reads an unknown Data ID (i.e. not contained in its data definition),
it shall skip the unknown member/argument by using the information of the wire type
and length field.
如果反序列化器读取到未知的数据标识符(即不在其数据定义中),则它应使用线型信息和长度字段来跳过未知的成员/参数。
[PRS_SOMEIP_00380] Behaviour if a required member/argument is missing in
the received SOME/IP message
Upstream requirements: RS_SOMEIP_00050
If the deserializer cannot find a required (i.e. non-optional) member/argument defined
in its data definition in the serialized byte stream and a complementary default value for
this missing member/argument is available, then the available complementary default
value shall be used for this missing member/argument. Ohterwise the deserialization
shall be aborted and the message shall be treated as malformed.
[PRS_SOMEIP_00380] 接收到的SOME/IP消息中缺少必需成员/参数时的行为
如果反序列化器在序列化字节省中找不到其数据定义中定义的必需(即非可选)成员/参数,而且为该缺失的成员/参数提供了补充默认值,则应使用此可用的补充默认值来添补该缺失的成员/参数。否则,应中止反序列化过程,并将消息视为格式错误。
这条需求强调了SOME/IP通信中数据完备性的告急性。在SOME/IP消息中,如果缺少了根据接口规范定义的必需成员/参数,这大概会影响到消息的正确剖析和后续处理。因此,系统需要有肯定的容错机制来处理这种情况。
当碰到缺少必需成员/参数的情况时,如果系统能够提供一个公道的默认值来添补这个缺失的部门,那么这可以确保系统的稳固运行,并减少因数据不完备而导致的通信失败。然而,如果没有可用的默认值,或者默认值不足以保证系统的正确运行,那么系统应该中止反序列化过程,并将该消息视为格式错误,以避免潜伏的题目。
这种处理战略有助于在异构的车辆网络中实现可靠的SOME/IP通信,并确保系统能够机动地顺应不同的数据设置和通信场景。
4.1.5.3 Strings
Strings could be configured with a fixed length or dynamic length. Independent a string has fixed length or dynamic length configured, a serialized string, which is received with a larger length than expected according the configured service interface data type, should be treated as malformed. For strings with fixed length and received with a length which is less than expected and this string is correctly terminated, the string should be processed. Otherwise the message shall be treated as malformed.
对于变长 定长 字符串:
接收的长度 大于 设置的长度(没看到竣事符)则视为 格式错误 
对于定长字串:
接收到小于设置的长度 可根据需要 处理 或是报错
4.1.5.3.1 Strings (fixed length)
[PRS_SOMEIP_00911]
Upstream requirements: RS_SOMEIP_00038
If the length of a string with fixed length is greater than expected (expectation shall
be based on the data type definition), the deserialization shall be aborted and the
message shall be treated as malformed.
定长字串 接收到比预期长的字串 则应停止反序列化 并报错
[PRS_SOMEIP_00912]
Upstream requirements: RS_SOMEIP_00038
If the length of a string with fixed length is less than expected (expectation shall be
based on the data type definition) and it is correctly terminated using "\0", it shall be
accepted.
定长字串 接收到比预期少的长度(但后面有竣事符) 可以接收
[PRS_SOMEIP_00913]
Upstream requirements: RS_SOMEIP_00038
If the length of a string with fixed length is less than expected (expectation shall be
based on the data type definition) and it is not correctly terminated using "\0", the
deserialization shall be aborted and the message shall be treated as malformed.
定长字串 收到比预期少的长度 而且后面竣事符用的不对 (比如utf-16需要两个竣事符 但是只收到1个)则应停止反序列化 并报错---认为时丢数据了 或者对方程序出错了     
Instead of transferring application strings as SOME/IP strings with BOM and "\0" termination,
strings can also be transported as plain dynamic length arrays without BOM
and "\0" termination (see chapter 4.1.4.5.2). Please note that this requires the full string
handling (e.g. endianness conversion) to be done in the applications.
可用用动态数组替换 string 到达不带BOM和竣事符的目的,但需要做字节次序转换
4.1.5.3.2 Strings (dynamic length)
[PRS_SOMEIP_00914]
Upstream requirements: RS_SOMEIP_00039
If the length of a string with variable length is greater than expected (expectation
shall be based on the data type definition), the deserialization shall be aborted and the
message shall be treated as malformed.
如果动态数组长度 长于 期待的(客户定义的最大长度)则应停止反序列化 并报错
规范中未定义的点:
有些客户也会定义动态string的最小长度,接收的长度小于这个 也应该停止反序列化 并报错
4.1.5.4 Arrays
Arrays could be configured with a fixed length or dynamic length. Independent if an
array has fixed length or dynamic length configured, if a serialized array was received
with a larger length than expected according the configured service interface data type,
then all known elements according the configured service interface data type should
be considered and the remaining elements should be skipped by the de-serialization
process.
For arrays with fixed length and the de-serialization process detect a missing element,
which is required according the configured service interface data type and a complementary default value (e.g. initial value) is available, then the de-serialization process
should use the complementary default value for this missing member/argument. Otherwise the SOME/IP message is treated as malformed.
定长、变长数组
如果收到长度 大于 预期的长度 则跳过 或 忽略这些多余的元素
什么情况?
1. 数组嵌套 外层指定了元素长度 内层也有长度 会有不一致的情况
2. SOME/IP header中的payload指示的定长数组长度 大于 客户规范中规定的定长长度
2. 客户会指定 动态长度的最大值
3. 客户 为了版本兼容 大概会设置开启定长前面的长度字段

对于具有固定长度的数组,如果反序列化过程检测到缺少元素(根据设置的服务接⼝数据
范例,该元素是必需的),而且有可⽤的补充默认值(例如初始值),则反序列化过程应
使⽤此缺失成员/参数的补充默认值。否则,SOME/IP 消息将被视为格式错误。
4.1.5.4.1 Arrays (fixed length)
[PRS_SOMEIP_00917]
Upstream requirements: RS_SOMEIP_00036
If the length of a fixed length array is greater than expected (expectation shall be
based on the data type definition) only the elements specified in the data type shall be
interpreted and the other bytes shall be skipped based on the length field.
[PRS_SOMEIP_00381] Behaviour if a required element is missing in the received
SOME/IP message
Upstream requirements: RS_SOMEIP_00036
dIf the length of a fixed length array is less than expected (expectation shall be based
on the data type definition) and a complementary default value (e.g. initial value) for the
missing data can be provided locally by the receiver, then the deserialization consider
this complementary default value as value for the missing data. Otherwise the deserialization process shall be aborted and the message shall be treated as malformed.c
Note: Overruns of fixed-size arrays can only be detected with a length field.
定长数组:
接收到过少的长度元素 如果没有默认值添补 则可停止剖析 并报错。
4.1.5.4.2 Arrays (dynamic length)
[PRS_SOMEIP_00919] Upstream requirements: RS_SOMEIP_00037
If the length of a variable length array is greater than expected (expectation shall be based on the data type definition) only the elements specified in the data type shall be interpreted and the other bytes shall be skipped based on the length field.
注意点和定长一样:跳过多余的
4.1.5.5 Enumeration
No further requirements considered for the deserialization.
4.1.5.6 Bitfield
No further requirements considered for the deserialization
上面俩 没啥特殊说的
4.1.5.7 Union / Variant
[PRS_SOMEIP_00915]
Upstream requirements: RS_SOMEIP_00034
If the length of a union is greater than expected (expectation shall be based on the
data type definition) only the bytes specified in the data type shall be interpreted and
the other bytes shall be skipped based on the length field.
团结体收到的 多余 客户自己定义的最大长度 则应该根据 团结体头中数据范例 指定的字节数 剖析需要的 ,,多余的跳过即可
[PRS_SOMEIP_00916]
Upstream requirements: RS_SOMEIP_00034
If the length of a union is less than expected (expectation shall be based on the
data type definition) it shall depend on the inner data type whether valid data can be
deserialized or the deserialization shall be aborted and the message shall be treated
as malformed.
团结体收到过少的情况,如果够头部中范例指定的数据范例长度(由于有大概多余的是添补)则直接用就行,否则停止剖析 并报错

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

飞不高

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表