Repository navigation
Fix torn fan readings, tooltip truncation, driver inventory crash, release check - #13
fisherjdjdj wants to merge 7 commits into
Conversation
The HONOR EC latches the tachometer value about once a second. A read that lands on the update returns an impossible number, and the corrupt bytes survive the whole latch window, so reading several times inside one refresh repeats the same bad value rather than averaging it out. Measured on a FMB-P (Core Ultra 5 225H): raw reads of 53645 and 34482 RPM while the fan spun near 2000, and 1.11.1 flashed 0 RPM twice in ten seconds of a spinning fan. Take two reads per refresh one latch window apart, drop values above 10000 RPM, and show the median of the last five samples (~12 s), kept in HKCU\Software\HonorPCHelper\FanRpmHistory so the next hover adds to the same window. Largest jump between tooltip values drops from 2656 to 759 RPM and no impossible reading survives, at 1.4 s per refresh against the five seconds the tray waits for. A real ramp is followed about one refresh late, which the comment in the code spells out.
NotifyIcon.Text accepts at most 127 characters and the builder cut the string at exactly that index, so the Russian text - 153 characters in performance mode with the sensor lines present - ended mid-word and showed no fan numbers at all. Rebuild once with short Russian labels when the text overflows, and trim to whole lines only if that still does not fit. Measured against the shipped builder: ru 153 -> 119 characters with all six lines, en 125 and zh 78 unchanged. The power line is the battery charge/discharge rate, not the machine draw, and a battery held inside its charge range legitimately reports neither, so the label says Battery and a zero rate says so instead of showing a bare "0 W".
The searcher runs forward-only, so each row is released as the enumerator moves on. Sorting the live ManagementObject sequence ran the key selector over rows that were already gone: on a machine with an orphaned device (ROOT\SYSTEM\0002, CM_PROB_FAILED_INSTALL, with no Name and no PNPClass) the whole driver inventory threw a NullReferenceException, which the shipped log records as "Initial driver device inventory failed" followed by "0 detected, 22 requested". Copy the three values while enumerating and sort the copies, the pattern the other queries in this file already use.
EnsureSuccessStatusCode turned a 502 from the releases API into an ERROR entry in the log users are asked to send. Returning an empty ApplicationUpdateCheck would have been worse: the watcher publishes .Update, so a transient failure would clear an update a successful check had already found. CheckAsync now returns a nullable result where null means "this round said nothing", which is exactly what both call sites already did on the exception path, and the log line drops to INFO.
Decompiling the ACPI tables (acpidump + iasl) showed that OemWMIfun's input bytes are a main/sub function pair, and that GTMP's zone byte is a fixed table: 0x00 CDTS (CPU package), 0x0B DDRS (memory), 0x0E BTND (battery), 0x21..0x28 skin temperatures. Zones outside the table return status 1 from the AML Default branch, so those "BIOS rejected it" readings were never EC errors. Report DDRS alongside CPU and battery: it is the sensor the right fan actually ramps for, so it explains noise the package temperature does not. Fan filtering kept 5560 and 7547 RPM on a machine whose measured envelope is 0..3303, because a torn latch is only rejected above 10000. Drop the ceiling to the physical envelope and require a second sample in the window to agree: a tear is a number nothing else corroborates, and in a five sample window it is also the median, so a ceiling alone cannot catch it. Both fan tach bytes are read from separate EC offsets, so a reading below 256 is a fan at the bottom of its range rather than one turning at 130 RPM. Say so instead of showing a number that reads as a broken fan. Also pin the same WMI instance for reads that the write path already pins: the two can otherwise disagree about which HWMI device they are talking to.
Decompiling the ACPI tables showed GCFD (function 4/sub 0x17), which returns the enable flag and the current duty for a fan. Calibrated against the tach on a FMB-P over 319 one-second samples, RPM = 72.5 x duty +/- 0.9. That matters for the machines the speed readout cannot describe: one fan reports 94-117 RPM at a duty of 97-100%, so "it barely spins" was never a statement about the fan. The duty also stays valid across a torn latch window, where the median of speeds correctly refuses to guess, so the tooltip has something to show instead of "?" for a refresh. Snapshot fields are appended, so a snapshot written by an older helper still parses with the new sensors left unknown.
The left fan's duty and its speed readout disagree, and which of the two is lying has not been settled - the comment claimed the duty was the exact one. What is actually established is that the two are independent readings and the duty never tears.
|
Thanks for this, it's one of the most carefully measured PRs this repo has had. I read the whole diff, and the branch builds clean on my side. I'd like to split it, because the parts carry very different risk: Happy to merge as-is:
Would like to hold back for now:
Could you split this into two PRs: one with the fixes above and one with the new sensors? I'll merge the first quickly. For the second, data from another model or the AML excerpts would go a long way. Gating the new reads behind a list of verified models would also work for me. |
|
Update: the driver NRE, release-check and |
|
Closing since the fixes are in main (1.13.1, 1.13.3). For the sensors, please open a fresh PR against current main — ideally gated to verified models, with the GCFD AML excerpt. Thanks for the thorough work. |
What this fixes
Four defects and two missing sensors found while investigating "power is not detected" and
"the fans look broken" on a HONOR MagicBook (FMB-P, Core Ultra 5 225H, BIOS 1.16,
Windows 11 26100) running 1.11.1. Every claim below is measured on that machine with the
shipped build as the control; the measurement scripts are listed at the end.
Related issue: #14 — the battery-power wording that started this investigation. The other
sections are written to stand on their own: each defect below carries the measurements it
came from, so nothing here depends on reading another issue. §5–§6 continue the fan thread
(they are why the ceiling quoted in §1 changed again).
1. Fan speed reaches the tooltip unfiltered (
HardwareSensors.cs,HardwareSettings.cs)The EC latches the tachometer value about once a second. A read that lands on the
update returns a torn value, and the corrupt bytes survive the whole window, so
reading several times inside one refresh repeats the same impossible number. Raw
OemWMIfunreads, no app involved, CPU at 98 °C:A later run caught
34482the same way, and 1.11.1 flashed0 RPMtwice while the fanwas spinning at 1760-2650 RPM in the same seconds.
The commit takes two reads per refresh one latch window apart, drops values above
10000 RPM outright, and shows the median of the last five samples (~12 s), kept in
HKCU\Software\HonorPCHelper\FanRpmHistoryso the next hover adds to the same window.Follow-up commits in this same PR replace the 10000 ceiling (see §5): the bound is now
6500 RPM, and a value only counts when a second sample in the window lies within 10% of it
(never closer than 200 RPM) — a tear is a number nothing else agrees with, so corroboration
catches the 5560 and 7547 cases that walked straight through 10000.
Two trade-offs I want on the record rather than buried: a real ramp is followed about
one refresh late, and
0is not treated as invalid on this model because the first fangenuinely idles near a stop (90 RPM at rest, 0 when cold). If you would rather keep the
lag out and only discard impossible magnitudes, that is the smaller half of the commit.
2. Russian tooltip overruns 127 characters and loses the readings (
DiagnosticsService.cs)NotifyIcon.Texttakes 127 characters and the builder cuts at exactly that index. TheRussian text needs 153 characters in performance mode with the sensor lines present, so
the tooltip ended mid-word and showed no fan numbers at all — measured by calling the
shipped builder through reflection:
The text is rebuilt once with short Russian labels when it overflows, and only trimmed
to whole lines if that still does not fit. Wording part of the same commit: the power
line is the battery's charge/discharge rate, not the machine's draw, so the label says
Batteryand a battery held inside its charge range says0 W, idleinstead of a bare0 W— that ambiguity is exactly what made me think the sensor path was broken.3. Driver inventory throws
NullReferenceException(DriverUpdateService.cs)The missing-device query runs forward-only (
Rewindable = false) and then sorts thelive
ManagementObjectsequence.OrderBybuffers by enumerating first, and theenumerator releases each row as it moves on, so the key selector runs over rows that are
already gone. This machine has one such row —
ROOT\SYSTEM\0002with noNameand noPNPClass— and it takes the entire inventory down:Copying the three values while enumerating and sorting the copies (the pattern the other
queries in the same file already use) gives
RESULT: OK, components detected = 20fromthe same call at the same moment.
4. A throttled release check becomes an error entry (
ApplicationUpdateService.cs,ApplicationUpdateWatcher.cs)EnsureSuccessStatusCode()turned a502from the releases API into an ERROR line inthe log users are asked to send. Returning an empty
ApplicationUpdateCheckinsteadwould be wrong — the watcher publishes
.Update, so a transient failure would clear a"Update to 1.12.0" that a successful check had already found.
CheckAsyncnow returnsApplicationUpdateCheck?, withnullmeaning "this round said nothing", which is whatboth call sites already did on the exception path; the log line drops to INFO.
Two more sensors the firmware already exposes: memory temperature and fan duty
5.
HardwareSensors.cs,DiagnosticsService.cs— what the EC answers that we were not askingI decompiled this machine's ACPI tables (
acpidump -b+iasl -d, read-only) because"no interface exists" was doing a lot of work in my diagnosis.
OemWMIfun's 64-byte inputturns out to be
byte[0] = main function, byte[1] = sub function, byte[2] = index, and theout[0] = 1we both treat as "BIOS refused" is the AMLDefaultbranch — the EC never sawthose reads. Two consequences the app can use today:
GTMP (
0x0202) has a memory zone. The switch over the index byte namesCDTS(CPU,0x00),DDRS(memory,0x0B) andBTND(battery,0x0E) among others. On this machine0x0Bis the sensor the right fan actually ramps for — it is what explains a fan risingwhile the CPU line looks flat — so the tooltip now carries it next to the battery
temperature. Measured 45–49 °C idle, 53–59 °C during the event that opened this report.
GCFD (function 4 / sub
0x17) returns the PWM duty each fan is being driven with, andit is ungated. Calibrating it against the tachometer, 319 one-second samples:
That rewrites the conclusion of §1: the highest speed this machine ever reported, 3303 RPM,
is ~45% duty, not the fan's ceiling — the EC was never asked for more. And it separates two
things the speed line alone cannot:
The left fan reports 94–117 RPM all day while its duty says 97–100%. Which of the two is
lying is still open on this unit — but with both on screen, "the fan stopped" and "this
model's speed readout is broken" are no longer the same tooltip, and the duty stays valid
in the exact refresh where the median of speeds correctly refuses to guess. Both readings
are appended to the snapshot, so a snapshot written by an older build still parses with the
new sensors unknown rather than dropping every hardware line.
The 127-character budget from §2 still holds with both additions: Chinese measures 111
characters live, and rebuilding the same label table gives 115 (compact) / 120 (full
labels) for Russian and 121 for English, so Russian users land on the short-label variant.
6.
HonorWmi.cs— read and write paths could pick different WMI instancesGetInstance()tookFirstOrDefault()out ofroot\wmi\OemWMIMethod, while the privilegedwrite path prefers the
HWMI_0instance, so the two could otherwise disagree about whichdevice they were talking to. The read path now pins
HWMI_0and only falls back to thefirst instance if it is missing. Both instances answered identically on this machine, so
this is consistency rather than a reproduced defect.
Not included
TouchpadVendorLink.SupportedDevicesdoes not contain this machine's pad, so theTouchpad menu is hidden here. The device is
ACPI\BLTP785=347D:7853, and itsvendor collection passes every other test in
FindDeviceCore(
UsagePage 0xFF00,Usage 0x0001,OutputReportLength 33). I deliberately did notadd it: I never sent a vendor report to the pad, so I cannot confirm haptics and edge
gestures actually respond on this model. Filed separately.
How to verify
dotnet build -c Release— 0 warnings, 0 errors on .NET 10.0 SDK.Behaviour was checked with four small harnesses (reflection over the shipped private
members, so nothing in the app had to be made public for testing): alternating
stock/patched
--read-sensorsrounds against rawOemWMIfunprobes for the fan series,DiagnosticsService.BuildCompactToolTip()per culture for the character counts, andDriverUpdateService.ReadInstalledComponents()before and after.