SENSOR_ATTACH(9)
πΈ NAME πΈ
okay bestie, this is SENSOR_ATTACH(9) from the Kernel Developer's Manual, and it's literally the whole sensors framework vibe. π
The stars of the show are:
sensor_attachsensor_detachsensor_findsensordev_installsensordev_deinstallsensordev_getsensor_task_registersensor_task_unregister
They're all part of the sensors framework, no cap. β¨
β¨ SYNOPSIS β¨
#include <sys/sensors.h>
void
sensordev_install(struct ksensordev *sensdev);
void
sensordev_deinstall(struct ksensordev *sensdev);
struct ksensordev *
sensordev_get(int devnum);
void
sensor_attach(struct ksensordev *sensdev, struct ksensor *sens);
void
sensor_detach(struct ksensordev *sensdev, struct ksensor *sens);
struct ksensor *
sensor_find(int devnum, enum sensor_type stype, int numt);
struct sensor_task *
sensor_task_register(void *arg, void (*func)(void *), int period);
void
sensor_task_unregister(struct sensor_task *st);
π DESCRIPTION π
okay so the sensors framework API is the whole mechanism for manipulating hardware sensors that live under the hw.sensors sysctl(8) tree. iconic. π
sensor_attach()β adds the sensor specified by thesensargument to the sensor device specified by thesensdevargument.sensor_detach()can be used to remove sensors previously added bysensor_attach(). bestie, it's giving add-and-remove energy. π¦sensordev_install()β registers the sensor device specified by thesensdevargument so that all sensors attached to the device become accessible via thesysctlinterface.sensordev_deinstall()can be used to remove sensor devices previously registered bysensordev_install(). πsensordev_get()β takes ordinal numberdevnumspecifying a sensor device and returns a pointer to the correspondingstruct ksensordev, orNULLif no such sensor device exists. lowkey straightforward, highkey useful. πsensor_find()β takes ordinal numberdevnumspecifying a sensor device, sensor typestype, and ordinal number of sensor of such typenumt, and returns a pointer to the correspondingstruct ksensor, orNULLif no such sensor exists. also,sensor_find()will always returnNULLif the corresponding sensor devices are not registered bysensordev_install(). periodt. β
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. no stress, just driver duties. π§
sensor_task_register()β used to register a periodic task to update sensors. thefuncargument is a pointer to the function to run with an interval ofperiodseconds. theargparameter is the argument given to thefuncfunction. obsessed with a scheduled little task. πsensor_task_unregister()β ensures that the task specified by thestargument is no longer running, and then removes it from the queue. bye bestie, you're off the queue. π
β οΈ real talk: all the functions in the sensor framework must be called during autoconf(9) or from a process context.
π and sensor_task_unregister() must not be called from the sensor task that it is about to remove. not me warning you twice, but like, don't do it.
π SEE ALSO π
π 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. Constantine A. Murenin <cnst+openbsd@bugmail.mojo.ru> extended it even further by introducing the concept of sensor devices in OpenBSD 4.1. literal glow-up history. π
π and that's the whole page, bestie β source/version is Debian, the date is September 14, 2015, and this is SENSOR_ATTACH(9). slay. π
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 2006 Michael Knudsen <mk@openbsd.org>
- Copyright (c) 2006 Constantine A. Murenin <cnst+openbsd@bugmail.mojo.ru>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms