Robot Framework HIL Harness for CAN Devices
Drive a CAN-connected controller from Robot Framework keywords on a bench rig.
- Runs out of the box: no
- Tests: yes
- CI: yes
- Docs: yes
- Used in production: yes
Purpose#
A keyword library and bench layout for testing a CAN-connected controller. Test authors write plain keywords such as "Power Cycle Unit" and "Expect Frame Within"; the library translates them into power-supply commands and CAN reads, and attaches the raw bus log to every test result.
The rig description, wiring notes and a calibration checklist live next to the code so a second bench can be reproduced from the repository.
What you will learn#
- Structure keyword libraries and resource files per bench instrument
- Assert on CAN frame timing with explicit windows rather than sleeps
- Attach raw bus logs to test results automatically
- Tag tests so smoke runs and nightly runs share one suite
Media#
Technologies & features#
- Technologies
- PythonRobot FrameworkCAN bus
- Features
- Hardware-in-the-Loop TestingKeyword-Driven Testing
- Topics
- System & HIL TestingprimaryHardware Integration
Lessons learned#
- Worked
A virtual bench variable file let authors develop tests at their desks and only use the physical rig for final runs.
- Didn’t work
Fixed sleeps between power-up and the first frame made the suite flaky on a slow unit. Waiting for the first heartbeat frame removed the flakiness.
- Decision
Bench addresses and channel numbers live in variable files, never in suites, so the same tests run on every bench.
Try it#
git clone https://git.example.internal/test-engineering/hil-can-harness.git
cd hil-can-harness
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
robot --variablefile config/virtual_bench.py tests/smokeThe virtual_bench.py variable file uses a simulated CAN interface, so the smoke suite runs without hardware.
Commands come from the owner’s README. Credentials are never stored here.
