On 27/02/20(Thu) 16:58, [email protected] wrote:
> >Synopsis:    boolean indicators in sensorsd.conf(5) are too cumbersome
> >Category:    system
> >Environment:
>       System      : OpenBSD 6.6
>       Details     : OpenBSD 6.6 (GENERIC.MP) #372: Sat Oct 12 10:56:27 MDT 
> 2019
>                        
> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> 
>       Architecture: OpenBSD.amd64
>       Machine     : amd64
> >Description:
>       Some upd(4) devices use -1 for "On" and some use 1.  sysctl(8) and senso
> rsd(8) hide this detail from the user, which makes it difficult to define low 
> an
> d high values in sensorsd.conf(5).

Which device reports "-1" for which usage?  Is this from any
specification or is it a workaround for your device? 

Diff looks fine, although we could do simpler, see below.

Index: upd.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/upd.c,v
retrieving revision 1.26
diff -u -p -r1.26 upd.c
--- upd.c       8 Apr 2017 02:57:25 -0000       1.26
+++ upd.c       27 Feb 2020 16:25:24 -0000
@@ -425,7 +425,10 @@ upd_sensor_update(struct upd_softc *sc, 
        }
 
        hdata = hid_get_data(buf, len, &sensor->hitem.loc);
-       sensor->ksensor.value = hdata * adjust;
+       if (sensor->ksensor.type == SENSOR_INDICATOR)
+               sensor->ksensor.value = hdata ? 1 : 0;
+       else
+               sensor->ksensor.value = hdata * adjust;
        sensor->ksensor.status = SENSOR_S_OK;
        sensor->ksensor.flags &= ~SENSOR_FINVALID;
 

Reply via email to