SENSOR_ATTACH(9)

πŸ“¦ in nixpkgs unstable

🌸 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_attach
  • sensor_detach
  • sensor_find
  • sensordev_install
  • sensordev_deinstall
  • sensordev_get
  • sensor_task_register
  • sensor_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 the sens argument to the sensor device specified by the sensdev argument. sensor_detach() can be used to remove sensors previously added by sensor_attach(). bestie, it's giving add-and-remove energy. πŸ¦‹
  • sensordev_install() β€” registers the sensor device specified by the sensdev argument so that all sensors attached to the device become accessible via the sysctl interface. sensordev_deinstall() can be used to remove sensor devices previously registered by sensordev_install(). πŸ’–
  • sensordev_get() β€” takes ordinal number devnum specifying a sensor device and returns a pointer to the corresponding struct ksensordev, or NULL if no such sensor device exists. lowkey straightforward, highkey useful. 😌
  • sensor_find() β€” takes ordinal number devnum specifying a sensor device, sensor type stype, and ordinal number of sensor of such type numt, and returns a pointer to the corresponding struct ksensor, or NULL if no such sensor exists. also, sensor_find() will always return NULL if the corresponding sensor devices are not registered by sensordev_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. the func argument is a pointer to the function to run with an interval of period seconds. the arg parameter is the argument given to the func function. obsessed with a scheduled little task. πŸ“
  • sensor_task_unregister() β€” ensures that the task specified by the st argument 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms