Connect hardware (SIL to HIL)
RemotiveTopology uses the same network protocols as the vehicle, so a hardware ECU can take the place of a virtual one. You keep the platform, the mocks of the other ECUs, and the tests, and only change how the ECU and its channels are instantiated. This lets you move step by step:
- Software-in-the-loop (SIL): all ECUs are mocks, behavioral models, or virtual ECUs, on your computer or in CI.
- Hybrid HIL: some ECUs are hardware, connected to the virtual ECUs over CAN, LIN, or Ethernet.
- Hardware-in-the-loop (HIL): the device under test is hardware, and RemotiveTopology provides the restbus and the tests around it.
Since the tests run against the signals on the channels, the same tests run in all three.
Connecting hardware needs RemotiveBus, which is available on Linux. In WSL2 on Windows, USB adapters need to be passed through to WSL, see WSL2 in Windows. See Supported platforms.
Split the instance
Put what differs between SIL and HIL in instance files of their own, so you can combine them. For the sample vehicle with the BCM as device under test:
topology/
├── vehicle.platform.yaml
├── main.instance.yaml # SCCM mock, FLCM, and tests: the same in SIL and HIL
├── bcm-model.instance.yaml # BCM as a behavioral model
├── bcm-hardware.instance.yaml # BCM as hardware
└── hil-channels.instance.yaml # the channels connected to CAN adapters
main.instance.yaml has what's the same in SIL and HIL: the SCCM mock, FLCM, and the tests. It doesn't mention the BCM:
schema: remotive-topology-instance:0.18
platform:
includes:
- ./vehicle.platform.yaml
ecus:
SCCM:
mock: {}
FLCM: {}
containers:
tester:
profiles: [tester]
build:
dockerfile: ../tests/Dockerfile
volumes:
- ../tests:/app
working_dir: /app
command: "pytest --broker_url=http://topology-broker.com:50051 -v"
The tests are in a tests folder next to topology, and run in the tester container when you start the topology with the tester profile. See Writing tests for the tests and Test and tool containers for the container.
bcm-model.instance.yaml instantiates the BCM as a behavioral model:
schema: remotive-topology-instance:0.18
ecus:
BCM:
models:
bcm:
type: container
container:
build:
context: ../models/bcm
dockerfile: ../models/bcm/Dockerfile
command: python -m bcm
The SIL instance is main.instance.yaml and bcm-model.instance.yaml:
remotive topology build -f topology/main.instance.yaml -f topology/bcm-model.instance.yaml --name sil output
Replace the model with hardware
1. Connect the hardware to the computer
Connect each bus of the hardware ECU to the computer that runs the topology, with an adapter that has a Linux driver, such as a SocketCAN adapter for CAN. In the example the BCM is on both DriverCan and BodyCan, so it needs two CAN interfaces.
Rename the interfaces after the buses, so it's clear which is which:
sudo ip link set can0 name drivercan
sudo ip link set can1 name bodycan
A DBC file doesn't contain the bit rate of the bus. Add it to the channels in the platform, see CAN channel.
2. Mark the ECU as external
The hardware ECU is part of the topology, but RemotiveTopology doesn't run it. Mark it as external in bcm-hardware.instance.yaml:
schema: remotive-topology-instance:0.18
ecus:
BCM:
external: {}
3. Connect the channels to the hardware
By default channels are virtual. Connect them to the interfaces on the host in hil-channels.instance.yaml, with the RemotiveBus CAN driver:
schema: remotive-topology-instance:0.18
channels:
DriverCan:
type: can
driver:
type: remotivebus
config:
type: can
device: drivercan
host_device: drivercan
BodyCan:
type: can
driver:
type: remotivebus
config:
type: can
device: bodycan
host_device: bodycan
Now the SCCM mock sends on the physical DriverCan, where the hardware BCM receives it, and the RemotiveBroker of FLCM receives what the hardware sends on the physical BodyCan.
4. Build and run the HIL instance
The HIL instance replaces bcm-model.instance.yaml with the two hardware files:
remotive topology build -f topology/main.instance.yaml -f topology/bcm-hardware.instance.yaml -f topology/hil-channels.instance.yaml --name hil output
docker compose -f output/hil/docker-compose.yml --profile tester up --abort-on-container-exit --exit-code-from tester
To check the traffic on the physical buses, use standard tools on the host, such as candump bodycan, or the TopologyBroker namespaces, such as topology-BodyCan.
Other channels
- LIN: hardware LIN needs a software bridge between the LIN adapter and the channel, for example the open source plugin for Kvaser adapters. See Connecting to hardware LIN.
- Ethernet: bridge the channel to a physical network interface with
host_physical_devices, see VLAN with physical device. The hardware uses the IP addresses from the platform. If other hosts on the network use addresses that the topology would assign, set the TopologyBroker IP address. To observe traffic between hardware ECUs, use a test access point.
The same tests in SIL and HIL
Tests that only control mocks and check the signals on the channels run unchanged against hardware. A few things differ:
- Control requests:
PingRequestandRebootRequestgo to mocks and behavioral models, not to hardware. Don't send them to the device under test in the HIL instance. Reset hardware in another way, for example with a power cycle, or by sending inputs that put it in a known state. - Timing: hardware has its own start-up time and timing. Choose timeouts from the requirements, not from how fast a model happens to respond.
- Instance-specific checks: if a test needs to know where it runs, pass that to it, for example as a command line option in the
commandof the test container, rather than duplicating the test.
See Writing tests.
HIL rigs in CI
A HIL rig is a computer, with the hardware and adapters connected, that runs the HIL instance. To run tests on it in CI, register the computer as a self-hosted runner in your CI system, such as a GitHub Actions self-hosted runner, and send the HIL jobs to it.
Rigs are scarce, so run the SIL tests first, on ordinary CI runners, and the HIL tests only when they pass. In GitHub Actions, building on the job in RemotiveTopology in CI:
jobs:
sil-tests:
runs-on: ubuntu-latest
# ... build with main.instance.yaml and bcm-model.instance.yaml, and run the tests
hil-tests:
needs: sil-tests
runs-on: [self-hosted, hil-rig]
concurrency: hil-rig
env:
REMOTIVE_CLOUD_AUTH_TOKEN: ${{ secrets.REMOTIVE_CLOUD_AUTH_TOKEN }}
REMOTIVE_CLOUD_ORGANIZATION: ${{ secrets.REMOTIVE_CLOUD_ORGANIZATION }}
steps:
- uses: actions/checkout@v4
- name: Build the HIL topology
run: remotive topology build -f topology/main.instance.yaml -f topology/bcm-hardware.instance.yaml -f topology/hil-channels.instance.yaml --name hil output
- name: Run the tests
run: docker compose -f output/hil/docker-compose.yml --profile tester up --abort-on-container-exit --exit-code-from tester
- name: Clean up
if: always()
run: docker compose -f output/hil/docker-compose.yml --profile tester down
needs: sil-testsruns the HIL tests only when the SIL tests pass.runs-on: [self-hosted, hil-rig]sends the job to the rig, by a label you give the runner.concurrency: hil-rigmakes jobs wait for each other, since only one topology at a time can use the hardware.
Install RemotiveCLI, RemotiveBus, and Docker or Podman on the rig once, as on any Linux computer, see Install RemotiveTopology. The job uses a service account, the same way as on other CI runners.