A portfolio project demonstrating modern automotive test automation using Robot Framework with UV package management and REST API-based Virtual ECU simulation to replicate Hardware-in-the-Loop (HIL) testing workflows.
- ECU Simulation: Battery Management System (BMS), Body Domain Controller (BDC/Door)
- CAN Communication: Virtual CAN bus with message logging and monitoring
- UDS Diagnostics: Full ISO 14229 diagnostic server implementation
- Fault Injection: Comprehensive fault injection for testing
- Robot Framework Integration: Ready-to-use test libraries
- Docker Support: Containerized deployment
- CI/CD Ready: GitHub Actions workflows
- Python 3.11+
- uv package manager
# Clone the repository
git clone https://github.com/yourusername/Virtual-HIL-Framework.git
cd Virtual-HIL-Framework
# Install dependencies
uv sync# Run all tests
uv run robot --pythonpath ./libraries:./ecu_simulation --outputdir reports tests/
# Run specific test suite
uv run robot --pythonpath ./libraries:./ecu_simulation --outputdir reports tests/functional/test_battery_monitoring.robot
# Run with tags
uv run robot --pythonpath ./libraries:./ecu_simulation --outputdir reports --include smoke tests/# Start all ECUs
docker-compose up -d
# Run tests
docker-compose --profile test run --rm test-runner
# View logs
docker-compose logs -f
# Stop
docker-compose downVirtual-HIL-Framework/
├── ecu_simulation/ # ECU simulation modules
│ ├── battery_ecu.py # Battery Management System
│ ├── door_ecu.py # Body Domain Controller
│ ├── can_interface.py # CAN bus interface
│ ├── diagnostic_server.py # UDS diagnostic server
│ └── rest_interface.py # REST API (optional)
├── libraries/ # Robot Framework libraries
│ ├── ECUSimulatorLibrary.py
│ ├── CANLibrary.py
│ ├── DiagnosticLibrary.py
│ └── FaultInjectionLibrary.py
├── tests/ # Test suites
│ ├── functional/ # Functional tests
│ ├── diagnostic/ # Diagnostic tests
│ ├── integration/ # Integration tests
│ └── fault_injection/ # Fault injection tests
├── resources/ # Test resources
│ ├── common_keywords.robot
│ ├── ecu_variables.robot
│ └── test_data.robot
├── config/ # Configuration files
│ ├── ecu_config.yaml
│ ├── can_database.dbc
│ └── diagnostic_database.json
├── scripts/ # Utility scripts
│ ├── start_ecu_simulator.sh
│ ├── generate_can_trace.py
│ ├── analyze_logs.py
│ └── extract_stats.py
├── docker/ # Docker configuration
│ ├── Dockerfile
│ └── docker-compose.yml
├── docs/ # Documentation
│ ├── architecture.md
│ ├── ecu_specification.md
│ ├── test_strategy.md
│ └── ci_setup.md
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock file
└── README.md
- Architecture - System architecture and design
- ECU Specifications - ECU technical details
- Test Strategy - Testing approach and guidelines
- CI Setup - CI/CD configuration guide
The Battery Management System simulator provides:
- 96-cell battery pack simulation
- Cell-level voltage and temperature monitoring
- State of Charge (SOC) estimation
- Cell balancing control
- Thermal management
- Fault detection (overvoltage, undervoltage, overtemperature, etc.)
The Body Domain Controller simulator provides:
- 4-door simulation with position control
- Lock/unlock functionality
- Window control
- Pinch protection (anti-trap)
- Child lock support
- Fault detection and reporting
Control and monitor ECU simulations:
*** Settings ***
Library ECUSimulatorLibrary
*** Test Cases ***
Check Battery SOC
Start Battery Simulation num_cells=96
${soc}= Get Battery SOC
Should Be True ${soc} > 80
Stop All SimulationsSend and receive CAN messages:
*** Settings ***
Library CANLibrary
*** Test Cases ***
Send CAN Message
Start CAN Interface
Send CAN Message can_id=0x100 data=01A20405060708
${received}= Wait For CAN Message can_id=0x100 timeout=5
Should Be True ${received}Perform UDS diagnostics:
*** Settings ***
Library DiagnosticLibrary
*** Test Cases ***
Read ECU Info
Start Diagnostic Session
${version}= Read Software Version
Log ECU Software Version: ${version}Inject faults for testing:
*** Settings ***
Library ECUSimulatorLibrary
Library FaultInjectionLibrary
*** Test Cases ***
Test Overvoltage Detection
Start Battery Simulation
${battery}= Get Battery ECU Instance
Set Battery ECU ${battery}
Inject Cell Overvoltage cell_id=0 voltage=4.3
${detected}= Verify Battery Fault Detected OVERVOLTAGE
Should Be True ${detected}
Clear All FaultsStandard CAN message IDs:
| ID | Message | Period | Description |
|---|---|---|---|
| 0x100 | BMS_Status | 100ms | Battery pack status |
| 0x101 | BMS_Cell_Data | 500ms | Individual cell voltages |
| 0x102 | BMS_Fault | Event | Battery fault indication |
| 0x200 | BDC_Door_Status | 100ms | Door open/closed and lock status |
| 0x201 | BDC_Door_Position | 50ms | Door position percentage |
| 0x202 | BDC_Window_Position | 100ms | Window position percentage |
Supported diagnostic services (ISO 14229):
| SID | Service | Description |
|---|---|---|
| 0x10 | Diagnostic Session Control | Change diagnostic session |
| 0x22 | Read Data By Identifier | Read data identifiers |
| 0x2E | Write Data By Identifier | Write data identifiers |
| 0x14 | Clear DTC | Clear diagnostic trouble codes |
| 0x19 | Read DTC | Read stored DTCs |
| 0x27 | Security Access | Security authentication |
| 0x31 | Routine Control | Execute diagnostic routines |
| 0x3E | Tester Present | Keep session alive |
| 0x85 | Control DTC Setting | Enable/disable DTC storage |
- Create new file in
ecu_simulation/ - Implement required methods:
__init__(config_path)to_dict()- Export statecheck_faults()- Return fault list
- Update
ecu_simulation/__init__.py - Add Robot Framework keywords to
ECUSimulatorLibrary.py
- Create
.robotfile in appropriate test directory - Use resources from
resources/directory - Tag tests appropriately (smoke, critical, battery, door, etc.)
- Follow naming conventions
ECU behavior is configured via config/ecu_config.yaml:
battery_ecu:
enabled: true
can_id: 0x100
pack:
num_cells: 96
cell_capacity_ah: 3.2
voltage:
max_cell_v: 4.2
min_cell_v: 2.8
# ... more configurationThe framework includes GitHub Actions workflows:
- SIL CI: Runs on push/PR to main branches
- Nightly Regression: Daily full regression test
- Manual HIL Test: On-demand test execution
See CI Setup for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License - see LICENSE file for details
- Robot Framework for excellent test automation framework
- ISO 14229 standard for UDS diagnostic specification
- Python CAN library for CAN bus communication
For issues and questions:
- GitHub Issues: https://github.com/yourusername/Virtual-HIL-Framework/issues
- Documentation: https://virtual-hil-framework.readthedocs.io/
- Add more ECU types (Engine, Transmission, ABS, etc.)
- Implement additional UDS services
- Add real CAN hardware support
- Develop GUI for manual testing
- Create test case recorder
- Add performance benchmarking
- Implement test data management
