Skip to content

ups-live: macOS live dashboard for the UPS (WUPS over USB-CDC) - #3

Merged
cmd0s merged 3 commits into
mainfrom
feat/ups-live
Jul 17, 2026
Merged

ups-live: macOS live dashboard for the UPS (WUPS over USB-CDC)#3
cmd0s merged 3 commits into
mainfrom
feat/ups-live

Conversation

@cmd0s

@cmd0s cmd0s commented Jul 17, 2026

Copy link
Copy Markdown
Member

What

New binary in the crate: ups-live — a single-screen terminal dashboard that opens the UPS's USB-CDC port directly on a desktop machine and renders the WUPS v1 stream live.

Primary use case: macOS bench/diagnostics. With the PD_DataRole firmware (Web3-Pi-UPS c98e7fc) a laptop plugged into the UPS output takes the USB host role via PD DR_Swap, so the full telemetry stream is available without a Raspberry Pi in the loop — while the laptop is simultaneously powered by the UPS.

cargo run --release --bin ups-live       # auto-detects the UPS (2e8a:000a)

How

  • src/lib.rs exposes the existing proto module as a library target — the tool reuses the agent's deframer/Fletcher-8/payload catalogue, zero protocol duplication; the agent binary keeps its private module tree and is unaffected (all 52 proto tests pass against the lib target)
  • dashboard: power path (mains/USB-C flags, HUSB238 input contract, output PD contract, TPS set/read/ilim), battery + charge state, both temperature sensors, faults, UPS uptime, stale-frame indicator, frame/CRC counters
  • log pane: system.log frames (includes the CH32X PD: ... event trace) + highlighted power.event broadcasts
  • alternate screen buffer TUI — terminal content restored on exit
  • no new dependencies (tokio-serial + clap already in the tree)

Testing

Verified live on macOS 26.5.2 (MBP M4) against a UPS powering the MacBook at 15 V: auto-detect, 1 Hz refresh, CRC counters at zero over multi-minute sessions, PD trace visible on attach. Not exercised on a Pi (out of scope — the installed agent owns the port there; documented in README).

cmd0s added 3 commits July 17, 2026 17:53
Second binary in the crate: a single-screen ANSI terminal dashboard for
bench use. With the PD_DataRole firmware a laptop attached to the UPS
output takes the USB host role via DR_Swap, so the WUPS stream is
readable directly on macOS — this renders it live:

- auto-detects the Web3_Pi_UPS CDC (VID:PID 2e8a:000a; prefers /dev/cu.*
  on macOS), or takes an explicit port path
- power.status v2: input path (mains/USB-C flags, HUSB238 PD-in
  contract), output rail (PD-out contract, TPS set/read/ilim), battery,
  charge state, temps, faults, UPS uptime + stale-frame indicator
- scrolling tail of system.log frames (includes the CH32X "PD: ..."
  event trace) and highlighted power.event broadcasts
- frame/CRC counters from the shared deframer

Protocol code is reused, not duplicated: new src/lib.rs exposes the
existing proto module as a library target consumed by the bin. The agent
binary keeps its private module tree and is byte-for-byte unaffected;
all 52 proto tests pass against the lib target.

Verified live on macOS against a UPS powering the MacBook at 15 V.
The startup clear was a bare print! — the escapes sat in the stdout
buffer and the first frame raced the shell prompt, intermittently eating
the title row (seen on first bench run). Use the alternate screen buffer
(?1049h/?1049l) with an explicit flush: the dashboard gets a clean empty
screen and the user's terminal content is restored intact on exit.
@cmd0s
cmd0s merged commit 9eecd02 into main Jul 17, 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.

1 participant