Skip to content

Simple CAN based HIL#83

Open
LelsersLasers wants to merge 26 commits into
masterfrom
millan/simple_hil
Open

Simple CAN based HIL#83
LelsersLasers wants to merge 26 commits into
masterfrom
millan/simple_hil

Conversation

@LelsersLasers

@LelsersLasers LelsersLasers commented Jun 11, 2026

Copy link
Copy Markdown
Member
HIL_Loopback_Demo.mp4

Simple HIL only supporting expecting to receive CAN messages at certain windows and validating the values received. Supports both individual tests and presets which are a collection of individual tests.

Synatx

hil_config/presets.json:

{
	"Preset name": [ "individual_test_basename", "another_test_basename" ],
	"All Heartbeats": [ "heartbeats_crit", "heartbeats_non_crit" ]
}

hil_config/tests/individual_test_basename.json:

{
	"$schema": "../schema.json",

	"name": "Test name",
	"description": "test description",

	"expect": [
		{
			"window": [0, 10000],
			"msg_name": "abox_version"
		},
		{
			"window": [15, 20],
			"msg_name": "thermistor_telemetry",
			"signals": {
				"temperature": [30.0, 40.0]
			}
		}
	]
}

Signals is optional. If not provided, will only check that the message is received within the window. You do no have to specify all signals. If a signal is not listed, then it's value will be ignored, only listed signals will be checked.

window is in milliseconds after the test has started.

As currently implemented, the UI thread is in charge of running the tests and checking the received CAN messages, so time precision is only ~16-20ms when running at 60 FPS

Not (yet) supported

  • TX. The schema has been added, but support for having the HIL test send messages is not yet implemented.
  • Alternative behaviors:
    • Being able to choose to run subtests in a preset back-to-back instead of always in parallel
    • Being able to choose if the first, last, or any message in a expected window is the CAN message used instead of always the first
  • An independent HIL thread (or built into the CAN thread) for 1-2ms precision instead of being tied to the UI.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new CAN-based HIL (hardware-in-the-loop) test runner to DAQApp2, with an egui UI widget and a JSON-based configuration format (individual tests + presets) for validating received CAN messages within time windows.

Changes:

  • Introduces a new hil module for config discovery/loading and runtime evaluation of expectations.
  • Adds a new Hil UI widget and wires it into the widget system, sidebar, and action spawning.
  • Adds hil_config/ schema + sample presets/tests to define expectations and presets.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/widgets.rs Registers the new Hil widget and forwards show/CAN handling.
src/ui/sidebar.rs Adds “Add HIL” button to spawn the HIL widget.
src/ui/mod.rs Exposes the new ui::hil module.
src/ui/hil.rs Implements the egui HIL widget UI/state machine and test execution loop.
src/main.rs Adds mod hil; to compile the new module.
src/hil/mod.rs Declares hil::config and hil::run submodules.
src/hil/config.rs Implements listing/loading HIL presets/tests from JSON on disk.
src/hil/run.rs Implements expectation tracking, matching, and pass/fail evaluation.
src/app.rs Adds per-widget instance counter and spawn logic for Hil.
src/action.rs Adds WidgetType::Hil and command palette entry.
hil_config/schema.json Defines the JSON schema for HIL test files.
hil_config/presets.json Adds a sample preset referencing included tests.
hil_config/tests/idk.json Adds a sample test including tx and expect sections.
hil_config/tests/heartbeats_non_crit.json Adds a sample heartbeat expectation test (non-critical).
hil_config/tests/heartbeats_crit.json Adds a sample heartbeat expectation test (critical).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ui/hil.rs Outdated
Comment thread src/ui/hil.rs
Comment thread src/ui/hil.rs
Comment thread src/ui/hil.rs
Comment thread src/ui/hil.rs
Comment thread src/hil/run.rs Outdated
Comment thread src/hil/config.rs
Comment thread src/hil/config.rs
Comment thread hil_config/tests/heartbeats_non_crit.json Outdated
Comment thread hil_config/tests/heartbeats_crit.json Outdated
@LelsersLasers LelsersLasers marked this pull request as ready for review June 13, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants