Write a SOME/IP type definition

When defining Scalable service-Oriented MiddlewarE over IP (SOME/IP) mappings in VSIDL, you describe the wire format serialization and payload encoding of each SOME/IP message. Using the SomeIpType and SomeIpStruct definitions, you can model primitives, strings, arrays, and nested structs that match AUTOSAR ARXML (SOMEIP-TRANSFORMATION-PROPS) and SOME/IP stack payload encoding rules (including COVESA vsomeip).

This page focuses on how to write a SomeIpStruct type definition, which is used in type_definition blocks for event and method mappings.

SomeIpStruct message

A SomeIpStruct message represents a structured SOME/IP payload consisting of multiple fields. The structure defined here is used by the SOME/IP broker to translate between raw SOME/IP bytes and the fields of an SDV protobuf message.

When defining a struct, you configure two main properties:

  • length_field_size (optional): Specifies the size (in bytes) of the length field that precedes the struct in the serialized payload. Used values from the LengthFieldSize enum include ZERO (no length field), ONE, TWO, and FOUR.
  • field (repeated): A list of fields that make up the struct.

Define struct fields

Each field inside SomeIpStruct requires:

  • field_name: The name of the field. This must exactly match the corresponding field name defined in the SDV protobuf message to ensure proper message translation.
  • field_type: The SOME/IP data type of the field (SomeIpType). This can be a primitive, string, array, or another nested struct.

Write SomeIpType field types

The field_type block configures the specific data type using one of the following variants:

  • Primitive types: Use someip_primitive with values like UINT8, UINT32, INT32, FLOAT32, and BOOL.
  • Strings: Use someip_string and specify the encoding (for example, UTF_8 or UTF_16_LE) and length information (either fixed_length or length_field_size).
  • Arrays: Use someip_array and define array_type (which is another recursive SomeIpType), along with length information (fixed_length or length_field_size).
  • Nested structs: Use someip_struct to embed another struct definition recursively.

Example: Write a struct type definition

Here is a practical example of how to write a SomeIpStruct inside a type_definition block. This payload contains an 8-bit unsigned integer named interval and a 32-bit unsigned integer named counter:

type_definition {
  # No length field precedes this struct
  length_field_size: ZERO

  # First field: interval
  field {
    field_name: "interval"
    field_type {
      someip_primitive: UINT8
    }
  }

  # Second field: counter
  field {
    field_name: "counter"
    field_type {
      someip_primitive: UINT32
    }
  }
}

Add complex types

To include a dynamic-length string field and an array inside the struct, add fields like this:

field {
  field_name: "status_message"
  field_type {
    someip_string {
      string_encoding: UTF_8
      length_field_size: FOUR
    }
  }
}
field {
  field_name: "measurements"
  field_type {
    someip_array {
      length_field_size: FOUR
      array_type { someip_primitive: FLOAT32 }
    }
  }
}

Map AUTOSAR ARXML and vsomeip payload encoding

When integrating AAOS SDV with external AUTOSAR electronic control units (ECUs) or SOME/IP stacks such as COVESA vsomeip, ensure your VSIDL type_definition matches the wire serialization parameters defined in your system's ARXML (SOMEIP-TRANSFORMATION-PROPS and SOMEIP-DATA-PROTOTYPE-TRANSFORMATION-PROPS) or vsomeip configuration:

AUTOSAR ARXML and vsomeip Parameter VSIDL SomeIpType Equivalent Wire Serialization and Payload Encoding Rule
sizeOfStructLengthField (0, 1, 2, 4 bytes) SomeIpStruct.length_field_size (ZERO, ONE, TWO, FOUR) Prepends an explicit byte-length prefix before the serialized struct payload. Set to ZERO for fixed-layout structs without a length prefix.
sizeOfArrayLengthField (0, 1, 2, 4 bytes) SomeIpArray.length_field_size (ZERO, ONE, TWO, FOUR) or fixed_length Dynamic arrays require a length field prefix (ONE, TWO, or FOUR bytes) indicating the byte length of the serialized array elements.
sizeOfStringLengthField and Encoding (UTF-8, UTF-16LE, UTF-16BE) SomeIpString.string_encoding and length_field_size or fixed_length Matches AUTOSAR string serialization rules (including BOM and null-termination handling) for variable-length and fixed-length strings.
Primitive Base Types (uint8, uint16, uint32, float32, boolean) SomeIpPrimitive (UINT8, UINT16, UINT32, INT32, FLOAT32, BOOL) Encodes primitive values in network byte order (Big-Endian by default per SOME/IP specification) matching the target protobuf field.