Jon Burgess
2010-Mar-19 21:21 UTC
[Nut-upsdev] usbhid-ups fails with Belkin F6C120-UNV in nut-2.4.3
I recently upgraded from nut-2.4.1 to 2.4.3 and my UPS stopped working. usbhid-ups now fails two communicate with the UPS: With 2.4.1: # /sbin/usbhid-ups -D -a auto Network UPS Tools - Generic HID driver 0.34 (2.4.1) USB communication driver 0.31 debug level is '1' upsdrv_initups... Using subdriver: Belkin HID 0.12 Path: UPS.BELKINConfig.BELKINConfigVoltage, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8, Value: 230.000000 Path: UPS.BELKINConfig.BELKINConfigFrequency, Type: Feature, ReportID: 0x02, Offset: 0, Size: 8, Value: 50.000000 Path: UPS.BELKINConfig.BELKINConfigApparentPower, Type: Feature, ReportID: 0x03, Offset: 0, Size: 16, Value: 1200.000000 Path: UPS.BELKINConfig.BELKINConfigBatteryVoltage, Type: Feature, ReportID: 0x04, Offset: 0, Size: 16, Value: 24.000000 Path: UPS.BELKINConfig.BELKINConfigOverloadTransfer, Type: Feature, ReportID: 0x05, Offset: 0, Size: 8, Value: 100.000000 ... With 2.4.3: # /sbin/usbhid-ups -D -a auto Network UPS Tools - Generic HID driver 0.34 (2.4.3) USB communication driver 0.31 0.000000 debug level is '1' 0.001172 upsdrv_initups... 0.279899 Using subdriver: Belkin HID 0.12 0.284577 libusb_get_report: No error 0.284609 Can't retrieve Report 01: Operation not permitted 0.284628 Path: UPS.BELKINConfig.BELKINConfigVoltage, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8 0.289575 libusb_get_report: No error 0.289590 Can't retrieve Report 02: Operation not permitted 0.289602 Path: UPS.BELKINConfig.BELKINConfigFrequency, Type: Feature, ReportID: 0x02, Offset: 0, Size: 8 0.294574 libusb_get_report: No error 0.294589 Can't retrieve Report 03: Operation not permitted 0.294601 Path: UPS.BELKINConfig.BELKINConfigApparentPower, Type: Feature, ReportID: 0x03, Offset: 0, Size: 16 0.299576 libusb_get_report: No error .. The change in SVN r2098 triggers the problem. By looking at the usbmon output I see that this device fails to respond to the get_report requests when the request size is 512 bytes. The requests worked correctly when they were using the sizes reported by the device: usbmon get_report() requests from nut-2.4.1 The length of each request matches the response from the device and works: ffff880102d5ec00 1618372802 S Ci:7:002:0 s a1 01 0301 0000 0002 2 < ffff880102d5ec00 1618376440 C Ci:7:002:0 0 2 = 01e6 ffff880102d5ec00 1618376497 S Ci:7:002:0 s a1 01 0302 0000 0002 2 < ffff880102d5ec00 1618381439 C Ci:7:002:0 0 2 = 0232 ffff880102d5ec00 1618381469 S Ci:7:002:0 s a1 01 0303 0000 0003 3 < ffff880102d5ec00 1618385439 C Ci:7:002:0 0 3 = 03b004 ffff880102d5ec00 1618385469 S Ci:7:002:0 s a1 01 0304 0000 0003 3 < ffff880102d5ec00 1618389440 C Ci:7:002:0 0 3 = 041800 usbmon get_report() requests from nut-2.4.3 Now the code always requests 512 bytes and never gets back any data: ffff88002b799d80 593626443 S Ci:7:002:0 s a1 01 0301 0000 0200 512 < ffff88002b799d80 593631086 C Ci:7:002:0 0 0 ffff88002b799d80 593631161 S Ci:7:002:0 s a1 01 0302 0000 0200 512 < ffff88002b799d80 593636087 C Ci:7:002:0 0 0 ffff88002b799d80 593636142 S Ci:7:002:0 s a1 01 0303 0000 0200 512 < ffff88002b799d80 593641085 C Ci:7:002:0 0 0 ffff88002b799d80 593641136 S Ci:7:002:0 s a1 01 0304 0000 0200 512 < ffff88002b799d80 593646085 C Ci:7:002:0 0 0 I can workaround this by using the attached patch. Each of the failed 512 byte reads triggers a superfluous log message as below but at least it works. $ sudo ./drivers/usbhid-ups -D -a auto Network UPS Tools - Generic HID driver 0.34 (2.4.3) USB communication driver 0.31 0.000000 debug level is '1' 0.000652 upsdrv_initups... 0.277074 Using subdriver: Belkin HID 0.12 0.281742 libusb_get_report: No error 0.285758 Path: UPS.BELKINConfig.BELKINConfigVoltage, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8, Value: 230.000000 0.290742 libusb_get_report: No error 0.294749 Path: UPS.BELKINConfig.BELKINConfigFrequency, Type: Feature, ReportID: 0x02, Offset: 0, Size: 8, Value: 50.000000 0.299745 libusb_get_report: No error 0.303753 Path: UPS.BELKINConfig.BELKINConfigApparentPower, Type: Feature, ReportID: 0x03, Offset: 0, Size: 16, Value: 1200.000000 0.308744 libusb_get_report: No error 0.312755 Path: UPS.BELKINConfig.BELKINConfigBatteryVoltage, Type: Feature, ReportID: 0x04, Offset: 0, Size: 16, Value: 24.000000 Jon -------------- next part -------------- A non-text attachment was scrubbed... Name: belkin-fix.patch Type: text/x-patch Size: 398 bytes Desc: not available URL: <http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20100319/69e18ffb/attachment.bin>
Arjen de Korte
2010-Mar-20 18:27 UTC
[Nut-upsdev] usbhid-ups fails with Belkin F6C120-UNV in nut-2.4.3
Citeren Jon Burgess <jburgess777 op googlemail.com>:> The change in SVN r2098 triggers the problem. By looking at the usbmon > output I see that this device fails to respond to the get_report > requests when the request size is 512 bytes.Thanks for reporting this. Can you try if fixing the size to 8 bytes (instead of SMALLBUF) helps? You may wish to change both of the following lines in in 'drivers/libhid.c': 144 unsigned char buf[8]; 472 unsigned char buf[8]; I vaguely remember that you can't read more than 8 bytes in a single operation, but I don't recall if this is a Belkin specific limitation or depends on the libusb version used. Note that the logic that attempted to calculate the size of reports is flawed in earlier versions. Devices that would report more than the calculated size would find that these reports would be ignored completely. This isn't good either. Best regards, Arjen -- Please keep list traffic on the list