[Nut-upsdev] Changes to usbhid-ups driver

Arjen de Korte nut+devel at de-korte.org
Tue Sep 4 18:26:25 UTC 2007

Peter Selinger wrote:

>>> The Belkin device gives its serial number in both places. The one in
>>> UPS.PowerSummary.iSerialNumber is strictly for the convenience of
>>> being able to display the serial number with upsc. It's not necessary
>>> for matching.
>> In that case, the better option would be in the HID-to-NUT translation
>> table for Belkin, like
>> { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s",
>> HU_FLAG_OK, stringid_conversion },
> I just checked again, and it turns out that I misspoke. My Belkin
> device shows the serial number only in UPS.PowerSummary.iSerialNumber,
> and *not* in (usb_device *)descriptor.iSerialNumber, which is exactly
> what you originally said. Sorry for that. -- Peter

In that case, the 'matching = delayed' is just what you want. That will
initially match only on the subdriver_matcher (ie, VendorID and
ProductID), then read and parse the report descriptor, apply the vendor
specific formatting and only then do the regex and exact matching. It
will also check if all commands and variables are still available as a
bonus (we need that, since all pointers for the HID-to-NUT translation
will be changed because of parsing a new report descriptor).

I just applied the patch (r1087) to make this effective (ie, let the
belkin_format_serial() function modify hd->Serial, instead of just
returning a pointer to the serial number). Is the same valid for the
(usb_device *)descriptor.iManufacturer and (usb_device
*)descriptor.iProduct by the way? There is no reason why we couldn't do
the same for belkin_format_mfr() and belkin_format_model(), if that is

Best regards, Arjen

More information about the Nut-upsdev mailing list