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

Signal-Based Testing Fundamentals

Test TypeWhat It ChecksAutomotive Example
Value testSignal value within expected rangeVehicleSpeed 0-250 km/h; out-of-range triggers DTC
Timing testSignal cycle time within specWheelSpeed 5ms cycle; jitter < 10% of period
Sequence testSignal transitions in correct orderAEB: INACTIVE -> ALERT -> BRAKING -> INACTIVE
Cross-signal testConsistency between related signalsIf gear=PARK then VehicleSpeed must be 0
Absence testSignal not sent when it should not beNo AEB_BrakeRequest when speed < 5 km/h

Bus Monitoring with python-can

Pythonbus_monitor.py
"""CAN bus monitoring: collect and analyse all signals."""
import can, cantools, time, threading
from collections import defaultdict
from typing import Dict, List

class CanBusMonitor:
    def __init__(self, channel: str, db_path: str):
        self.db = cantools.database.load_file(db_path)
        self.bus = can.interface.Bus(channel, bustype="socketcan")
        self.signal_log: Dict[str, List[tuple]] = defaultdict(list)
        self._running = False

    def start(self):
        self._running = True
        self._thread = threading.Thread(target=self._receive_loop, daemon=True)
        self._thread.start()

    def stop(self):
        self._running = False
        self._thread.join(timeout=2.0)

    def _receive_loop(self):
        while self._running:
            msg = self.bus.recv(timeout=0.01)
            if msg:
                try:
                    decoded = self.db.decode_message(
                        msg.arbitration_id, msg.data)
                    for name, value in decoded.items():
                        self.signal_log[name].append((msg.timestamp, value))
                except Exception:
                    pass

    def check_timing(self, signal: str, expected_period_ms: float,
                      tolerance_pct: float = 10.0) -> dict:
        entries = self.signal_log.get(signal, [])
        if len(entries) < 2:
            return {"ok": False, "reason": "insufficient samples"}
        periods = [(entries[i+1][0]-entries[i][0])*1000
                    for i in range(len(entries)-1)]
        avg_period = sum(periods) / len(periods)
        max_jitter = max(abs(p - expected_period_ms) for p in periods)
        ok = max_jitter <= expected_period_ms * tolerance_pct / 100
        return {"ok": ok, "avg_period_ms": avg_period,
                "max_jitter_ms": max_jitter}

Fault Injection Testing

Pythonfault_inject.py
"""Fault injection: corrupt or withhold signals to test ECU responses."""
import can, time

class FaultInjector:
    def __init__(self, bus: can.BusABC, db):
        self.bus = bus
        self.db = db

    def inject_out_of_range(self, signal_name: str,
                            value: float, duration_s: float):
        """Send signal with value outside physical range."""
        msg_def = self.db.get_message_by_signal_name(signal_name)
        raw_data = msg_def.encode({signal_name: value},
                                   scaling=False)  # bypass range check
        deadline = time.monotonic() + duration_s
        while time.monotonic() < deadline:
            self.bus.send(can.Message(
                arbitration_id=msg_def.frame_id,
                data=raw_data, is_extended_id=False))
            time.sleep(0.010)  # 10ms cycle

    def withhold_signal(self, signal_name: str, duration_s: float):
        """Stop sending a signal to trigger timeout behaviour."""
        # Simply do not send -- the ECU should detect timeout
        time.sleep(duration_s)

Summary

Signal-based testing at the bus level is the foundation of automotive ECU test automation because the CAN/Ethernet bus is the observable interface of the ECU -- it is what the ECU "says" to the network. Bus monitoring combined with fault injection creates a powerful test capability: inject an out-of-range signal value and verify the ECU sets the correct DTC; withhold a signal for longer than the timeout and verify the ECU enters the correct degradation state; send a signal with incorrect E2E CRC and verify the ECU rejects it. These fault injection tests are impossible to perform manually at the required precision and frequency, making them one of the highest-value automated test categories.

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

← PreviousTest Cases and Test ConfigurationsNext →Parameterised and Data-Driven Tests