[Nut-upsdev] usbhid-ups bug

Arjen de Korte nut+devel at de-korte.org
Sat Jan 12 10:07:11 UTC 2008


> Symptom: when connecting to an APC Back-UPS 500, everything works fine
> until r1209; from r1210, I get lots of error messages such as
>
> Can't retrieve Report 22: Value too large for defined data type
> HIDGetDataValue: Value too large for defined data type

Ouch, you don't have to go any further, I found the mistake. The
'placeholder' reports shouldn't be removed at the place they are removed
now, since they are used to calculate the lenght of the full report (the
last part of Parse_ReportDesc() in 'drivers/hidparser.c'). If (like in
your case) they make up the remainder of a report (and nothing useful is
after them), it will effectively trim the length of the report to the used
data only. This is wrong, since we won't allocate enough room in the
report buffer then, which will cause the failures you're seeing.

> For reference, attached are five files:
>
> r1209 and r1210: respective output of '/usr/bin/usbhid-ups -DD -a apc'
> u1209 and u1210: respective output of 'upsc apc'
> descriptor-apc.hex: the APC's report descriptor dump
>
> Further notes: it seems (see r1209) that
> UPS.PowerSummary.PresentStatus.00000000
>
> is indeed something meaningful for the APC driver. I am not sure
> why. It holds the status info. Comparing the outputs of "upsc", r1210
> wrongly thinks the device is on battery.

If we miscalculate the lenght of the reports (which r1210 will cause), you
can expect all kinds of problems. Thanks to your detailed problem
analysis, this won't be difficult to fix.

Best regards, Arjen
-- 
Eindhoven - The Netherlands
Key fingerprint - 66 4E 03 2C 9D B5 CB 9B  7A FE 7E C1 EE 88 BC 57




More information about the Nut-upsdev mailing list