[Bug 284338] x11/sfwbar: cpu-temp.widget shows wrong temperature in FreeBSD

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 25 Jan 2025 13:25:30 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284338

            Bug ID: 284338
           Summary: x11/sfwbar: cpu-temp.widget shows wrong temperature in
                    FreeBSD
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: fabio.comolli@gmail.com
                CC: tino.engel@mail.de
                CC: tino.engel@mail.de
             Flags: maintainer-feedback?(tino.engel@mail.de)

x11/sfwbar cpu-temp.widget uses cpu-temp.source to assign a value to
BsdCpuTemp, using BSDCtl("dev.cpu.0.temperature"). This function gets the vaule
in HEX and then converts it in DEC. The widget assumes that this value is in °C
and expressed with four digits without decimals, therefore it prints:

  value = Str(XCpuTemp/1000,0)+"C"

This is wrong as the sysctl HEX value is expressed in deciKelvin and thus to
convert it to Celsius you need to divide the value by 10 and subtract 273.15 .
Something like:

  value = Str(XCpuTemp/10-273.15)+"C"

I think that there's also another bug, this time in cpu-temp.source : the line 

  set XCpuTemp = If(!Ident(BSDCtl),CPUTemp,Val(BsdCPUTemp))

should read as:

  set XCpuTemp = If(!Ident(BSDCtl),CPUTemp,BsdCPUTemp)

otherwise the temperature value will always be reported as zero.

-- 
You are receiving this mail because:
You are the assignee for the bug.