Rig object is injected into every test function by the framework. Test code never constructs a Rig — it only receives one.
Signal naming
All signals are identified as"MessageName.SignalName" — the exact names from the DBC file. This convention works identically for CAN and Ethernet signals.
rig.can — CAN bus API
rig.can.send()
Send a DBC-encoded message by name.
Raises:
BlockedError if DBC is not loaded or message is unknown.
rig.can.send_raw()
Send a raw CAN frame without DBC encoding.
rig.can.expect()
Wait for a signal to satisfy a condition.
Returns:
ExpectResult — see Result model below.
rig.can.receive()
Wait for a specific CAN frame by arbitration ID.
CANTimeoutError if no matching frame arrives within the timeout.
rig.can.bus_load()
Measure current CAN bus load as a percentage.
rig.sim — Bus Simulation Engine control
The rig.sim namespace controls the virtual Bus Simulation Engine (BSE). It is useful when testing the ECU’s response to simulated bus traffic.
rig.sim.set()
Set a signal value in the simulation. Takes effect on the next scheduled frame.
rig.sim.start_scheduling()
Start periodic transmission of a DBC message.
rig.sim.stop_scheduling()
Stop periodic transmission of a message.
rig.sim.override() (context manager)
Temporarily override a signal value. Always restores the original value, even on exception (Rule R8).
rig.sim.status()
Get current simulation state — which messages are active, signal count.
rig.fault — Fault injection
Fault methods return FaultDescriptor objects — they do not execute anything. The fault is activated only when passed to rig.fault.inject().
rig.fault.inject() (context manager)
Activate a fault for the duration of the async with block. Always cleans up on exit, even on exception.
rig.fault.can_dropout()
Suppress TX and RX of a specific CAN arbitration ID.
rig.fault.can_noise()
Inject random bit errors into a specific CAN message.
rig.fault.power_cycle()
Power-cycle a rail — off for off_duration seconds, then back on.
rig.fault.gpio_stuck()
Hold a GPIO output pin at a fixed value.
rig.ecu — ECU management
The rig.ecu namespace provides access to ECUs defined in [rig.ecus.*] in the TOML.
Result model
ExpectResult
Returned by rig.can.expect().
assert result.passed, result.fail_msg — this gives useful output in test reports:
BlockedError vs fail
CruciHiL distinguishes between rig problems and firmware problems:
Use
BlockedError for infrastructure problems — missing hardware, DBC not loaded, backend not connected. These should never count as firmware regressions.