drivers/cps-hid.c: fix clipped input and battery voltage on CyberPower 0764:0601 - #3575
Open
ktsaou wants to merge 2 commits into
Open
drivers/cps-hid.c: fix clipped input and battery voltage on CyberPower 0764:0601#3575ktsaou wants to merge 2 commits into
ktsaou wants to merge 2 commits into
Conversation
…r 0764:0601 PR3000ELCDSL/PR3000ELCDSXL and sibling models sharing USB ID 0764:0601 declare HID Logical Maximums below the values they transmit for UPS.Input.Voltage/ConfigVoltage (LogMax 70) and UPS.PowerSummary.Voltage/ConfigVoltage (LogMax 255). GetValue() masks with hibit(LogMax) and clamps to [LogMin..LogMax], so input.voltage is reported as 70 and battery.voltage as 22.4 instead of the ~225 / ~48 V values actually sent on the wire. Extend cps_fix_report_desc() to widen the under-declared maximums using the patterns already established for this device family: - input voltage: also trigger when the HVT LogMax is greater than the input voltage LogMax (oracle sub-form, as used in apc-hid.c), placed as a sibling of the output voltage fix under the HVT block - input config voltage: set LogMax to 255 when the HVT LogMax is greater (byte-sized item; mirrors apc-hid.c) - battery voltage / battery config voltage: raise to CPS_BATTVOLT_LOGMAX when declared below it (constant sub-form, as used for the nominal power fix) All new fix-ups skip items with an active physical scaling (logical_to_physical() would rescale their already-in-range values), stay gated to the existing CPS_VENDORID / 0x0501 / 0x0601 product list, and remain skippable via disable_fix_report_desc. Add getvaluetest cases locking the mask/clamp semantics the fix relies on (wire values 225/230/480 against declared LogMax 70/255 and the widened 511/255/4096). Tested on a PR3000ELCDSXL (0764:0601, firmware CR01901A5P1): before the change input.voltage 70 / battery.voltage 22.4; after 227 / 48.0, with output.voltage and input transfer limits unchanged. [issue networkupstools#3089] Signed-off-by: Costa Tsaousis <costa@netdata.cloud>
|
A ZIP file with standard source tarball and another tarball with pre-built docs for commit e13e8c9 is temporarily available: NUT-tarballs-PR-3575.zip. |
The NEWS entry for the cps-hid logical-maximum fix references the CyberPower PR3000ELCDSL and PR3000ELCDSXL models; aspell flags ELCDSL/ELCDSXL as unknown words and fails the NUT spellcheck and distcheck stages on the PR CI. Add both model-name fragments to the accepted words list (alphabetically, next to ELCD). Signed-off-by: Costa Tsaousis <costa@netdata.cloud>
|
✅ Build nut 2.8.5.5084-master completed (commit 4b458d5c32 by @ktsaou)
|
|
✅ Build nut 2.8.5.5085-master completed (commit edea5aa2ca by @ktsaou)
|
Member
|
Looks great, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CyberPower
0764:0601devices (e.g. PR3000ELCDSL / PR3000ELCDSXL, and sibling models sharing the USB ID) transmit correct HID values, but their report descriptor declares Logical Maximums smaller than the values sent.GetValue()(drivers/hidparser.c) then masks withhibit(LogMax)and clamps into[LogMin..LogMax], sousbhid-upsreports:input.voltage70.0input.voltage.nominal70230battery.voltage22.448.0(4x12 V)battery.voltage.nominal2248Covered by issue #3089.
Root cause
Raw captures (
usbhid-ups -DDDDDD) and the parsed descriptor limits:0x0FUPS.Input.Voltage70.00x0EUPS.Input.ConfigVoltage700x0AUPS.PowerSummary.Voltage22.40x09UPS.PowerSummary.ConfigVoltage220x12UPS.Output.Voltage225.0output.voltagewas already correct because the existingcps_fix_report_desc()widens it (withCPS_VOLTAGE_LOGMAX 511). Input and battery items were not covered.Change
All in
drivers/cps-hid.c,cps_fix_report_desc()— the subdriver-level fix-up mechanism this device family already uses, gated to vendor0764product0501/0601and skippable viadisable_fix_report_desc:apc-hid.c);UPS.Input.ConfigVoltageLogMax to 255 (byte-sized item, mirrorsapc-hid.c, resolvesinput.voltage.nominal);UPS.PowerSummary.Voltage/UPS.PowerSummary.ConfigVoltageLogMax toCPS_BATTVOLT_LOGMAX (4096)when declared below it (constant form, mirrors the existing nominal-power fixCPS_NOMINALPWR_LOGMAX, resolvesbattery.voltage/battery.voltage.nominal).Raising a LogMax is inert when a device declares zero/undefined physical bounds (all items on this device do), and only widens the mask/clamp window for the affected items on devices with too-strict declared maximums.
Tested on hardware
PR3000ELCDSXL,
0764:0601, firmwareCR01901A5P1, 230 V mains.input.voltageinput.voltage.nominalbattery.voltagebattery.voltage.nominaloutput.voltageinput.transfer.low/highdriver.version.dataNew debug lines emitted on the same run:
With
disable_fix_report_descthe fix is fully suppressed (old wrong values return), as intended.Regression tests
tests/getvaluetest.cgained six cases locking the exact mask/clamp semantics the fix relies on (wire values 225 / 230 / 480 against declared LogMax 70 / 255, and against the widened 511 / 255 / 4096).Notes on the existing PR #3425
PR #3425 targets the same product ID
0764:0601but a different firmware variant (that device sends tenths of a volt,0f e5 08= 2277, and has no HVT0x10item; this device sends whole volts and has HVT). The two changes are independent: #3425's heuristic only fires for reconstructed values in[1000,3000], so it neither fixes nor breaks this device, and this change does not touch that decoding path.Scope limits (documented, not a regression)
0x10) item. The HVT-less firmware variant reported in PR drivers: fix CPS HID input/output voltage decoding for 0764:0601 #3425 (same PID0764:0601, tenths-of-a-volt payloads) is not covered by this change; that PR uses a different decoding mechanism.logical_to_physical()indrivers/libhid.c).Fixes #3089