[Nut-upsdev] usbhidparser requirements to fix CyberPower OutputVoltage issue.

Dave Williams dave at opensourcesolutions.co.uk
Tue Nov 16 15:54:32 GMT 2021


I would welcome a little assistance. I am debugging the issue affecting
CyberPower CP*PFCLCD devices as per
https://github.com/networkupstools/nut/issues/439 and others.


The parser HIDParse() in drivers/hidparser.c appears to terminate
processing of a HID report when an INPUT, OUTPUT, or FEATURE item is
encountered (or the data expires) and then saves it for later recall
with a memcpy().

In the case of the CyberPower HID the FEATURE item that is the normal
trigger is half way through the reports which means that any subsequent
items are not associated with the correct HID report. Worse still any
unprocessed items from the preceding report are used instead.

Here is an excerpt (from a CP900EPFCLCD) as an example:

        Report ID (16),
...
        Usage (54h),
        Logical Minimum (260),
        Logical Maximum (270),
        Feature (Variable, No Preferred, Volatile),
        Usage (54h),
        Input (Constant, Variable, No Preferred),
    End Collection,
    Usage (1Ch),
    Collection (Physical),
        Report ID (18),
        Usage (30h),
        Feature (Constant, Variable, No Preferred, Volatile),
        Report Size (8),
        Logical Minimum (0),
        Logical Maximum (255)

LogMin and LogMax items from Report ID 16 (with values 260 and 270) are
associated with reportID 18 not values 0 and 255 as should be the case.

This results in the erroneous behaviour raised in the GitHub issue.

The question is "What are the assumptions or requirements of the Parser
and the HID data that the code supports or should support?"

I understand this may or may not be consistent with the USB Usage Tables for
Power Devices spec but without having any real examples of vendor usb HID's
available it is not possible to work out how to proceed to develop a solution
that doesn't break support for other devices.

Have I missed something? - As it stands it doesnt seem like a reliable way of
delimiting each report.

Thanks
Dave



More information about the Nut-upsdev mailing list