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

SOME/IP Payload Deserialization to Classic Signal

CSOMEIP_to_Classic.c
/* Gateway BSW SWC: Adaptive → Classic signal bridge */

/* SOME/IP serialization rules (AUTOSAR AP SWS):
   - Integers: Big-endian unless configured otherwise
   - Structs: members packed in declaration order, no padding unless aligned
   - Strings: 4-byte length prefix + UTF-8 bytes */

typedef struct {
    uint32_t someip_header[2];   /* 8 bytes: MsgID, Length, RequestID, version */
    uint16_t audioVolume;         /* bytes 8-9: BE uint16 */
    uint8_t  volumeValid;         /* byte 10: validity flag */
    uint8_t  reserved;            /* byte 11: alignment */
} SomeIP_AudioEvent_t;

FUNC(void, GW_CODE) Gateway_SOMEIP_to_Classic_Runnable(void)
{
    SomeIP_AudioEvent_t event;

    /* 1. Read from IPC shared memory (Adaptive writes, Classic reads) */
    HwSemaphore_Acquire(HW_SEM_IPC_AUDIO);
    if (ipc_shared_mem.audio_event_new_flag) {
        memcpy(&event, &ipc_shared_mem.audio_event, sizeof(event));
        ipc_shared_mem.audio_event_new_flag = 0;
        HwSemaphore_Release(HW_SEM_IPC_AUDIO);

        /* 2. Deserialize: SOME/IP BE uint16 → Classic uint16 */
        uint16 volumeClassic = (uint16)(event.audioVolume); /* already BE on Cortex-R */

        /* 3. Write to Classic COM signal */
        if (event.volumeValid) {
            (void)Com_SendSignal(COM_SIG_AUDIO_VOLUME, &volumeClassic);
        } else {
            (void)Com_InvalidateSignal(COM_SIG_AUDIO_VOLUME);
        }
    } else {
        HwSemaphore_Release(HW_SEM_IPC_AUDIO);
    }
}

Gateway Application Role

ResponsibilityClassic SideAdaptive Side
SOME/IP serializationSerialize Classic struct to SOME/IP binary formatDeserialize SOME/IP events into C++ data structures
IPC shared memoryWrite (owns write access to IPC region)Read (polls or interrupt-driven read)
Signal validityCom_InvalidateSignal on E2E or timeoutSet kInvalid SamplePtr on E2E failure
Cycle time controlCOM TX period defines signal update rate to CANGetNewSamples() poll rate defines event consumption rate

Update Rate Mismatch: SOME/IP 20ms vs Classic COM 10ms

CLastIsBest_Gateway.c
/* SOME/IP event arrives at 20ms; Classic COM Tx fires at 10ms */
/* Gateway uses last-is-best: same value retransmitted every 10ms */
/* until next SOME/IP event updates it */

static uint16 lastAudioVolume = 0;
static boolean volumeValid = FALSE;

/* Called from 20ms SOME/IP event handler */
void Gateway_UpdateAudioVolume(uint16 newVolume, boolean valid)
{
    /* Spinlock protects against 10ms COM task reading simultaneously */
    GetSpinlock(SPINLOCK_GW_AUDIO);
    lastAudioVolume = newVolume;
    volumeValid = valid;
    ReleaseSpinlock(SPINLOCK_GW_AUDIO);
}

/* Called from 10ms COM task (BSW SWC runnable) */
FUNC(void, GW_CODE) Gateway_AudioVolume_Runnable(void)
{
    uint16 volume;
    boolean valid;
    GetSpinlock(SPINLOCK_GW_AUDIO);
    volume = lastAudioVolume;
    valid  = volumeValid;
    ReleaseSpinlock(SPINLOCK_GW_AUDIO);

    if (valid) {
        (void)Com_SendSignal(COM_SIG_AUDIO_VOLUME, &volume);
    } else {
        (void)Com_InvalidateSignal(COM_SIG_AUDIO_VOLUME);
    }
}

Signal Validity Propagation via Com_InvalidateSignal

EventClassic ActionCAN ResultDownstream SWC Effect
SOME/IP E2E check failsCom_InvalidateSignal(SIG)PDU transmitted with init value (0) in that signal positionFIM inhibits function via DEM event for COM_E_INVALID
IPC timeout (no update >200ms)Com_InvalidateSignal(SIG)Same as aboveFIM inhibit; SWC applies safe default
Valid SOME/IP eventCom_SendSignal(SIG, &val)Normal PDU with updated valueSWC uses new value normally

Summary

SOME/IP to Classic signal mapping requires explicit handling of: byte-order conversion (SOME/IP BE vs. Classic signal endianness from DBC), update rate mismatch (last-is-best buffer with spinlock protection), and validity propagation (Com_InvalidateSignal on E2E failure or timeout). The gateway is a critical FFI boundary — an unhandled Adaptive-side fault that silently sends stale data to a Classic safety function is a safety violation.

🔬 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.

← PreviousClassic ↔ Adaptive Gateway DesignNext →Hybrid Architecture Patterns