Skip to main content

Mocks

A mock provides a restbus simulation of the ECU. The mock sends the frames that the ECU sends according to the signal databases, at their cycle times, so the bus looks as it does in the vehicle. Mocking several ECUs around a device gives you a restbus for the rest of the vehicle, so you can test the device in a realistic bus environment.

A mock starts out by sending the default value of all cyclic signals where the ECU is the sender. Your test cases, or other code, can then control the values to simulate different scenarios, see Controlling mocks. If the code that controls a mock gets complicated, write a behavioral model instead.

By default a mock is created for all channels that the ECU is connected to:

ecus:
FLCM:
mock: {}

You can also specify what channels you want to mock. This is useful when you want to exclude certain channels from the simulated environment, for example to use less CPU and memory.

ecus:
FLCM:
mock:
channels:
BodyCan:

Mock ECUs are only needed for ECUs that are sending signals. If you have an ECU that's only receiving signals, then you shouldn't create a mock. To make sure the ECU isn't instantiated you can use external:

ecus:
FLCM:
external: {}