Skip to content

Custom topic injection mode with per-topic intervals#291

Open
bracyw wants to merge 4 commits intoDevelopfrom
289-sim-custom-topic-injection-mode
Open

Custom topic injection mode with per-topic intervals#291
bracyw wants to merge 4 commits intoDevelopfrom
289-sim-custom-topic-injection-mode

Conversation

@bracyw
Copy link
Copy Markdown
Collaborator

@bracyw bracyw commented Mar 28, 2026

Changes

Added --topic "TOPIC=INTERVAL_MS" flag to the simulator for selecting specific topics with custom per-topic loop intervals. This is the "injection mode" from #289 — only the specified topics are published, each on their own frequency.

Also gated imd_poll behind cfg(target_os = "linux") to fix macOS builds (matches the existing linux-only socketcan dep in Cargo.toml).

Notes

Refactored simulate_out so component creation and filtering now happen in main at startup. This means invalid topic names fail immediately with a clear error instead of silently inside the async task. Extracted compile_regex_patterns helper to deduplicate the blacklist/whitelist regex loops while I was in there.

The --topic flag conflicts with --enable-topic and --disable-topic since they're different modes.

Test Cases

  • simulate --topic "BMS/Pack/Voltage=30000" — only publishes BMS/Pack/Voltage at 30s intervals
  • simulate --topic "BMS/Pack/Voltage=30000" --topic "BMS/Pack/Current=10000" — publishes both at their own intervals
  • simulate --topic "Nonexistent/Topic=1000" — fails at startup with "Unknown topic(s): Nonexistent/Topic"
  • simulate --topic "BadFormat" — fails with "expected TOPIC=INTERVAL_MS"
  • simulate --topic "BMS/Pack/Voltage=0" — fails with "Interval must be positive"
  • simulate (no flags) — all topics published at default intervals, unchanged behavior

Checklist

  • No merge conflicts
  • All checks passing
  • Remove any non-applicable sections of this template
  • Assign the PR to yourself
  • Request reviewers & ping on Slack
  • PR is linked to the ticket (fill in the closes line below)

Closes #289

@bracyw bracyw self-assigned this Mar 28, 2026
@bracyw bracyw marked this pull request as draft March 29, 2026 00:19
@bracyw bracyw marked this pull request as ready for review March 29, 2026 21:07
@bracyw bracyw requested a review from bjackson312006 March 29, 2026 21:07
@bracyw bracyw changed the title #289 - Custom topic injection mode with per-topic intervals Custom topic injection mode with per-topic intervals Mar 29, 2026
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.

[Sim] - Custom Topic Injection Mode for Calypso Mock

1 participant