networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
1.94k stars 346 forks source link

Wrong input voltage reported for APC Back-UPS XS 1400U #1189

Closed smainz closed 2 years ago

smainz commented 2 years ago

I am trying to set up nut fpr my APC Back-UPS XS 1400U formerly used with apcupsd.

Got almost all working, but nut us reporting wrong input voltage:

$ upsc usv01
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2015/07/02
battery.runtime: 1464
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 27.1
battery.voltage.nominal: 24.0
device.mfr: American Power Conversion
device.model: Back-UPS XS 1400U
device.serial: 3B1527X15613
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.productid: 0002
driver.parameter.synchronous: no
driver.parameter.vendorid: 051d
driver.version: 2.7.4
driver.version.data: APC HID 0.96
driver.version.internal: 0.41
input.sensitivity: medium
input.transfer.high: 280
input.transfer.low: 155
input.voltage: 98.0
input.voltage.nominal: 102
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 926.T1 .I
ups.firmware.aux: T1
ups.load: 17
ups.mfr: American Power Conversion
ups.mfr.date: 2015/07/02
ups.model: Back-UPS XS 1400U
ups.productid: 0002
ups.realpower.nominal: 700
ups.serial: 3B1527X15613
ups.status: OL
ups.test.result: No test initiated
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d

These values are defiitly wrong:

I am in Germany and we have 230V. apcupsd reports the correct values.

OS: Raspbian GNU/Linux 10 (buster) nut version 2.7.4 aken from the official raspbian repositories

Maybe this helps to analyze:

pi@pi:~ $ sudo /lib/nut/usbhid-ups -a usv01 -DDD 2>&1
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
   0.000000     debug level is '3'
   0.008989     upsdrv_initups...
   0.016938     Checking device (051D/0002) (001/004)
   0.057316     - VendorID: 051d
   0.060576     - ProductID: 0002
   0.061877     - Manufacturer: American Power Conversion
   0.062256     - Product: Back-UPS XS 1400U  FW:926.T1 .I USB FW:T1
   0.062934     - Serial Number: 3B1527X15613
   0.064345     - Bus: 001
   0.064827     - Device release number: 0106
   0.065179     Trying to match device
   0.065853     Device matches
   0.067297     failed to claim USB device: could not claim interface 0: Device or resource busy
   0.073446     detached kernel driver from USB device...
   0.074100     nut_usb_set_altinterface: skipped usb_set_altinterface(udev, 0)
   0.076898     HID descriptor, method 1: (9 bytes) => 09 21 10 01 21 01 22 04 04
   0.077695     HID descriptor length (method 1) 1028
   0.078087     HID descriptor, method 2: (9 bytes) => 09 21 10 01 21 01 22 04 04
   0.078439     HID descriptor length (method 2) 1028
   0.079847     HID descriptor length 1028
   0.261963     Report Descriptor size = 1028
   0.262226     Report Descriptor: (1028 bytes) => 05 84 09 04 a1 01 09 24 a1 00 85 01 09
   0.262409      fe 79 01 75 08 95 01 15 00 26 ff 00 b1 22 85 02 09 ff 79 02 b1 22 85 03 05
   0.262580      85 09 89 79 04 b1 22 85 04 09 8f 79 03 b1 22 85 05 09 8b b1 22 85 06 09 44
   0.262751      81 a2 09 44 b1 a2 09 45 81 a2 09 45 b1 a2 06 86 ff 09 60 81 a2 09 60 b1 a2
   0.262923      85 07 05 85 09 85 75 10 27 ff ff 00 00 b1 a2 85 08 05 84 09 40 67 21 d1 f0
   0.263097      00 55 05 b1 22 85 09 09 30 b1 a2 85 0a 09 fd 75 08 26 ff 00 65 00 55 00 79
   0.263263      03 b1 22 85 0b 05 85 09 2c b1 22 85 0c 09 66 25 64 81 a2 09 66 b1 a2 09 68
   0.263432      75 10 27 ff ff 00 00 66 01 10 81 a2 09 68 b1 a2 85 0d 09 83 75 08 25 64 65
   0.263599      00 b1 22 85 0e 09 67 b1 22 85 0f 09 8c b1 22 85 10 09 8e b1 22 85 11 09 29
   0.263815      15 01 b1 a2 85 12 09 8d 15 00 b1 22 85 13 09 d0 25 01 81 a2 09 d0 b1 a2 85
   0.264044      14 09 42 81 a2 09 42 b1 a2 05 84 09 69 81 a2 09 69 b1 a2 85 15 09 57 75 10
   0.264218      16 ff ff 26 ff 7f 66 01 10 b1 a2 09 02 a1 02 85 16 05 85 65 00 75 01 15 00
   0.264389      25 01 09 44 81 a2 09 44 b1 a2 09 45 81 a2 09 45 b1 a2 09 d0 81 a2 09 d0 b1
   0.264654      a2 09 d1 81 a2 09 d1 b1 a2 09 42 81 a2 09 42 b1 a2 05 84 09 69 81 a2 09 69
   0.264835      b1 a2 05 85 09 43 81 a2 09 43 b1 a2 05 84 09 73 81 a2 09 73 b1 a2 05 85 09
   0.265004      4b 81 a2 09 4b b1 a2 05 84 09 65 81 a2 09 65 b1 a2 05 85 09 db 81 a2 09 db
   0.265174      b1 a2 95 15 81 01 b1 01 c0 85 17 09 2a 95 01 75 10 27 ff ff 00 00 66 01 10
   0.265343      b1 a2 85 18 05 84 09 5a 75 08 15 01 25 03 65 00 b1 a2 c0 09 12 a1 00 85 1c
   0.265511      06 86 ff 09 16 75 18 15 00 27 ff ff ff 00 b2 a2 01 85 20 05 85 09 85 75 10
   0.265674      27 ff ff 00 00 b1 a2 85 21 05 84 09 58 75 08 25 06 81 a2 09 58 b1 a2 85 22
   0.265844      05 85 09 66 75 08 25 64 b1 a2 85 23 09 68 75 10 27 ff ff 00 00 66 01 10 b1
   0.266015      a2 85 24 09 2a b1 a2 85 25 05 84 09 40 67 21 d1 f0 00 55 05 b1 22 85 26 09
   0.266184      30 b1 a2 85 27 06 86 ff 09 24 75 08 16 e5 00 26 fe 00 65 00 55 00 b1 a2 85
   0.266355      28 09 18 75 20 17 01 00 00 80 27 ff ff ff 7f b2 a2 01 c0 05 84 09 1a a1 00
   0.266526      85 30 05 84 09 40 75 08 15 4b 26 8c 00 67 21 d1 f0 00 55 07 b1 a2 85 31 09
   0.266692      30 75 10 b1 a2 85 32 09 53 16 96 00 26 a0 00 b1 a2 85 33 09 54 16 18 01 26
   0.266862      18 01 b1 a2 85 34 06 86 ff 09 24 75 08 15 73 26 8d 00 65 00 55 00 b1 a2 85
   0.267033      35 09 61 15 00 25 02 b1 a2 85 36 09 52 25 0d b1 a2 c0 09 05 a1 00 85 40 09
   0.267199      7c 25 01 b1 a2 85 41 09 7d 75 10 16 ff ff 26 ff 7f 66 01 10 b1 a2 85 42 05
   0.267367      84 09 57 b1 a2 c0 09 16 a1 00 85 50 09 35 75 08 15 00 25 64 65 00 b1 a2 85
   0.267534      51 06 86 ff 09 24 15 73 26 8d 00 b1 a2 75 10 15 00 27 ff ff 00 00 66 21 d1
   0.267700      55 07 85 52 05 84 09 44 b1 a2 c0 06 86 ff 09 01 a1 00 85 60 09 23 65 00 55
   0.267866      00 b1 a2 85 61 09 26 75 08 16 8c 00 26 94 00 b1 a2 85 62 09 25 75 20 17 01
   0.268035      00 00 80 27 ff ff ff 7f b2 a2 01 c0 85 7f 05 84 09 fe 79 05 75 08 95 01 15
   0.268205      00 26 ff 00 b1 22 85 7e 06 86 ff 09 42 79 06 b1 22 85 7d 05 84 09 ff 79 02
   0.268376      b1 22 85 7c 09 fd 79 03 b1 22 85 7b 05 85 09 85 75 10 27 ff ff 00 00 b1 a2
   0.268547      05 84 09 02 a1 02 85 7a 05 85 09 44 75 01 25 01 b1 a2 09 45 b1 a2 09 d0 b1
   0.268716      a2 09 d1 b1 a2 09 42 b1 a2 05 84 09 69 b1 a2 05 85 09 43 b1 a2 05 84 09 73
   0.268884      b1 a2 05 85 09 4b b1 a2 05 84 09 65 b1 a2 05 85 09 db b1 a2 95 15 b1 01 c0
   0.269053      85 79 06 86 ff 09 72 75 08 95 01 b1 a2 85 78 05 84 09 5a 15 01 25 03 b1 a2
   0.269223      85 75 06 86 ff 09 29 75 10 15 00 27 ff ff 00 00 b1 a2 85 74 06 86 ff 09 2a
   0.269364      75 20 17 01 00 00 80 27 ff ff ff 7f b1 a2 c0
   0.270168     Using subdriver: APC HID 0.96
   0.270304     104 HID objects found
   0.275060     Report[get]: (2 bytes) => 01 01
   0.279500     Path: UPS.PowerSummary.iProduct, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8, Value: 1
   0.287236     Report[get]: (2 bytes) => 02 02
   0.287748     Path: UPS.PowerSummary.iSerialNumber, Type: Feature, ReportID: 0x02, Offset: 0, Size: 8, Value: 2
   0.291582     Report[get]: (2 bytes) => 03 04
   0.292081     Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, ReportID: 0x03, Offset: 0, Size: 8, Value: 4
   0.295586     Report[get]: (2 bytes) => 04 03
   0.296212     Path: UPS.PowerSummary.iOEMInformation, Type: Feature, ReportID: 0x04, Offset: 0, Size: 8, Value: 3
   0.298582     Report[get]: (2 bytes) => 05 01
   0.299507     Path: UPS.PowerSummary.Rechargeable, Type: Feature, ReportID: 0x05, Offset: 0, Size: 8, Value: 1
   0.303212     Report[get]: (4 bytes) => 06 00 00 08
   0.303727     Path: UPS.PowerSummary.Charging, Type: Input, ReportID: 0x06, Offset: 0, Size: 8, Value: 0
   0.304234     Report[buf]: (4 bytes) => 06 00 00 08
   0.304778     Path: UPS.PowerSummary.Charging, Type: Feature, ReportID: 0x06, Offset: 0, Size: 8, Value: 0
   0.305169     Report[buf]: (4 bytes) => 06 00 00 08
   0.305566     Path: UPS.PowerSummary.Discharging, Type: Input, ReportID: 0x06, Offset: 8, Size: 8, Value: 0
   0.305947     Report[buf]: (4 bytes) => 06 00 00 08
   0.307436     Path: UPS.PowerSummary.Discharging, Type: Feature, ReportID: 0x06, Offset: 8, Size: 8, Value: 0
   0.307857     Report[buf]: (4 bytes) => 06 00 00 08
   0.308263     Path: UPS.PowerSummary.APCStatusFlag, Type: Input, ReportID: 0x06, Offset: 16, Size: 8, Value: 8
   0.309966     Report[buf]: (4 bytes) => 06 00 00 08
   0.310403     Path: UPS.PowerSummary.APCStatusFlag, Type: Feature, ReportID: 0x06, Offset: 16, Size: 8, Value: 8
   0.315356     Report[get]: (3 bytes) => 07 e2 46
   0.315898     Path: UPS.PowerSummary.ManufacturerDate, Type: Feature, ReportID: 0x07, Offset: 0, Size: 16, Value: 18146
   0.319592     Report[get]: (3 bytes) => 08 60 09
   0.320587     Path: UPS.PowerSummary.ConfigVoltage, Type: Feature, ReportID: 0x08, Offset: 0, Size: 16, Value: 24
   0.324353     Report[get]: (3 bytes) => 09 95 0a
   0.324965     Path: UPS.PowerSummary.Voltage, Type: Feature, ReportID: 0x09, Offset: 0, Size: 16, Value: 27.09
   0.328984     Report[get]: (2 bytes) => 0a 03
   0.329510     Path: UPS.PowerSummary.iManufacturer, Type: Feature, ReportID: 0x0a, Offset: 0, Size: 8, Value: 3
   0.331846     Report[get]: (2 bytes) => 0b 02
   0.332362     Path: UPS.PowerSummary.CapacityMode, Type: Feature, ReportID: 0x0b, Offset: 0, Size: 8, Value: 2
   0.337363     Report[get]: (4 bytes) => 0c 64 b8 05
   0.337741     Path: UPS.PowerSummary.RemainingCapacity, Type: Input, ReportID: 0x0c, Offset: 0, Size: 8, Value: 100
   0.337889     Report[buf]: (4 bytes) => 0c 64 b8 05
   0.338040     Path: UPS.PowerSummary.RemainingCapacity, Type: Feature, ReportID: 0x0c, Offset: 0, Size: 8, Value: 100
   0.338176     Report[buf]: (4 bytes) => 0c 64 b8 05
   0.338326     Path: UPS.PowerSummary.RunTimeToEmpty, Type: Input, ReportID: 0x0c, Offset: 8, Size: 16, Value: 1464
   0.338459     Report[buf]: (4 bytes) => 0c 64 b8 05
   0.338605     Path: UPS.PowerSummary.RunTimeToEmpty, Type: Feature, ReportID: 0x0c, Offset: 8, Size: 16, Value: 1464
   0.340724     Report[get]: (2 bytes) => 0d 64
   0.341248     Path: UPS.PowerSummary.DesignCapacity, Type: Feature, ReportID: 0x0d, Offset: 0, Size: 8, Value: 100
   0.344981     Report[get]: (2 bytes) => 0e 64
   0.345500     Path: UPS.PowerSummary.FullChargeCapacity, Type: Feature, ReportID: 0x0e, Offset: 0, Size: 8, Value: 100
   0.347846     Report[get]: (2 bytes) => 0f 32
   0.348218     Path: UPS.PowerSummary.WarningCapacityLimit, Type: Feature, ReportID: 0x0f, Offset: 0, Size: 8, Value: 50
   0.352856     Report[get]: (2 bytes) => 10 01
   0.353116     Path: UPS.PowerSummary.CapacityGranularity2, Type: Feature, ReportID: 0x10, Offset: 0, Size: 8, Value: 1
   0.357849     Report[get]: (2 bytes) => 11 0a
   0.358117     Path: UPS.PowerSummary.RemainingCapacityLimit, Type: Feature, ReportID: 0x11, Offset: 0, Size: 8, Value: 10
   0.361576     Report[get]: (2 bytes) => 12 01
   0.361825     Path: UPS.PowerSummary.CapacityGranularity1, Type: Feature, ReportID: 0x12, Offset: 0, Size: 8, Value: 1
   0.365217     Report[get]: (2 bytes) => 13 01
   0.365477     Path: UPS.PowerSummary.ACPresent, Type: Input, ReportID: 0x13, Offset: 0, Size: 8, Value: 1
   0.365610     Report[buf]: (2 bytes) => 13 01
   0.365750     Path: UPS.PowerSummary.ACPresent, Type: Feature, ReportID: 0x13, Offset: 0, Size: 8, Value: 1
   0.370349     Report[get]: (3 bytes) => 14 00 00
   0.370608     Path: UPS.PowerSummary.BelowRemainingCapacityLimit, Type: Input, ReportID: 0x14, Offset: 0, Size: 8, Value: 0
   0.370746     Report[buf]: (3 bytes) => 14 00 00
   0.370890     Path: UPS.PowerSummary.BelowRemainingCapacityLimit, Type: Feature, ReportID: 0x14, Offset: 0, Size: 8, Value: 0
   0.371017     Report[buf]: (3 bytes) => 14 00 00
   0.371154     Path: UPS.PowerSummary.ShutdownImminent, Type: Input, ReportID: 0x14, Offset: 8, Size: 8, Value: 0
   0.371279     Report[buf]: (3 bytes) => 14 00 00
   0.371416     Path: UPS.PowerSummary.ShutdownImminent, Type: Feature, ReportID: 0x14, Offset: 8, Size: 8, Value: 0
   0.373598     Report[get]: (3 bytes) => 15 ff ff
   0.373855     Path: UPS.PowerSummary.DelayBeforeShutdown, Type: Feature, ReportID: 0x15, Offset: 0, Size: 16, Value: -1
   0.378613     Report[get]: (5 bytes) => 16 0c 00 00 00
   0.378877     Path: UPS.PowerSummary.PresentStatus.Charging, Type: Input, ReportID: 0x16, Offset: 0, Size: 1, Value: 0
   0.379024     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.379169     Path: UPS.PowerSummary.PresentStatus.Charging, Type: Feature, ReportID: 0x16, Offset: 0, Size: 1, Value: 0
   0.379302     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.379445     Path: UPS.PowerSummary.PresentStatus.Discharging, Type: Input, ReportID: 0x16, Offset: 1, Size: 1, Value: 0
   0.379576     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.379719     Path: UPS.PowerSummary.PresentStatus.Discharging, Type: Feature, ReportID: 0x16, Offset: 1, Size: 1, Value: 0
   0.379854     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.379997     Path: UPS.PowerSummary.PresentStatus.ACPresent, Type: Input, ReportID: 0x16, Offset: 2, Size: 1, Value: 1
   0.380128     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.380273     Path: UPS.PowerSummary.PresentStatus.ACPresent, Type: Feature, ReportID: 0x16, Offset: 2, Size: 1, Value: 1
   0.380406     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.380548     Path: UPS.PowerSummary.PresentStatus.BatteryPresent, Type: Input, ReportID: 0x16, Offset: 3, Size: 1, Value: 1
   0.380680     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.380821     Path: UPS.PowerSummary.PresentStatus.BatteryPresent, Type: Feature, ReportID: 0x16, Offset: 3, Size: 1, Value: 1
   0.380952     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.381096     Path: UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit, Type: Input, ReportID: 0x16, Offset: 4, Size: 1, Value: 0
   0.381228     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.381369     Path: UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit, Type: Feature, ReportID: 0x16, Offset: 4, Size: 1, Value: 0
   0.381500     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.381639     Path: UPS.PowerSummary.PresentStatus.ShutdownImminent, Type: Input, ReportID: 0x16, Offset: 5, Size: 1, Value: 0
   0.381771     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.381911     Path: UPS.PowerSummary.PresentStatus.ShutdownImminent, Type: Feature, ReportID: 0x16, Offset: 5, Size: 1, Value: 0
   0.382042     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.382188     Path: UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired, Type: Input, ReportID: 0x16, Offset: 6, Size: 1, Value: 0
   0.382319     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.382461     Path: UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired, Type: Feature, ReportID: 0x16, Offset: 6, Size: 1, Value: 0
   0.382594     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.382734     Path: UPS.PowerSummary.PresentStatus.CommunicationLost, Type: Input, ReportID: 0x16, Offset: 7, Size: 1, Value: 0
   0.382865     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.383005     Path: UPS.PowerSummary.PresentStatus.CommunicationLost, Type: Feature, ReportID: 0x16, Offset: 7, Size: 1, Value: 0
   0.383143     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.383284     Path: UPS.PowerSummary.PresentStatus.NeedReplacement, Type: Input, ReportID: 0x16, Offset: 8, Size: 1, Value: 0
   0.383416     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.383561     Path: UPS.PowerSummary.PresentStatus.NeedReplacement, Type: Feature, ReportID: 0x16, Offset: 8, Size: 1, Value: 0
   0.383693     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.383936     Path: UPS.PowerSummary.PresentStatus.Overload, Type: Input, ReportID: 0x16, Offset: 9, Size: 1, Value: 0
   0.384080     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.384224     Path: UPS.PowerSummary.PresentStatus.Overload, Type: Feature, ReportID: 0x16, Offset: 9, Size: 1, Value: 0
   0.384356     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.386736     Path: UPS.PowerSummary.PresentStatus.VoltageNotRegulated, Type: Input, ReportID: 0x16, Offset: 10, Size: 1, Value: 0
   0.389467     Report[buf]: (5 bytes) => 16 0c 00 00 00
   0.389906     Path: UPS.PowerSummary.PresentStatus.VoltageNotRegulated, Type: Feature, ReportID: 0x16, Offset: 10, Size: 1, Value: 0
   0.394622     Report[get]: (3 bytes) => 17 78 00
   0.395139     Path: UPS.PowerSummary.RemainingTimeLimit, Type: Feature, ReportID: 0x17, Offset: 0, Size: 16, Value: 120
   0.397578     Report[get]: (2 bytes) => 18 02
   0.398476     Path: UPS.PowerSummary.AudibleAlarmControl, Type: Feature, ReportID: 0x18, Offset: 0, Size: 8, Value: 2
   0.403329     Report[get]: (4 bytes) => 1c 01 25 09
   0.403850     Path: UPS.Battery.APCBattReplaceDate, Type: Feature, ReportID: 0x1c, Offset: 0, Size: 24, Value: 599297
   0.407586     Report[get]: (3 bytes) => 20 e2 46
   0.407951     Path: UPS.Battery.ManufacturerDate, Type: Feature, ReportID: 0x20, Offset: 0, Size: 16, Value: 18146
   0.411322     Report[get]: (2 bytes) => 21 06
   0.411561     Path: UPS.Battery.Test, Type: Input, ReportID: 0x21, Offset: 0, Size: 8, Value: 6
   0.411691     Report[buf]: (2 bytes) => 21 06
   0.411826     Path: UPS.Battery.Test, Type: Feature, ReportID: 0x21, Offset: 0, Size: 8, Value: 6
   0.413826     Report[get]: (2 bytes) => 22 64
   0.414092     Path: UPS.Battery.RemainingCapacity, Type: Feature, ReportID: 0x22, Offset: 0, Size: 8, Value: 100
   0.418850     Report[get]: (3 bytes) => 23 b8 05
   0.419126     Path: UPS.Battery.RunTimeToEmpty, Type: Feature, ReportID: 0x23, Offset: 0, Size: 16, Value: 1464
   0.423929     Report[get]: (3 bytes) => 24 78 00
   0.424204     Path: UPS.Battery.RemainingTimeLimit, Type: Feature, ReportID: 0x24, Offset: 0, Size: 16, Value: 120
   0.427593     Report[get]: (3 bytes) => 25 60 09
   0.427851     Path: UPS.Battery.ConfigVoltage, Type: Feature, ReportID: 0x25, Offset: 0, Size: 16, Value: 24
   0.431359     Report[get]: (3 bytes) => 26 95 0a
   0.431622     Path: UPS.Battery.Voltage, Type: Feature, ReportID: 0x26, Offset: 0, Size: 16, Value: 27.09
   0.436345     Report[get]: (2 bytes) => 27 f1
   0.436615     Path: UPS.Battery.ff860024, Type: Feature, ReportID: 0x27, Offset: 0, Size: 8, Value: 241
   0.440192     Report[get]: (5 bytes) => 28 02 96 0d 5d
   0.440471     Path: UPS.Battery.ff860018, Type: Feature, ReportID: 0x28, Offset: 0, Size: 32, Value: 1.56117e+09
   0.443837     Report[get]: (2 bytes) => 30 e6
   0.444096     Path: UPS.Input.ConfigVoltage, Type: Feature, ReportID: 0x30, Offset: 0, Size: 8, Value: 102
   0.447604     Report[get]: (3 bytes) => 31 e2 00
   0.447957     Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 98
   0.452593     Report[get]: (3 bytes) => 32 9b 00
   0.452851     Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x32, Offset: 0, Size: 16, Value: 155
   0.456619     Report[get]: (3 bytes) => 33 18 01
   0.456891     Path: UPS.Input.HighVoltageTransfer, Type: Feature, ReportID: 0x33, Offset: 0, Size: 16, Value: 280
   0.460320     Report[get]: (2 bytes) => 34 84
   0.460585     Path: UPS.Input.ff860024, Type: Feature, ReportID: 0x34, Offset: 0, Size: 8, Value: 132
   0.463992     Report[get]: (2 bytes) => 35 01
   0.464245     Path: UPS.Input.APCSensitivity, Type: Feature, ReportID: 0x35, Offset: 0, Size: 8, Value: 1
   0.468841     Report[get]: (2 bytes) => 36 0b
   0.469097     Path: UPS.Input.APCLineFailCause, Type: Feature, ReportID: 0x36, Offset: 0, Size: 8, Value: 11
   0.472602     Report[get]: (2 bytes) => 40 00
   0.472852     Path: UPS.APCGeneralCollection.APCDelayBeforeReboot, Type: Feature, ReportID: 0x40, Offset: 0, Size: 8, Value: 0
   0.477599     Report[get]: (3 bytes) => 41 ff ff
   0.477845     Path: UPS.APCGeneralCollection.APCDelayBeforeShutdown, Type: Feature, ReportID: 0x41, Offset: 0, Size: 16, Value: -1
   0.480002     Report[get]: (3 bytes) => 42 ff ff
   0.480573     Path: UPS.APCGeneralCollection.DelayBeforeShutdown, Type: Feature, ReportID: 0x42, Offset: 0, Size: 16, Value: -1
   0.485346     Report[get]: (2 bytes) => 50 10
   0.485608     Path: UPS.PowerConverter.PercentLoad, Type: Feature, ReportID: 0x50, Offset: 0, Size: 8, Value: 16
   0.488974     Report[get]: (2 bytes) => 51 7c
   0.489247     Path: UPS.PowerConverter.ff860024, Type: Feature, ReportID: 0x51, Offset: 0, Size: 8, Value: 124
   0.493847     Report[get]: (3 bytes) => 52 bc 02
   0.494109     Path: UPS.PowerConverter.ConfigActivePower, Type: Feature, ReportID: 0x52, Offset: 0, Size: 16, Value: 700
   0.496332     Report[get]: (3 bytes) => 60 00 00
   0.496591     Path: UPS.ff860001.ff860023, Type: Feature, ReportID: 0x60, Offset: 0, Size: 16, Value: 0
   0.502577     Report[get]: (2 bytes) => 61 9a
   0.502854     Path: UPS.ff860001.ff860026, Type: Feature, ReportID: 0x61, Offset: 0, Size: 8, Value: 148
   0.506360     Report[get]: (5 bytes) => 62 00 01 02 03
   0.506644     Path: UPS.ff860001.ff860025, Type: Feature, ReportID: 0x62, Offset: 0, Size: 32, Value: 5.0463e+07
   0.509962     Report[get]: (2 bytes) => 7f 05
   0.510204     Path: UPS.iProduct, Type: Feature, ReportID: 0x7f, Offset: 0, Size: 8, Value: 5
   0.513603     Report[get]: (2 bytes) => 7e 06
   0.513849     Path: UPS.APC_UPS_FirmwareRevision, Type: Feature, ReportID: 0x7e, Offset: 0, Size: 8, Value: 6
   0.518592     Report[get]: (2 bytes) => 7d 02
   0.518835     Path: UPS.iSerialNumber, Type: Feature, ReportID: 0x7d, Offset: 0, Size: 8, Value: 2
   0.522354     Report[get]: (2 bytes) => 7c 03
   0.522601     Path: UPS.iManufacturer, Type: Feature, ReportID: 0x7c, Offset: 0, Size: 8, Value: 3
   0.527347     Report[get]: (3 bytes) => 7b e2 46
   0.527605     Path: UPS.ManufacturerDate, Type: Feature, ReportID: 0x7b, Offset: 0, Size: 16, Value: 18146
   0.529711     Report[get]: (5 bytes) => 7a 0c 00 00 00
   0.529963     Path: UPS.PresentStatus.Charging, Type: Feature, ReportID: 0x7a, Offset: 0, Size: 1, Value: 0
   0.530105     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.530246     Path: UPS.PresentStatus.Discharging, Type: Feature, ReportID: 0x7a, Offset: 1, Size: 1, Value: 0
   0.530380     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.530520     Path: UPS.PresentStatus.ACPresent, Type: Feature, ReportID: 0x7a, Offset: 2, Size: 1, Value: 1
   0.530652     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.530791     Path: UPS.PresentStatus.BatteryPresent, Type: Feature, ReportID: 0x7a, Offset: 3, Size: 1, Value: 1
   0.530922     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.531059     Path: UPS.PresentStatus.BelowRemainingCapacityLimit, Type: Feature, ReportID: 0x7a, Offset: 4, Size: 1, Value: 0
   0.531191     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.531327     Path: UPS.PresentStatus.ShutdownImminent, Type: Feature, ReportID: 0x7a, Offset: 5, Size: 1, Value: 0
   0.531458     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.531592     Path: UPS.PresentStatus.RemainingTimeLimitExpired, Type: Feature, ReportID: 0x7a, Offset: 6, Size: 1, Value: 0
   0.531723     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.531859     Path: UPS.PresentStatus.CommunicationLost, Type: Feature, ReportID: 0x7a, Offset: 7, Size: 1, Value: 0
   0.531990     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.532129     Path: UPS.PresentStatus.NeedReplacement, Type: Feature, ReportID: 0x7a, Offset: 8, Size: 1, Value: 0
   0.532260     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.532391     Path: UPS.PresentStatus.Overload, Type: Feature, ReportID: 0x7a, Offset: 9, Size: 1, Value: 0
   0.532517     Report[buf]: (5 bytes) => 7a 0c 00 00 00
   0.532655     Path: UPS.PresentStatus.VoltageNotRegulated, Type: Feature, ReportID: 0x7a, Offset: 10, Size: 1, Value: 0
   0.535121     Report[get]: (2 bytes) => 79 00
   0.535610     Path: UPS.APCPanelTest, Type: Feature, ReportID: 0x79, Offset: 0, Size: 8, Value: 0
   0.539347     Report[get]: (2 bytes) => 78 02
   0.539699     Path: UPS.AudibleAlarmControl, Type: Feature, ReportID: 0x78, Offset: 0, Size: 8, Value: 2
   0.542973     Report[get]: (3 bytes) => 75 62 00
   0.543236     Path: UPS.ff860029, Type: Feature, ReportID: 0x75, Offset: 0, Size: 16, Value: 98
   0.546584     Report[get]: (5 bytes) => 74 a9 1a 64 64
   0.546859     Path: UPS.ff86002a, Type: Feature, ReportID: 0x74, Offset: 0, Size: 32, Value: 1.68428e+09
   0.547205     Report descriptor retrieved (Reportlen = 1028)
jimklimov commented 2 years ago

Can you please check if it performs better with a build of recent NUT codebase, checked out from master, https://github.com/networkupstools/nut/tree/libusb-1.0 or https://github.com/networkupstools/nut/tree/libusb-1.0+0.1 branch?

smainz commented 2 years ago

I am using a Raspberry Pi 1 for my UPS, compiling takes some time.

Using the branch libusb-1.0 and building with

apt-get remove nut-client nut-server  # remove nut packages
sudo apt-get install autoconf build-essentials automake libtool pkg-config m4
sudo apt-get install libusb-1.0 libusb-1.0.0-dev
autoreconf --install
./autogen.sh
autoconf
./configure --with-user=nut --with-group=nut --with-usb
make
sudo make install

and testing with

cd /usr/local/ups
cp -rp /etc/nut/* etc   # use my old config files
chown -R nut etc/*
sudo sbin/upsdrvctl start
sudo sbin/upsd
bin/upsc usv01

input.voltage is still wrong (but different):

pi@pi:/usr/local/ups $ bin/upsc usv01
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2015/07/02
battery.runtime: 1248
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 27.1
battery.voltage.nominal: 24.0
device.mfr: American Power Conversion
device.model: Back-UPS XS 1400U
device.serial: 3B1527X15613
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.productid: 0002
driver.parameter.synchronous: no
driver.parameter.vendorid: 051d
driver.version: 2.7.4-3392-ga2a81dd1
driver.version.data: APC HID 0.96
driver.version.internal: 0.44
driver.version.usb: libusb-1.0 (API: 0x1000106)
input.sensitivity: medium
input.transfer.high: 280
input.transfer.low: 155
input.voltage: 140.0
input.voltage.nominal: 140
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 926.T1 .I
ups.firmware.aux: T1
ups.load: 19
ups.mfr: American Power Conversion
ups.mfr.date: 2015/07/02
ups.model: Back-UPS XS 1400U
ups.productid: 0002
ups.realpower.nominal: 700
ups.serial: 3B1527X15613
ups.status: OL
ups.test.result: No test initiated
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d

Will try with the other branches tomorrow

smainz commented 2 years ago

Same result with branch libusb-1.0+0.1

branch master is compiling now, will report this evening.

smainz commented 2 years ago

OK tried master as well, but still the wrong input.voltage and input.voltage.nominal.

Is there anything else I can do to help fix this?

andbez commented 2 years ago

Same for my device Back-UPS XS 950U. I am living in Germany too with 230V. Any news on this issue?

smainz commented 2 years ago

Unfortunately not. I had to switch back to apcupsd to make it work.

My setup is now, that I have an old Raspberry Pi with apcupsd monitoring the UPS on the USB-port and provide the UPS info to the local networt.

On other systems I use nut with the apcupsd-ups driver having the port pointing to the Pi.

jimklimov commented 2 years ago

One more idea popped up like in other tickets: can you try following the developer docs to try generating a usbhid-ups subdriver - there's a script that effectively walks your device and generates a C file with mapping table for whatever it finds.

Possibly your device serves the needed data in nodes not mapped (maybe also scaled) into NUT names, standards are ambiguously implemented by many market actors; then it would be a matter of adding the lines to your originally used subdriver source (note: first hit in a walk wins), rebuild, test - and if that helps - post a PR to update the subdriver.

On Tue, Nov 23, 2021, 20:41 smainz @.***> wrote:

OK tried master as well, but still the wrong input.voltage and input.voltage.nominal.

Is there anything else I can do to help fix this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/1189#issuecomment-977078029, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMPTFBZMDUIIAVF5SAKU5LUNPVAHANCNFSM5IG337SA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

smainz commented 2 years ago

@jimklimov I will try this weekend and scream back on you if I need more advice.

Thanks for careing

smainz commented 2 years ago

OK, no luck so far. I created the subdriver using the documented commands:

$ drivers/usbhid-ups -DD -u root -x explore -x vendorid=051D \
        -x port=auto -s ups 2>&1 | tee apcxs1400.txt
$ cd drivers
$ ../scripts/subdriver/gen-usbhid-subdriver.sh < ../apcxs1400.txt

Followed the instructions

Please enter a name for this driver. Use only letters and numbers. Use
natural (upper- and lowercase) capitalization, e.g., 'Belkin', 'APC'.
Name of subdriver: APCXS1400
Creating apcxs1400-hid.h
Creating apcxs1400-hid.c
Done.

Do not forget to:
* add #include "apcxs1400-hid.h" to drivers/usbhid-ups.c,
* add &apcxs1400_subdriver to drivers/usbhid-ups.c:subdriver_list,
* add apcxs1400-hid.c to USBHID_UPS_SUBDRIVERS in drivers/Makefile.am
* add apcxs1400-hid.h to dist_noinst_HEADERS in drivers/Makefile.am
* "autoreconf" from the top level directory

Placed my driver before the apc-hid already in usbhid-ups.c

and rebuilt it.

Unfortunally it segfaults when executing

Network UPS Tools - Generic HID driver 0.45 (2.7.4-4536-gd46d5153)
USB communication driver (libusb 1.0) 0.42
   0.000000     [D1] debug level is '2'
   0.009538     [D2] Initializing an USB-connected UPS with library libusb-1.0.24 (API: 0x1000108) (NUT subdriver name='USB communication driver (libusb 1.0)' ver='0.42')
   0.013648     [D1] upsdrv_initups (non-SHUT)...
   0.057151     [D2] Checking device 1 of 4 (051D/0002)
   0.099389     [D2] - VendorID: 051d
   0.103395     [D2] - ProductID: 0002
   0.105010     [D2] - Manufacturer: American Power Conversion
   0.106493     [D2] - Product: Back-UPS XS 1400U  FW:926.T1 .I USB FW:T1
   0.107006     [D2] - Serial Number: 3B1527X15613
   0.107381     [D2] - Bus: 001
   0.107748     [D2] - Device: unknown
   0.109048     [D2] - Device release number: 0106
   0.109443     [D2] Trying to match device
   0.110196     [D2] match_function_subdriver (non-SHUT mode): matching a device...
   0.111621     [D2] Device matches
   0.112020     [D2] Reading first configuration descriptor
   0.113502     [D2] Claimed interface 0 successfully
   0.116668     [D2] HID descriptor length 1028
   0.298714     [D2] Report Descriptor size = 1028

   0.299895     Using subdriver: APCXS1400 HID 0.1
Speicherzugriffsfehler

What else can I do?

Files attached. apcxs1400.txt apcxs1400-hid.c.txt

jimklimov commented 2 years ago

Can you see if you can get a meaningful reason for that segfault? maybe some null pointer or a buffer overflow (e.g. your HID custom name looks long :))

Something like

gdb --args drivers/usbhid-ups -x ...

and when GDB starts, type "run", and when that fails - "bt" for backtrace.

You may need to embed this into the libtool shell script if "drivers/usbhid-ups" is one (with binary in ".libs" subdir).

On Sun, Feb 6, 2022, 17:47 smainz @.***> wrote:

OK, no luck so far. I created the subdriver using the documented commands:

$ drivers/usbhid-ups -DD -u root -x explore -x vendorid=051D \ -x port=auto -s ups 2>&1 | tee apcxs1400.txt $ cd drivers $ ../scripts/subdriver/gen-usbhid-subdriver.sh < ../apcxs1400.txt

Followed the instructions

Please enter a name for this driver. Use only letters and numbers. Use natural (upper- and lowercase) capitalization, e.g., 'Belkin', 'APC'. Name of subdriver: APCXS1400 Creating apcxs1400-hid.h Creating apcxs1400-hid.c Done.

Do not forget to:

  • add #include "apcxs1400-hid.h" to drivers/usbhid-ups.c,
  • add &apcxs1400_subdriver to drivers/usbhid-ups.c:subdriver_list,
  • add apcxs1400-hid.c to USBHID_UPS_SUBDRIVERS in drivers/Makefile.am
  • add apcxs1400-hid.h to dist_noinst_HEADERS in drivers/Makefile.am
  • "autoreconf" from the top level directory

Placed my driver before the apc-hid already in usbhid-ups.c

and rebuilt it.

Unfortunally it segfaults when executing

Network UPS Tools - Generic HID driver 0.45 (2.7.4-4536-gd46d5153) USB communication driver (libusb 1.0) 0.42 0.000000 [D1] debug level is '2' 0.009538 [D2] Initializing an USB-connected UPS with library libusb-1.0.24 (API: 0x1000108) (NUT subdriver name='USB communication driver (libusb 1.0)' ver='0.42') 0.013648 [D1] upsdrv_initups (non-SHUT)... 0.057151 [D2] Checking device 1 of 4 (051D/0002) 0.099389 [D2] - VendorID: 051d 0.103395 [D2] - ProductID: 0002 0.105010 [D2] - Manufacturer: American Power Conversion 0.106493 [D2] - Product: Back-UPS XS 1400U FW:926.T1 .I USB FW:T1 0.107006 [D2] - Serial Number: 3B1527X15613 0.107381 [D2] - Bus: 001 0.107748 [D2] - Device: unknown 0.109048 [D2] - Device release number: 0106 0.109443 [D2] Trying to match device 0.110196 [D2] match_function_subdriver (non-SHUT mode): matching a device... 0.111621 [D2] Device matches 0.112020 [D2] Reading first configuration descriptor 0.113502 [D2] Claimed interface 0 successfully 0.116668 [D2] HID descriptor length 1028 0.298714 [D2] Report Descriptor size = 1028

0.299895 Using subdriver: APCXS1400 HID 0.1 Speicherzugriffsfehler

What else can I do?

Files attached. apcxs1400.txt https://github.com/networkupstools/nut/files/8010613/apcxs1400.txt apcxs1400-hid.c.txt https://github.com/networkupstools/nut/files/8010615/apcxs1400-hid.c.txt

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/1189#issuecomment-1030869920, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMPTFGOHUOOB2T7I3TUO7TUZ2Q35ANCNFSM5IG337SA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

smainz commented 2 years ago

Need more help:

Thread 1 "usbhid-ups" received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x00012b94 in callback (argudev=<optimized out>, arghd=0x4a2f0 <curDevice>, rdbuf=<optimized out>, rdlen=<optimized out>)
    at usbhid-ups.c:1239
#2  0x00016d08 in nut_libusb_open (udevp=udevp@entry=0x4a2bc <udev>, curDevice=curDevice@entry=0x4a2f0 <curDevice>, matcher=0x0,
    callback=0x404, callback@entry=0x12ad0 <callback>) at libusb1.c:548
#3  0x00014730 in upsdrv_initups () at usbhid-ups.c:1037
#4  0x00012450 in main (argc=<optimized out>, argv=<optimized out>) at main.c:690

renamed apcxs1400 to xs, but no change

Running on a Raspberry Pi (early model), on buster

smainz commented 2 years ago

OK, found the reason for the segfault. The script creates incorect c code.

instead of:

subdriver_t xs_subdriver = {
        XS_HID_VERSION,
        xs_claim,
        xs_utab,
        xs_hid2nut,
        xs_format_model,
        xs_format_mfr,
        xs_format_serial,
        fix_report_desc,
};

it creates

subdriver_t xs_subdriver = {
        XS_HID_VERSION,
        xs_claim,
        xs_utab,
        xs_hid2nut,
        xs_format_model,
        xs_format_mfr,
        xs_format_serial,
};

Note the missing last line.

smainz commented 2 years ago

But it does not seem to be different from what the apc-hid subdriver does:

  64.798816     [D2] Path: UPS.Input.ConfigVoltage, Type: Feature, ReportID: 0x30, Offset: 0, Size: 8, Value: 140
  64.808107     [D2] Path: UPS.Input.HighVoltageTransfer, Type: Feature, ReportID: 0x33, Offset: 0, Size: 16, Value: 280
  64.814238     [D2] Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x32, Offset: 0, Size: 16, Value: 155
  64.819999     [D2] Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 140

apcupsd reports:

LOTRANS  : 155.0 Volts
HITRANS  : 280.0 Volts
LINEV    : 228.0 Volts

Maybe LINEV is not equal to Input.Voltage?

jimklimov commented 2 years ago

Maybe... did the generation script find some other mapping lines for voltage that were not there in original APC subdriver?

Or maybe values are shifted by market (EU/US/...) based on some other reading, there was recently a discussion of such possibility. Especially if needing to fit high limits of 260-280V into a byte (ConfigVoltage is 8 bits in your sample; others claim 16 bits).

On Sun, Feb 6, 2022, 22:46 smainz @.***> wrote:

But it does not seem to be different from what the apc-hid subdriver does:

64.798816 [D2] Path: UPS.Input.ConfigVoltage, Type: Feature, ReportID: 0x30, Offset: 0, Size: 8, Value: 140 64.808107 [D2] Path: UPS.Input.HighVoltageTransfer, Type: Feature, ReportID: 0x33, Offset: 0, Size: 16, Value: 280 64.814238 [D2] Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x32, Offset: 0, Size: 16, Value: 155 64.819999 [D2] Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 140

apcupsd reports:

LOTRANS : 155.0 Volts HITRANS : 280.0 Volts LINEV : 228.0 Volts

Maybe LINEV is not equal to Input.Voltage?

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/1189#issuecomment-1030921046, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMPTFHSWJELTDONTB7TCL3UZ3TZ3ANCNFSM5IG337SA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

smainz commented 2 years ago

This is all the EXPLORE gave me, no additional voltage reading, nor a sign to indicate EU/US/... (I am in the EU).

0.322581    Using subdriver: EXPLORE HID 0.2
   0.322696 [D1] 104 HID objects found
   0.326426 [D1] Path: UPS.PowerSummary.iProduct, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8, Value: 1
   0.333161 [D1] Path: UPS.PowerSummary.iSerialNumber, Type: Feature, ReportID: 0x02, Offset: 0, Size: 8, Value: 2
   0.337649 [D1] Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, ReportID: 0x03, Offset: 0, Size: 8, Value: 4
   0.342204 [D1] Path: UPS.PowerSummary.iOEMInformation, Type: Feature, ReportID: 0x04, Offset: 0, Size: 8, Value: 3
   0.350154 [D1] Path: UPS.PowerSummary.Rechargeable, Type: Feature, ReportID: 0x05, Offset: 0, Size: 8, Value: 1
   0.353826 [D1] Path: UPS.PowerSummary.Charging, Type: Input, ReportID: 0x06, Offset: 0, Size: 8, Value: 0
   0.354865 [D1] Path: UPS.PowerSummary.Charging, Type: Feature, ReportID: 0x06, Offset: 0, Size: 8, Value: 0
   0.356885 [D1] Path: UPS.PowerSummary.Discharging, Type: Input, ReportID: 0x06, Offset: 8, Size: 8, Value: 0
   0.358825 [D1] Path: UPS.PowerSummary.Discharging, Type: Feature, ReportID: 0x06, Offset: 8, Size: 8, Value: 0
   0.361031 [D1] Path: UPS.PowerSummary.ff860060, Type: Input, ReportID: 0x06, Offset: 16, Size: 8, Value: 8
   0.362884 [D1] Path: UPS.PowerSummary.ff860060, Type: Feature, ReportID: 0x06, Offset: 16, Size: 8, Value: 8
   0.366948 [D1] Path: UPS.PowerSummary.ManufacturerDate, Type: Feature, ReportID: 0x07, Offset: 0, Size: 16, Value: 18146
   0.371530 [D1] Path: UPS.PowerSummary.ConfigVoltage, Type: Feature, ReportID: 0x08, Offset: 0, Size: 16, Value: 24
   0.374599 [D1] Path: UPS.PowerSummary.Voltage, Type: Feature, ReportID: 0x09, Offset: 0, Size: 16, Value: 27.25
   0.383155 [D1] Path: UPS.PowerSummary.iManufacturer, Type: Feature, ReportID: 0x0a, Offset: 0, Size: 8, Value: 3
   0.387652 [D1] Path: UPS.PowerSummary.CapacityMode, Type: Feature, ReportID: 0x0b, Offset: 0, Size: 8, Value: 2
   0.391916 [D1] Path: UPS.PowerSummary.RemainingCapacity, Type: Input, ReportID: 0x0c, Offset: 0, Size: 8, Value: 100
   0.392934 [D1] Path: UPS.PowerSummary.RemainingCapacity, Type: Feature, ReportID: 0x0c, Offset: 0, Size: 8, Value: 100
   0.394852 [D1] Path: UPS.PowerSummary.RunTimeToEmpty, Type: Input, ReportID: 0x0c, Offset: 8, Size: 16, Value: 524
   0.396789 [D1] Path: UPS.PowerSummary.RunTimeToEmpty, Type: Feature, ReportID: 0x0c, Offset: 8, Size: 16, Value: 524
   0.399362 [D1] Path: UPS.PowerSummary.DesignCapacity, Type: Feature, ReportID: 0x0d, Offset: 0, Size: 8, Value: 100
   0.407140 [D1] Path: UPS.PowerSummary.FullChargeCapacity, Type: Feature, ReportID: 0x0e, Offset: 0, Size: 8, Value: 100
   0.412675 [D1] Path: UPS.PowerSummary.WarningCapacityLimit, Type: Feature, ReportID: 0x0f, Offset: 0, Size: 8, Value: 50
   0.419637 [D1] Path: UPS.PowerSummary.CapacityGranularity2, Type: Feature, ReportID: 0x10, Offset: 0, Size: 8, Value: 1
   0.423883 [D1] Path: UPS.PowerSummary.RemainingCapacityLimit, Type: Feature, ReportID: 0x11, Offset: 0, Size: 8, Value: 10
   0.432659 [D1] Path: UPS.PowerSummary.CapacityGranularity1, Type: Feature, ReportID: 0x12, Offset: 0, Size: 8, Value: 1
   0.437273 [D1] Path: UPS.PowerSummary.ACPresent, Type: Input, ReportID: 0x13, Offset: 0, Size: 8, Value: 1
   0.439321 [D1] Path: UPS.PowerSummary.ACPresent, Type: Feature, ReportID: 0x13, Offset: 0, Size: 8, Value: 1
   0.444659 [D1] Path: UPS.PowerSummary.BelowRemainingCapacityLimit, Type: Input, ReportID: 0x14, Offset: 0, Size: 8, Value: 0
   0.445822 [D1] Path: UPS.PowerSummary.BelowRemainingCapacityLimit, Type: Feature, ReportID: 0x14, Offset: 0, Size: 8, Value: 0
   0.447452 [D1] Path: UPS.PowerSummary.ShutdownImminent, Type: Input, ReportID: 0x14, Offset: 8, Size: 8, Value: 0
   0.447576 [D1] Path: UPS.PowerSummary.ShutdownImminent, Type: Feature, ReportID: 0x14, Offset: 8, Size: 8, Value: 0
   0.453654 [D1] Path: UPS.PowerSummary.DelayBeforeShutdown, Type: Feature, ReportID: 0x15, Offset: 0, Size: 16, Value: -1
   0.457017 [D1] Path: UPS.PowerSummary.PresentStatus.Charging, Type: Input, ReportID: 0x16, Offset: 0, Size: 1, Value: 0
   0.458068 [D1] Path: UPS.PowerSummary.PresentStatus.Charging, Type: Feature, ReportID: 0x16, Offset: 0, Size: 1, Value: 0
   0.459586 [D1] Path: UPS.PowerSummary.PresentStatus.Discharging, Type: Input, ReportID: 0x16, Offset: 1, Size: 1, Value: 0
   0.459710 [D1] Path: UPS.PowerSummary.PresentStatus.Discharging, Type: Feature, ReportID: 0x16, Offset: 1, Size: 1, Value: 0
   0.459820 [D1] Path: UPS.PowerSummary.PresentStatus.ACPresent, Type: Input, ReportID: 0x16, Offset: 2, Size: 1, Value: 1
   0.459926 [D1] Path: UPS.PowerSummary.PresentStatus.ACPresent, Type: Feature, ReportID: 0x16, Offset: 2, Size: 1, Value: 1
   0.460030 [D1] Path: UPS.PowerSummary.PresentStatus.BatteryPresent, Type: Input, ReportID: 0x16, Offset: 3, Size: 1, Value: 1
   0.460133 [D1] Path: UPS.PowerSummary.PresentStatus.BatteryPresent, Type: Feature, ReportID: 0x16, Offset: 3, Size: 1, Value: 1
   0.460597 [D1] Path: UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit, Type: Input, ReportID: 0x16, Offset: 4, Size: 1, Value: 0
   0.460740 [D1] Path: UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit, Type: Feature, ReportID: 0x16, Offset: 4, Size: 1, Value: 0
   0.460848 [D1] Path: UPS.PowerSummary.PresentStatus.ShutdownImminent, Type: Input, ReportID: 0x16, Offset: 5, Size: 1, Value: 0
   0.460951 [D1] Path: UPS.PowerSummary.PresentStatus.ShutdownImminent, Type: Feature, ReportID: 0x16, Offset: 5, Size: 1, Value: 0
   0.461051 [D1] Path: UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired, Type: Input, ReportID: 0x16, Offset: 6, Size: 1, Value: 0
   0.461155 [D1] Path: UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired, Type: Feature, ReportID: 0x16, Offset: 6, Size: 1, Value: 0
   0.461256 [D1] Path: UPS.PowerSummary.PresentStatus.CommunicationLost, Type: Input, ReportID: 0x16, Offset: 7, Size: 1, Value: 0
   0.461354 [D1] Path: UPS.PowerSummary.PresentStatus.CommunicationLost, Type: Feature, ReportID: 0x16, Offset: 7, Size: 1, Value: 0
   0.461456 [D1] Path: UPS.PowerSummary.PresentStatus.NeedReplacement, Type: Input, ReportID: 0x16, Offset: 8, Size: 1, Value: 0
   0.461556 [D1] Path: UPS.PowerSummary.PresentStatus.NeedReplacement, Type: Feature, ReportID: 0x16, Offset: 8, Size: 1, Value: 0
   0.461657 [D1] Path: UPS.PowerSummary.PresentStatus.Overload, Type: Input, ReportID: 0x16, Offset: 9, Size: 1, Value: 0
   0.461754 [D1] Path: UPS.PowerSummary.PresentStatus.Overload, Type: Feature, ReportID: 0x16, Offset: 9, Size: 1, Value: 0
   0.461856 [D1] Path: UPS.PowerSummary.PresentStatus.VoltageNotRegulated, Type: Input, ReportID: 0x16, Offset: 10, Size: 1, Value: 0
   0.461961 [D1] Path: UPS.PowerSummary.PresentStatus.VoltageNotRegulated, Type: Feature, ReportID: 0x16, Offset: 10, Size: 1, Value: 0
   0.472487 [D1] Path: UPS.PowerSummary.RemainingTimeLimit, Type: Feature, ReportID: 0x17, Offset: 0, Size: 16, Value: 120
   0.476768 [D1] Path: UPS.PowerSummary.AudibleAlarmControl, Type: Feature, ReportID: 0x18, Offset: 0, Size: 8, Value: 2
   0.482671 [D1] Path: UPS.Battery.ff860016, Type: Feature, ReportID: 0x1c, Offset: 0, Size: 24, Value: 599297
   0.486896 [D1] Path: UPS.Battery.ManufacturerDate, Type: Feature, ReportID: 0x20, Offset: 0, Size: 16, Value: 18146
   0.490248 [D1] Path: UPS.Battery.Test, Type: Input, ReportID: 0x21, Offset: 0, Size: 8, Value: 6
   0.491268 [D1] Path: UPS.Battery.Test, Type: Feature, ReportID: 0x21, Offset: 0, Size: 8, Value: 6
   0.499135 [D1] Path: UPS.Battery.RemainingCapacity, Type: Feature, ReportID: 0x22, Offset: 0, Size: 8, Value: 100
   0.503275 [D1] Path: UPS.Battery.RunTimeToEmpty, Type: Feature, ReportID: 0x23, Offset: 0, Size: 16, Value: 524
   0.506539 [D1] Path: UPS.Battery.RemainingTimeLimit, Type: Feature, ReportID: 0x24, Offset: 0, Size: 16, Value: 120
   0.510103 [D1] Path: UPS.Battery.ConfigVoltage, Type: Feature, ReportID: 0x25, Offset: 0, Size: 16, Value: 24
   0.515781 [D1] Path: UPS.Battery.Voltage, Type: Feature, ReportID: 0x26, Offset: 0, Size: 16, Value: 27.09
   0.519013 [D1] Path: UPS.Battery.ff860024, Type: Feature, ReportID: 0x27, Offset: 0, Size: 8, Value: 241
   0.523789 [D1] Path: UPS.Battery.ff860018, Type: Feature, ReportID: 0x28, Offset: 0, Size: 32, Value: 8.90083e+08
   0.531909 [D1] Path: UPS.Input.ConfigVoltage, Type: Feature, ReportID: 0x30, Offset: 0, Size: 8, Value: 140
   0.536022 [D1] Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 140
   0.540922 [D1] Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x32, Offset: 0, Size: 16, Value: 155
   0.548907 [D1] Path: UPS.Input.HighVoltageTransfer, Type: Feature, ReportID: 0x33, Offset: 0, Size: 16, Value: 280
   0.552150 [D1] Path: UPS.Input.ff860024, Type: Feature, ReportID: 0x34, Offset: 0, Size: 8, Value: 132
   0.556283 [D1] Path: UPS.Input.ff860061, Type: Feature, ReportID: 0x35, Offset: 0, Size: 8, Value: 1
   0.559963 [D1] Path: UPS.Input.ff860052, Type: Feature, ReportID: 0x36, Offset: 0, Size: 8, Value: 0
   0.565557 [D1] Path: UPS.ff860005.ff86007c, Type: Feature, ReportID: 0x40, Offset: 0, Size: 8, Value: 0
   0.568896 [D1] Path: UPS.ff860005.ff86007d, Type: Feature, ReportID: 0x41, Offset: 0, Size: 16, Value: -1
   0.573025 [D1] Path: UPS.ff860005.DelayBeforeShutdown, Type: Feature, ReportID: 0x42, Offset: 0, Size: 16, Value: -1
   0.576144 [D1] Path: UPS.PowerConverter.PercentLoad, Type: Feature, ReportID: 0x50, Offset: 0, Size: 8, Value: 20
   0.581181 [D1] Path: UPS.PowerConverter.ff860024, Type: Feature, ReportID: 0x51, Offset: 0, Size: 8, Value: 124
   0.585821 [D1] Path: UPS.PowerConverter.ConfigActivePower, Type: Feature, ReportID: 0x52, Offset: 0, Size: 16, Value: 700
   0.590026 [D1] Path: UPS.ff860001.ff860023, Type: Feature, ReportID: 0x60, Offset: 0, Size: 16, Value: 0
   0.593290 [D1] Path: UPS.ff860001.ff860026, Type: Feature, ReportID: 0x61, Offset: 0, Size: 8, Value: 148
   0.597666 [D1] Path: UPS.ff860001.ff860025, Type: Feature, ReportID: 0x62, Offset: 0, Size: 32, Value: 5.0463e+07
   0.602001 [D1] Path: UPS.iProduct, Type: Feature, ReportID: 0x7f, Offset: 0, Size: 8, Value: 5
   0.606674 [D1] Path: UPS.ff860042, Type: Feature, ReportID: 0x7e, Offset: 0, Size: 8, Value: 6
   0.614130 [D1] Path: UPS.iSerialNumber, Type: Feature, ReportID: 0x7d, Offset: 0, Size: 8, Value: 2
   0.618617 [D1] Path: UPS.iManufacturer, Type: Feature, ReportID: 0x7c, Offset: 0, Size: 8, Value: 3
   0.623127 [D1] Path: UPS.ManufacturerDate, Type: Feature, ReportID: 0x7b, Offset: 0, Size: 16, Value: 18146
   0.626365 [D1] Path: UPS.PresentStatus.Charging, Type: Feature, ReportID: 0x7a, Offset: 0, Size: 1, Value: 0
   0.627413 [D1] Path: UPS.PresentStatus.Discharging, Type: Feature, ReportID: 0x7a, Offset: 1, Size: 1, Value: 0
   0.629289 [D1] Path: UPS.PresentStatus.ACPresent, Type: Feature, ReportID: 0x7a, Offset: 2, Size: 1, Value: 1
   0.631541 [D1] Path: UPS.PresentStatus.BatteryPresent, Type: Feature, ReportID: 0x7a, Offset: 3, Size: 1, Value: 1
   0.633393 [D1] Path: UPS.PresentStatus.BelowRemainingCapacityLimit, Type: Feature, ReportID: 0x7a, Offset: 4, Size: 1, Value: 0
   0.635620 [D1] Path: UPS.PresentStatus.ShutdownImminent, Type: Feature, ReportID: 0x7a, Offset: 5, Size: 1, Value: 0
   0.637499 [D1] Path: UPS.PresentStatus.RemainingTimeLimitExpired, Type: Feature, ReportID: 0x7a, Offset: 6, Size: 1, Value: 0
   0.639926 [D1] Path: UPS.PresentStatus.CommunicationLost, Type: Feature, ReportID: 0x7a, Offset: 7, Size: 1, Value: 0
   0.640090 [D1] Path: UPS.PresentStatus.NeedReplacement, Type: Feature, ReportID: 0x7a, Offset: 8, Size: 1, Value: 0
   0.640191 [D1] Path: UPS.PresentStatus.Overload, Type: Feature, ReportID: 0x7a, Offset: 9, Size: 1, Value: 0
   0.640292 [D1] Path: UPS.PresentStatus.VoltageNotRegulated, Type: Feature, ReportID: 0x7a, Offset: 10, Size: 1, Value: 0
   0.644248 [D1] Path: UPS.ff860072, Type: Feature, ReportID: 0x79, Offset: 0, Size: 8, Value: 0
   0.647845 [D1] Path: UPS.AudibleAlarmControl, Type: Feature, ReportID: 0x78, Offset: 0, Size: 8, Value: 2
   0.651544 [D1] Path: UPS.ff860029, Type: Feature, ReportID: 0x75, Offset: 0, Size: 16, Value: 98
   0.655814 [D1] Path: UPS.ff86002a, Type: Feature, ReportID: 0x74, Offset: 0, Size: 32, Value: 1.68428e+09

So no hint to a different Voltage definition, nor a value showing something to the 228V apcupsd gives me.

In the subdrive i did not change anything, especially i did not remove the 'unmapped.' anywhere. See:

static hid_info_t xs_hid2nut[] = {

    { "unmapped.ups.apcxs140010", 0, 0, "UPS.APCXS140010", NULL, "%.0f", 0, NULL },
    { "unmapped.ups.apcxs140011", 0, 0, "UPS.APCXS140011", NULL, "%.0f", 0, NULL },
    { "unmapped.ups.apcxs140015", 0, 0, "UPS.APCXS140015", NULL, "%.0f", 0, NULL },
    { "unmapped.ups.apcxs14001.apcxs14005", 0, 0, "UPS.APCXS14001.APCXS14005", NULL, "%.0f", 0, NULL },
    { "unmapped.ups.apcxs14001.apcxs14007", 0, 0, "UPS.APCXS14001.APCXS14007", NULL, "%.0f", 0, NULL },

Is this something I should have done?

jimklimov commented 2 years ago

Just in case: the fix-up of faulty HID info was explored in PR #1245 adding a generic hook method that subdrivers may implement for known deficiencies as those surface...

jimklimov commented 2 years ago

CC @nbriggs : Hi, maybe you can help make sense out of this?

I also wonder what the explore-hid(.c?) covers - maybe it may need some improvements from some source of modern standard tables? And likewise, what are those hex name components - something reported by the device that we don't know how to interpret (in that case, do we see everything it cares to report)?..

Alas, I'm "just" a maintainer to help things roll along, but not a deep expert in all the nuances...

nbriggs commented 2 years ago

Hi @jimklimov -- I'll have a look over the next few days.

smainz commented 2 years ago

Tell me, what I can do to help, but it es gtting close to my skill level. I do not know the details of how USB works, not am I into the internals of nut.

Compiling and running stuff is ok and some C skills have resist the ravages of time.

nbriggs commented 2 years ago

Hi @smainz -- nothing specific to do yet, but I expect that seeing the results of running some NUT programs in debug mode will be the most useful once I've had a chance to look at the code. I have a "American Power Conversion Back-UPS RS 1500G", but I'm in the US and that unit is 120VAC only (you'd think that auto voltage sensing would make sense, but I guess the market is large enough they can save cost by selling models specific to the input voltage)

nbriggs commented 2 years ago

The "EXPLORE" driver doesn't know about any of the vendor-specific usages (as defined for the APC units in apc-hid.c) so it will put out the hex value for those. For example, you see

   0.361031 [D1] Path: UPS.PowerSummary.ff860060, Type: Input, ReportID: 0x06, Offset: 16, Size: 8, Value: 8
   0.362884 [D1] Path: UPS.PowerSummary.ff860060, Type: Feature, ReportID: 0x06, Offset: 16, Size: 8, Value: 8

in the explore output dump, where ff860060 actually corresponds to "APCStatusFlag" in the original dump that was submitted:

   0.307857     Report[buf]: (4 bytes) => 06 00 00 08
   0.308263     Path: UPS.PowerSummary.APCStatusFlag, Type: Input, ReportID: 0x06, Offset: 16, Size: 8, Value: 8
   0.309966     Report[buf]: (4 bytes) => 06 00 00 08
   0.310403     Path: UPS.PowerSummary.APCStatusFlag, Type: Feature, ReportID: 0x06, Offset: 16, Size: 8, Value: 8
nbriggs commented 2 years ago

... so the newly generated sub-driver will only make things worse here, and any info that you learn about undecoded fields can be merged back into the apc-specific tables in apc-hid.c -- however, I don't see a path to finding any authoritative documentation unless Schneider Electric/APC is willing to give it up, and I am not hopeful about that.

smainz commented 2 years ago

This is so crazy, apcupsd from 2016 can read the data and nut can not. I am not aware where the guys from apcupsd got their specs from and am too dumb to find it within a few minutes in their code/docs.

Is this something which rings a bell on you

from src/drivers/usb/usb.c:

/*
 * This table is used when walking through the USB reports to see
 * what information found in the UPS that we want. If the usage_code 
 * and the physical code match, then we make an entry in the command
 * index table containing the usage information provided by the UPS
 * as well as the data type from this table. Entries in the table 
 * with ci == CI_NONE are not used, for the moment, they are
 * retained just so they are not forgotten.
 */
const UsbUpsDriver::s_known_info UsbUpsDriver::_known_info[] = {
   /*  Page 0x84 is the Power Device Page */
   /* CI                        USAGE       PHYSICAL   LOGICAL  TYPE        VOLATILE? */
   {CI_NONE,                    0x00840001, P_ANY,     P_ANY,   T_INDEX,    false},  /* iName */
   {CI_VLINE,                   0x00840030, P_INPUT,   P_ANY,   T_UNITS,    true },  /* Line Voltage */
   {CI_VOUT,                    0x00840030, P_OUTPUT,  P_ANY,   T_UNITS,    true },  /* Output Voltage */
   {CI_VBATT,                   0x00840030, P_BATTERY, P_ANY,   T_UNITS,    true },  /* Battery Voltage */
   {CI_VBATT,                   0x00840030, P_ANY,     P_PWSUM, T_UNITS,    true },  /* Battery Voltage (alternative) */
   {CI_NONE,                    0x00840031, P_ANY,     P_ANY,   T_UNITS,    false},  /* Current */
   {CI_FREQ,                    0x00840032, P_OUTPUT,  P_ANY,   T_UNITS,    true },  /* Frequency */

from example/hid-ups_info.c:

struct s_ups_info {
    unsigned usage;
    int type;
    const char *label;
} ups_info[] = {

    /* MGE & APC */
    { 0x000000, T_NONE,    "None" },
    /* Page 0x84 is the Power Device Page */
    { 0x840000, T_NONE,    "UPS-Power" },
    { 0x840001, T_INDEX,   "iName" },
    { 0x840002, T_NONE,    "PresentStatus" },
    { 0x840004, T_NONE,    "UPS" },
    { 0x840012, T_NONE,    "Battery" },
    { 0x840016, T_NONE,    "PowerConverter" },
    { 0x840018, T_NONE,    "OutletSystem" },
    { 0x840017, T_NONE,    "PowerConverterID" },
    { 0x840019, T_NONE,    "OutletSystemID" },
    { 0x84001a, T_NONE,    "Input" },
    { 0x84001c, T_NONE,    "Output" },
    { 0x84001e, T_NONE,    "Flow" }, 
    { 0x84001d, T_NONE,    "OutputID" },
    { 0x84001f, T_NONE,    "FlowID" },
    { 0x840020, T_NONE,    "Outlet" },
    { 0x840021, T_NONE,    "OutletID" },
    { 0x840024, T_NONE,    "PowerSummary" },
    { 0x840025, T_NONE,    "PowerSummaryID" },
    { 0x840030, T_UNITS,   "Voltage" },
    { 0x840031, T_UNITS,   "Current" },
nbriggs commented 2 years ago

@smainz & @jimklimov -- I've just started to look at the apcupsd code.

Regarding why the apcupsd can report the voltage and NUT cannot: I think what I'm seeing is that the apcupsd code (mostly?) ignores the logical minimum/logical maximum information in the report descriptor.

So, I've decoded the report descriptor that the UPS sent, and this is the relevant portion of it:

09 1A          (LOCAL)  USAGE              0x0084001A Input (Physical Collection)
A1 00          (MAIN)   COLLECTION         0x00 Physical (Usage=0x0084001A: Page=Power Device Page, Usage=Input, Type=Physical Collection)
85 30            (GLOBAL) REPORT_ID          0x30 (48) '0'
05 84            (GLOBAL) USAGE_PAGE         0x0084 Power Device Page <-- Redundant: USAGE_PAGE is already 0x0084
09 40            (LOCAL)  USAGE              0x00840040 Config Voltage (Static Value or Dynamic Value)
75 08            (GLOBAL) REPORT_SIZE        0x08 (8) Number of bits per field
15 4B            (GLOBAL) LOGICAL_MINIMUM    0x4B (75)
26 8C00          (GLOBAL) LOGICAL_MAXIMUM    0x008C (140)
67 21D1F000      (GLOBAL) UNIT               0x00F0D121 Electric potential difference in volts [0.1 μV units] (1=System=SI Linear, 2=Length=Centimetre², 1=Mass=Gram, D=Time=Seconds⁻³, F=Current=Ampere⁻¹)
55 07            (GLOBAL) UNIT_EXPONENT      0x07 (Unit Value x 10⁷)
B1 A2            (MAIN)   FEATURE            0x000000A2 (1 field x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 1=NoPrefState 0=NoNull 1=Volatile 0=Bitmap
85 31            (GLOBAL) REPORT_ID          0x31 (49) '1'
09 30            (LOCAL)  USAGE              0x00840030 Voltage (Dynamic Value)
75 10            (GLOBAL) REPORT_SIZE        0x10 (16) Number of bits per field
B1 A2            (MAIN)   FEATURE            0x000000A2 (1 field x 16 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 1=NoPrefState 0=NoNull 1=Volatile 0=Bitmap
85 32            (GLOBAL) REPORT_ID          0x32 (50) '2'
09 53            (LOCAL)  USAGE              0x00840053 Low Voltage Transfer (Dynamic Value)
16 9600          (GLOBAL) LOGICAL_MINIMUM    0x0096 (150)
26 A000          (GLOBAL) LOGICAL_MAXIMUM    0x00A0 (160)
B1 A2            (MAIN)   FEATURE            0x000000A2 (1 field x 16 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 1=NoPrefState 0=NoNull 1=Volatile 0=Bitmap
85 33            (GLOBAL) REPORT_ID          0x33 (51) '3'
09 54            (LOCAL)  USAGE              0x00840054 High Voltage Transfer (Dynamic Value)
16 1801          (GLOBAL) LOGICAL_MINIMUM    0x0118 (280)
26 1801          (GLOBAL) LOGICAL_MAXIMUM    0x0118 (280)
B1 A2            (MAIN)   FEATURE            0x000000A2 (1 field x 16 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 1=NoPrefState 0=NoNull 1=Volatile 0=Bitmap

Notice for config voltage (report 0x30) and voltage (report 0x31) it has set up the logical min/max range as 75-140. Given that you're operating in a nominal 220-240V region (plus the transfer voltage ranges) that makes no sense. But, since NUT honours the logical min/max values, it will clamp the reported values at 140 if they exceed that. So... the fix_report_descriptor method should be able to help here... I'll look at what this will take.

nbriggs commented 2 years ago

@smainz -- If your UPS is still under warranty (or you have any kind of support contract) you might consider opening a case with APC/Schneider Electric to get them to fix their firmware so that it reports the "correct" logical range for the input and configured input voltage in the HID report descriptor. I suspect they just forgot to update those limits when they produced the unit for the European market. If people complain, there's a small chance they might fix it.

nbriggs commented 2 years ago

@smainz Could you try the branch 1189_APC_UPS_wrong_minmax_input_voltage -- if you don't want to recompile the whole thing, copy drivers/apc-hid.c from there to the corresponding place in your previously compiled nut master branch and redo the make there. Re-run your test with debug level 4 (-DDDD) and see if you see the right stuff.

smainz commented 2 years ago

If your UPS is still under warranty (or you have any kind of support contract) you might consider opening a case with APC/Schneider Electric to get them to fix their firmware so that it reports the "correct" logical range for the input and configured input voltage in the HID report descriptor. I suspect they just forgot to update those limits when they produced the unit for the European market. If people complain, there's a small chance they might fix it.

My UPS is out of warranty and I do not have a support contract. In the net I have found a few complaints about the same problem on the same model. Maybe APC has changed the firmware in the mean time.

smainz commented 2 years ago

Could you try the branch 1189_APC_UPS_wrong_minmax_input_voltage -- if you don't want to recompile the whole thing, copy drivers/apc-hid.c from there to the corresponding place in your previously compiled nut master branch and redo the make there. Re-run your test with debug level 4 (-DDDD) and see if you see the right stuff.

Checked out your branch, my pi will be compiling a while and when I am back this evening I will report progress. Thanks for taking a look.

smainz commented 2 years ago

How much of the output do you need? I have the following:

  0.343381     Using subdriver: APC HID 0.97
   0.347043     [D3] Attempting Report Descriptor fix for UPS: Vendor: 051d, Product: 0002
   0.348353     [D4] Report Descriptor: hvt input LogMin: 280 LogMax: 280
   0.349634     [D4] Report Descriptor: voltage LogMin: 75 LogMax: 140
   0.350030     [D3] Fixing Report Descriptor. Set voltage LogMin = 0, LogMax = 560
   0.350407     [D4] Report Descriptor: configVoltage LogMin: 75 LogMax: 140
   0.351448     [D3] Fixing Report Descriptor. Set configVoltage LogMin = 0, LogMax = 255
   0.351942     [D2] Report Descriptor Fixed
   0.353638     [D1] 104 HID objects found
   0.354071     [D4] Entering libusb_get_report
   0.357943     [D3] Report[get]: (2 bytes) => 01 01
   0.358474     [D1] Path: UPS.PowerSummary.iProduct, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8, Value: 1
  0.594872     [D1] Path: UPS.Battery.ff860018, Type: Feature, ReportID: 0x28, Offset: 0, Size: 32, Value: 8.90083e+08
   0.595259     [D4] Entering libusb_get_report
   0.602577     [D3] Report[get]: (2 bytes) => 30 e6
   0.603128     [D1] Path: UPS.Input.ConfigVoltage, Type: Feature, ReportID: 0x30, Offset: 0, Size: 8, Value: 230
   0.604434     [D4] Entering libusb_get_report
   0.606983     [D3] Report[get]: (3 bytes) => 31 e4 00
   0.607525     [D1] Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 228
   0.609183     [D4] Entering libusb_get_report
   0.613316     [D3] Report[get]: (3 bytes) => 32 9b 00
   0.614231     [D1] Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x32, Offset: 0, Size: 16, Value: 155
   0.615553     [D4] Entering libusb_get_report
   0.618396     [D3] Report[get]: (3 bytes) => 33 18 01
   0.618939     [D1] Path: UPS.Input.HighVoltageTransfer, Type: Feature, ReportID: 0x33, Offset: 0, Size: 16, Value: 280
   0.619328     [D4] Entering libusb_get_report
   0.622674     [D3] Report[get]: (2 bytes) => 34 84

This looks right to me 228V Input Voltage. So your idea was correct, the min and max values are wrong and nut limits the values to these values.

Now what can I do to get this into a release?

PS: it was too early this morning and I made the little Pi compile the master branch, so I had do compile it again. So I was lucky about the message Fixing Report Descriptor. ...

nbriggs commented 2 years ago

That output is sufficient, thanks. Sorry to hear you ended up compiling twice. I'll ask a couple of people (probably Jim K and the guy who added the scaffolding for the fix_report_descriptor feature) to review the changes I made and if they approve then Jim K will merge my changes into master.

I don't know what Jim's schedule is for creating NUT releases -- I see v2.7.4 from Sep 26, 2021. I also don't know what constraints, if any, you have on what version of the code you run -- one of the sites I installed NUT for is happy to run off the master branch rather than waiting for a tagged release, others, not so much.

smainz commented 2 years ago

@andbez Does the version of @nbriggs work for your UPS as well? If you can not comple it, I can provide you with binaries.

smainz commented 2 years ago

I don't know what Jim's schedule is for creating NUT releases -- I see v2.7.4 from Sep 26, 2021. I also don't know what constraints, if any, you have on what version of the code you run -- one of the sites I installed NUT for is happy to run off the master branch rather than waiting for a tagged release, others, not so much.

If I do it the normal way, I'd to wait until it ends up in a distribution, but if I see it will end up in nut some time, I am going to convert from apcupsd to nut in the near future. I will take the master branch and be happy.

Thank you so much.

nbriggs commented 2 years ago

@andbez -- let me know if you have something other than "Vendor: 051d, Product: 0002". It's also dependent on the report ids, so it would be good to get all the same debug output from you that @smainz reported originally:

sudo /lib/nut/usbhid-ups -a usv01 -DDD 2>&1
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
   0.000000     debug level is '3'
   0.008989     upsdrv_initups...
   0.016938     Checking device (051D/0002) (001/004)
   0.057316     - VendorID: 051d
[... and so on ...]

preferably from the version off my branch, but output from the original version would do if that's too much work.

andbez commented 2 years ago

@nbriggs First let me thank all of you for your support. Please find attached the Output of usbhid-ups (Network UPS Tools - Generic HID driver 0.41 (2.7.4) on Debian Bullseye). ups_device.log .

nbriggs commented 2 years ago

@andbez Thanks. Your log info shows exactly the same issue (wrong logical minimum/maximum in the report descriptor) as smainz's. Also, the vendor ID and product ID are the same, and the report numbers of the problematic items (voltage and configVoltage) are also the same. So... I believe if you were to compile my branch 1189_APC_UPS_wrong_minmax_input_voltage you'd find that running the same test would report the correct values for configVoltage and voltage -- are you in a position to try that?

andbez commented 2 years ago

@nbriggs Not really. I am SQL and Python-Developer, but if @smainz can provide an Debian Intel/AMD-Binary, I can test it.

nbriggs commented 2 years ago

@andbez -- I've built a Debian/Intel VM and built a usbhid-ups from my new code -- what's the best way to get it to you? I don't think attaching a 700 KB file here is socially responsible ;-)

andbez commented 2 years ago

I can provide a Nextcloud-Share. Can I send you a PM somehow?

nbriggs commented 2 years ago

@andbez -- I remembered I have a generic web service from my ISP, so I put up http://nhbriggs.users.sonic.net/usbhid-ups (note http, 'cause it's a "free" service) and you can curl or wget that to test with.

% openssl sha256 usbhid-ups SHA256(usbhid-ups)= b33b5c77e5df1273025c98513b9a492d780757c833881f1a5da9096bdd212809

nbriggs commented 2 years ago

@andbez -- sorry, had to correct the URL there. It's http://nhbriggs.users.sonic.net/usbhid-ups (rather than nbriggs).

andbez commented 2 years ago

@nbriggs Thank you! Got it up and running. The Log is attached ups_log_new.log .

smainz commented 2 years ago

@andbez I can't see these lines

  0.343381     Using subdriver: APC HID 0.97
   0.347043     [D3] Attempting Report Descriptor fix for UPS: Vendor: 051d, Product: 0002
   0.348353     [D4] Report Descriptor: hvt input LogMin: 280 LogMax: 280

in the output. Is this log taken with the correct verison?

Looks like the log from the old subdriver and as you see:

   0.325815 [D1] Path: UPS.Input.ConfigVoltage, Type: Feature, ReportID: 0x30, Offset: 0, Size: 8, Value: 140
   0.330057 [D3] Report[get]: (3 bytes) => 31 e6 00
   0.330107 [D1] Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 140
   0.333114 [D3] Report[get]: (3 bytes) => 32 9b 00

Input.Voltage is still 140

You APC is the same model as mine, except for the smaller battery.

nbriggs commented 2 years ago

@andbez, @smainz -- sorry, I messed up and compiled the master branch instead of the fixed branch. I've fixed that and put the correct version up at the same link - http://nhbriggs.users.sonic.net/usbhid-ups

New SHA256:

% openssl sha256 usbhid-ups
SHA256(usbhid-ups)= 02eb842b85664fcb2be4ddeaee8935ee8430613f5dcc8c62c7f73a7406976ef1

andbez commented 2 years ago

@nbriggs @smainz Tried with the new version and now the Input.Voltage-Value looks better: 0.330174 [D1] Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 234 Whole log attached ups_log_new.log .

jimklimov commented 2 years ago

Looks promising, thanks @nbriggs for the proposed fix and @andbez & @smainz for testing on short notice!

NUT releases -- I see v2.7.4 from Sep 26, 2021

It's actually "worse" than that: this release date is from "drafting a release" on github, which is independent of the release tag... would be 6 years since that point, soon :( So tying up loose threads in order for 2.7.5 to not be an epic to talk about for eons ;)

smainz commented 2 years ago

It's actually "worse" than that: this release date is from "drafting a release" on github, which is independent of the release tag... would be 6 years since that point, soon :( So tying up loose threads in order for 2.7.5 to not be an epic to talk about for eons ;)

I see what you mean, but the longer it is since the last release, the sooner we will see the next one :-)

Thank you for your effort.

nbriggs commented 2 years ago

@flashydave -- quick question if you don't mind: I'm using your fix_report_desc framework to fix the problem smainz reported here for an APC unit, and I noticed that in the CPS code you chose to implement FindReport() to find the entry by ReportID and node. I'm wondering (a) if that should be in hidparser.c, along with FindObject_with_path() and FindObject_with_ID(), and (b) what was the reasoning behind your locating the entry to be fixed based on the ID+node rather than either of the existing methods?

flashydave commented 2 years ago

I agree it is similar to those functions. I see no reason not to relocate it if has wider use with other UPS models. I was simply trying to keep the fix local to the driver it related to and the function itself fell out of the need to call it multiple times. I would have preferred one of the existing funxtions but there were complications over access to parameters at the point where it was called and there were speed/performance issues to consider as mentioned in the HIDDumpTree() comments.

On 11:39, Fri 11 Feb 22, Nick Briggs wrote:

@flashydave -- quick question if you don't mind: I'm using your fix_report_desc framework to fix the problem smainz reported here for an APC unit, and I noticed that in the CPS code you chose to implement FindReport() to find the entry by ReportID and node. I'm wondering (a) if that should be in hidparser.c, along with FindObject_with_path() and FindObject_with_ID(), and (b) what was the reasoning behind your locating the entry to be fixed based on the ID+node rather than either of the existing methods?

-- Reply to this email directly or view it on GitHub: https://github.com/networkupstools/nut/issues/1189#issuecomment-1036552667 You are receiving this because you were mentioned.

Message ID: @.***>

nbriggs commented 2 years ago

@flashydave -- OK.

Re. speed & performance: The comments in HIDDumpTree() don't apply to our situation -- HIDDumpTree() is going to fetch the value from the UPS for each item in the tree, which as they note might take a non-trivial amount of time (especially if the UPS doesn't respond), while we are only inspecting the descriptor array itself and never fetch anything from the UPS, so both FindReport() and FindObject_with_ID() are O(n) (for n = number of descriptors) and run at memory access speed, once, at startup.

For the APC case I also need to look at the high voltage transfer threshold, but initially chose to use

pData=FindObject_with_ID(pDesc_arg, 0x33, 0, ITEM_FEATURE)

vs.

pData=FindReport(pDesc_arg, 16, (PAGE_POWER_DEVICE<<16)+USAGE_HIGHVOLTAGETRANSFER)

-- I checked the report descriptor to see that for the APC it sends report ID 0x33 (vs. 16 for your CPS) at an offset of 0 and as a FEATURE. I think I prefer your approach to locating the specific item, but I was a little surprised to find that the headers didn't already have a standard set of definitions for the usage tables based on the USB-IF spec (pdcv11.pdf -- "Universal Serial Bus Usage Tables for HID Power Devices"). There's the array of string to code (hid_usage_lkp) defined in libhid.c, but it just uses the magic numbers rather than constructing them from individual defines (or enum elements -- style choice!) -- looking at what includes what, perhaps hidparser.h (where you put the USAGE_HIGHVOLTAGETRANSFER) would be the right place to put a complete set?

flashydave commented 2 years ago

Agree with your point in general re performance and accessing hardware but felt also the computational (and programming) effort constructing path objects wasnt worth it. In my case numerics were sufficient to detect the buggy situation reasonably reliably and apply the fix.

I also was surprised a full set of magic numbers had not been defined but I guess it starts to get complicated if you have to deal with vendor unique numbers too should those be needed as they might not be interpreted the same across manufacturers. I just added the ones I needed. I cant see any reason not to add more if you need them..

On 14:13, Fri 11 Feb 22, Nick Briggs wrote:

@flashydave -- OK.

Re. speed & performance: The comments in HIDDumpTree() don't apply to our situation -- HIDDumpTree() is going to fetch the value from the UPS for each item in the tree, which as they note might take a non-trivial amount of time (especially if the UPS doesn't respond), while we are only inspecting the descriptor array itself and never fetch anything from the UPS, so both FindReport() and FindObject_with_ID() are O(n) (for n = number of descriptors) and run at memory access speed, once, at startup.

For the APC case I also need to look at the high voltage transfer threshold, but initially chose to use

pData=FindObject_with_ID(pDesc_arg, 0x33, 0, ITEM_FEATURE)

vs.

pData=FindReport(pDesc_arg, 16, (PAGE_POWER_DEVICE<<16)+USAGE_HIGHVOLTAGETRANSFER)

-- I checked the report descriptor to see that for the APC it sends report ID 0x33 (vs. 16 for your CPS) at an offset of 0 and as a FEATURE. I think I prefer your approach to locating the specific item, but I was a little surprised to find that the headers didn't already have a standard set of definitions for the usage tables based on the USB-IF spec (pdcv11.pdf -- "Universal Serial Bus Usage Tables for HID Power Devices"). There's the array of string to code (hid_usage_lkp) defined in libhid.c, but it just uses the magic numbers rather than constructing them from individual defines (or enum elements -- style choice!) -- looking at what includes what, perhaps hidparser.h (where you put the USAGE_HIGHVOLTAGETRANSFER) would be the right place to put a complete set?

-- Reply to this email directly or view it on GitHub: https://github.com/networkupstools/nut/issues/1189#issuecomment-1036677074 You are receiving this because you were mentioned.

Message ID: @.***>