[Nut-upsdev] Re: about [ #302111 ] newhidups support for Belkin

Peter Selinger selinger at mathstat.dal.ca
Tue Sep 13 21:25:45 UTC 2005


I have checked in a cleaned-up version of patch #302111 (Belkin
support) into CVS. See

 cvs diff -uN -r before_PSE_2 -r after_PSE_2

to check the difference. Here is the CHANGES entry:

Tue Sep 13 20:50:14 UTC 2005 / Peter Selinger <selinger at users.sourceforge.net>

 - newhidups: added Belkin support. Also added some new variables and
   instant commands (some of these were already used by other
   drivers); see new-names.txt.

 - newhidups: fixed return value bug in libusb.c:libusb_open() when no
   device was found.

Please let me know if there's anything you don't like. 

Notes: 

* I documented the new variables and instant commands in
  new-names.txt. Some of them already existed in other drivers, but
  had not yet been documented.

* One exception is the variable ups.serial.internal, which should not
  really exist. The information contained in that variable should
  normally be in ups.serial. The problem is that the Belkin UPS does
  not announce its serial number in the device descriptor (like a good
  HID device should), but in a report. So this info is not available
  at initialization time. So either one needs a specialized function
  for retrieving the Belkin serial number at initialization time, or
  one needs to set the variable ups.serial "after the fact". I could
  not figure out how to do that, so I left the variable
  ups.serial.internal, and a "FIXME" comment, for the time being. 

> - why did you remove the restriction on Belkin ProductID
>  
> (dev->descriptor.idProduct == 0x0551)
> 
> It's not useful for UPS only mfrs, but belkin also sells other devices...

My Belkin UPS has product ID 0x0980. It seems silly to start making a
long list of Belkin UPS products, because every user would have to
email us their product ID before their device could be supported. A
better strategy seems to support all Belkin devices. They do make
non-UPS devices, but I think it's mostly passive devices like power
strips. I don't know if they make any other USB HID devices. I can see
no harm in trying to connect to the first Belkin device we find; if a
user wants to specify a specific device, they can e.g. use my new
regex mechanism.

I am planning to work on modularizing the code for newhidups a bit, so
that there can be specialized policies for different manufacturers.  A
better permanent solution might be to look at the product string (for
Belkin devices only) to determine whether it's a UPS.

> - about your comment in newhidups.h (specifically "there is not file 
> libusb.h"):  
> 
> +/* there is not file libusb.h, so we have to declare this "by hand":
> */+int libusb_get_string(int StringIdx, char *string);
> 
> => if you mean the nut file that should go with libusb.c, then it's 
> hid-usb.h
> (the reason is linked to the old libHID, and it's various backends...)
> => if you mean the header from the libusb project, then it's named usb.h
> and is included in hid-usb.h.

Thanks, I fixed that.

-- Peter



More information about the Nut-upsdev mailing list