Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

Skeleton Instantiation

C++skeleton.cpp
// Skeleton constructor takes an InstanceIdentifier
// and registers the service with Communication Management
TemperatureServiceSkeleton skel(
    ara::core::InstanceSpecifier{
        "SensorApp/TemperatureServiceInterface/Instance0"});

// OfferService() triggers SOME/IP-SD Offer; returns immediately
skel.OfferService();

// StopOfferService() sends SD StopOffer and unregisters
// Called automatically by destructor if not called explicitly
skel.StopOfferService();

💡 Skeleton Destructor

The AUTOSAR AP spec requires that StopOfferService() is called before the skeleton is destroyed. Most implementations call it automatically in the destructor as a safety net, but relying on this in production code is bad practice — always call it explicitly before ara::core::Deinitialize().

Proxy Construction

C++proxy.cpp
// Option A: Synchronous — blocks until service is found or timeout
auto handles = TemperatureServiceProxy::FindService(
    ara::core::InstanceSpecifier{
        "ConsumerApp/TemperatureServiceInterface/Instance0"});
if (!handles.empty()) {
    auto proxy = TemperatureServiceProxy{handles[0]};
}

// Option B: Asynchronous — returns immediately, callback on discovery
auto findHandle = TemperatureServiceProxy::StartFindService(
    [](ara::com::ServiceHandleContainer<
           TemperatureServiceProxy::HandleType> handles,
       ara::com::FindServiceHandle) {
        if (!handles.empty()) {
            g_proxy = std::make_unique<TemperatureServiceProxy>(handles[0]);
        }
    },
    ara::core::InstanceSpecifier{...});

// Stop discovery when no longer needed
TemperatureServiceProxy::StopFindService(findHandle);

ara::com::SamplePtr<T>

SamplePtr<T> is a smart pointer to event sample data in the ara::com receive cache. The CM pre-allocates a ring buffer of maxSampleCount slots. Each call to GetNewSamples(callback, N) invokes the callback for up to N samples, passing a SamplePtr<T>.

C++sample_ptr.cpp
proxy.Temperature.Subscribe(10); // cache 10 samples max

proxy.Temperature.GetNewSamples(
    [](ara::com::SamplePtr<float> sample) {
        float val = *sample;   // dereference
        Process(val);
        // SamplePtr released here — slot returned to cache
    }, 10);

⚠️ SamplePtr Lifetime

Do NOT store a SamplePtr beyond the callback invocation. The underlying buffer slot is returned to the ring buffer when the SamplePtr is destroyed. Storing it in a global and reading it later causes a data race with the CM overwriting the slot.

Method Call Future

C++method_call.cpp
// Async method call — returns Future immediately
ara::core::Future<CalibrateOutput> fut =
    proxy.Calibrate(0.5f /* offset */);

// Option A: blocking get (avoid on dispatcher thread)
auto result = fut.get();

// Option B: continuation (runs on dispatcher thread pool)
std::move(fut).then(
    [](ara::core::Future<CalibrateOutput> f) {
        auto res = f.GetResult();
        if (res.HasValue()) {
            ApplyCalibration(res.Value());
        }
    });

💡 Fire-and-Forget Methods

Methods declared as fire-and-forget in the ARXML (<FIRE-AND-FORGET>true</FIRE-AND-FORGET>) return void immediately. There is no Future, no return value, and no error indication. Use only for non-critical notifications where loss is acceptable.

Summary

The Proxy/Skeleton pattern decouples service providers from consumers entirely. Skeleton manages service lifetime; Proxy manages discovery and subscription. SamplePtr provides zero-copy receive; Future provides non-blocking method dispatch. These four concepts are the foundation of all ara::com usage.

🔬 Deep Dive — Core Concepts Expanded

This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.

Key principles to reinforce:

  • Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
  • Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
  • Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.

🏭 How This Topic Appears in Production Projects

  • Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
  • Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
  • Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.

⚠️ Common Mistakes and How to Avoid Them

  1. Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
  2. Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
  3. Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
  4. Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.

📊 Industry Note

Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.

← PreviousService Interface Definition (ARXML)Next →Events, Methods, and Fields