Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jan 2011 12:50:10 -0800
From:      Matthew Fleming <mdf356@gmail.com>
To:        Harald Servat <redcrash@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Question about sysctl-ing coretemp module values
Message-ID:  <AANLkTimqBHg2tx7gY_Ly4fP4vxZX=GYwe8gCytSdhBe9@mail.gmail.com>
In-Reply-To: <AANLkTi=eTpy%2BTkbXJy_sCgtPHAV8qd%2BgB=FabWc=d6vu@mail.gmail.com>
References:  <AANLkTi=eTpy%2BTkbXJy_sCgtPHAV8qd%2BgB=FabWc=d6vu@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jan 15, 2011 at 12:09 PM, Harald Servat <redcrash@gmail.com> wrote:
> Hello,
>
> =A0First of all, forgive if this is not the appropiate list to ask this.
> Could you point me the correct list if so?
>
> =A0I'm writing a small program to capture the temperature reported by the
> coretemp kernel module. I'm doing this by using the sysctl API. However, =
I'm
> facing a problem when reading that value (dev.cpu.0.temperature, for
> example).
>
> =A0man 3 sysctl has an example (labeled as "To retrieve the standard sear=
ch
> path for the system utilities:") which seems great to me to know the leng=
th
> of the OID it wants to read before running the "real" sysctl. I wrote a
> similar example (attached) based on that, but it does not work appropiate=
ly.
> The 1st call tells me that len =3D 4 (whereas the value for
> dev.cpu.0.temperature is "37.0C" which should be 5 if \0 is not counted).
>
> =A0Can anyone shed some light on what I'm doing wrong?

The list ate your attachment but I think I know what you're misinterpreting=
.

The coretemp sysctl is, if I'm reading the code correctly, returning
the temperature as an int (hence len=3D4) in 10ths of a degree K.  Then
sysctl(8) is printing this as %.1fC, which is where the 37.0C comes
from.  So the sysctl returns an int with some value and then printf
does the conversion.

The coretemp sysctl uses the unconventional "IK" format, meaning that
it's a signed int that should be interpreted as Kelvin.

Cheers,
matthew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimqBHg2tx7gY_Ly4fP4vxZX=GYwe8gCytSdhBe9>