Skip to content

Support EMFI campaigns in the TUI and wait for HV charge on arm - #4

Merged
Darcko123 merged 5 commits into
mainfrom
fix/TUI_controlPanel
Jul 17, 2026
Merged

Support EMFI campaigns in the TUI and wait for HV charge on arm#4
Darcko123 merged 5 commits into
mainfrom
fix/TUI_controlPanel

Conversation

@Darcko123

Copy link
Copy Markdown
Member

Summary

This PR adds EMFI-engine campaign support to the TUI, makes the emfi arm
command wait for the high-voltage capacitor to finish charging, and
centralizes status/result formatting shared between the CLI and the TUI.
It also bumps the version to 1.0.1.

Changes

EMFI campaigns in the TUI

Previously the Campaign panel only supported the crowbar engine (CDC1).
Now both engines are supported:

  • crowbar runs the sweep over CDC1
  • emfi runs the sweep over CDC0

CDC0 is now shared between the EMFI status/control client and a new
emfi-engine CampaignClient through a SharedSerial wrapper (mirroring the
existing CDC1 crowbar+campaign sharing). The active engine is pinned when
Configure is applied in the Campaign modal, and the live panel, hotkeys
(s stop), and start/stop/drain all follow it. This matches the CLI's
campaign --engine behavior, where the firmware infers the engine from the
CDC the command arrives on.

emfi arm waits for HV charge

arm only kicks off HV charging on the firmware; the state machine reaches
CHARGED asynchronously. Firing before that returned a misleading INTERNAL
error. arm now polls status until the cap is actually CHARGED before
reporting success, with a configurable --charge-timeout-s (default 10s).

Centralized status/result formatting

Added as_rows() to EmfiStatus, CrowbarStatus, and CampaignStatus, and
render_line() to CampaignResult, as a single source of truth for display.
The CLI status tables and the TUI panels now share this, so a new status
field only has to be added in one place.

Version bump

Bumped to 1.0.1 across the CI workflows, Debian control, macOS build
script, and the Windows installer.

The `emfi arm` command previously only initiated HV charging, but the hardware reached the `CHARGED` state asynchronously. Attempting to `fire` before the capacitor was fully charged resulted in a misleading `INTERNAL` error.

This change introduces polling of the EMFI module's status after `arm` is called, waiting until the `EmfiState` is `CHARGED` or an error/timeout occurs. This ensures that when `arm` reports success, the module is genuinely ready for a subsequent `fire` command. A `--charge-timeout-s` option is added to configure the maximum wait time.
Adds the capability to run full campaign sweeps using the EMFI engine
from the TUI, mirroring the functionality previously limited to the
crowbar engine.

This change refactors the TUI's connection management to allow CDC0 to be
shared between the EMFI status client and a new EMFI campaign client via
`SharedSerial`. This is consistent with how CDC1 is shared for crowbar
campaigns. The active campaign engine is now selected in the modal,
determining which CDC is used for polling, start, stop, and drain operations.
Moves the logic for rendering status fields into `(key, value)` pairs and
campaign results into single lines to their respective protocol objects.

This centralizes display formatting, reducing duplication between the CLI
and TUI, and simplifies the addition of new status fields.
@Darcko123
Darcko123 merged commit 90e069e into main Jul 17, 2026
9 checks passed
@Darcko123
Darcko123 deleted the fix/TUI_controlPanel branch July 17, 2026 17:46
@sabas1080

Copy link
Copy Markdown
Member

#3

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