Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jul 2010 22:17:01 +0200
From:      Andreas Tobler <andreast-list@fgznet.ch>
To:        freebsd-hackers@freebsd.org
Subject:   sysctl question
Message-ID:  <4C3B783D.5050200@fgznet.ch>

next in thread | raw e-mail | index | archive | help
Dear all,

I have an issue here, I do read a temperature sensor and I got a value 
back, in integer. This value is 'encoded', it contains the integer and 
the fractional part of the temperature I read.

This is inside a kernel module. I offer a sysctl interface to read this 
value. Currently the access is done with sysctl_handle_int.

In my userland application I can print this value with the following macro:

FIX32TOPRINT(f) ((f) >> 16),((((f) & 0xffff) * 1000) >> 16)

But now I wonder how can I teach the sysctl to print my tempreature the 
same way as my userland app does.

Right now it looks this way:
dev.sm.1.sensor.cpu_b_ad7417_amb.temp: 2736128

If I feed this 2736128 into the macro above I get this:

41.750 this is what I expect.

Is this even possible?

TIA for any pointer.

Andreas



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C3B783D.5050200>