SENSOR_ADD(9)                OpenBSD Kernel Manual               SENSOR_ADD(9)

NAME
     sensor_add, sensor_del, sensor_get, sensor_task_register,
     sensor_task_unregister - sensor framework

SYNOPSIS
     #include <sys/sensors.h>

     void
     sensor_add(struct sensor *sens);

     void
     sensor_del(struct sensor *sens);

     struct sensor
     *sensor_get(int num);

     int
     sensor_task_register(void *arg, void (*func)(void *), int period);

     void
     sensor_task_unregister(void *arg);

DESCRIPTION
     The sensor framework API provides a mechanism to manipulate the sensor
     framework available under the hw.sensors sysctl(8).

     sensor_add() adds a sensor specified by the sens argument.  sensor_del()
     removes a sensor previously added by sensor_add().  Both sensor_add() and
     sensor_del() take an argument of a pointer to a struct sensor, defined in
     <sys/sensors.h>, as:

     struct sensor {
             SLIST_ENTRY(sensor) list;
             int num;                        /* sensor number */
             char device[16];                /* device name */
             enum sensor_type type;          /* sensor type */
             char desc[32];                  /* sensor description */
             int64_t value;                  /* current value */
             u_int rfact;                    /* resistor factor */
             enum sensor_status status;      /* sensor status */
             int flags;                      /* sensor flags */
             struct timeval tv;              /* sensor value last change time */
     };

     sensor_get() takes an index parameter and returns a pointer to the corre-
     sponding struct sensor, or NULL if no such sensor exists.

     Drivers are responsible for retrieving, interpreting, and normalising
     sensor values and updating the sensor struct periodically.  If the driver
     needs process context, for example to sleep, it can register a task with
     the sensor framework.

     sensor_task_register() is used to register a periodic task to update sen-
     sors.  The func argument is a pointer to the function to run with an in-
     terval of period seconds.  The arg parameter is the argument given to the
     func function.  The sensor_task_unregister() removes all tasks previously
     registered with sensor_task_register() with an argument of arg.

SEE ALSO
     sysctl(8)

HISTORY
     The sensor framework was written by Alexander Yurchenko
     <grange@openbsd.org> and first appeared in OpenBSD 3.4.  David Gwynne
     <dlg@openbsd.org> later extended it for OpenBSD 3.8.

OpenBSD 4.0                     April 23, 2006                               2
