
Recall first from Service instance and Application manifests
- The Service Instance Manifest configures how a particular service instance is offered or consumed through a communication binding.
- SOME/IP interface deployment assigns service and member IDs, while instance deployment identifies the deployed instance and connects it to the network configuration.
- TLS protects a configured connection, while SecOC authenticates configured messages and checks freshness.
How modes affect processes and services
4 min readThe manifests now describe a static system. This lesson answers how mode-dependent behavior is declared and why the generated proxy and skeleton code must never be edited.
A service provider may need to keep collecting measurements while it temporarily withdraws an interface. On Linux, executing a program and terminating a process are OS operations. Withdrawing a service offer is a middleware operation. That distinction matters when you read a mode requirement such as “disable telemetry in standby.” It could mean that the telemetry process should exit, that it should keep sampling and withdraw its service, or that a consumer should stop requesting data. Each interpretation produces a different result for the process and for its clients. See execve(2) and signal(7).
A an AUTOSAR model element that groups named mode declarations for a common operating concern defines the vocabulary for that concern. For example, a group named TelemetryModes can declare Standby, Active, and Service, and identify Standby as its initial mode. A use of that group can have one current mode at a time. Other groups can have their own current modes. Declaring Active supplies a name that other model elements can reference. Declaring it alone creates no process, starts no executable, and sends no network message.
In Adaptive AUTOSAR, a Function Group groups processes for lifecycle control. Its configured states give State Management and Execution Management a way to coordinate the lifecycle of those processes. TelemetryModes can supply the mode declarations used for the states of a telemetry Function Group. State Management determines the requested state, and Execution Management applies the process configuration for it. A process startup configuration associates a process and its startup settings with the state or states in which that configuration applies. To predict whether a process runs, follow that association rather than relying on the name of the state.
In a lesson example, configure Sampler to run in Standby, Active, and Service. Configure a separate Exporter to run only in Active, and let Exporter offer a telemetry service after it initializes. On a completed transition from Standby to Active, Sampler can continue with the same applicable startup configuration and Exporter starts. On a completed transition to Service, Exporter stops and its service becomes unavailable, while Sampler continues. The example assumes both processes are controlled by this Function Group and that the transitions succeed. A state that requires a provider to run still gives no guarantee that the provider has finished initialization or offered the service at the instant a client checks.
Another design puts sampling and service provision in the same process. Keep that process configured to run in all three states, arrange for its application logic to learn when export policy changes, and have it offer the service in Active and withdraw the offer when it leaves Active. A consumer that also stays running must handle availability changes and decide when to use the service again. If the requirement only concerns one consumer, that consumer can stop issuing requests while the provider continues to serve other consumers. The mode name alone supplies none of this communication policy. The execution configuration, application logic, and communication stack determine the observable behavior.
How ARXML becomes C++ and startup artifacts
3 min readA generator reads the ARXML files as a connected model. It resolves references across packages and files, then uses the resolved elements as inputs to its output rules. For a service method, that means following the interface member to its arguments and their types. A generator can then produce a client-side declaration and a matching provider-side declaration. The the generated client-side interface through which application code uses a service exposes the method to the consumer. The the generated provider-side interface that connects incoming service operations to the provider implementation supplies the corresponding implementation contract. The application developer writes the code that obtains the measurement and decides which value to return.
The logical service interface answers questions such as “What does ReadTemperature return?” For a SOME/IP deployment, the binding model answers “Which numeric method identifier does this binding use for ReadTemperature?” The deployment refers to the interface method. When you inspect generated code, follow that reference before comparing values. A method ID identifies an operation in its service context. A service ID identifies the service in the binding, and an instance ID identifies a deployed instance. A type reference identifies data used in the method signature. These are distinct model relationships. A production generator may put the method identifier in generated binding source, a descriptor, or configuration consumed by its runtime. A public proxy header might show only the C++ signature.
Startup generation uses different inputs. For example, a toolchain can translate a process definition and its execution configuration into launch data containing the executable, startup arguments, and applicable Function Group states. Execution Management uses the deployed configuration when it starts processes. Some toolchains also emit application startup source or a wrapper that initializes the vendor runtime, loads generated configuration, and hands control to handwritten application code. Other toolchains leave the application entry point to the developer and generate support code and configuration. The exact files and entry point depend on the toolchain. A service interface supplies too little information to decide where or when an application launches. On Linux, the launched program runs as compiled code. The AUTOSAR tooling and runtime interpret the model and its resulting configuration.
Keep a fix at the source of the problem. If the model says an argument has the wrong type, fix the model or its type mapping. If the model is correct and the emitted declaration is wrong, fix the generator or its configuration. If the provider calculates the wrong measurement, fix the handwritten implementation. Editing a generated header can appear to fix a compilation error on one machine. A clean generation then discards the edit, and other generated files or a separately built peer may still use the original declaration or binding. A mismatch can survive compilation when each side builds successfully against its own generated files. Regenerate the affected outputs together, rebuild the affected consumers and providers, and review the generated differences against the intended model change. Reading generated files is how you check what the tool did. Fixing their inputs is how you make the correction repeatable.
Trace a method through a stub generator
4 min readThe practice uses an XML fixture with AUTOSAR element names and a small Python generator. Save the following as temperature.arxml. This is a teaching subset for extraction, with a type reference resolved through an explicit table in the script. A production project supplies full type definitions and the surrounding deployment model, and validates them against the toolchain's supported schema. The numeric method ID here is a lab input.
<AUTOSAR xmlns="http://autosar.org/schema/r4.0">
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>Telemetry</SHORT-NAME>
<ELEMENTS>
<SERVICE-INTERFACE>
<SHORT-NAME>Temperature</SHORT-NAME>
<METHODS>
<CLIENT-SERVER-OPERATION>
<SHORT-NAME>ReadTemperature</SHORT-NAME>
<ARGUMENTS>
<ARGUMENT-DATA-PROTOTYPE>
<SHORT-NAME>Value</SHORT-NAME>
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/Types/TemperatureValue</TYPE-TREF>
<DIRECTION>OUT</DIRECTION>
</ARGUMENT-DATA-PROTOTYPE>
</ARGUMENTS>
</CLIENT-SERVER-OPERATION>
</METHODS>
</SERVICE-INTERFACE>
<SOMEIP-SERVICE-INTERFACE-DEPLOYMENT>
<SHORT-NAME>TemperatureDeployment</SHORT-NAME>
<SERVICE-INTERFACE-REF DEST="SERVICE-INTERFACE">/Telemetry/Temperature</SERVICE-INTERFACE-REF>
<METHOD-DEPLOYMENTS>
<SOMEIP-METHOD-DEPLOYMENT>
<SHORT-NAME>ReadTemperatureDeployment</SHORT-NAME>
<METHOD-REF DEST="CLIENT-SERVER-OPERATION">/Telemetry/Temperature/ReadTemperature</METHOD-REF>
<METHOD-ID>1</METHOD-ID>
</SOMEIP-METHOD-DEPLOYMENT>
</METHOD-DEPLOYMENTS>
</SOMEIP-SERVICE-INTERFACE-DEPLOYMENT>
</ELEMENTS>
</AR-PACKAGE>
</AR-PACKAGES>
</AUTOSAR>
Save the generator as generate.py. It accepts the structure shown above, follows the deployment references by checking their full paths, and supports one method with one output argument. The table deliberately contains two implementation-type references so you can change a type in the model and regenerate. Here the output argument becomes the return type of a synchronous C++ declaration. The skeleton declares a pure virtual method for the provider to implement. The proxy supplies a declaration for inspection. A production proxy has a middleware implementation and follows the calling conventions of its API, which can include asynchronous results.
import sys
import xml.etree.ElementTree as ET
ns = {"": "http://autosar.org/schema/r4.0"}
root = ET.parse(sys.argv[1]).getroot()
def text(element, path):
return element.findtext(path, namespaces=ns)
package = root.find("AR-PACKAGES/AR-PACKAGE", ns)
service = package.find("ELEMENTS/SERVICE-INTERFACE", ns)
method = service.find("METHODS/CLIENT-SERVER-OPERATION", ns)
argument = method.find("ARGUMENTS/ARGUMENT-DATA-PROTOTYPE", ns)
binding = package.find("ELEMENTS/SOMEIP-SERVICE-INTERFACE-DEPLOYMENT", ns)
deployment = binding.find("METHOD-DEPLOYMENTS/SOMEIP-METHOD-DEPLOYMENT", ns)
service_name = text(service, "SHORT-NAME")
method_name = text(method, "SHORT-NAME")
service_path = f"/{text(package, 'SHORT-NAME')}/{service_name}"
if text(binding, "SERVICE-INTERFACE-REF") != service_path:
raise SystemExit("Service reference does not match")
if text(deployment, "METHOD-REF") != f"{service_path}/{method_name}":
raise SystemExit("Method reference does not match")
if text(argument, "DIRECTION") != "OUT":
raise SystemExit("Expected an OUT argument")
types = {
"/Types/TemperatureValue": "std::int16_t",
"/Types/WideTemperatureValue": "std::int32_t",
}
cpp_type = types[text(argument, "TYPE-TREF")]
method_id = int(text(deployment, "METHOD-ID"))
print("// Generated from the lesson fixture. Edit the inputs.")
print("#include <cstdint>\n")
print(f"inline constexpr std::uint16_t k{method_name}Id{{{method_id}}};")
print(f"struct {service_name}Proxy {{")
print(f" {cpp_type} {method_name}();")
print("};")
print(f"struct {service_name}Skeleton {{")
print(f" virtual ~{service_name}Skeleton() = default;")
print(f" virtual {cpp_type} {method_name}() = 0;")
print("};")
Generate a header and ask the compiler to check it as C++ (the generator output below is from a real run of the script; the generator output and the syntax check passed on Ubuntu 24.04 with GCC 13). Run the commands from the directory containing both inputs. The && causes the syntax check to run only if generation succeeds.
python3 generate.py temperature.arxml > temperature.hpp &&
g++ -std=c++17 -Wall -Wextra -x c++ -fsyntax-only temperature.hpp
The syntax check reads the declarations and verifies that they form valid C++. This exercise ends before linking, startup, and communication. The lab proxy has no method definition, so a call through it would need an implementation before it could link. The method ID constant beside the declarations makes the model mapping easy to inspect. It does not send a request or configure a binding. The header makes the same type appear on both sides because the generator reads the argument once and uses that resolved C++ type in both declarations.
When reviewing the header, find ReadTemperature in both classes and trace the signatures back to the output argument's TYPE-TREF. Then trace kReadTemperatureId back to METHOD-ID and check that the deployment's METHOD-REF names the exact method. Those checks answer different questions. Changing the deployment ID should change the constant. Changing the declared type reference to the wider type should change both signatures. A compiler check can catch malformed C++ after either change. Comparing the header with the model can catch a well-formed declaration that represents the wrong type or ID.
Keep that distinction when reviewing generated startup artifacts too. A launch configuration can be well formed and still select the wrong Function Group state. A service stub can compile and still carry an identifier from the wrong deployment. Trace each generated value to the model element that owns it, and use the resulting behavior to check whether the model expresses the intended design.
The next lesson, ARXML authoring and deployment decisions, asks where to record those choices so that the interface, process configuration, and deployment can be reviewed together.
Key takeaways
- A mode declaration group defines named choices, while configuration or application code gives those choices runtime effects.
- A running provider and an offered service are separate conditions.
- The service interface supplies the logical signature, while binding deployment supplies the numeric method identifier.
- Corrections belong in the model, generator, or handwritten implementation so they survive regeneration.
Reflect
- Explain to a colleague, in two sentences: distinguish a mode declaration group from a process startup configuration.
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Man pageexecve(2): execute a program
- Man pagesignal(7): overview of signals
- SpecificationAUTOSAR AP R24-11: Specification of Manifest
Official documentation first. Links checked when the lesson was published.