On 06/17/2011 12:31 AM, Arnaud Quette wrote:
> 2011/6/16 Charles Lepple <clep...@gmail.com>
> 
>> On Jun 15, 2011, at 5:40 PM, n...@johnea.net wrote:
>> (...)
>> Is it consistently disconnecting every 20 seconds? That almost sounds like
>> some proprietary extension to the HID protocol - the UPS expects the
>> computer to send something that only the CyberPower software knows to send.
> 
> 
> in this case, doing an usbsnoop run is the way to go:
> http://lists.alioth.debian.org/pipermail/nut-upsdev/2010-February/004528.html

It seems the usbhid-ups driver already knows how to make the UPS happy. Once the
driver has successfully connected to the UPS, the disconnect/reconnect cycle
stops and the UPS stays connected and communicating from then on.

It only misses connecting if the device is given enough time to disconnect
(presumably because it timed out after 20sec).

Unless the administrator can guarantee to _always_ connect to the device within
20sec of boot, the usbhid-ups needs to delay a second or two and then retry, 2
or 3 times, before giving up on finding the CyberPower subdriver based UPS.

> cheers,
> Arnaud

Thank You Arnaud!

p.s. I tried to make a patch for this, but it failed, attached for reference
--- src/nut-2.6.1/drivers/usbhid-ups.c  2011-05-31 03:36:49.000000000 -0700
+++ usbhid-ups.c        2011-06-17 14:11:30.000000000 -0700
@@ -860,6 +860,7 @@
 void upsdrv_initups(void)
 {
        int ret;
+       int retry;
        char *val;
 #ifdef SHUT_MODE
        /*!
@@ -906,7 +907,15 @@
 
        /* Search for the first supported UPS matching the
           regular expression (USB) or device_path (SHUT) */
-       ret = comm_driver->open(&udev, &curDevice, subdriver_matcher, 
&callback);
+    /* retry HID UPS connection 2011-06-17 -jea */
+    for (retry=0, ret=0; retry<3 && ret<1; retry++) {
+           ret = comm_driver->open(&udev, &curDevice, subdriver_matcher, 
&callback);
+        if (ret < 1) {
+            retry++;
+            upsdebugx(1, "Retry Detection of HID UPS: %d", retry);
+            sleep(1);
+        }
+    }
        if (ret < 1)
                fatalx(EXIT_FAILURE, "No matching HID UPS found");
 
_______________________________________________
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to