Monitoring the input and output currents reported through upsc for an
OpenUPS device suggests that it is an energy creation device - the
power out is greater than the power into the system once the battery
is fully charged.
Analysis and measurement reveals several issues:
1. "UPS.PowerStatus.Output.Current" is scaled for NUTs "output.current"
value, which should be the output current from the UPS.
However, the value reported for "UPS.PowerStatus.Output.Current" is
not the output from the UPS terminals to the load, but is the
current into the LTC3780 buck-boost converter on the output. The
evidence for this is that with a known constant load, the current
reported is dependent on whether we are using battery voltage or
input voltage, and varies as one would expect if it were reporting
the current supplied to the LTC3780.
2. "UPS.PowerStatus.Input.Current" is scaled for NUTs "input.current"
value, which should be the input current to the UPS.
The value reported for "UPS.PowerStatus.Input.Current" follows and
matches the current supplied to the battery while charging is taking
place, whether bulk charging or floating.
In order to fix these issues, the general principle of switch mode
power conversion is employed:
Power out = Power in * Efficiency (where Efficiency is between 0..1)
The fix for "output.current" involves knowing whether the UPS was
powered from the battery or the input voltage (which is the voltage
fed to the LTC3780), calculating the power into the LTC3780 converter,
and using the above equation to refer it to the output.
Fixing "input.current" requires a similar process, except in reverse.
We calculate the power being supplied into the battery, and refer that
back to the input terminals, remembering to sum the current draw from
the LTC3780.
Add generic facility to override HID report descriptor in usbhid-ups
Some UPSes contain HID report descriptors that fail to correctly
describe the contents of reports. For example, the OpenUPS
descriptor fails to set the units, logical maximum and logical
minimum before the corresponding `main item' as required by the HID
specification.
This commit allows an override HID report descriptor to be given to
usbhid-ups which replaces the one produced by the UPS, allowing the
report descriptors to be properly parsed.
With an appropriately fixed report descriptor, OpenUPS reports correct
battery current (+ve for charging, -ve for discharging.)
Input and Output reports are used for interrupt endpoints rather than
control endpoints. HIDGetItemData() only ever requests feature
report IDs, and requesting non-feature report IDs as feature IDs may
lead to undesirable results and errors.