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)
nbriggs commented 2 years ago

@flashydave, @jimklimov -- I have a NUT style question: I've taken the rd.conf file from github.com:abend0c1/hidrdd.git (actually, a very slightly updated version of that for which I've submitted a PR), which incorporates the complete USB-IF usage definitions for power device and battery system pages and processed it with

grep -e ^0084 -e ^0085 rd.conf | sed 's/,.*$//;s/ *$//' | sed 's/ /_/g;s/_/ /' | tr '[:lower:]' '[:upper:]' | sed 's/\(0085.... \)/\1USAGE_BAT_/;s/\(0084.... \)/\1USAGE_POW_/;s/\([A-Z_]*\)_PAGE/PAGE_\1/' | awk '{print "#define "$2" 0x"$1}'

to produce defines for the usages that look like

#define PAGE_POWER_DEVICE 0x0084
#define USAGE_POW_UNDEFINED 0x00840000
#define USAGE_POW_I_NAME 0x00840001
#define USAGE_POW_PRESENT_STATUS 0x00840002
[...]
#define PAGE_BATTERY_SYSTEM 0x0085
#define USAGE_BAT_UNDEFINED 0x00850000
#define USAGE_BAT_SMB_BATTERY_MODE 0x00850001
#define USAGE_BAT_SMB_BATTERY_STATUS 0x00850002
#define USAGE_BAT_SMB_ALARM_WARNING 0x00850003
[...]

... since the power device and battery system pages have conflicting field names we need to include the POW_ or BAT_ to differentiate, but the real style question is: underscores in the variable part of the field names or not? -- that is USAGE_BAT_SMB_BATTERY_MODE or USAGE_BAT_SMBBATTERYMODE?

I'm happy either way but it's not my codebase so I'm asking...

flashydave commented 2 years ago

I prefer the latter style so that the _ acts more like a heirarchical separator but I'm sure someone else could suggest an alternative rule. Its not my code either so I can't say definitively!

On 11:57, Sat 12 Feb 22, Nick Briggs wrote:

@flashydave, @jimklimov -- I have a NUT style question: I've taken the rd.conf file from github.com:abend0c1/hidrdd.git (actually, a very slightly updated version of that for which I've submitted a PR), which incorporates the complete USB-IF usage definitions for power device and battery system pages and processed it with

grep -e ^0084 -e ^0085 rd.conf | sed 's/,.*$//;s/ *$//' | sed 's/ /_/g;s/_/ /' | tr '[:lower:]' '[:upper:]' | sed 's/\(0085.... \)/\1USAGE_BAT_/;s/\(0084.... \)/\1USAGE_POW_/;s/\([A-Z_]*\)_PAGE/PAGE_\1/' | awk '{print "#define "$2" 0x"$1}'

to produce defines for the usages that look like

#define PAGE_POWER_DEVICE 0x0084
#define USAGE_POW_UNDEFINED 0x00840000
#define USAGE_POW_I_NAME 0x00840001
#define USAGE_POW_PRESENT_STATUS 0x00840002
[...]
#define PAGE_BATTERY_SYSTEM 0x0085
#define USAGE_BAT_UNDEFINED 0x00850000
#define USAGE_BAT_SMB_BATTERY_MODE 0x00850001
#define USAGE_BAT_SMB_BATTERY_STATUS 0x00850002
#define USAGE_BAT_SMB_ALARM_WARNING 0x00850003
[...]

... since the power device and battery system pages have conflicting field names we need to include the POW_ or BAT_ to differentiate, but the real style question is: underscores in the variable part of the field names or not? -- that is USAGE_BAT_SMB_BATTERY_MODE or USAGE_BAT_SMBBATTERYMODE?

I'm happy either way but it's not my codebase so I'm asking...

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

Message ID: @.***>

jimklimov commented 2 years ago

I like underscores as more readable, especially where we can't have CamelCase etc. Maybe follow precedent of nut-ddl structured names with two underscores between tokens? like USAGEBATSMB_BATTERY_STATUS ?

flashydave commented 2 years ago

Thats starting to get messy. Not only does it become irksome to type (especially for those using command line type editors) and reduces the amount of code that can seen on any guven size of screen. For example my recent contributions were all developed using ssh from my phone!

On 02:51, Sun 13 Feb 22, Jim Klimov wrote:

I like underscores as more readable, especially where we can't have CamelCase etc. Maybe follow precedent of nut-ddl structured names with two underscores between tokens? like USAGEBATSMB_BATTERY_STATUS ?

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

Message ID: @.***>

jimklimov commented 2 years ago

Well then, given a small dictionary of prefixes to juggle, single underscores can be good and not ambiguous... at least, it's sure better to get fixes delivered than to bikeshed over this :-)

On Sun, Feb 13, 2022, 12:17 flashydave @.***> wrote:

Thats starting to get messy. Not only does it become irksome to type (especially for those using command line type editors) and reduces the amount of code that can seen on any guven size of screen. For example my recent contributions were all developed using ssh from my phone!

On 02:51, Sun 13 Feb 22, Jim Klimov wrote:

I like underscores as more readable, especially where we can't have CamelCase etc. Maybe follow precedent of nut-ddl structured names with two underscores between tokens? like USAGEBATSMB_BATTERY_STATUS ?

-- Reply to this email directly or view it on GitHub:

https://github.com/networkupstools/nut/issues/1189#issuecomment-1038010123 You are receiving this because you were mentioned.

Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/1189#issuecomment-1038028148, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMPTFCAVNIQKN53KKSAJSDU26HNRANCNFSM5IG337SA . 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: @.***>

flashydave commented 2 years ago

I agree!

On 11:43, Sun 13 Feb 22, Jim Klimov wrote:

Well then, given a small dictionary of prefixes to juggle, single underscores can be good and not ambiguous... at least, it's sure better to get fixes delivered than to bikeshed over this :-)

On Sun, Feb 13, 2022, 12:17 flashydave @.***> wrote:

Thats starting to get messy. Not only does it become irksome to type (especially for those using command line type editors) and reduces the amount of code that can seen on any guven size of screen. For example my recent contributions were all developed using ssh from my phone!

On 02:51, Sun 13 Feb 22, Jim Klimov wrote:

I like underscores as more readable, especially where we can't have CamelCase etc. Maybe follow precedent of nut-ddl structured names with two underscores between tokens? like USAGEBATSMB_BATTERY_STATUS ?

-- Reply to this email directly or view it on GitHub:

https://github.com/networkupstools/nut/issues/1189#issuecomment-1038010123 You are receiving this because you were mentioned.

Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/1189#issuecomment-1038028148, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMPTFCAVNIQKN53KKSAJSDU26HNRANCNFSM5IG337SA . 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: @.***>

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

Message ID: @.***>

nbriggs commented 2 years ago

OK... I've (force) pushed a revised version of 1189_APC_UPS_wrong_minmax_input_voltage with all the changes and stored a new version of usbhid-ups for x86_64 (SHA256(usbhid-ups)= 17d3420fc892f1cd8fb3d5e4c3b766708890725b76dbfe90ea8a6ddaaa27d495) on http://nhbriggs.users.sonic.net/usbhid-ups if @smainz and/or @andbez want to re-test on their APC units.

smainz commented 2 years ago

@nbriggs Is it enough for you when I run this commit on my Pi or do you need x86_64 too? The later means, i have to move cabinets.

Pi is compiling now, you will have feedback later this evening.

nbriggs commented 2 years ago

@smainz -- Pi is enough, I think @andbez has the x86_64 but not the setup for compiling it.

smainz commented 2 years ago

Here is:

$ sudo drivers/usbhid-ups -DDD -s usv01 -x port=auto  -u root
Network UPS Tools - Generic HID driver 0.45 (2.7.4-4615-gbaae14d9)
USB communication driver (libusb 1.0) 0.42
   0.390418     Using subdriver: APC HID 0.97
   0.392100     [D3] Attempting Report Descriptor fix for UPS: Vendor: 051d, Product: 0002
   0.392516     [D3] Fixing Report Descriptor. Set voltage LogMin = 0, LogMax = 560
   0.392899     [D3] Fixing Report Descriptor. Set configVoltage LogMin = 75, LogMax = 255
   0.393278     [D2] Report Descriptor Fixed
   0.614673     [D1] Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x31, Offset: 0, Size: 16, Value: 228
   0.618179     [D3] Report[get]: (3 bytes) => 32 9b 00
   0.618711     [D1] Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x32, Offset: 0, Size: 16, Value: 155
   0.621399     [D3] Report[get]: (3 bytes) => 33 18 01

Looks good. Thank you

andbez commented 2 years ago

Here is: ;-)

root@omv:~# ./usbhid-ups -a ups -u root -DDD 2>&1 Network UPS Tools - Generic HID driver 0.45 (2.7.4-4540-gaefcdc0a) USB communication driver (libusb 1.0) 0.42

0.185032 Using subdriver: APC HID 0.97 0.185036 [D3] Attempting Report Descriptor fix for UPS: Vendor: 051d, Product: 0002 0.185041 [D3] Fixing Report Descriptor. Set voltage LogMin = 0, LogMax = 560 0.185045 [D3] Fixing Report Descriptor. Set configVoltage LogMin = 75, LogMax = 255 0.185048 [D2] Report Descriptor Fixed

0.329770 [D1] Path: UPS.Input.Voltage, Type: Fea ture, ReportID: 0x31, Offset: 0, Size: 16, Value: 236 0.334925 [D3] Report[get]: (3 bytes) => 32 9b 00 0.334941 [D1] Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x32, Offset: 0, Size: 16, Value: 155 0.339027 [D3] Report[get]: (3 bytes) => 33 18 01

@nbriggs Thank you for providing the binary file.

nbriggs commented 2 years ago

Thanks @smainz and @andbez for testing. I re-read my code and realized there's one more minor change to make having to do with when it reports ("Report Descriptor Fixed") that it did (or did not) find the problem. That probably only requires someone visually inspect the change, though. Famous last words and all that...

nbriggs commented 2 years ago

Updated again with bumped driver version number and check as mentioned above. % openssl sha256 usbhid-ups SHA256(usbhid-ups)= 828a31c62d819f04c4ad305163adb9108f0acfd9d526e0285d5ff8fa77725d49 and updated at the same link as before (x86_64 version). Submitted PR for it -- I think this one's done for now.

jimklimov commented 2 years ago

Thanks all for reporting, fixing and testing! Will follow up on the posted PR :)

smainz commented 2 years ago

Do you need another test or do you trust in you famous last words?

nbriggs commented 2 years ago

If you'd be happy to just eyeball the last change in source rather than build/test it that would be enough for me. Can't speak to anyone else's wishes.

smainz commented 2 years ago

OK, checked it and it looks good. Did not check the constants though. I like the style of your code and comments.

nbriggs commented 2 years ago

@smainz -- thank you, though the code style is from @flashydave so thanks to him.