It also lacks SENSOR_UNUSEDFEATURES. No.
Paul de Weerd <[email protected]> wrote: > Hi all, > > While browsing sensorsd.c for inspiration for a small project I'm > working on, I noticed that both src/usr.sbin/sensorsd/sensorsd.c and > src/sbin/sysctl/sysctl.c have a 'print_sensor' function that > returns/prints the value of the given sensor, including unit. > > However, sensorsd doesn't handle sensors with type SENSOR_OHMS or > SENSOR_ENERGY. That doesn't seem right. Below is a diff that adds > support for these types of sensors to sensorsd(8), using the same > format string as the print_sensor in sysctl(8). > > I'm not sure if these kinds of sensors even exist (I don't have > them), so I've not been able to test this outside of compiling the > program and seeing that it starts normally. > > Cheers, > > Paul > > Index: sensorsd.c > =================================================================== > RCS file: /home/OpenBSD/cvs/src/usr.sbin/sensorsd/sensorsd.c,v > retrieving revision 1.67 > diff -u -p -r1.67 sensorsd.c > --- sensorsd.c 22 Jul 2020 15:33:49 -0000 1.67 > +++ sensorsd.c 21 Sep 2020 21:37:24 -0000 > @@ -654,6 +654,9 @@ print_sensor(enum sensor_type type, int6 > case SENSOR_VOLTS_AC: > snprintf(fbuf, RFBUFSIZ, "%.2f V AC", value / 1000000.0); > break; > + case SENSOR_OHMS: > + snprintf(fbuf, RFBUFSIZ, "%lld ohm", value); > + break; > case SENSOR_WATTS: > snprintf(fbuf, RFBUFSIZ, "%.2f W", value / 1000000.0); > break; > @@ -707,6 +710,9 @@ print_sensor(enum sensor_type type, int6 > break; > case SENSOR_VELOCITY: > snprintf(fbuf, RFBUFSIZ, "%4.3f m/s", value / 1000000.0); > + break; > + case SENSOR_ENERGY: > + snprintf(fbuf, RFBUFSIZ, "%.2f J", value / 1000000000.0); > break; > default: > snprintf(fbuf, RFBUFSIZ, "%lld ???", value); > > -- > >++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+ > +++++++++++>-]<.>++[<------------>-]<+.--------------.[-] > http://www.weirdnet.nl/ >
