Skip to contentSkip to conversation

Question regarding temperature readings

lm-sensors Michael Renzmann 2 participants 3 messages Dec 15, 2005 – Dec 19, 2005

lore
Share & tools
lore
#0 lore raw

Hi all.

Maybe the question sounds a little stupid, but I currently have no good option to reliably find out, so...

Let's assume that one sensor is to report a temperature of 42 degrees celcius. The system is running on 2.4.x. doc/developers/proc (in the latest lm_sensors package) says that temperatures are given as "millidegrees celcius". That would be "42000" then, right?

The reason for asking is that lm77.c (which is the only driver I can use here atm) reports "4200.0" - the value isn't matching what I'd expect (can be fixed easily, though), and the decimal point is a bit irritating.

Did I miss something?

Bye, Mike

#1 lore raw

Hi Michael,

Quoted 7 lines

Maybe the question sounds a little stupid, but I currently have no good option to reliably find out, so...

Let's assume that one sensor is to report a temperature of 42 degrees celcius. The system is running on 2.4.x. doc/developers/proc (in the latest lm_sensors package) says that temperatures are given as "millidegrees celcius". That would be "42000" then, right?

I just checked and doc/developers/proc doesn't say that, which is good because that's not true. Temperatures are reported in millidegrees Celsius in Linux 2.6 (sysfs interface) as integer values. In Linux 2.4 (procfs interface, which is what is documented in lm_sensors), temperatures are reported in degrees Celsius as real values. The number of digits after the decimal point is driver-dependant.

Quoted 6 lines

The reason for asking is that lm77.c (which is the only driver I can use here atm) reports "4200.0" - the value isn't matching what I'd expect (can be fixed easily, though), and the decimal point is a bit irritating.

Did I miss something?

It would be easier to help you with the code.

As the LM77 reports temperature values with a resolution of 0.5 degree Celsius, your driver should declare a magnitude (number of digits after the decimal point) of 1, and should report the temperature values with a LSB representing 0.1 degree Celsius.

The magnitude is returned by the procfs callbacks when operation = SENSORS_PROC_REAL_INFO. The temperature value is returned for operation = SENSORS_PROC_REAL_READ. Take a look at function lm75_temp in the lm75 driver for an example. The lm77 case should be very similar. If the driver currently reports 4200.0 for 42 degrees, it means that the magnitude is properly set to 1, but the temperature value has been multiplied by 500 (from the register value) instead of 5.

Signature · 1 line
Jean Delvare
#2 lore raw
In reply to Michael Renzmann

Hi.

Quoted 2 lines · Jean Delvare

I just checked and doc/developers/proc doesn't say that, which is good because that's not true.

Hmm, indeed, seems that I mixed up something here. Maybe I shouldn't report things like that after working for 14+ hours. :( Sorry for the confusion that might have caused.

Quoted 4 lines

As the LM77 reports temperature values with a resolution of 0.5 degree Celsius, your driver should declare a magnitude (number of digits after the decimal point) of 1, and should report the temperature values with a LSB representing 0.1 degree Celsius.

After having a closer look how the LM87 does these things (and after enabling that sensor on a second box I have at hands for testing purposes) I got that working now. With this and your comments in mind it ended up to be an issue of "RTFM" - I somehow missed to check the meaning of SENSORS_PROC_REAL_INFO, which would have cleared up a lot.

Quoted 4 lines

lm75 driver for an example. The lm77 case should be very similar. If the driver currently reports 4200.0 for 42 degrees, it means that the magnitude is properly set to 1, but the temperature value has been multiplied by 500 (from the register value) instead of 5.

Yeah, that was exactly the kind of problem I was facing. Thanks a lot for your comments on that and for the patience to explain it rather than giving the "RTFM" I'd deserve :)

Bye, Mike