Skip to content

apc-hid: map shutdown.return for APC Back-UPS BX*MI units [#2683] - #3566

Open
faluc-dev wants to merge 1 commit into
networkupstools:masterfrom
faluc-dev:apc-hid-bxmi-shutdown-return
Open

apc-hid: map shutdown.return for APC Back-UPS BX*MI units [#2683]#3566
faluc-dev wants to merge 1 commit into
networkupstools:masterfrom
faluc-dev:apc-hid-bxmi-shutdown-return

Conversation

@faluc-dev

Copy link
Copy Markdown

Closes the practical side of #2683 (and matches the empirical conclusion of #2666): on newer APC Back-UPS units such as the BX750MI, the built-in upsdrvctl shutdown / usbhid-ups -k sequence reports success but never powers the load off.

Why: on these units the only shutdown-capable HID usage is UPS.APCGeneralCollection.APCDelayBeforeReboot. The only command previously mapped to that path, shutdown.reboot, writes its default value "10" — which this firmware ACKs at the USB level but never executes. The shutdown chain then stops at that first "successful" command.

Fix (one table line): map shutdown.return to the same usage with value "1" — the exact write APC's own PowerChute Serial Shutdown performs (single SET_REPORT(Feature, 0x40) = 01, decoded from the USBPcap captures archived in #2683). With it, the driver-default chain (shutdown.return,shutdown.reboot,load.off.delay,shutdown.stayoff) succeeds on its first command with a write that actually works. This mirrors the existing "Back-UPS CS" shutdown.return entry, which uses the same value "1" on the UPS.Output path.

Semantics of the write, per our bench work on a 2025-11 BX750MI-GR unit (051d:0002) — complementing the PowerChute captures in #2683, which came from the original reporter's 2024-build unit:

  • Fixed ~2 minute internal grace; the value is not a seconds count on this firmware.
  • Executes only while on battery; race-immune — the cycle completes even if AC returns during the grace (matching PowerChute pcap capture 11-14-2 and our live retest).
  • Output re-energizes when wall power is present — proper shutdown.return behavior.

Verification of this patch (2026-08-12, BX750MI-GR, macOS/arm64 bench, libusb 1.0.30):

  • On battery: usbhid-ups -a ups4 -k -u root → chain used shutdown.return via UPS.APCGeneralCollection.APCDelayBeforeReboot, Report[set]: (2 bytes) => 40 01, "Shutdown successful with 'shutdown.return'". Output cut 2 min 2 s after the write; replugging the wall re-energized the output within seconds. Full debug logs available.
  • On line (the "checking if wall power is on/off" question from Extracting APC Back-UPS BX750MI shutdown command from "sniffed" USB traffic #2683): same command with AC present throughout → the write is ACKed identically (40 01 on the same path, driver reports success) but is silently dropped by the firmware: no output cut within 8 minutes, a subsequent register read showed ups.timer.reboot: 0 (disarmed — an armed timer holds 1), and a battery transition several minutes after the write produced no delayed fire either. So on this family no on-line/on-battery conditional command logic is needed: the write only ever does anything when issued on battery, and there it is race-immune. The unconditional default chain is safe on both sides of the power race.

Review point worth flagging: older Back-UPS ES devices also expose the APCGeneralCollection path. Previously shutdown.return did not match on them at all, and the default chain used shutdown.reboot (value "10"). With this patch the chain will prefer shutdown.return (value "1") on those units too. If their firmware honors the value as a seconds delay, this shortens the pre-cut delay from 10 s to 1 s; we could not test an ES unit. If that is a concern, the entry could be gated by product string instead — happy to rework it that way.

The NEWS.adoc entry currently references issue #2683; I can amend it with this PR's number once known (or per your preference).

Transparency, as discussed in #2683: I am not a programmer — the analysis, this patch, and this PR text were authored by an AI assistant (Claude / Fable 5, via Claude Code) under my direction; I performed the hardware tests on my BX750MI unit. Maintainer OK for AI-assisted contribution: #2683 comment follow-up.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QQEAfDBxtHupEdAcv3Bgz2

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

A ZIP file with standard source tarball and another tarball with pre-built docs for commit baee2b0 is temporarily available: NUT-tarballs-PR-3566.zip.

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@faluc-dev
faluc-dev force-pushed the apc-hid-bxmi-shutdown-return branch from 20c223c to 243d712 Compare August 12, 2026 17:40
…tools#2683]

On newer APC Back-UPS devices (e.g. Back-UPS BX750MI, 051d:0002) the only
shutdown-capable HID usage is UPS.APCGeneralCollection.APCDelayBeforeReboot.
The previously only matching command mapped to it, shutdown.reboot, writes
the default value 10, which this firmware accepts (USB-level success) but
never executes — so the built-in shutdown sequence reported success without
ever powering the load off.

Map shutdown.return to the same usage with value 1, matching the write APC
PowerChute Serial Shutdown performs (confirmed by decoding the USBPcap
captures archived in issue networkupstools#2683, and live on a 2025-11 BX750MI-GR unit):
the load is cycled after a fixed ~2 minute grace (the value is not a seconds
count on this firmware), the command executes only while on battery, and
output returns when wall power is present, even if AC came back during the
grace period.

With this mapping the driver-default shutdown command chain
(shutdown.return,shutdown.reboot,load.off.delay,shutdown.stayoff) succeeds
on its first command: verified on battery with 'usbhid-ups -k' on a
BX750MI-GR — output cut 2 min 2 s after the write and re-energized on AC
restore.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QQEAfDBxtHupEdAcv3Bgz2
Signed-off-by: Falusi Tamás <tamas.falusi@gmail.com>
@faluc-dev
faluc-dev force-pushed the apc-hid-bxmi-shutdown-return branch from 243d712 to baee2b0 Compare August 12, 2026 18:07
@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.5047-master completed (commit 871ea658ed by @faluc-dev)

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.5048-master completed (commit 171b34d07d by @faluc-dev)

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