AP_autosar_com_note

SOMP/IP(Scalable service-oriented middleware over IP)

Definition
  • SOME/IP provide service oriented comunication over network.
  • It is based on service definitions that functionaities that the service provides.
  • A service can consist of combinations of zero or multiple methods, events, and fields.
  • Events provide data that are sent cyclically or on change from the provider to the subscriber.
  • Methods provide the possibility to the subscriber to issue remote procedure calls which are executed on provider side
  • Fields are combinations of one or more of the following three
    • a notifier which sends data on change from the provider to the subscriber.
    • a getter which can be called by the subscriber to explicitly query the provider for a value
    • a setter which can be called by subscriber when it wants to change the value on provider side
SOME/IP header format
  block-beta
  columns 4
  a1("Message ID(service ID/method ID) [32 bits]"):4  
  a2("Length [32 bits]"):4  
  a3("Request ID(client ID/session ID) [32 bits]"):4 
  a4("Protocol version [8 bits]") a5("Interface version [8 bits]") a6("Message type [8 bits]") a7("Return code [8 bits]")
  a8("E2E header [variable size/depentent on selected E2E profiles]"):4
  a9("Payload [variable size]"):4
  classDef E2E_STYTE fill:#FFEC9E;
  class a8 E2E_STYTE
  • Header: 采用网络字节序(大端)
  • Payload(E2E): 包含Event的数据元素,或者method参数
  • Service ID
    bit0bit1-15
    Service ID0 [1 bit]Method ID[last 15 bits]
    Service ID1 [1 bit]Event ID[last 15 bits]
  • Request ID: 请求报文和响应报文保持一致
    • client ID: 唯一标识客户端
    • session ID: 随每次调用增加[1, 0xffff]
  • Protocal version: SOME/IP 版本
  • Interface version: 服务接口主版本
  • Message Type
    valuedescription
    0x00REQUESTa request expect a response(even void)
    0x01REQUEST_NO_RETURNa fire&forget request
    0x02NOTIFICATIONa request notification/event callback without expecting no response
    0x80RESPONSEthe response message
    0x81ERRORthe response containing an error
    0x20TP_REQUESTa TP request expect a response(even void)
    0x21TP_REQUEST_NO_RETURNa TP fire&forget request
    0x22TP_NOTIFICATIONa TP request notification/event callback without expecting no response
    0xa0TP_RESPONSEthe TP response message
    0xa1TP_ERRORthe TP response containing an error
  • Return code
    • 针对response或者error报文有效
serialization

数据结构序列化: 将结构化的数据按照规则转换为字节流

  • 结构体序列化: 内存对齐

  • 带标签结构体序列化(=wireType + DataID): 每个数据配置DataID, 插入tag。对于基本类型(wireType4~7), 后面要加length Field

      block-beta
      columns 8
      a1("wire type")
      a2("data id(higher)")
      a3("data id(lower)"):2 
      a4("len(8/16/32 bits)"):2
      a5("member data"):2
      classDef WIRE_STYTE fill:#FFEC9E;
      class a1 WIRE_STYTE
      classDef DATA_STYTE fill:#3ABEF9;
      class a2 DATA_STYTE
      class a3 DATA_STYTE
      classDef LENTH_STYLE fill:#FFDB00;
      class a4 LENTH_STYLE
    
    wireTypefollowing data
    08 bit data base data type
    116 bit data base data type
    232 bit data base data type
    364 bit data base data type
    4complex data type: array, struct, string, union with length field of static size(configured in data definition)
    5complex data type: array, struct, string, union with length field size 1 byte(ignore static definition)
    6complex data type: array, struct, string, union with length field size 2 byte(ignore static definition)
    7complex data type: array, struct, string, union with length field size 4 byte(ignore static definition)
  • 字符串序列化: 以ByteOrderMask起始, '\0’终止,变长要加length field

  • 数组序列化: 变长要加length field

  • 联合体序列化: length filed要考虑padding

protocal
  • 支持UDP(单播/多播), TCP
    • 一个传输层PDU中可能包含多个SOME/IP报文(UDP packet, TCP segment)
    • 同一个服务的不同服务实例需要不同的端口
    • 较长的UDP传输报文使用SOME/IP-TP协议,分段SessionID相同,messageType(0x20)带TP-Flag(1),offset(base 16)为已发送字节数, more flag标识是否有更多报文
      • 基于UDP的SOME/IP报文payload不能超过1400字节
      • 分段不能超过1392字节
      block-beta
      columns 8
      a1("Message ID(service ID/method ID) \n [32 bits]"):8  
      a2("Length [32 bits]"):8  
      a3("Request ID(client ID/session ID) [32 bits]"):8 
      a4("Protocol version [8 bits]"):2 a5("Interface version [8 bits]"):2 a6("Message type [8 bits]"):2 a7("Return code [8 bits]"):2
      a8("offset [28 bits]"):7 a9("reserve [3 bits] \n More-flag [1 bits]")
      a10("payload"):8
      classDef E2E_STYTE fill:#FFEC9E;
      class a6 E2E_STYTE
      class a8 E2E_STYTE
      class a9 E2E_STYTE
    
  • Method
    • request/response通信
      • 请求报文: 序列化in, inout参数,报文类型REQUEST
      • 响应报文: 序列化output, inout参数,报文类型为RESPONSE或者ERROR
    • fire&forget通信(无响应请求)
  • Notification Event
    • 通过SOME/IP-SD机制实现,服务端序列化event,周期或者变更时发送
  • field:状态值
    • setter, getter: request/response
    • notify: Notification event
  • 错误处理
    • Error Message
      • 联合体或者字符串说明错误信息
    • Return Code
      IDNameDescription
      0x00E_OKno error occurred
      0x01E_NOT_OKan unspecified error occurred
      0x02E_UNKNOWN_SERVICEthe request service ID is unkonwn
      0x03E_UNKNOWN_METHODthe request method ID is unknown, service ID is known
      0x04E_NOT_READYservice ID and method ID is known, application is not running
      0x05E_NOT_READCHABLEsystem running the service is not reachable(internal code error only)
      0x06E_TIMEOUTa timeout occurred(internal code error only)
      0x07E_WRONG_PROTOCAL_VERSIONversion of SOME/IP not supported
      0x08E_WRONG_INTERFACE_VERSIONinterface version mismatch
      0x09E_MALFORMED_MESSAGEdeserialization is not corrced so payload can’t be serialized
      0x0aE_WRONG_MESSAGE_TYPEan unexcepted message type was received
      0x0bE_E2E_REPEATEDRepeated E2E calculation error
      0x0cE_E2E_WRONG_SEQUENCEwrong E2E sequence error
      0x0dE_E2Enot further specified E2E error
      0x0eE_E2E_NOT_AVALIABLEE2E not supported
      0x0fE_E2E_NO_NEW_DATAno new data for E2E calculation present.
      0x10-0x1fRESERVEDreserved for generic SOME/IP errors. These errors will be specified in future versions of this document
      0x20-0x5eRESERVEDreserved for sepcific errors of services and methods, these error are specified by the interface specification
module features-SOME/IP-SD
  • SOME/IP-SD用于定位服务实例,检测服务是否在运行,实现发现订阅
  • UDP发送
  • 报文格式:
    • Header:
      • Client ID:0
      • Session ID:每发出一帧加1
        block-beta
        columns 4
        a1("Message ID(service ID/method ID) [32 bits]"):4  
        a2("Length [32 bits]"):4  
        a3("Request ID(client ID/session ID) [32 bits]"):4 
        a4("Protocol version [8 bits]") a5("Interface version [8 bits]") a6("Message type [8 bits]") a7("Return code [8 bits]")
        a8("Flags [8 bits]"):1 a9("Reserved [24 bits]"):3
        a10("len of entries array [32 bits]"):4  
        a11("entries array [32 bits]"):4  
        a12("len of options array [32 bits]"):4  
        a13("options array [32 bits]"):4  
        classDef SD1_STYTE fill:#FFD0D0;
        class a8 SD1_STYTE
        class a9 SD1_STYTE
        classDef SD2_STYTE fill:#F9F9E0;
        class a10 SD2_STYTE
        class a11 SD2_STYTE
        classDef SD3_STYTE fill:#3AA6B9;
        class a12 SD3_STYTE
        class a13 SD3_STYTE
      
    • Entry: 支持多组
      • service Entry:
        • Type:FindService(0x00), OfferService(0x01) and StopOfferService(0x01)
        • Service ID, Instance ID: 一个service有多个instance
          block-beta
          columns 8
          a1("Type [8 bits]"):2
          a2("Index 1st options [8 bits]"):2 
          a3("Index 1st options [8 bits]"):2 
          a4("# of opt 1 [4 bits]") a5("# of opt 2 [4 bits]") 
          a6("Service ID [16 bits]"):4 a7("Instance ID [16 bits]"):4
          a8("Major version [8 bits]"):2 a9("TTL [24 bits]"):6
          a10("Minor version [32 bits]"):8
        
      • Eventgroup Entry:
        • Type: Subscribe(0x06), StopSubscribeEventgroup(0x06), SubscribeAck(0x07) and SubscribeEventgroupNack(0x07)
          block-beta
          columns 8
          a1("Type [8 bits]"):2
          a2("Index 1st options [8 bits]"):2 
          a3("Index 1st options [8 bits]"):2 
          a4("# of opt 1 [4 bits]") a5("# of opt 2 [4 bits]") 
          a6("Service ID [16 bits]"):4 a7("Instance ID [16 bits]"):4
          a8("Major version [8 bits]"):2 a9("TTL [24 bits]"):6
          a10("reserved [8 bits]"):2 a11("init-flag [1 bits]"):1 a12("Counter [4 bits]"):1
          a13("Eventgroup ID [16 bits]"):4
        
    • option:
      • Configuration Option: 传输任意配置字符串键值对
          block-beta
          columns 4
          a1("len [16 bits]"):2  
          a2("Type(=0x01) [8 bits]") 
          a3("Reserved(=0x00) [8 bits]") 
          a4("Zero-terminated configuration string \n ([len]id = value [len]id = value[0])"):4
        
      • Loading Balancing Option: Service Instance = 0xFFFF时使用,根据权重选择优先级最高的服务
          block-beta
          columns 4
          a1("len (= 0x0005) [16 bits]"):2  
          a2("Type(=0x02) [8 bits]") 
          a3("Reserved(=0x00) [8 bits]") 
          a4("Priority [16 bits]"):2
          a5("Weigth [16 bits]"):2
        
      • IPv4 Endpoint Option: 在offer中代表事件源(发送方), subscribe Eventgroup中代表接收源(发送方)
          block-beta
          columns 4
          a1("len (= 0x0009) [16 bits]"):2  
          a2("Type(=0x04) [8 bits]") 
          a3("Reserved(=0x00) [8 bits]") 
          a4("ipv4 address [32 bits]"):4
          a5("reserved(=0x00) [8 bits]") 
          a6("L4-proto(UDP/TCP) [8 bits]") 
          a7("port num [16 bits]"):2
        
      • IPv4 Multicast Option: Subscribe eventgroup ack代表多播目的地,仅支持UDP
          block-beta
          columns 4
          a1("len (= 0x0009) [16 bits]"):2  
          a2("Type(=0x14) [8 bits]") 
          a3("Reserved(=0x00) [8 bits]") 
          a4("ipv4 address [32 bits]"):4
          a5("reserved(=0x00) [8 bits]") 
          a6("L4-proto(UDP) [8 bits]") 
          a7("port num [16 bits]"):2
        
      EndpointMulticastConfigurationLoad Balancing
      FindService000-10-1
      OfferService1-200-10-1
      StopOfferService1-200-10-1
      Subcribe Eventgroup0-200-10-1
      StopSubscribe Eventgroup0-200-10-1
      Subscribe EventgroupAck00-10-10-1
      Subscribe EventgroupNack000-10-1
  • 通信过程
    • 启动阶段:
      • 初始等待阶段(inital wait phase):随机等待时间发送SD报文
        • wait for random-delay time in range(INITAL-DELAY-MIN, MAX)
        • send message(find service and offer service entries)
      • 重复阶段(repetition phase-REPETITIONS_BASE_DELAY = 100ms, REPETITIONS_MAX = 2):重复发送指定次数, 每次延时时间翻倍
        • wait 2^0 * 100ms
        • send message(find service and offer service entries)
        • wait 2^1 * 100ms
        • send message(find service and offer service entries)
      • 运行阶段(main phase-as long message is active and CYCLIC_OFFER_DELAY is defined):周期发送offer报文
        • wait CYCLIC_OFFER_DELAY
        • send message (offer service entries)
    • 服务应答:
      • 收到多播find报文后延迟发送offer报文
      • 收到多播offer报文后延迟发送subscribe报文
    • 下电: 发送stopOffer报文,删除注册表
  • 订阅发布机制(注册/注销)
client1 server client2 offerService() offerService() subscribeEventgroup() updateRegistration() subscribeEventgroupAck + Events() Events() subscribeEventgroup() updateRegistration() subscribeEventgroupAck + Events() Events() Events() Events() stopScribeEventgroup() updateRegistration Events() client1 server client2
  • 配置参数
    NameDescription
    INITAL_DELAY_MINminimum duration of delay randomly the transmission of a message
    INITAL_DELAY_MAXmaximum duration of delay randomly the transmission of a message
    REPETITIONS_BASE_DELAYduration of delay for repetition
    REPETITIIONS_NUMconfiguration for the maxinum number of repetitions
    REQUEST_RESPONSE_DELAYthe service discovery shall delay answers using this configuration item
    CYCLIC_OFFER_DELAYinterval for cyclic offers in the main phase
    SD_PORTis a UDP port for SD messagSe(30490 as default)
    SD_MULTICAST_IPaddress which shall be used by the SD multicast messages
    SUBSCRIBE_RETRY_MAXMax counts of retries for subscribe, as long as the Eventgrpup is requested(0 no retry, INF retry forever(as long as the Eventgroup is requested and no SubscribeEventgroupAck/Nack entry was received))
    SUBSCRIBE_RETRY_DELAYduration of delay to send consecutive subscribe entries, if a Eventgroup is requested and no SubscribeEventgroupAck/Nack entry was received
module features-Runtime
  • COM: SOC通信中间件
    • 使用抽象的API与传输协议层绑定(SOMP/IP,IPC)
  • SOME/IP:
    • demon负责SOME/IP通信和服务发现
    • APP通过IPC和daemon交互
  • IPC: 本地节点多播监听和发送消息
  • 版本控制: 大版本不兼容,小版本向下兼容
  • Runtime处理模式:
    • 线程驱动: 输入包到达后立即处理
    • 轮询: 调用Skeleton::ProcessNextMethodCall()处理
module features-SOME/IP
  • 通信
    • 使能(默认),daemon处理sockets并路由method, events 和服务发现
    • 禁用,daemon仅处理服务发现
  • 连接
    • 建立条件: proxy创建,或者收到服务
    • 保持条件: 进程运行时
    • 断开条件: skeleton或者proxy被销毁
  • 服务发现
    • deamon启动后被动监听
    • 进程启动后主动请求
  • event配置时间戳,E2E,过载保护
    • 发送方: 调用skeleton::send()时依据配置生成
    • 接收方: 调用ProxyEvent::update()/ProxyEvent::GetNewSamples()自动检查
  • SecOC: FV, 完整性,身份认证
### 回答1: my_autosar_project-master是指一个名为my_autosar_project的Autosar项目的主文件夹(也称为主分支),其托管在Github代码托管平台上。Autosar是一种面向电子控制单元(ECU)的开放式软件架构,用于高级驾驶辅助系统(ADAS)和自动驾驶(AV)系统。my_autosar_project是一个使用Autosar软件开发的项目,目的是创建一个可在汽车行业中使用的可靠软件。 据我所知,该项目具有良好的文档,可以通过Github页面查看和下载。在该页面上还可以找到包含项目所有代码和分类版本的README文件,以及一些有关如何使用代码、如何贡献代码和如何提出问题的说明。此外,该项目似乎已被开源社区广泛接受,并且有很多开发者已经为该项目做出了贡献。 总的来说,my_autosar_project-master是一个基于Autosar架构的开源项目,旨在为汽车行业提供一种可靠的软件解决方案。该项目有很好的文档,并且收到了广泛的开源社区支持,已经吸引了众多开发者的贡献。 ### 回答2: my_autosar_project-master是一个基于AUTOSARAutomotive Open System Architecture)标准的项目,旨在提高汽车系统软件的可靠性、可复用性和可维护性。该项目使用C编程语言实现,包含了许多AUTOSAR规范中的接口和功能。它可以帮助汽车制造商、供应商和开发人员在设计、开发和测试汽车电子控制系统时更好地遵循AUTOSAR标准,同时提高他们的工作效率。项目中还包含了一些示例代码和说明文档,可以帮助开发者更快地理解和使用该项目。该项目需要在AUTOSAR的开发环境中运行,例如Vector CANoe或dSPACE SystemDesk。总之,my_autosar_project-master是一个优秀的汽车软件开发项目,有助于提高汽车控制系统的质量和效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值