[Nut-upsdev] belkin-hid:

Arjen de Korte nut+devel at de-korte.org
Wed Aug 1 06:59:41 UTC 2007


> I am confused by the question of how best to compute NUT's OL
> flag. You argue that ACPresent is more accurately than inverting
> Discharging. I thought that NUT has three mutually exclusive states,
> of which at least one applies at any give time:
>
> OL - the load is powered by wall power
> OB - the load is powered by battery
> OFF - the load is not powered

Giving the fact that nowadays many UPSes have multiple switched outputs,
the OFF status is probably too course to be of much value. I think that
applications that need this, better look at the 'outlet.n.status' values.
Short of the fact that this probably doesn't belong in the 'ups.status'
anyway, since it doesn't require immediate action from clients (if they
are powered by the UPS in question, they probably never see it).

> In this case, during a battery test, the status should be OB,
> regardless of whether AC is present or not, because the status is
> about how the load is powered. So inverting the "discharging" bit
> seems the more correct thing.

No. See below.

> However, all the other usbhid-ups subdrivers map ACPresent to OL. This
> is probably how it got duplicated in the belkin subdriver. Is this a bug?
>
> Moreover, the OFF flag is not computed correctly by the belkin-hid
> subdriver at the moment. Correct would be:
>
> OL  = (reg22 & 0x0021) == 0x0000
> OB  = (reg22 & 0x0021) == 0x0001
> OFF = (reg22 & 0x0021) == 0x0020
>
> The remaining case, (reg22 & 0x0021) == 0x0021, is presumably
> inconsistent and could be mapped to OB or OFF.
>
> Is my reasoning correct?

It is, but it is not what clients are expecting. :-)

Let me explain. Usually, if you perform a deep discharge test, you'd drain
the batteries to the level where the low battery indicator hits. If we
would indeed indicate 'OB' when running a battery test, it means that at
that time, we would show 'OB LB'. Oops. If clients are looking over our
shoulders, they might determine that it is time to shutdown at that time,
if we're not quick enough to switch back to mains. I actually have a UPS
that takes a couple of seconds to do that and indeed, the system rebooted
at the end of a battery test until I masked this state out (which is not
pretty either). Also, any 'upssched' that may be running (for people that
shed part of the load if the systems are running on battery for a fixed
time interval to maximize runtime or in case of shutdown sequences longer
than the runtime available when the battery is low) might initiate a
shutdown sequence if we would indicate 'OB' during battery tests.

For the above reasons, during battery tests you should never show the 'OB'
indication (although the load is powered by the inverter), but rather the
'OL' (to indicate the mains is present) status. The documentation we
presently have is not very clear in this respect. I propose to change this
and make clear that clients expect this to be an indication of the line
status. So for systems that have an ACPresent indication should preferably
be

    OL = ACPresent
    OB = !ACPresent

Best regards, Arjen




More information about the Nut-upsdev mailing list