Hi all,
I'm trying to read temperature sensor values from my ugold(4) device.
Seems to work alright (I get the same temperature reading as sysctl(8)
returns for the sensor), but the 'sensor value last change time'
doesn't seem to be updated.
[weerd@pom] $ cat sensor_last_change.c
#include <stdio.h>
#include <sys/time.h>
#include <sys/sensors.h>
#include <sys/sysctl.h>
int
main()
{
int mib[5];
size_t sensorlen;
struct sensor sensor;
mib[0] = CTL_HW;
mib[1] = HW_SENSORS;
mib[2] = 3; /* ugold0 on my machine */
mib[3] = SENSOR_TEMP;
mib[4] = 0;
sensorlen = sizeof(sensor);
sysctl(mib, 5, &sensor, &sensorlen, NULL, 0);
printf("%lld.%06ld: %.2f\n",
sensor.tv.tv_sec,
sensor.tv.tv_usec,
((sensor.value-273150000)/1000000.0));
return 0;
}
[weerd@pom] $ make sensor_last_change
cc -O2 -pipe -MD -MP -o sensor_last_change sensor_last_change.c
[weerd@pom] $ ./sensor_last_change
0.000000: 32.32
[weerd@pom] $ sysctl -n hw.sensors.ugold0.temp0
32.32 degC (inner)
The 'tv' member of struct sensor seems to always be 0.0. Am I doing
something wrong?
Cluesticks very welcome...
Thanks,
Paul
--
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.weirdnet.nl/